Skip to content

Commit

Permalink
Fixed to use deprecated APIs in GTK 3.12
Browse files Browse the repository at this point in the history
Changed xalign to halign.
Changed GtkAlignment to gtk_widget_set_margin_start().
Changed gtk_widget_override_background_color() to GtkCssProvider.
  • Loading branch information
fujiwarat committed Apr 16, 2015
1 parent 51211f0 commit ab87d6c
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 130 deletions.
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# input-pad - The input pad
#
# Copyright (c) 2010-2014 Takao Fujiwara <takao.fujiwara1@gmail.com>
# Copyright (c) 2010-2014 Red Hat, Inc.
# Copyright (c) 2010-2015 Takao Fujiwara <takao.fujiwara1@gmail.com>
# Copyright (c) 2010-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -94,7 +94,7 @@ PKG_CHECK_MODULES(GMODULE2,
)

PKG_CHECK_MODULES(GTK3, [
gtk+-3.0 >= 3.10
gtk+-3.0 >= 3.12
])
GTK_API_VERSION=3.0
AC_SUBST(GTK_API_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion input-pad/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ libinput_pad_1_0_la_LDFLAGS = \
$(no_undefined) \
$(NULL)

resources.c: input-pad.gresource.xml
resources.c: input-pad.gresource.xml app-menu.ui dialog.ui window-gtk.ui
$(GLIB_COMPILE_RESOURCES) $< --target=$@ --generate-source

input-pad-marshal.h: input-pad-marshal.list
Expand Down
114 changes: 48 additions & 66 deletions input-pad/dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,7 @@ You also can copy pad files from /usr/share/input-pad/pad to $HOME/.config/pad t
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="halign">start</property>
<property name="mnemonic_widget">ConfigLayoutsAddTreeView</property>
</object>
<packing>
Expand Down Expand Up @@ -403,10 +400,7 @@ You also can copy pad files from /usr/share/input-pad/pad to $HOME/.config/pad t
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="halign">start</property>
<property name="mnemonic_widget">ConfigLayoutsRemoveTreeView</property>
</object>
<packing>
Expand Down Expand Up @@ -538,79 +532,67 @@ You also can copy pad files from /usr/share/input-pad/pad to $HOME/.config/pad t
<property name="border-width">10</property>
<property name="spacing">12</property>
<child>
<object class="GtkAlignment" id="alignment4">
<object class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="top_padding">12</property>
<property name="left_padding">12</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkFrame" id="frame4">
<object class="GtkBox" id="vbox40">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="margin_top">12</property>
<property name="margin_start">12</property>
<!--
<child>
<object class="GtkCheckButton" id="ConfigOptionsCheckButton">
<property name="label" translatable="yes">_Use the default keyboard option</property>
<property name="use-underline">TRUE</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Use the defualt XKB option</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
-->
<child>
<object class="GtkAlignment" id="alignment40">
<object class="GtkScrolledWindow" id="scrolledwindow40">
<property name="visible">True</property>
<property name="top_padding">12</property>
<property name="left_padding">12</property>
<property name="can_focus">True</property>
<property name="border_width">5</property>
<property name="width_request">450</property>
<property name="height_request">350</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">out</property>
<child>
<object class="GtkBox" id="vbox40">
<object class="GtkViewport" id="viewport40">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<!--
<property name="shadow_type">none</property>
<child>
<object class="GtkCheckButton" id="ConfigOptionsCheckButton">
<property name="label" translatable="yes">_Use the default keyboard option</property>
<property name="use-underline">TRUE</property>
<object class="GtkBox" id="ConfigOptionsVBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Use the defualt XKB option</property>
<property name="draw_indicator">True</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
-->
<child>
<object class="GtkScrolledWindow" id="scrolledwindow40">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">5</property>
<property name="width_request">450</property>
<property name="height_request">350</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">out</property>
<child>
<object class="GtkViewport" id="viewport40">
<property name="visible">True</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkBox" id="ConfigOptionsVBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="label">
<object class="GtkLabel" id="label40">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Keyboard Option&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label40">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Keyboard Option&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
Expand Down
122 changes: 62 additions & 60 deletions input-pad/window-gtk.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* vim:set et sts=4: */
/* input-pad - The input pad
* Copyright (C) 2010-2014 Takao Fujiwara <takao.fujiwara1@gmail.com>
* Copyright (C) 2010-2014 Red Hat, Inc.
* Copyright (C) 2010-2015 Takao Fujiwara <takao.fujiwara1@gmail.com>
* Copyright (C) 2010-2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -129,7 +129,6 @@ struct _InputPadGtkWindowPrivate {
gchar **group_variants;
gchar **group_options;
guint char_button_sensitive : 1;
GdkRGBA *color_gray;
/* The kbdui_name is used for each window instance. */
gchar *kbdui_name;
InputPadGtkKbdui *kbdui;
Expand Down Expand Up @@ -992,7 +991,6 @@ on_button_config_options_close_clicked (GtkButton *button, gpointer data)
GList *list = NULL;
GList *list_button = NULL;
GtkWidget *expander;
GtkWidget *alignment;
GtkWidget *vbox;
GtkWidget *checkbutton;
GtkWidget *combobox;
Expand All @@ -1018,10 +1016,6 @@ on_button_config_options_close_clicked (GtkButton *button, gpointer data)
expander = GTK_WIDGET (list->data);

tmp_list = gtk_container_get_children (GTK_CONTAINER (expander));
alignment = GTK_WIDGET (tmp_list->data);
g_list_free (tmp_list);

tmp_list = gtk_container_get_children (GTK_CONTAINER (alignment));
vbox = GTK_WIDGET (tmp_list->data);
g_list_free (tmp_list);

Expand Down Expand Up @@ -2024,17 +2018,34 @@ append_unicode_table (GtkWidget *table,
int row, col;

css_provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (css_provider,
"GtkButton { padding-left: 1px;" \
" padding-right: 1px;" \
" padding-top: 1px;" \
" padding-bottom: 1px;" \
" border-top-width: 0px;" \
" border-left-width: 0px;" \
" border-bottom-width: 0px;" \
" border-right-width: 0px; }",
-1,
&error);
if (input_pad->child)
gtk_css_provider_load_from_data (
css_provider,
"GtkButton { padding-left: 1px;" \
" padding-right: 1px;" \
" padding-top: 1px;" \
" padding-bottom: 1px;" \
" border-top-width: 0px;" \
" border-left-width: 0px;" \
" border-bottom-width: 0px;" \
" border-right-width: 0px; }",
-1,
&error);
else
/* FIXME: cannot change background in GTK3 button. */
gtk_css_provider_load_from_data (
css_provider,
"GtkButton { padding-left: 1px;" \
" padding-right: 1px;" \
" padding-top: 1px;" \
" padding-bottom: 1px;" \
" border-top-width: 0px;" \
" border-left-width: 0px;" \
" border-bottom-width: 0px;" \
" border-right-width: 0px;" \
" background-color: LightGray; }",
-1,
&error);

for (num = start; num <= end; num++) {
button = input_pad_gtk_button_new_with_unicode (num);
Expand All @@ -2047,15 +2058,9 @@ append_unicode_table (GtkWidget *table,
gtk_grid_attach (GTK_GRID (table), button,
col, row, 1, 1);
gtk_widget_show (button);
if (input_pad->child) {
if (input_pad->child)
gtk_widget_set_sensitive (button,
input_pad->priv->char_button_sensitive);
} else if (input_pad->priv->color_gray) {
/* char button is stdout only */
/* FIXME: cannot change background in GTK3 button. */
gtk_widget_override_background_color (button, GTK_STATE_NORMAL,
input_pad->priv->color_gray);
}
g_signal_connect (G_OBJECT (button), "pressed",
G_CALLBACK (on_button_pressed),
input_pad);
Expand Down Expand Up @@ -2178,17 +2183,34 @@ append_custom_char_view_table (GtkWidget *scrolled, InputPadTable *table_data)
#endif

css_provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (css_provider,
"GtkButton { padding-left: 1px;" \
" padding-right: 1px;" \
" padding-top: 1px;" \
" padding-bottom: 1px;" \
" border-top-width: 0px;" \
" border-left-width: 0px;" \
" border-bottom-width: 0px;" \
" border-right-width: 0px; }",
-1,
&error);
if (input_pad->child)
gtk_css_provider_load_from_data (
css_provider,
"GtkButton { padding-left: 1px;" \
" padding-right: 1px;" \
" padding-top: 1px;" \
" padding-bottom: 1px;" \
" border-top-width: 0px;" \
" border-left-width: 0px;" \
" border-bottom-width: 0px;" \
" border-right-width: 0px; }",
-1,
&error);
else
/* FIXME: cannot change background in GTK3 button. */
gtk_css_provider_load_from_data (
css_provider,
"GtkButton { padding-left: 1px;" \
" padding-right: 1px;" \
" padding-top: 1px;" \
" padding-bottom: 1px;" \
" border-top-width: 0px;" \
" border-left-width: 0px;" \
" border-bottom-width: 0px;" \
" border-right-width: 0px;" \
" background-color: LightGray; }",
-1,
&error);

table = gtk_grid_new ();
/* gtk_table_attach_defaults assigns GTK_EXPAND and
Expand Down Expand Up @@ -2279,15 +2301,9 @@ append_custom_char_view_table (GtkWidget *scrolled, InputPadTable *table_data)
col, row, 1, 1);

gtk_widget_show (button);
if (input_pad->child) {
if (input_pad->child)
gtk_widget_set_sensitive (button,
input_pad->priv->char_button_sensitive);
} else if (input_pad->priv->color_gray) {
/* char button is stdout only */
/* FIXME: cannot change background in GTK3 button. */
gtk_widget_override_background_color (button, GTK_STATE_NORMAL,
input_pad->priv->color_gray);
}
g_signal_connect (G_OBJECT (button), "pressed",
G_CALLBACK (on_button_pressed),
(gpointer) table_data->priv->signal_window);
Expand Down Expand Up @@ -2919,7 +2935,6 @@ config_options_treeview_set (InputPadGtkWindow *input_pad,
{
InputPadXKBOptionGroupList *groups = NULL;
GtkWidget *expander;
GtkWidget *alignment;
GtkWidget *vbox;
GtkWidget *checkbutton;
GtkWidget *label;
Expand All @@ -2937,12 +2952,9 @@ config_options_treeview_set (InputPadGtkWindow *input_pad,
(gpointer) groups->option_group);
g_object_set_data (G_OBJECT (expander), "checked",
GINT_TO_POINTER (checked));
alignment = gtk_alignment_new (0, 0, 1, 0);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 18, 0);
gtk_container_add (GTK_CONTAINER (expander), alignment);
gtk_widget_show (alignment);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (alignment), vbox);
gtk_widget_set_margin_start (vbox, 18);
gtk_container_add (GTK_CONTAINER (expander), vbox);
gtk_widget_show (vbox);

InputPadXKBOptionList *options = groups->options;
Expand Down Expand Up @@ -4424,18 +4436,12 @@ static void
input_pad_gtk_window_set_priv (InputPadGtkWindow *window)
{
InputPadGtkWindowPrivate *priv = input_pad_gtk_window_get_instance_private (window);
GdkRGBA color;

if (priv->group == NULL) {
priv->group = input_pad_group_parse_all_files (NULL, NULL);
}
priv->char_button_sensitive = TRUE;

if (!gdk_rgba_parse (&color, "gray")) {
color.red = color.green = color.blue = 1.;
color.alpha = 1.;
}
priv->color_gray = gdk_rgba_copy (&color);
if (kbdui_name) {
priv->kbdui_name = g_strdup (kbdui_name);
}
Expand Down Expand Up @@ -4468,10 +4474,6 @@ input_pad_gtk_window_real_destroy (GtkWidget *widget)
input_pad_group_destroy (window->priv->group);
window->priv->group = NULL;
}
if (window->priv->color_gray) {
gdk_rgba_free (window->priv->color_gray);
window->priv->color_gray = NULL;
}
#ifdef MODULE_XTEST_GDK_BASE
if (use_module_xtest) {
input_pad_gtk_window_xtest_gdk_destroy (window);
Expand Down

0 comments on commit ab87d6c

Please sign in to comment.