example: Use declared callbacks where possible
Replace manual signal connections with signal handlers declared in the ui file, where possible.
This commit is contained in:
parent
3bb059b6e8
commit
c9ce98714d
@ -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;
|
||||
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");
|
||||
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);
|
||||
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_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, close);
|
||||
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_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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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>
|
||||
|
@ -21,11 +21,16 @@ 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)
|
||||
{
|
||||
@ -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 *
|
||||
|
@ -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 *
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -21,11 +21,16 @@ 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)
|
||||
{
|
||||
@ -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 *
|
||||
|
@ -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 *
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -21,11 +21,16 @@ 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)
|
||||
{
|
||||
@ -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 *
|
||||
|
@ -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 *
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user