X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-window.c;h=0b4f849906900225de653b83f21d8976818633ec;hb=dafad623b1c0f184142ce09a51882fa967d7eb09;hp=79aad9ac5483280bb30a01fcabd78dafe587ab61;hpb=28f2206c21738a94d6a41de73abba693c7ff323d;p=modest diff --git a/src/widgets/modest-window.c b/src/widgets/modest-window.c index 79aad9a..0b4f849 100644 --- a/src/widgets/modest-window.c +++ b/src/widgets/modest-window.c @@ -29,7 +29,10 @@ #include "modest-window.h" #include "modest-window-priv.h" +#include "modest-ui-actions.h" #include "modest-tny-platform-factory.h" +#include "modest-runtime.h" +#include "modest-window-mgr.h" /* 'private'/'protected' functions */ static void modest_window_class_init (ModestWindowClass *klass); @@ -44,6 +47,9 @@ static gboolean modest_window_zoom_minus_default (ModestWindow *window); static void modest_window_show_toolbar_default (ModestWindow *window, gboolean show_toolbar); +static gboolean on_key_pressed (GtkWidget *self, GdkEventKey *event, gpointer user_data); + + /* list my signals */ enum { LAST_SIGNAL @@ -112,10 +118,16 @@ modest_window_init (ModestWindow *obj) priv = MODEST_WINDOW_GET_PRIVATE(obj); priv->ui_manager = NULL; + priv->ui_dimming_manager = NULL; priv->toolbar = NULL; priv->menubar = NULL; priv->active_account = NULL; + + /* Connect signals */ + g_signal_connect (G_OBJECT (obj), + "key-press-event", + G_CALLBACK (on_key_pressed), NULL); } static void @@ -129,6 +141,10 @@ modest_window_finalize (GObject *obj) g_object_unref (G_OBJECT(priv->ui_manager)); priv->ui_manager = NULL; } + if (priv->ui_dimming_manager) { + g_object_unref (G_OBJECT(priv->ui_dimming_manager)); + priv->ui_dimming_manager = NULL; + } g_free (priv->active_account); @@ -156,11 +172,66 @@ modest_window_set_active_account (ModestWindow *self, const gchar *active_accoun return; else { g_free (priv->active_account); - priv->active_account = g_strdup (active_account); + priv->active_account = NULL; + if (active_account) + priv->active_account = g_strdup (active_account); } } void +modest_window_check_dimming_rules (ModestWindow *self) +{ + ModestWindowPrivate *priv; + + g_return_if_fail (MODEST_IS_WINDOW (self)); + priv = MODEST_WINDOW_GET_PRIVATE(self); + + modest_ui_dimming_manager_process_dimming_rules (priv->ui_dimming_manager); +} + +void +modest_window_check_dimming_rules_group (ModestWindow *self, + const gchar *group_name) +{ + ModestWindowPrivate *priv; + + g_return_if_fail (MODEST_IS_WINDOW (self)); + priv = MODEST_WINDOW_GET_PRIVATE(self); + + modest_ui_dimming_manager_process_dimming_rules_group (priv->ui_dimming_manager, group_name); +} + +GtkAction * +modest_window_get_action (ModestWindow *window, + const gchar *action_path) +{ + GtkAction *action = NULL; + ModestWindowPrivate *priv; + + g_return_val_if_fail (MODEST_IS_WINDOW (window), NULL); + priv = MODEST_WINDOW_GET_PRIVATE(window); + + action = gtk_ui_manager_get_action (priv->ui_manager, action_path); + + return action; +} + +GtkWidget * +modest_window_get_action_widget (ModestWindow *window, + const gchar *action_path) +{ + GtkWidget *widget = NULL; + ModestWindowPrivate *priv; + + g_return_val_if_fail (MODEST_IS_WINDOW (window), NULL); + priv = MODEST_WINDOW_GET_PRIVATE(window); + + widget = gtk_ui_manager_get_widget (priv->ui_manager, action_path); + + return widget; +} + +void modest_window_set_zoom (ModestWindow *window, gdouble zoom) { @@ -233,6 +304,8 @@ modest_window_show_toolbar_default (ModestWindow *window, g_warning ("modest: You should implement %s", __FUNCTION__); } + + void modest_window_save_state (ModestWindow *window) { @@ -240,3 +313,31 @@ modest_window_save_state (ModestWindow *window) if (klass->save_state_func) klass->save_state_func (window); } + +static gboolean +on_key_pressed (GtkWidget *self, + GdkEventKey *event, + gpointer user_data) +{ + ModestWindowMgr *mgr = NULL; + + mgr = modest_runtime_get_window_mgr (); + + switch (event->keyval) { + case GDK_F6: + modest_ui_actions_on_change_fullscreen (NULL, MODEST_WINDOW(self)); + return TRUE; + case GDK_F7: + modest_ui_actions_on_zoom_plus (NULL, MODEST_WINDOW(self)); + return TRUE; + case GDK_F8: + modest_ui_actions_on_zoom_minus (NULL, MODEST_WINDOW(self)); + return TRUE; + case GDK_Escape: + if (modest_window_mgr_get_fullscreen_mode (mgr)) + modest_ui_actions_on_change_fullscreen (NULL, MODEST_WINDOW(self)); + break; + } + + return FALSE; +}