X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-hildon2-window.c;h=d29430f6b847c958fb2e1379307572e5c57224ff;hb=bf73e6d4cafc7915d75baf18640e5aeb4753e02f;hp=34ec43d5bc79793eff99b108d59b290bb6814589;hpb=d7ace61fff2fe0e816ac8fc0831e58a622cd9610;p=modest diff --git a/src/hildon2/modest-hildon2-window.c b/src/hildon2/modest-hildon2-window.c index 34ec43d..d29430f 100644 --- a/src/hildon2/modest-hildon2-window.c +++ b/src/hildon2/modest-hildon2-window.c @@ -52,19 +52,30 @@ typedef struct _EditModeRegister { /* 'private'/'protected' functions */ static void modest_hildon2_window_class_init (gpointer klass, gpointer class_data); static void modest_hildon2_window_instance_init (GTypeInstance *instance, gpointer g_class); -static void modest_hildon2_window_finalize (GObject *obj); +static void modest_hildon2_window_dispose (GObject *obj); static gboolean on_zoom_minus_plus_not_implemented (ModestWindow *window); +static void modest_hildon2_window_show_progress (ModestWindow *window, + gboolean show); static void setup_menu (ModestHildon2Window *self); static void modest_hildon2_window_show_toolbar (ModestWindow *self, gboolean show_toolbar); +static void modest_hildon2_window_add_toolbar (ModestWindow *self, + GtkToolbar *toolbar); +static void modest_hildon2_window_add_to_menu (ModestWindow *window, + const gchar *label, + const gchar *accelerator, + ModestWindowMenuCallback callback, + ModestDimmingCallback dimming_callback); +static void modest_hildon2_window_add_item_to_menu (ModestWindow *window, + GtkWidget *item, + ModestDimmingCallback dimming_callback); +static void modest_hildon2_window_set_title (ModestWindow *self, + const gchar *title); static gboolean modest_hildon2_window_toggle_menu (HildonWindow *window, guint button, guint32 time); -static void modest_hildon2_window_pack_toolbar_not_implemented (ModestHildon2Window *self, - GtkPackType pack_type, - GtkWidget *toolbar); static EditModeRegister *edit_mode_register_new (const gchar *description, const gchar *button_label, GtkTreeView *tree_view, @@ -139,10 +150,9 @@ modest_hildon2_window_class_init (gpointer klass, gpointer class_data) gobject_class = (GObjectClass*) klass; ModestWindowClass *modest_window_class = (ModestWindowClass *) klass; HildonWindowClass *hildon_window_class = (HildonWindowClass *) klass; - ModestHildon2WindowClass *modest_hildon2_window_class = (ModestHildon2WindowClass *) klass; parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = modest_hildon2_window_finalize; + gobject_class->dispose = modest_hildon2_window_dispose; signals[EDIT_MODE_CHANGED_SIGNAL] = g_signal_new ("edit-mode-changed", @@ -160,24 +170,32 @@ modest_hildon2_window_class_init (gpointer klass, gpointer class_data) modest_window_class->zoom_minus_func = on_zoom_minus_plus_not_implemented; modest_window_class->zoom_plus_func = on_zoom_minus_plus_not_implemented; modest_window_class->show_toolbar_func = modest_hildon2_window_show_toolbar; + modest_window_class->add_toolbar_func = modest_hildon2_window_add_toolbar; + modest_window_class->add_to_menu_func = modest_hildon2_window_add_to_menu; + modest_window_class->add_item_to_menu_func = modest_hildon2_window_add_item_to_menu; + modest_window_class->set_title_func = modest_hildon2_window_set_title; + modest_window_class->show_progress_func = modest_hildon2_window_show_progress; - modest_hildon2_window_class->pack_toolbar_func = modest_hildon2_window_pack_toolbar_not_implemented; } static void -modest_hildon2_window_finalize (GObject *obj) +modest_hildon2_window_dispose (GObject *obj) { ModestHildon2WindowPrivate *priv; priv = MODEST_HILDON2_WINDOW_GET_PRIVATE(obj); - g_object_unref (priv->app_menu_dimming_group); - priv->app_menu_dimming_group = NULL; + if (priv->app_menu_dimming_group) { + g_object_unref (priv->app_menu_dimming_group); + priv->app_menu_dimming_group = NULL; + } - g_hash_table_destroy (priv->edit_mode_registry); - priv->edit_mode_registry = NULL; + if (priv->edit_mode_registry) { + g_hash_table_unref (priv->edit_mode_registry); + priv->edit_mode_registry = NULL; + } - G_OBJECT_CLASS(parent_class)->finalize (obj); + G_OBJECT_CLASS(parent_class)->dispose (obj); } static void @@ -200,7 +218,6 @@ modest_hildon2_window_instance_init (GTypeInstance *instance, gpointer g_class) priv->edit_mode_registry = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, edit_mode_register_destroy); - parent_priv->ui_dimming_manager = modest_ui_dimming_manager_new(); priv->app_menu_dimming_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_MENU, FALSE); gtk_window_add_accel_group (GTK_WINDOW (self), priv->accel_group); @@ -221,34 +238,13 @@ on_zoom_minus_plus_not_implemented (ModestWindow *window) { g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW (window), FALSE); - hildon_banner_show_information (NULL, NULL, _CS("ckct_ib_cannot_zoom_here")); + hildon_banner_show_information (NULL, NULL, _CS_CANNOT_ZOOM_HERE); return FALSE; } - -static void -modest_hildon2_window_pack_toolbar_not_implemented (ModestHildon2Window *self, - GtkPackType pack_type, - GtkWidget *toolbar) -{ - g_return_if_fail (MODEST_IS_HILDON2_WINDOW (self)); - - g_warning ("%s not implemented", __FUNCTION__); -} - -void -modest_hildon2_window_pack_toolbar (ModestHildon2Window *self, - GtkPackType pack_type, - GtkWidget *toolbar) -{ - g_return_if_fail (MODEST_IS_HILDON2_WINDOW (self)); - - MODEST_HILDON2_WINDOW_GET_CLASS (self)->pack_toolbar_func (self, pack_type, toolbar); -} - void -modest_hildon2_window_add_button_to_menu (ModestHildon2Window *self, - GtkButton *button, - ModestDimmingCallback dimming_callback) +modest_hildon2_window_add_item_to_menu (ModestWindow *self, + GtkWidget *button, + ModestDimmingCallback dimming_callback) { ModestHildon2WindowPrivate *priv; @@ -256,19 +252,23 @@ modest_hildon2_window_add_button_to_menu (ModestHildon2Window *self, g_return_if_fail (GTK_IS_BUTTON (button)); priv = MODEST_HILDON2_WINDOW_GET_PRIVATE (self); + modest_ui_dimming_manager_set_widget_dimming_mode (GTK_WIDGET (button), + MODEST_UI_DIMMING_MODE_HIDE); + if (dimming_callback) modest_dimming_rules_group_add_widget_rule (priv->app_menu_dimming_group, GTK_WIDGET (button), (GCallback) dimming_callback, MODEST_WINDOW (self)); hildon_app_menu_append (HILDON_APP_MENU (priv->app_menu), GTK_BUTTON (button)); + gtk_widget_show (GTK_WIDGET (button)); } -void -modest_hildon2_window_add_to_menu (ModestHildon2Window *self, - gchar *label, +static void +modest_hildon2_window_add_to_menu (ModestWindow *self, + const gchar *label, const gchar *accelerator, - ModestHildon2AppMenuCallback callback, + ModestWindowMenuCallback callback, ModestDimmingCallback dimming_callback) { ModestHildon2WindowPrivate *priv = NULL; @@ -293,7 +293,7 @@ modest_hildon2_window_add_to_menu (ModestHildon2Window *self, accel_key, accel_mods, 0); } - modest_hildon2_window_add_button_to_menu (self, GTK_BUTTON (button), dimming_callback); + modest_window_add_item_to_menu (MODEST_WINDOW (self), GTK_WIDGET (button), dimming_callback); } static void setup_menu (ModestHildon2Window *self) @@ -337,6 +337,30 @@ modest_hildon2_window_show_toolbar (ModestWindow *self, * doesn't switch toolbar visibility */ } +static void +modest_hildon2_window_add_toolbar (ModestWindow *self, + GtkToolbar *toolbar) +{ + hildon_window_add_toolbar (HILDON_WINDOW (self), + toolbar); +} + +static void +modest_hildon2_window_set_title (ModestWindow *self, + const gchar *title) +{ + gtk_window_set_title (GTK_WINDOW (self), + title); +} + +static void +modest_hildon2_window_show_progress (ModestWindow *self, + gboolean show) +{ + hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), + show); +} + void modest_hildon2_window_register_edit_mode (ModestHildon2Window *self, gint edit_mode_id, @@ -411,8 +435,8 @@ modest_hildon2_window_set_edit_mode (ModestHildon2Window *self, reg->description); hildon_edit_toolbar_set_button_label (HILDON_EDIT_TOOLBAR (priv->edit_toolbar), reg->button_label); - modest_hildon2_window_pack_toolbar (self, GTK_PACK_START, - priv->edit_toolbar); + modest_window_pack_toolbar (MODEST_WINDOW (self), GTK_PACK_START, + priv->edit_toolbar); g_signal_connect (G_OBJECT (priv->edit_toolbar), "button-clicked", G_CALLBACK (edit_toolbar_button_clicked), (gpointer) self); @@ -501,7 +525,7 @@ edit_toolbar_button_clicked (HildonEditToolbar *toolbar, GINT_TO_POINTER (priv->edit_command)); if (reg) { - if ((reg->action == NULL) || reg->action (self)) + if ((reg->action == NULL) || reg->action (MODEST_WINDOW (self))) modest_hildon2_window_unset_edit_mode (self); } else { modest_hildon2_window_unset_edit_mode (self);