2008-10-09 [colin] 3.6.0cvs19
[claws.git] / src / mainwindow.c
index fabed5458069ededaa948d09320b7ea0bf7e95b1..886cbe249cc1ca07114ebb8f80b1dcaa1584eab0 100644 (file)
@@ -144,7 +144,7 @@ static void empty_trash_cb   (GtkAction     *action,
                                  gpointer       data);
 static void save_as_cb          (GtkAction     *action,
                                  gpointer       data);
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
+#if GTK_CHECK_VERSION(2,10,0)
 static void page_setup_cb       (GtkAction     *action,
                                  gpointer       data);
 #endif
@@ -187,6 +187,8 @@ static void view_source_cb          (GtkAction      *action,
 
 static void show_all_header_cb         (GtkAction      *action,
                                  gpointer       data);
+static void toggle_fullscreen_cb       (GtkAction      *action,
+                                 gpointer       data);
 
 static void hide_quotes_cb(GtkAction   *action,
                                  gpointer       data);
@@ -480,7 +482,7 @@ static GtkActionEntry mainwin_entries[] =
 
        {"File/SaveAs",                         NULL, N_("_Save as..."), "<control>S", NULL, G_CALLBACK(save_as_cb) },
 
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
+#if GTK_CHECK_VERSION(2,10,0)
        {"File/PageSetup",                      NULL, N_("Page setup..."), NULL, NULL, G_CALLBACK(page_setup_cb) },
 #endif
        {"File/Print",                          NULL, N_("_Print..."), "<control>P", NULL, G_CALLBACK(print_cb) },
@@ -734,6 +736,9 @@ static GtkToggleActionEntry mainwin_toggle_entries[] = {
        {"View/ShowHide/ColumnHeaders",         NULL, N_("Column headers"), NULL, NULL, G_CALLBACK(toggle_col_headers_cb) }, /* toggle */
        {"View/ThreadView",                     NULL, N_("Th_read view"), "<control>T", NULL, G_CALLBACK(thread_cb) }, /* toggle */
        {"View/HideReadMessages",               NULL, N_("_Hide read messages"), NULL, NULL, G_CALLBACK(hide_read_messages) }, /* toggle */
+#ifndef MAEMO
+       {"View/FullScreen",                     NULL, N_("_Fullscreen"), "F11", NULL, G_CALLBACK(toggle_fullscreen_cb) }, /* toggle */
+#endif
        {"View/AllHeaders",                     NULL, N_("Show all _headers"), "<control>H", NULL, G_CALLBACK(show_all_header_cb) }, /* toggle */
        {"View/Quotes/FoldAll",                 NULL, N_("_Fold all"), "<control><shift>Q", NULL, G_CALLBACK(hide_quotes_cb) }, /* 1 toggle */
        {"View/Quotes/Fold2",                   NULL, N_("Fold from level _2"), NULL, NULL, G_CALLBACK(hide_quotes_cb) }, /* 2 toggle */
@@ -1038,6 +1043,33 @@ static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
        summary_set_tag(mainwin->summaryview, id, NULL);
 }
 
+void mainwin_accel_changed_cb (GtkAccelGroup *accelgroup, guint keyval, GdkModifierType modifier,
+                                 GClosure *closure, GtkMenuItem *item)
+{
+       GList *closures = gtk_widget_list_accel_closures(GTK_WIDGET(item));
+       GList *cur;
+       for (cur = closures; cur; cur = cur->next) {
+               if (closure == cur->data) {
+                       GtkLabel *label = g_object_get_data(G_OBJECT(item), "accel_label");
+                       gchar *new_accel;
+                       
+                       if (keyval == GDK_BackSpace) {
+                               const gchar *accel_path;
+#if GTK_CHECK_VERSION(2,14,0)
+                               accel_path = gtk_menu_item_get_accel_path(item);
+#else
+                               accel_path = GTK_MENU_ITEM(item)->accel_path;
+#endif
+                               keyval = 0; modifier = 0;
+                               gtk_accel_map_change_entry (accel_path, keyval, modifier, TRUE);
+                       }
+                       new_accel = gtk_accelerator_get_label(keyval, modifier);
+                       gtk_label_set_text(label, new_accel);
+                       g_free(new_accel);
+               }
+       }
+}
+
 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
 {
        GtkWidget *label_menuitem;
@@ -1089,11 +1121,15 @@ static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refr
                g_object_set_data(G_OBJECT(item), "mainwin",
                                  mainwin);
                gtk_widget_show(item);
-               accel_path = g_strdup_printf("<ClawsColorLabels>/%d", i);
+               accel_path = g_strdup_printf("<ClawsColorLabels>/%d", i+1);
                gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item), accel_path);
                if (i < 9)
                        gtk_accel_map_add_entry(accel_path, GDK_1+i, GDK_CONTROL_MASK);
                g_free(accel_path);
+               g_signal_connect (gtk_ui_manager_get_accel_group(mainwin->ui_manager), 
+                       "accel-changed", G_CALLBACK (mainwin_accel_changed_cb), item);
+
+
        }
        gtk_widget_show(menu);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
@@ -1283,6 +1319,7 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
                        }
                }
                break;
+
 #ifdef MAEMO
        case GDK_F6:
                if (maemo_mainwindow_is_fullscreen(widget)) {
@@ -1566,7 +1603,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "EmptyTrashes", "File/EmptyTrashes", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator4", "File/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM)
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
+#if GTK_CHECK_VERSION(2,10,0)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "PageSetup", "File/PageSetup", GTK_UI_MANAGER_MENUITEM)
 #endif
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM)
@@ -1606,6 +1643,9 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/SetColumns", "Messagelist", "View/SetColumns/Messagelist", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator1", "View/---", GTK_UI_MANAGER_SEPARATOR)
 
+#ifndef MAEMO
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "FullScreen", "View/FullScreen", GTK_UI_MANAGER_MENUITEM)
+#endif
 #ifndef GENERIC_UMPC
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Layout", "View/Layout", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Layout", "Standard", "View/Layout/Standard", GTK_UI_MANAGER_MENUITEM)
@@ -1899,7 +1939,6 @@ MainWindow *main_window_create()
        hildon_window_set_menu(HILDON_WINDOW(window), GTK_MENU(menubar));
 #endif
 
-
        if (prefs_common.toolbar_detachable) {
                handlebox = gtk_handle_box_new();
                gtk_widget_show(handlebox);
@@ -2154,6 +2193,9 @@ MainWindow *main_window_create()
        }
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
 
+       toolbar_set_style(mainwin->toolbar->toolbar, 
+                         mainwin->handlebox, 
+                         prefs_common.toolbar_style);
 #ifndef GENERIC_UMPC
        gtk_widget_hide(mainwin->hbox_stat);
        menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/ShowHide/StatusBar");
@@ -2233,6 +2275,13 @@ MainWindow *main_window_create()
 
 #ifdef MAEMO
        main_window_install_maemo_hooks(mainwin);
+#endif
+#ifndef MAEMO
+       if (prefs_common.mainwin_fullscreen) {
+               cm_toggle_menu_set_active_full(mainwin->ui_manager, 
+                       "Menu/View/FullScreen",
+                       TRUE);
+       }
 #endif
        return mainwin;
 }
@@ -2810,8 +2859,12 @@ void main_window_get_size(MainWindow *mainwin)
        }
 
        allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
-
-       if (allocation->width > 1 && allocation->height > 1) {
+       
+       if (prefs_common.mainwin_fullscreen) {
+               debug_print("mainwin in full screen state. "
+                           "Keeping original settings\n");
+       }
+       if (allocation->width > 1 && allocation->height > 1 && !prefs_common.mainwin_fullscreen) {
                prefs_common.summaryview_width = allocation->width;
 
                if (messageview_is_visible(mainwin->messageview))
@@ -2822,20 +2875,22 @@ void main_window_get_size(MainWindow *mainwin)
 
        allocation = &mainwin->window->allocation;
        if (allocation->width > 1 && allocation->height > 1 &&
-           !prefs_common.mainwin_maximised) {
+           !prefs_common.mainwin_maximised && !prefs_common.mainwin_fullscreen) {
                prefs_common.mainview_height = allocation->height;
                prefs_common.mainwin_width   = allocation->width;
                prefs_common.mainwin_height  = allocation->height;
        }
 
        allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
-       if (allocation->width > 1 && allocation->height > 1) {
+       if (allocation->width > 1 && allocation->height > 1 &&
+           !prefs_common.mainwin_fullscreen) {
                prefs_common.folderview_width  = allocation->width;
                prefs_common.folderview_height = allocation->height;
        }
 
        allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
-       if (allocation->width > 1 && allocation->height > 1) {
+       if (allocation->width > 1 && allocation->height > 1 &&
+           !prefs_common.mainwin_fullscreen) {
                prefs_common.msgview_width = allocation->width;
                prefs_common.msgview_height = allocation->height;
        }
@@ -2855,7 +2910,7 @@ void main_window_get_position(MainWindow *mainwin)
 {
        gint x, y;
 
-       if (prefs_common.mainwin_maximised)
+       if (prefs_common.mainwin_maximised || prefs_common.mainwin_fullscreen)
                return;
 
        gtkut_widget_get_uposition(mainwin->window, &x, &y);
@@ -3900,7 +3955,7 @@ static void print_cb(GtkAction *action, gpointer data)
        summary_print(mainwin->summaryview);
 }
 
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
+#if GTK_CHECK_VERSION(2,10,0)
 static void page_setup_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4229,6 +4284,20 @@ static void show_all_header_cb(GtkAction *action, gpointer data)
                                     gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
 }
 
+static void toggle_fullscreen_cb(GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       if (mainwin->menu_lock_count) return;
+       if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+               gtk_window_unfullscreen(GTK_WINDOW(mainwin->window));
+               prefs_common.mainwin_fullscreen = FALSE;
+       }
+       else {
+               prefs_common.mainwin_fullscreen = TRUE;
+               gtk_window_fullscreen(GTK_WINDOW(mainwin->window));
+       }
+}
+
 static void hide_quotes_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;