Refactor part of ModestWindow and ModestHildon2Window
[modest] / src / hildon2 / modest-hildon2-window.c
index f0e33a1..8262f82 100644 (file)
@@ -63,14 +63,19 @@ 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,
@@ -167,10 +172,11 @@ modest_hildon2_window_class_init (gpointer klass, gpointer class_data)
        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
@@ -237,31 +243,10 @@ on_zoom_minus_plus_not_implemented (ModestWindow *window)
        hildon_banner_show_information (NULL, NULL, _CS("ckct_ib_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_debug ("%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;
 
@@ -281,11 +266,11 @@ modest_hildon2_window_add_button_to_menu (ModestHildon2Window *self,
        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;
@@ -310,7 +295,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)
@@ -452,8 +437,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);