Migrated hildon2 to text-utils dgettext macros
[modest] / src / hildon2 / modest-hildon2-window.c
index 0888f5a..995eeb9 100644 (file)
@@ -30,6 +30,7 @@
 #include <hildon/hildon-banner.h>
 #include <modest-platform.h>
 #include <hildon/hildon-program.h>
+#include "modest-marshal.h"
 #include <modest-maemo-utils.h>
 #include <modest-defs.h>
 #include <modest-ui-dimming-rules.h>
@@ -37,6 +38,7 @@
 #include <modest-window-priv.h>
 #include <modest-hildon2-window.h>
 #include <modest-ui-actions.h>
+#include "modest-text-utils.h"
 #include <hildon/hildon-edit-toolbar.h>
 
 typedef struct _EditModeRegister {
@@ -79,6 +81,7 @@ struct _ModestHildon2WindowPrivate {
 
        GtkWidget *app_menu;
        ModestDimmingRulesGroup *app_menu_dimming_group;
+       GtkAccelGroup *accel_group;
 
        /* Edit mode support */
        gboolean edit_mode;
@@ -91,9 +94,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
@@ -132,6 +144,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,
+                             modest_marshal_VOID__INT_BOOLEAN,
+                             G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_BOOLEAN);
+
        g_type_class_add_private (gobject_class, sizeof(ModestHildon2WindowPrivate));
        
        hildon_window_class->toggle_menu = modest_hildon2_window_toggle_menu;
@@ -170,15 +191,18 @@ modest_hildon2_window_instance_init (GTypeInstance *instance, gpointer g_class)
        parent_priv = MODEST_WINDOW_GET_PRIVATE (self);
        priv = MODEST_HILDON2_WINDOW_GET_PRIVATE (self);
 
+       priv->accel_group = gtk_accel_group_new ();
+
        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);
 
        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);
 
        setup_menu (self);
 
@@ -197,9 +221,8 @@ 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, dgettext("hildon-common-strings", "ckct_ib_cannot_zoom_here"));
+       hildon_banner_show_information (NULL, NULL, _CS("ckct_ib_cannot_zoom_here"));
        return FALSE;
-
 }
 
 static void 
@@ -244,6 +267,7 @@ modest_hildon2_window_add_button_to_menu (ModestHildon2Window *self,
 void 
 modest_hildon2_window_add_to_menu (ModestHildon2Window *self,
                                   gchar *label,
+                                  const gchar *accelerator,
                                   ModestHildon2AppMenuCallback callback,
                                   ModestDimmingCallback dimming_callback)
 {
@@ -260,6 +284,15 @@ modest_hildon2_window_add_to_menu (ModestHildon2Window *self,
        g_signal_connect_after (G_OBJECT (button), "clicked",
                                G_CALLBACK (callback), (gpointer) self);
 
+       if (accelerator != NULL) {
+               guint accel_key;
+               GdkModifierType accel_mods;
+
+               gtk_accelerator_parse (accelerator, &accel_key, &accel_mods);
+               gtk_widget_add_accelerator (button, "clicked", priv->accel_group,
+                                           accel_key, accel_mods, 0);
+       }
+
        modest_hildon2_window_add_button_to_menu (self, GTK_BUTTON (button), dimming_callback);
 }
 
@@ -379,6 +412,8 @@ 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, priv->edit_mode);
 }
 
 void 
@@ -396,7 +431,6 @@ modest_hildon2_window_unset_edit_mode (ModestHildon2Window *self)
 
        if (priv->edit_mode) {
                priv->edit_mode = FALSE;
-               priv->edit_command = -1;
                if (priv->current_edit_tree_view) {
                        g_object_set (G_OBJECT (priv->current_edit_tree_view), 
                                      "hildon-ui-mode", HILDON_UI_MODE_NORMAL, 
@@ -405,6 +439,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, priv->edit_mode);
+               priv->edit_command = MODEST_HILDON2_WINDOW_EDIT_MODE_NONE;
        }
 }