[gnome-calendar] window: move more code into ui file
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] window: move more code into ui file
- Date: Thu, 4 Dec 2014 22:44:51 +0000 (UTC)
commit f8f8991510ed19d2547b975c7cc2f5e71714a770
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Wed Nov 26 09:10:05 2014 -0500
window: move more code into ui file
Probably I can load the GMenuModel of the popover directly but I don't
know exactly how, and I've asked already and you can set bindings using
builder's ui file, just like before I don't know how at this time.
data/ui/window.ui | 17 +++++++++++++++++
src/gcal-window.c | 36 +++++++++---------------------------
2 files changed, 26 insertions(+), 27 deletions(-)
---
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 5378fc8..13ecd1f 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -8,6 +8,7 @@
<property name="default_width">800</property>
<property name="default_height">600</property>
<property name="show_menubar">False</property>
+ <signal name="key-press-event" handler="key_pressed" object="GcalWindow" swapped="no"/>
<child>
<object class="GtkOverlay" id="views_overlay">
<property name="visible">True</property>
@@ -25,6 +26,7 @@
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="show_close_button">True</property>
+ <signal name="notify::search-mode-enabled" handler="search_toggled" object="GcalWindow"
swapped="no"/>
<child>
<object class="GtkGrid" id="search_entry_grid">
<property name="visible">True</property>
@@ -39,6 +41,7 @@
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
+ <signal name="search-changed" handler="search_changed" object="GcalWindow"
swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
@@ -61,6 +64,8 @@
<property name="vexpand">True</property>
<property name="transition_duration">250</property>
<property name="transition_type">slide-left-right</property>
+ <signal name="notify::visible-child" handler="view_changed" object="GcalWindow" swapped="no"/>
+ <signal name="notify::transition-running" handler="stack_transition_running"
object="GcalWindow" swapped="no"/>
<style>
<class name="views"/>
</style>
@@ -96,6 +101,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="date_updated" object="GcalWindow" swapped="no"/>
</object>
</child>
<child type="title">
@@ -110,10 +116,12 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_popover">True</property>
<child>
<object class="GtkImage" id="menu_image">
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
+ <property name="icon_size">1</property>
</object>
</child>
</object>
@@ -144,4 +152,13 @@
<class name="views"/>
</style>
</template>
+ <object class="GtkPopover" id="popover">
+ <property name="visible">False</property>
+ <property name="relative_to">views_stack</property>
+ <child>
+ <object class="GcalNewEventWidget" id="new_event_widget">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 5c3ab44..a89b1d2 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -980,6 +980,15 @@ gcal_window_class_init(GcalWindowClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, views_overlay);
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, views_stack);
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, views_switcher);
+ gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, popover);
+ gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, new_event_widget);
+
+ gtk_widget_class_bind_template_callback (widget_class, key_pressed);
+ gtk_widget_class_bind_template_callback (widget_class, search_toggled);
+ gtk_widget_class_bind_template_callback (widget_class, search_changed);
+ gtk_widget_class_bind_template_callback (widget_class, view_changed);
+ gtk_widget_class_bind_template_callback (widget_class, stack_transition_running);
+ gtk_widget_class_bind_template_callback (widget_class, date_updated);
}
static void
@@ -1029,8 +1038,6 @@ gcal_window_constructed (GObject *object)
/* header_bar: menu */
- gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (priv->menu_button),
- TRUE);
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder,
"/org/gnome/calendar/menus.ui",
@@ -1049,7 +1056,6 @@ gcal_window_constructed (GObject *object)
priv->search_bar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
-
priv->views[GCAL_WINDOW_VIEW_WEEK] =
gcal_week_view_new (priv->manager);
gcal_week_view_set_first_weekday (
@@ -1086,18 +1092,7 @@ gcal_window_constructed (GObject *object)
"active-date",
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
- /* popover and content */
- priv->popover = gtk_popover_new (GTK_WIDGET(priv->views_stack));
-
- priv->new_event_widget = gcal_new_event_widget_new ();
-
- gtk_container_add (GTK_CONTAINER(priv->popover),
- GTK_WIDGET(priv->new_event_widget));
-
/* signals connection/handling */
- g_signal_connect (object, "key-press-event",
- G_CALLBACK (key_pressed), object);
-
/* HACK to ensure proper destroy of search-view widget */
g_signal_connect_swapped (priv->views_stack, "destroy",
G_CALLBACK (gtk_widget_destroy),
@@ -1120,19 +1115,6 @@ gcal_window_constructed (GObject *object)
}
}
- g_signal_connect (priv->search_bar, "notify::search-mode-enabled",
- G_CALLBACK (search_toggled), object);
- g_signal_connect (priv->search_entry, "search-changed",
- G_CALLBACK (search_changed), object);
-
- g_signal_connect (priv->views_stack, "notify::visible-child",
- G_CALLBACK (view_changed), object);
- g_signal_connect (priv->views_stack, "notify::transition-running",
- G_CALLBACK (stack_transition_running), object);
-
- g_signal_connect (priv->today_button, "clicked",
- G_CALLBACK (date_updated), object);
-
g_signal_connect (gcal_nav_bar_get_prev_button (GCAL_NAV_BAR (priv->nav_bar)),
"clicked", G_CALLBACK (date_updated), object);
g_signal_connect (gcal_nav_bar_get_next_button (GCAL_NAV_BAR (priv->nav_bar)),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]