summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-07-27 20:33:08 -0400
committerMatthias Clasen <mclasen@redhat.com>2013-07-27 21:00:33 -0400
commitc9ce98714da965062f514aa0ec8092a40bbe087a (patch)
tree3dfb70ca9d723fc0dd550ad07f4b060ff834c6aa
parent3bb059b6e869b8d4c8d5dda2b16fbc95347e0313 (diff)
downloadgtk+-c9ce98714da965062f514aa0ec8092a40bbe087a.tar.gz
example: Use declared callbacks where possible
Replace manual signal connections with signal handlers declared in the ui file, where possible.
-rw-r--r--examples/application6/exampleappprefs.c78
-rw-r--r--examples/application6/exampleappprefs.h4
-rw-r--r--examples/application6/prefs.ui1
-rw-r--r--examples/application7/exampleappprefs.c12
-rw-r--r--examples/application7/exampleappwin.c26
-rw-r--r--examples/application7/prefs.ui1
-rw-r--r--examples/application7/window.ui2
-rw-r--r--examples/application8/exampleappprefs.c12
-rw-r--r--examples/application8/exampleappwin.c24
-rw-r--r--examples/application8/prefs.ui1
-rw-r--r--examples/application8/window.ui2
-rw-r--r--examples/application9/exampleappprefs.c12
-rw-r--r--examples/application9/exampleappwin.c22
-rw-r--r--examples/application9/prefs.ui1
-rw-r--r--examples/application9/window.ui2
15 files changed, 118 insertions, 82 deletions
diff --git a/examples/application6/exampleappprefs.c b/examples/application6/exampleappprefs.c
index dd65699672..8cd5d5e3a3 100644
--- a/examples/application6/exampleappprefs.c
+++ b/examples/application6/exampleappprefs.c
@@ -4,68 +4,76 @@
#include "exampleappwin.h"
#include "exampleappprefs.h"
-struct ExampleAppPrefs {
- GtkDialog parent;
+struct _ExampleAppPrefs
+{
+ GtkDialog parent;
};
-struct ExampleAppPrefsClass {
- GtkDialogClass parent_class;
+struct _ExampleAppPrefsClass
+{
+ GtkDialogClass parent_class;
};
-typedef struct ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
-struct ExampleAppPrefsPrivate {
- GSettings *settings;
- GtkWidget *font;
- GtkWidget *transition;
- GtkWidget *close;
+typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
+
+struct _ExampleAppPrefsPrivate
+{
+ GSettings *settings;
+ GtkWidget *font;
+ GtkWidget *transition;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
+preferences_closed (GtkWidget *button)
+{
+ gtk_widget_destroy (gtk_widget_get_toplevel (button));
+}
+
+static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
- ExampleAppPrefsPrivate *priv;
-
- priv = example_app_prefs_get_instance_private (prefs);
- gtk_widget_init_template (GTK_WIDGET (prefs));
- priv->settings = g_settings_new ("org.gtk.exampleapp");
-
- g_settings_bind (priv->settings, "font",
- priv->font, "font",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (priv->settings, "transition",
- priv->transition, "active-id",
- G_SETTINGS_BIND_DEFAULT);
- g_signal_connect_swapped (priv->close, "clicked",
- G_CALLBACK (gtk_widget_destroy), prefs);
+ ExampleAppPrefsPrivate *priv;
+
+ priv = example_app_prefs_get_instance_private (prefs);
+ gtk_widget_init_template (GTK_WIDGET (prefs));
+ priv->settings = g_settings_new ("org.gtk.exampleapp");
+
+ g_settings_bind (priv->settings, "font",
+ priv->font, "font",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (priv->settings, "transition",
+ priv->transition, "active-id",
+ G_SETTINGS_BIND_DEFAULT);
}
static void
example_app_prefs_dispose (GObject *object)
{
- ExampleAppPrefsPrivate *priv;
+ ExampleAppPrefsPrivate *priv;
- priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
- g_clear_object (&priv->settings);
+ priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
+ g_clear_object (&priv->settings);
- G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
+ G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
}
static void
example_app_prefs_class_init (ExampleAppPrefsClass *class)
{
- G_OBJECT_CLASS (class)->dispose = example_app_prefs_dispose;
+ G_OBJECT_CLASS (class)->dispose = example_app_prefs_dispose;
+
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/prefs.ui");
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
- gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
- "/org/gtk/exampleapp/prefs.ui");
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, close);
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
- return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
+ return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
}
diff --git a/examples/application6/exampleappprefs.h b/examples/application6/exampleappprefs.h
index fe32a67c1a..c684889adf 100644
--- a/examples/application6/exampleappprefs.h
+++ b/examples/application6/exampleappprefs.h
@@ -9,8 +9,8 @@
#define EXAMPLE_APP_PREFS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_PREFS_TYPE, ExampleAppPrefs))
-typedef struct ExampleAppPrefs ExampleAppPrefs;
-typedef struct ExampleAppPrefsClass ExampleAppPrefsClass;
+typedef struct _ExampleAppPrefs ExampleAppPrefs;
+typedef struct _ExampleAppPrefsClass ExampleAppPrefsClass;
GType example_app_prefs_get_type (void);
diff --git a/examples/application6/prefs.ui b/examples/application6/prefs.ui
index 4e846b8e15..49781d194c 100644
--- a/examples/application6/prefs.ui
+++ b/examples/application6/prefs.ui
@@ -69,6 +69,7 @@
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
+ <signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
diff --git a/examples/application7/exampleappprefs.c b/examples/application7/exampleappprefs.c
index bb089e6f1e..8cd5d5e3a3 100644
--- a/examples/application7/exampleappprefs.c
+++ b/examples/application7/exampleappprefs.c
@@ -21,12 +21,17 @@ struct _ExampleAppPrefsPrivate
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
- GtkWidget *close;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
+preferences_closed (GtkWidget *button)
+{
+ gtk_widget_destroy (gtk_widget_get_toplevel (button));
+}
+
+static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
ExampleAppPrefsPrivate *priv;
@@ -41,8 +46,6 @@ example_app_prefs_init (ExampleAppPrefs *prefs)
g_settings_bind (priv->settings, "transition",
priv->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
- g_signal_connect_swapped (priv->close, "clicked",
- G_CALLBACK (gtk_widget_destroy), prefs);
}
static void
@@ -65,7 +68,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, close);
+
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
diff --git a/examples/application7/exampleappwin.c b/examples/application7/exampleappwin.c
index 3df14ad79e..0d50e96c71 100644
--- a/examples/application7/exampleappwin.c
+++ b/examples/application7/exampleappwin.c
@@ -20,15 +20,14 @@ struct _ExampleAppWindowPrivate
GtkWidget *stack;
GtkWidget *search;
GtkWidget *searchbar;
- GtkWidget *searchentry;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
static void
-search_text_changed (GtkEntry *entry,
- ExampleAppWindow *win)
+search_text_changed (GtkEntry *entry)
{
+ ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
const gchar *text;
GtkWidget *tab;
@@ -41,6 +40,7 @@ search_text_changed (GtkEntry *entry,
if (text[0] == '\0')
return;
+ win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
@@ -59,15 +59,17 @@ search_text_changed (GtkEntry *entry,
}
static void
-visible_child_changed (GObject *stack,
- GParamSpec *pspec,
- ExampleAppWindow *win)
+visible_child_changed (GObject *stack,
+ GParamSpec *pspec)
{
+ ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
- if (gtk_widget_in_destruction (GTK_WIDGET (win)))
+ if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
return;
+ win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
+
priv = example_app_window_get_instance_private (win);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
}
@@ -88,11 +90,6 @@ example_app_window_init (ExampleAppWindow *win)
g_object_bind_property (priv->search, "active",
priv->searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
-
- g_signal_connect (priv->searchentry, "changed",
- G_CALLBACK (search_text_changed), win);
- g_signal_connect (priv->stack, "notify::visible-child",
- G_CALLBACK (visible_child_changed), win);
}
static void
@@ -116,10 +113,13 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
+
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
+
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
}
ExampleAppWindow *
diff --git a/examples/application7/prefs.ui b/examples/application7/prefs.ui
index 4e846b8e15..49781d194c 100644
--- a/examples/application7/prefs.ui
+++ b/examples/application7/prefs.ui
@@ -69,6 +69,7 @@
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
+ <signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
diff --git a/examples/application7/window.ui b/examples/application7/window.ui
index 4ddd22e27c..feb8fe36c0 100644
--- a/examples/application7/window.ui
+++ b/examples/application7/window.ui
@@ -41,6 +41,7 @@
<property name="visible">True</property>
<child>
<object class="GtkSearchEntry" id="searchentry">
+ <signal name="changed" handler="search_text_changed"/>
<property name="visible">True</property>
</object>
</child>
@@ -48,6 +49,7 @@
</child>
<child>
<object class="GtkStack" id="stack">
+ <signal name="notify::visible-child" handler="visible_child_changed"/>
<property name="visible">True</property>
</object>
</child>
diff --git a/examples/application8/exampleappprefs.c b/examples/application8/exampleappprefs.c
index bb089e6f1e..8cd5d5e3a3 100644
--- a/examples/application8/exampleappprefs.c
+++ b/examples/application8/exampleappprefs.c
@@ -21,12 +21,17 @@ struct _ExampleAppPrefsPrivate
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
- GtkWidget *close;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
+preferences_closed (GtkWidget *button)
+{
+ gtk_widget_destroy (gtk_widget_get_toplevel (button));
+}
+
+static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
ExampleAppPrefsPrivate *priv;
@@ -41,8 +46,6 @@ example_app_prefs_init (ExampleAppPrefs *prefs)
g_settings_bind (priv->settings, "transition",
priv->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
- g_signal_connect_swapped (priv->close, "clicked",
- G_CALLBACK (gtk_widget_destroy), prefs);
}
static void
@@ -65,7 +68,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, close);
+
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
diff --git a/examples/application8/exampleappwin.c b/examples/application8/exampleappwin.c
index ea2303cd15..545a83812e 100644
--- a/examples/application8/exampleappwin.c
+++ b/examples/application8/exampleappwin.c
@@ -29,9 +29,9 @@ struct _ExampleAppWindowPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
static void
-search_text_changed (GtkEntry *entry,
- ExampleAppWindow *win)
+search_text_changed (GtkEntry *entry)
{
+ ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
const gchar *text;
GtkWidget *tab;
@@ -44,6 +44,7 @@ search_text_changed (GtkEntry *entry,
if (text[0] == '\0')
return;
+ win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
@@ -135,15 +136,17 @@ done:
}
static void
-visible_child_changed (GObject *stack,
- GParamSpec *pspec,
- ExampleAppWindow *win)
+visible_child_changed (GObject *stack,
+ GParamSpec *pspec)
{
+ ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
- if (gtk_widget_in_destruction (GTK_WIDGET (win)))
+ if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
return;
+ win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
+
priv = example_app_window_get_instance_private (win);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
update_words (win);
@@ -181,10 +184,6 @@ example_app_window_init (ExampleAppWindow *win)
priv->searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
- g_signal_connect (priv->searchentry, "changed",
- G_CALLBACK (search_text_changed), win);
- g_signal_connect (priv->stack, "notify::visible-child",
- G_CALLBACK (visible_child_changed), win);
g_signal_connect (priv->sidebar, "notify::reveal-child",
G_CALLBACK (words_changed), win);
@@ -219,6 +218,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
+
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
@@ -226,6 +226,10 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
+
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
+
}
ExampleAppWindow *
diff --git a/examples/application8/prefs.ui b/examples/application8/prefs.ui
index 4e846b8e15..49781d194c 100644
--- a/examples/application8/prefs.ui
+++ b/examples/application8/prefs.ui
@@ -69,6 +69,7 @@
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
+ <signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
diff --git a/examples/application8/window.ui b/examples/application8/window.ui
index 7463cc1236..8e70a8f615 100644
--- a/examples/application8/window.ui
+++ b/examples/application8/window.ui
@@ -56,6 +56,7 @@
<property name="visible">True</property>
<child>
<object class="GtkSearchEntry" id="searchentry">
+ <signal name="changed" handler="search_text_changed"/>
<property name="visible">True</property>
</object>
</child>
@@ -85,6 +86,7 @@
</child>
<child>
<object class="GtkStack" id="stack">
+ <signal name="notify::visible-child" handler="visible_child_changed"/>
<property name="visible">True</property>
</object>
</child>
diff --git a/examples/application9/exampleappprefs.c b/examples/application9/exampleappprefs.c
index bb089e6f1e..8cd5d5e3a3 100644
--- a/examples/application9/exampleappprefs.c
+++ b/examples/application9/exampleappprefs.c
@@ -21,12 +21,17 @@ struct _ExampleAppPrefsPrivate
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
- GtkWidget *close;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
+preferences_closed (GtkWidget *button)
+{
+ gtk_widget_destroy (gtk_widget_get_toplevel (button));
+}
+
+static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
ExampleAppPrefsPrivate *priv;
@@ -41,8 +46,6 @@ example_app_prefs_init (ExampleAppPrefs *prefs)
g_settings_bind (priv->settings, "transition",
priv->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
- g_signal_connect_swapped (priv->close, "clicked",
- G_CALLBACK (gtk_widget_destroy), prefs);
}
static void
@@ -65,7 +68,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, close);
+
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
diff --git a/examples/application9/exampleappwin.c b/examples/application9/exampleappwin.c
index 4dfe440ce3..26779e942c 100644
--- a/examples/application9/exampleappwin.c
+++ b/examples/application9/exampleappwin.c
@@ -31,9 +31,9 @@ struct _ExampleAppWindowPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
static void
-search_text_changed (GtkEntry *entry,
- ExampleAppWindow *win)
+search_text_changed (GtkEntry *entry)
{
+ ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
const gchar *text;
GtkWidget *tab;
@@ -46,6 +46,7 @@ search_text_changed (GtkEntry *entry,
if (text[0] == '\0')
return;
+ win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
@@ -172,15 +173,16 @@ update_lines (ExampleAppWindow *win)
}
static void
-visible_child_changed (GObject *stack,
- GParamSpec *pspec,
- ExampleAppWindow *win)
+visible_child_changed (GObject *stack,
+ GParamSpec *pspec)
{
+ ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
- if (gtk_widget_in_destruction (GTK_WIDGET (win)))
+ if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
return;
+ win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
priv = example_app_window_get_instance_private (win);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
update_words (win);
@@ -219,10 +221,6 @@ example_app_window_init (ExampleAppWindow *win)
priv->searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
- g_signal_connect (priv->searchentry, "changed",
- G_CALLBACK (search_text_changed), win);
- g_signal_connect (priv->stack, "notify::visible-child",
- G_CALLBACK (visible_child_changed), win);
g_signal_connect (priv->sidebar, "notify::reveal-child",
G_CALLBACK (words_changed), win);
@@ -265,6 +263,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
+
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
@@ -274,6 +273,9 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines_label);
+
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
}
ExampleAppWindow *
diff --git a/examples/application9/prefs.ui b/examples/application9/prefs.ui
index 4e846b8e15..49781d194c 100644
--- a/examples/application9/prefs.ui
+++ b/examples/application9/prefs.ui
@@ -69,6 +69,7 @@
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
+ <signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
diff --git a/examples/application9/window.ui b/examples/application9/window.ui
index 915dac6327..16046dbbc6 100644
--- a/examples/application9/window.ui
+++ b/examples/application9/window.ui
@@ -73,6 +73,7 @@
<property name="visible">True</property>
<child>
<object class="GtkSearchEntry" id="searchentry">
+ <signal name="changed" handler="search_text_changed"/>
<property name="visible">True</property>
</object>
</child>
@@ -102,6 +103,7 @@
</child>
<child>
<object class="GtkStack" id="stack">
+ <signal name="notify::visible-child" handler="visible_child_changed"/>
<property name="visible">True</property>
</object>
</child>