From 0f092ed43eb331d03c0db9ca1e76ab12cba678b5 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Sun, 15 Apr 2007 11:32:49 +0000 Subject: [PATCH] 2007-04-15 Sergio Villar Senin * Fixed the issue with the reply button popup * Removed create_toolbar virtual method * Fixed the GTK_STOCK_FULLSCREEN double definition in GNOME * Replaced the hildon_window_toolbar_add/remove by gtk_widget_show/remove functions pmo-trunk-r1561 --- src/maemo/modest-main-window.c | 55 +++++++++++++------------------ src/maemo/modest-msg-edit-window.c | 27 ++++----------- src/maemo/modest-msg-view-window.c | 54 ++++++++++++++---------------- src/widgets/modest-msg-edit-window-ui.h | 2 +- src/widgets/modest-window-mgr.c | 8 ++--- src/widgets/modest-window.c | 33 +------------------ src/widgets/modest-window.h | 11 +++---- 7 files changed, 65 insertions(+), 125 deletions(-) diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index c4d2559..e3c120f 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -64,7 +64,6 @@ static void connect_signals (ModestMainWindow *self); static void restore_sizes (ModestMainWindow *self); static void save_sizes (ModestMainWindow *self); -static void modest_main_window_create_toolbar (ModestWindow *window); static void modest_main_window_show_toolbar (ModestWindow *window, gboolean show_toolbar); @@ -143,7 +142,6 @@ modest_main_window_class_init (ModestMainWindowClass *klass) parent_class = g_type_class_peek_parent (klass); gobject_class->finalize = modest_main_window_finalize; - modest_window_class->create_toolbar_func = modest_main_window_create_toolbar; modest_window_class->show_toolbar_func = modest_main_window_show_toolbar; g_type_class_add_private (gobject_class, sizeof(ModestMainWindowPrivate)); @@ -578,44 +576,37 @@ set_homogeneous (GtkWidget *widget, } static void -modest_main_window_create_toolbar (ModestWindow *self) -{ - GtkWidget *reply_button, *menu; - ModestWindowPrivate *parent_priv; - - parent_priv = MODEST_WINDOW_GET_PRIVATE(self); - - /* Toolbar */ - parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, - "/ToolBar"); - - /* Set homogeneous toolbar */ - gtk_container_foreach (GTK_CONTAINER (parent_priv->toolbar), - set_homogeneous, NULL); - - /* Set reply button tap and hold menu */ - reply_button = gtk_ui_manager_get_widget (parent_priv->ui_manager, - "/ToolBar/ToolbarMessageReply"); - menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolbarReplyContextMenu"); - gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0); -} - -static void modest_main_window_show_toolbar (ModestWindow *self, gboolean show_toolbar) { ModestWindowPrivate *parent_priv; + GtkWidget *reply_button = NULL, *menu = NULL; parent_priv = MODEST_WINDOW_GET_PRIVATE(self); - if (!parent_priv->toolbar) - return; + if (!parent_priv->toolbar && show_toolbar) { + parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, + "/ToolBar"); + + /* Set homogeneous toolbar */ + gtk_container_foreach (GTK_CONTAINER (parent_priv->toolbar), + set_homogeneous, NULL); - if (show_toolbar) { + /* Add to window */ hildon_window_add_toolbar (HILDON_WINDOW (self), GTK_TOOLBAR (parent_priv->toolbar)); - gtk_widget_show_all (GTK_WIDGET (self)); - } else - hildon_window_remove_toolbar (HILDON_WINDOW (self), - GTK_TOOLBAR (parent_priv->toolbar)); + + /* Set reply button tap and hold menu */ + reply_button = gtk_ui_manager_get_widget (parent_priv->ui_manager, + "/ToolBar/ToolbarMessageReply"); + menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, + "/ToolbarReplyContextMenu"); + gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0); + } + + + if (show_toolbar) + gtk_widget_show (GTK_WIDGET (parent_priv->toolbar)); + else + gtk_widget_hide (GTK_WIDGET (parent_priv->toolbar)); } diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index 91cd6eb..8d6987b 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -100,7 +100,6 @@ static void modest_msg_edit_window_set_zoom (ModestWindow *window, gdouble zoom static gdouble modest_msg_edit_window_get_zoom (ModestWindow *window); static gboolean modest_msg_edit_window_zoom_minus (ModestWindow *window); static gboolean modest_msg_edit_window_zoom_plus (ModestWindow *window); -static void modest_msg_edit_window_create_toolbar (ModestWindow *window); static void modest_msg_edit_window_show_toolbar (ModestWindow *window, gboolean show_toolbar); @@ -191,7 +190,6 @@ modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass) modest_window_class->get_zoom_func = modest_msg_edit_window_get_zoom; modest_window_class->zoom_plus_func = modest_msg_edit_window_zoom_plus; modest_window_class->zoom_minus_func = modest_msg_edit_window_zoom_minus; - modest_window_class->create_toolbar_func = modest_msg_edit_window_create_toolbar; modest_window_class->show_toolbar_func = modest_msg_edit_window_show_toolbar; g_type_class_add_private (gobject_class, sizeof(ModestMsgEditWindowPrivate)); @@ -1409,15 +1407,6 @@ modest_msg_edit_window_show_bcc (ModestMsgEditWindow *window, gtk_widget_hide (priv->bcc_caption); } - -static void -modest_msg_edit_window_create_toolbar (ModestWindow *self) -{ - /* FIXME: we can not just use the code of - modest_msg_edit_window_setup_toolbar because it has a - mixture of both initialization and creation code. */ -} - static void modest_msg_edit_window_show_toolbar (ModestWindow *self, gboolean show_toolbar) @@ -1426,14 +1415,12 @@ modest_msg_edit_window_show_toolbar (ModestWindow *self, parent_priv = MODEST_WINDOW_GET_PRIVATE(self); - if (!parent_priv->toolbar) - return; + /* FIXME: we can not just use the code of + modest_msg_edit_window_setup_toolbar because it has a + mixture of both initialization and creation code. */ - if (show_toolbar) { - hildon_window_add_toolbar (HILDON_WINDOW (self), - GTK_TOOLBAR (parent_priv->toolbar)); - gtk_widget_show_all (GTK_WIDGET (self)); - } else - hildon_window_remove_toolbar (HILDON_WINDOW (self), - GTK_TOOLBAR (parent_priv->toolbar)); + if (show_toolbar) + gtk_widget_show (GTK_WIDGET (parent_priv->toolbar)); + else + gtk_widget_hide (GTK_WIDGET (parent_priv->toolbar)); } diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index 32be782..062e979 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -74,7 +74,6 @@ static TnyFolderType modest_msg_view_window_get_folder_type (ModestMsgViewWindow static void modest_msg_view_window_update_dimmed (ModestMsgViewWindow *window); static void modest_msg_view_window_update_priority (ModestMsgViewWindow *window); -static void modest_msg_view_window_create_toolbar (ModestWindow *window); static void modest_msg_view_window_show_toolbar (ModestWindow *window, gboolean show_toolbar); @@ -159,7 +158,6 @@ modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass) modest_window_class->get_zoom_func = modest_msg_view_window_get_zoom; modest_window_class->zoom_minus_func = modest_msg_view_window_zoom_minus; modest_window_class->zoom_plus_func = modest_msg_view_window_zoom_plus; - modest_window_class->create_toolbar_func = modest_msg_view_window_create_toolbar; modest_window_class->show_toolbar_func = modest_msg_view_window_show_toolbar; g_type_class_add_private (gobject_class, sizeof(ModestMsgViewWindowPrivate)); @@ -936,43 +934,39 @@ set_homogeneous (GtkWidget *widget, } } -static void -modest_msg_view_window_create_toolbar (ModestWindow *self) -{ - GtkWidget *reply_button, *menu; - ModestWindowPrivate *parent_priv; - - parent_priv = MODEST_WINDOW_GET_PRIVATE (self); - - /* Toolbar */ - parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar"); - - /* Set homogeneous */ - gtk_container_foreach (GTK_CONTAINER (parent_priv->toolbar), - set_homogeneous, NULL); - - /* Set reply button tap and hold menu */ - reply_button = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarMessageReply"); - menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolbarReplyCSM"); - gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0); -} - static void modest_msg_view_window_show_toolbar (ModestWindow *self, gboolean show_toolbar) { ModestWindowPrivate *parent_priv; + GtkWidget *reply_button = NULL, *menu = NULL; parent_priv = MODEST_WINDOW_GET_PRIVATE(self); - if (!parent_priv->toolbar) - return; + if (!parent_priv->toolbar && show_toolbar) { + parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, + "/ToolBar"); - if (show_toolbar) { + /* Set homogeneous toolbar */ + gtk_container_foreach (GTK_CONTAINER (parent_priv->toolbar), + set_homogeneous, NULL); + + /* Add to window */ hildon_window_add_toolbar (HILDON_WINDOW (self), GTK_TOOLBAR (parent_priv->toolbar)); - gtk_widget_show_all (GTK_WIDGET (self)); - } else - hildon_window_remove_toolbar (HILDON_WINDOW (self), - GTK_TOOLBAR (parent_priv->toolbar)); + + + /* Set reply button tap and hold menu */ + reply_button = gtk_ui_manager_get_widget (parent_priv->ui_manager, + "/ToolBar/ToolbarMessageReply"); + menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, + "/ToolbarReplyCSM"); + gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0); + } + + + if (show_toolbar) + gtk_widget_show (GTK_WIDGET (parent_priv->toolbar)); + else + gtk_widget_hide (GTK_WIDGET (parent_priv->toolbar)); } diff --git a/src/widgets/modest-msg-edit-window-ui.h b/src/widgets/modest-msg-edit-window-ui.h index c7b97ec..3e299b3 100644 --- a/src/widgets/modest-msg-edit-window-ui.h +++ b/src/widgets/modest-msg-edit-window-ui.h @@ -72,7 +72,7 @@ static const GtkToggleActionEntry modest_msg_edit_toggle_action_entries [] = { { "ViewBccField", NULL, N_("Bcc: filed"), NULL, N_("Shows the Bcc: field"), G_CALLBACK (modest_ui_actions_on_toggle_show_bcc), TRUE }, /* Fullscreen toggle */ - { "ViewToggleFullscreen", GTK_STOCK_FULLSCREEN, N_("Show fullscreen"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_toggle_fullscreen), FALSE}, + { "ViewToggleFullscreen", NULL, N_("Show fullscreen"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_toggle_fullscreen), FALSE}, /* Rich text editor functions */ { "ActionsBold", GTK_STOCK_BOLD, N_("Bold"), NULL, N_("Use bold"), G_CALLBACK (modest_ui_actions_on_toggle_bold), FALSE }, diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index 7758ca5..5ba17bc 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -189,7 +189,7 @@ modest_window_mgr_register_window (ModestWindowMgr *self, show = priv->show_toolbars_fullscreen; else show = priv->show_toolbars; - modest_window_view_toolbar (window, show); + modest_window_show_toolbar (window, show); } static void @@ -329,11 +329,11 @@ modest_window_mgr_set_fullscreen_mode (ModestWindowMgr *self, while (win) { if (on) { gtk_window_fullscreen (GTK_WINDOW (win->data)); - modest_window_view_toolbar (MODEST_WINDOW (win->data), + modest_window_show_toolbar (MODEST_WINDOW (win->data), priv->show_toolbars_fullscreen); } else { gtk_window_unfullscreen (GTK_WINDOW (win->data)); - modest_window_view_toolbar (MODEST_WINDOW (win->data), + modest_window_show_toolbar (MODEST_WINDOW (win->data), priv->show_toolbars); } win = g_list_next (win); @@ -386,7 +386,7 @@ modest_window_mgr_show_toolbars (ModestWindowMgr *self, GList *win = priv->window_list; while (win) { - modest_window_view_toolbar (MODEST_WINDOW (win->data), + modest_window_show_toolbar (MODEST_WINDOW (win->data), show_toolbars); win = g_list_next (win); } diff --git a/src/widgets/modest-window.c b/src/widgets/modest-window.c index 18296bc..ee4553e 100644 --- a/src/widgets/modest-window.c +++ b/src/widgets/modest-window.c @@ -41,7 +41,6 @@ static void modest_window_set_zoom_default (ModestWindow *window, static gdouble modest_window_get_zoom_default (ModestWindow *window); static gboolean modest_window_zoom_plus_default (ModestWindow *window); static gboolean modest_window_zoom_minus_default (ModestWindow *window); -static void modest_window_create_toolbar_default (ModestWindow *window); static void modest_window_show_toolbar_default (ModestWindow *window, gboolean show_toolbar); @@ -100,7 +99,6 @@ modest_window_class_init (ModestWindowClass *klass) klass->get_zoom_func = modest_window_get_zoom_default; klass->zoom_plus_func = modest_window_zoom_plus_default; klass->zoom_minus_func = modest_window_zoom_minus_default; - klass->create_toolbar_func = modest_window_create_toolbar_default; klass->show_toolbar_func = modest_window_show_toolbar_default; g_type_class_add_private (gobject_class, sizeof(ModestWindowPrivate)); @@ -188,13 +186,7 @@ modest_window_zoom_minus (ModestWindow *window) return MODEST_WINDOW_GET_CLASS (window)->zoom_minus_func (window); } -static void -modest_window_create_toolbar (ModestWindow *window) -{ - MODEST_WINDOW_GET_CLASS (window)->create_toolbar_func (window); -} - -static void +void modest_window_show_toolbar (ModestWindow *window, gboolean show_toolbar) { @@ -202,23 +194,6 @@ modest_window_show_toolbar (ModestWindow *window, show_toolbar); } -void -modest_window_view_toolbar (ModestWindow *window, - gboolean show_toolbar) -{ - ModestWindowPrivate *priv; - - priv = MODEST_WINDOW_GET_PRIVATE(window); - - /* Lazy strategy, we create the toolbar just when there is no - toolbar and we want to show it */ - if (!priv->toolbar && show_toolbar) - modest_window_create_toolbar (window); - - if (priv->toolbar) - modest_window_show_toolbar (window, show_toolbar); -} - /* Default implementations */ @@ -252,12 +227,6 @@ modest_window_zoom_minus_default (ModestWindow *window) } static void -modest_window_create_toolbar_default (ModestWindow *window) -{ - g_warning ("modest: You should implement %s", __FUNCTION__); -} - -static void modest_window_show_toolbar_default (ModestWindow *window, gboolean show_toolbar) { diff --git a/src/widgets/modest-window.h b/src/widgets/modest-window.h index 4ea979b..90b617a 100644 --- a/src/widgets/modest-window.h +++ b/src/widgets/modest-window.h @@ -53,12 +53,13 @@ typedef GtkWindowClass ModestWindowParentClass; #include typedef HildonWindow ModestWindowParent; typedef HildonWindowClass ModestWindowParentClass; -#endif /*MODEST_PLATFORM_MAEMO */ #ifndef GTK_STOCK_FULLSCREEN #define GTK_STOCK_FULLSCREEN "" #endif /*GTK_STOCK_FULLSCREEN*/ +#endif /*MODEST_PLATFORM_MAEMO */ + /* convenience macros */ #define MODEST_TYPE_WINDOW (modest_window_get_type()) #define MODEST_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_WINDOW,ModestWindow)) @@ -82,8 +83,6 @@ struct _ModestWindowClass { gdouble (*get_zoom_func) (ModestWindow *self); gboolean (*zoom_plus_func) (ModestWindow *self); gboolean (*zoom_minus_func) (ModestWindow *self); - /* Used by view_toolbar, with no public interface */ - void (*create_toolbar_func) (ModestWindow *self); void (*show_toolbar_func) (ModestWindow *self, gboolean show_toolbar); }; @@ -161,14 +160,14 @@ gboolean modest_window_zoom_minus (ModestWindow *window); /** - * modest_window_view_toolbar: + * modest_window_show_toolbar: * @window: * @view_toolbar: whether or not the toolbar should be shown * * shows/hides the window toolbar **/ -void modest_window_view_toolbar (ModestWindow *window, - gboolean view_toolbar); +void modest_window_show_toolbar (ModestWindow *window, + gboolean show_toolbar); G_END_DECLS -- 1.7.9.5