summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2015-12-30 17:37:12 -0200
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2015-12-30 17:37:12 -0200
commit961bf5dc886ecd0c5ed03cca73207218a79d45b5 (patch)
tree105b8aabff4ae8b4c27ca400d24c22fc2384ec5c
parent13c4145507bee8226ed2ed4cf143c6c91d64a4c1 (diff)
downloadgnome-calendar-wip/gbsneto/edit-dialog-cleanup.tar.gz
window: setup edit dialog from UI filewip/gbsneto/edit-dialog-cleanup
This commit sets up the edit dialog from the window's ui resource file, in a series of commits that tries to move all C code to the UI definitions. Also, GcalManager is a full GObject class, not a simple pointer. As such, update the property spec to be of type object, not pointer.
-rw-r--r--data/ui/window.ui9
-rw-r--r--src/gcal-window.c51
2 files changed, 33 insertions, 27 deletions
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 3873e594..27f0bf7e 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -55,7 +55,7 @@
<child>
<object class="GcalMonthView" id="month_view">
<property name="visible">True</property>
- <property name="active-date" bind-source="GcalWindow" bind-property="active-date" bind-flags="default|sync-create|bidirectional"/>
+ <property name="active-date" bind-source="GcalWindow" bind-property="active-date" bind-flags="bidirectional"/>
<signal name="create-event" handler="show_new_event_widget" object="GcalWindow" swapped="no"/>
<signal name="create-event-detailed" handler="create_event_detailed_cb" object="GcalWindow" swapped="no"/>
<signal name="event-activated" handler="event_activated" object="GcalWindow" swapped="no"/>
@@ -68,7 +68,7 @@
<child>
<object class="GcalYearView" id="year_view">
<property name="visible">True</property>
- <property name="active-date" bind-source="GcalWindow" bind-property="active-date" bind-flags="default|sync-create|bidirectional"/>
+ <property name="active-date" bind-source="GcalWindow" bind-property="active-date" bind-flags="bidirectional"/>
<signal name="create-event" handler="show_new_event_widget" object="GcalWindow" swapped="no"/>
<signal name="create-event-detailed" handler="create_event_detailed_cb" object="GcalWindow" swapped="no"/>
<signal name="event-activated" handler="event_activated" object="GcalWindow" swapped="no"/>
@@ -413,4 +413,9 @@
<property name="visible">False</property>
<property name="transient_for">GcalWindow</property>
</object>
+ <object class="GcalEditDialog" id="edit_dialog">
+ <property name="visible">False</property>
+ <property name="transient_for">GcalWindow</property>
+ <signal name="response" handler="edit_dialog_closed" object="GcalWindow" swapped="no"/>
+ </object>
</interface>
diff --git a/src/gcal-window.c b/src/gcal-window.c
index f10a8541..642351bc 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -1394,11 +1394,11 @@ gcal_window_class_init(GcalWindowClass *klass)
g_object_class_install_property (
object_class,
PROP_MANAGER,
- g_param_spec_pointer ("manager",
- "The manager object",
- "A weak reference to the app manager object",
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE));
+ g_param_spec_object ("manager",
+ "The manager object",
+ "A weak reference to the app manager object",
+ GCAL_TYPE_MANAGER,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
@@ -1420,6 +1420,7 @@ gcal_window_class_init(GcalWindowClass *klass)
G_PARAM_READWRITE));
/* widgets */
+ gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, edit_dialog);
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, header_bar);
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, main_box);
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, menu_button);
@@ -1478,6 +1479,9 @@ gcal_window_class_init(GcalWindowClass *klass)
/* search related */
gtk_widget_class_bind_template_callback (widget_class, search_event_selected);
+
+ /* Edit dialog related */
+ gtk_widget_class_bind_template_callback (widget_class, edit_dialog_closed);
}
static void
@@ -1485,17 +1489,14 @@ gcal_window_init (GcalWindow *self)
{
GcalWindowPrivate *priv = gcal_window_get_instance_private (self);
- /* source dialog */
- priv->source_dialog = gcal_source_dialog_new ();
- gtk_window_set_transient_for (GTK_WINDOW (priv->source_dialog), GTK_WINDOW (self));
+ gtk_widget_init_template (GTK_WIDGET (self));
+ /* source dialog */
g_object_bind_property (self, "application", priv->source_dialog, "application",
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
priv->active_date = g_new0 (icaltimetype, 1);
priv->rtl = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL;
-
- gtk_widget_init_template (GTK_WIDGET (self));
}
static void
@@ -1543,13 +1544,6 @@ gcal_window_constructed (GObject *object)
g_object_unref (builder);
- /* edit dialog initialization */
- priv->edit_dialog = gcal_edit_dialog_new (use_24h_format);
- gtk_window_set_transient_for (GTK_WINDOW (priv->edit_dialog), GTK_WINDOW (object));
- gcal_edit_dialog_set_manager (GCAL_EDIT_DIALOG (priv->edit_dialog), priv->manager);
-
- g_signal_connect (priv->edit_dialog, "response", G_CALLBACK (edit_dialog_closed), object);
-
/* XXX: Week view disabled until after the release when we restart the work on it*/
//priv->views[GCAL_WINDOW_VIEW_WEEK] = gcal_week_view_new ();
//gcal_week_view_set_manager (GCAL_WEEK_VIEW (priv->views[GCAL_WINDOW_VIEW_WEEK]), priv->manager);
@@ -1595,6 +1589,8 @@ gcal_window_finalize (GObject *object)
priv = gcal_window_get_instance_private (GCAL_WINDOW (object));
+ g_clear_object (&priv->manager);
+
g_free (priv->active_date);
g_free (priv->current_date);
@@ -1629,14 +1625,19 @@ gcal_window_set_property (GObject *object,
set_new_event_mode (GCAL_WINDOW (object), g_value_get_boolean (value));
return;
case PROP_MANAGER:
- priv->manager = g_value_get_pointer (value);
- g_signal_connect (priv->manager, "source-added", G_CALLBACK (add_source), object);
- g_signal_connect (priv->manager, "source-enabled", G_CALLBACK (source_enabled), object);
- g_signal_connect (priv->manager, "source-removed", G_CALLBACK (remove_source), object);
-
- gcal_year_view_set_manager (GCAL_YEAR_VIEW (priv->year_view), priv->manager);
- gcal_source_dialog_set_manager (GCAL_SOURCE_DIALOG (priv->source_dialog), priv->manager);
- update_current_date (GCAL_WINDOW (object));
+ if (g_set_object (&priv->manager, g_value_get_object (value)))
+ {
+ g_signal_connect (priv->manager, "source-added", G_CALLBACK (add_source), object);
+ g_signal_connect (priv->manager, "source-enabled", G_CALLBACK (source_enabled), object);
+ g_signal_connect (priv->manager, "source-removed", G_CALLBACK (remove_source), object);
+
+ gcal_edit_dialog_set_manager (GCAL_EDIT_DIALOG (priv->edit_dialog), priv->manager);
+ gcal_year_view_set_manager (GCAL_YEAR_VIEW (priv->year_view), priv->manager);
+ gcal_source_dialog_set_manager (GCAL_SOURCE_DIALOG (priv->source_dialog), priv->manager);
+ update_current_date (GCAL_WINDOW (object));
+
+ g_object_notify (object, "manager");
+ }
return;
}