From f02ac5fc983a182ad696716fabb5fd2242256031 Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Wed, 14 Jan 2009 09:48:33 +0000 Subject: [PATCH] Now ModestHildon2Window notifies with a signal about edit mode changes. pmo-trunk-r7138 --- src/hildon2/modest-hildon2-window.c | 28 ++++++++++++++++++++++++++-- src/hildon2/modest-hildon2-window.h | 4 ++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/hildon2/modest-hildon2-window.c b/src/hildon2/modest-hildon2-window.c index 86507cb..7e6f394 100644 --- a/src/hildon2/modest-hildon2-window.c +++ b/src/hildon2/modest-hildon2-window.c @@ -92,9 +92,18 @@ struct _ModestHildon2WindowPrivate { MODEST_TYPE_HILDON2_WINDOW, \ ModestHildon2WindowPrivate)) +/* list my signals */ +enum { + EDIT_MODE_CHANGED_SIGNAL, + LAST_SIGNAL +}; + /* globals */ static GtkWindowClass *parent_class = NULL; +/* uncomment the following if you have defined any signals */ +static guint signals[LAST_SIGNAL] = {0}; + /************************************************************************/ GType @@ -133,6 +142,15 @@ modest_hildon2_window_class_init (gpointer klass, gpointer class_data) parent_class = g_type_class_peek_parent (klass); gobject_class->finalize = modest_hildon2_window_finalize; + signals[EDIT_MODE_CHANGED_SIGNAL] = + g_signal_new ("edit-mode-changed", + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (ModestHildon2WindowClass, edit_mode_changed), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT); + g_type_class_add_private (gobject_class, sizeof(ModestHildon2WindowPrivate)); hildon_window_class->toggle_menu = modest_hildon2_window_toggle_menu; @@ -176,7 +194,7 @@ modest_hildon2_window_instance_init (GTypeInstance *instance, gpointer g_class) priv->edit_mode = FALSE; priv->edit_toolbar = NULL; priv->current_edit_tree_view = NULL; - priv->edit_command = -1; + priv->edit_command = MODEST_HILDON2_WINDOW_EDIT_MODE_NONE; priv->edit_mode_registry = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, edit_mode_register_destroy); @@ -393,6 +411,9 @@ modest_hildon2_window_set_edit_mode (ModestHildon2Window *self, gtk_widget_queue_resize (priv->current_edit_tree_view); gtk_window_fullscreen (GTK_WINDOW (self)); + g_signal_emit (G_OBJECT (self), signals[EDIT_MODE_CHANGED_SIGNAL], 0, + priv->edit_command); + } void @@ -410,7 +431,7 @@ modest_hildon2_window_unset_edit_mode (ModestHildon2Window *self) if (priv->edit_mode) { priv->edit_mode = FALSE; - priv->edit_command = -1; + priv->edit_command = MODEST_HILDON2_WINDOW_EDIT_MODE_NONE; if (priv->current_edit_tree_view) { g_object_set (G_OBJECT (priv->current_edit_tree_view), "hildon-ui-mode", HILDON_UI_MODE_NORMAL, @@ -419,6 +440,9 @@ modest_hildon2_window_unset_edit_mode (ModestHildon2Window *self) priv->current_edit_tree_view = NULL; } gtk_window_unfullscreen (GTK_WINDOW (self)); + g_signal_emit (G_OBJECT (self), signals[EDIT_MODE_CHANGED_SIGNAL], 0, + priv->edit_command); + } } diff --git a/src/hildon2/modest-hildon2-window.h b/src/hildon2/modest-hildon2-window.h index 51a52af..3c8f02e 100644 --- a/src/hildon2/modest-hildon2-window.h +++ b/src/hildon2/modest-hildon2-window.h @@ -56,6 +56,7 @@ struct _ModestHildon2WindowClass { ModestWindowClass parent_class; void (*pack_toolbar_func) (ModestHildon2Window *self, GtkPackType pack_type, GtkWidget *toolbar); + void (*edit_mode_changed) (ModestHildon2Window *self, gint edit_mode); }; typedef void (*ModestHildon2AppMenuCallback) (GObject *control, gpointer userdata); @@ -64,6 +65,9 @@ typedef gboolean (*ModestHildon2EditModeCallback) (ModestHildon2Window *self); #define APP_MENU_CALLBACK(x) ((ModestHildon2AppMenuCallback) (x)) #define EDIT_MODE_CALLBACK(x) ((ModestHildon2EditModeCallback) (x)) +/* edit mode id for no edit mode */ +#define MODEST_HILDON2_WINDOW_EDIT_MODE_NONE -1 + /** * modest_hildon2_window_get_type: * -- 1.7.9.5