2007-03-06 [wwp] 2.8.1cvs2
authorTristan Chabredier <wwp@claws-mail.org>
Tue, 6 Mar 2007 10:16:20 +0000 (10:16 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Tue, 6 Mar 2007 10:16:20 +0000 (10:16 +0000)
* src/gtk/gtkutils.c
* src/plugins/trayicon/trayicon_prefs.h
* src/plugins/trayicon/trayicon_prefs.c
* src/plugins/trayicon/trayicon.c
* src/mainwindow.h
* src/mainwindow.c
Add a new trayicon (optional) feature: minimize to tray. When enabled,
minimizing Claws-Mail main window will hide it to the trayicon instead.

ChangeLog
PATCHSETS
configure.ac
src/gtk/gtkutils.c
src/mainwindow.c
src/mainwindow.h
src/plugins/trayicon/trayicon.c
src/plugins/trayicon/trayicon_prefs.c
src/plugins/trayicon/trayicon_prefs.h

index 3305337b08233edfd1db7d7d9c5fc1a5877ec538..2db588b960ad7e12f99755b162a3d4f4e2d8a913 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-03-06 [wwp]       2.8.1cvs2
+
+       * src/gtk/gtkutils.c
+       * src/plugins/trayicon/trayicon_prefs.h
+       * src/plugins/trayicon/trayicon_prefs.c
+       * src/plugins/trayicon/trayicon.c
+       * src/mainwindow.h
+       * src/mainwindow.c
+               Add a new trayicon (optional) feature: minimize to tray. When enabled,
+               minimizing Claws-Mail main window will hide it to the trayicon instead.
+
+
 2007-03-06 [paul]      2.8.1cvs1
 
        * NEWS
index bbd860b8bb0be193357c141b60fe9bb5abd41086..8e38ba79fc121b4b455b52d84815b8a517751172 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.155.2.53 -r 1.155.2.54 src/Makefile.am;  cvs diff -u -r 1.49.2.89 -r 1.49.2.90 src/procmime.c;  ) > 2.8.0cvs23.patchset
 ( cvs diff -u -r 1.9.2.10 -r 1.9.2.11 po/cs.po;  ) > 2.8.0cvs24.patchset
 ( cvs diff -u -r 1.42.2.28 -r 1.42.2.29 NEWS;  cvs diff -u -r 1.8.2.32 -r 1.8.2.33 README;  cvs diff -u -r 1.1.2.17 -r 1.1.2.18 RELEASE_NOTES;  cvs diff -u -r 1.654.2.2473 -r 1.654.2.2474 configure.ac;  ) > 2.8.1cvs1.patchset
+( cvs diff -u -r 1.5.2.54 -r 1.5.2.55 src/gtk/gtkutils.c;  cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/plugins/trayicon/trayicon_prefs.h;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/plugins/trayicon/trayicon_prefs.c;  cvs diff -u -r 1.14.2.52 -r 1.14.2.53 src/plugins/trayicon/trayicon.c;  cvs diff -u -r 1.39.2.32 -r 1.39.2.33 src/mainwindow.h;  cvs diff -u -r 1.274.2.176 -r 1.274.2.177 src/mainwindow.c;  ) > 2.8.1cvs2.patchset
index 10f981f564d1135f3169c59d674a4eccb1aa459d..87f4dc56662533761c2c784ed2da62733008bd48 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=1
+EXTRA_VERSION=2
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index b8dacb064136884b686243f4d16dfc860cd3daf3..705a6e39054fa0319027caaaf939b3c37ceee0d3 100644 (file)
@@ -756,6 +756,7 @@ void gtkut_window_popup(GtkWidget *window)
        if (new_x != x || new_y != y)
                gdk_window_move(window->window, new_x, new_y);
 
+       gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), FALSE);
        gtk_window_present(GTK_WINDOW(window));
 }
 
index c9b961420c530816bd2622db94f0038f8abb2b03..db160890fa174852f00fd0fea13dd8e3b431a6b7 100644 (file)
@@ -106,6 +106,8 @@ static GList *mainwin_list = NULL;
 static GdkCursor *watch_cursor = NULL;
 static GdkCursor *hand_cursor = NULL;
 
+static gint iconified_count = 0;
+
 static void main_window_menu_callback_block    (MainWindow     *mainwin);
 static void main_window_menu_callback_unblock  (MainWindow     *mainwin);
 
@@ -473,6 +475,9 @@ static gboolean mainwindow_focus_in_event   (GtkWidget      *widget,
 static gboolean mainwindow_visibility_event_cb (GtkWidget      *widget, 
                                                 GdkEventVisibility     *state,
                                                 gpointer        data);
+static gboolean mainwindow_state_event_cb      (GtkWidget      *widget, 
+                                                GdkEventWindowState    *state,
+                                                gpointer        data);
 static void main_window_reply_cb                       (MainWindow     *mainwin, 
                                                 guint           action,
                                                 GtkWidget      *widget);
@@ -1432,6 +1437,8 @@ MainWindow *main_window_create()
 
        gtk_window_iconify(GTK_WINDOW(mainwin->window));
 
+       g_signal_connect(G_OBJECT(window), "window_state_event",
+                        G_CALLBACK(mainwindow_state_event_cb), mainwin);
        g_signal_connect(G_OBJECT(window), "visibility_notify_event",
                         G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
        gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
@@ -3794,6 +3801,22 @@ static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibi
        return FALSE;
 }
 
+static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
+                                         gpointer data)
+{
+       if (!claws_is_starting()
+               && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
+               && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
+
+               if (iconified_count > 0)
+                       hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
+               iconified_count++;
+       }
+       if (state->new_window_state == 0)
+               gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
+       return FALSE;
+}
+
 gboolean mainwindow_is_obscured(void)
 {
        return is_obscured;
index c549f31fd1ecf07201a0546c90bf82b7494297fb..533112cb0c13ea1292930a9bc9d9943ceb586af9 100644 (file)
@@ -34,6 +34,7 @@ typedef struct _MainWindow  MainWindow;
 #define OFFLINE_SWITCH_HOOKLIST "offline_switch"
 #define ACCOUNT_LIST_CHANGED_HOOKLIST "account_list_changed"
 #define MAIN_WINDOW_CLOSE "mainwindow_close"
+#define MAIN_WINDOW_GOT_ICONIFIED "mainwindow_iconified"
 
 typedef enum
 {
index b6b886e16a9ca7f49dc4eed035d073258604006f..da974279b2efe125f4c3f9662547a0d732ab640b 100644 (file)
@@ -65,6 +65,7 @@ static guint folder_hook_id;
 static guint offline_hook_id;
 static guint account_hook_id;
 static guint close_hook_id;
+static guint iconified_hook_id;
 
 static GdkPixmap *newmail_pixmap[2];
 static GdkPixmap *newmail_bitmap[2];
@@ -263,6 +264,18 @@ static gboolean trayicon_close_hook(gpointer source, gpointer data)
        return FALSE;
 }
 
+static gboolean trayicon_got_iconified_hook(gpointer source, gpointer data)
+{
+       MainWindow *mainwin = mainwindow_get_mainwindow();
+
+       if (trayicon_prefs.hide_when_iconified
+                       && GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window))
+                       && !gtk_window_get_skip_taskbar_hint(GTK_WINDOW(mainwin->window))) {
+               gtk_window_set_skip_taskbar_hint(GTK_WINDOW(mainwin->window), TRUE);
+       }
+       return FALSE;
+}
+
 static void resize_cb(GtkWidget *widget, GtkRequisition *req,
                      gpointer user_data)
 {
@@ -286,6 +299,7 @@ static gboolean click_cb(GtkWidget * widget,
                        if ((gdk_window_get_state(GTK_WIDGET(mainwin->window)->window)&GDK_WINDOW_STATE_ICONIFIED)
                                        || mainwindow_is_obscured()) {
                                gtk_window_deiconify(GTK_WINDOW(mainwin->window));
+                               gtk_window_set_skip_taskbar_hint(GTK_WINDOW(mainwin->window), FALSE);
                                main_window_show(mainwin);
                                gtk_window_present(GTK_WINDOW(mainwin->window));
                        } else {
@@ -293,6 +307,7 @@ static gboolean click_cb(GtkWidget * widget,
                        }
                } else {
                        gtk_window_deiconify(GTK_WINDOW(mainwin->window));
+                       gtk_window_set_skip_taskbar_hint(GTK_WINDOW(mainwin->window), FALSE);
                        main_window_show(mainwin);
                        gtk_window_present(GTK_WINDOW(mainwin->window));
         }
@@ -414,6 +429,12 @@ int plugin_init(gchar **error)
                return -1;
        }
 
+       iconified_hook_id = hooks_register_hook (MAIN_WINDOW_GOT_ICONIFIED, trayicon_got_iconified_hook, NULL);
+       if (offline_hook_id == -1) {
+               *error = g_strdup(_("Failed to register got iconified hook"));
+               return -1;
+       }
+
        create_trayicon();
        trayicon_set_accounts_hook(NULL, NULL);
 
@@ -439,6 +460,7 @@ void plugin_done(void)
        hooks_unregister_hook(OFFLINE_SWITCH_HOOKLIST, offline_hook_id);
        hooks_unregister_hook(ACCOUNT_LIST_CHANGED_HOOKLIST, account_hook_id);
        hooks_unregister_hook(MAIN_WINDOW_CLOSE, close_hook_id);
+       hooks_unregister_hook(MAIN_WINDOW_GOT_ICONIFIED, iconified_hook_id);
 
        if (claws_is_exiting())
                return;
index 556248e06757ca8ff5c18a87ba39564c0ae08247..038654fc60731b5efd99cc1c528f47be5ac6cd83 100644 (file)
@@ -43,11 +43,13 @@ struct _TrayIconPage {
         PrefsPage page;
         GtkWidget *hide_at_startup;
                GtkWidget *close_to_tray;
+               GtkWidget *hide_when_iconified;
 };
 
 static PrefParam param[] = {
         {"hide_at_startup", "FALSE", &trayicon_prefs.hide_at_startup, P_BOOL, NULL, NULL, NULL},
         {"close_to_tray", "FALSE", &trayicon_prefs.close_to_tray, P_BOOL, NULL, NULL, NULL},
+        {"hide_when_iconified", "FALSE", &trayicon_prefs.hide_when_iconified, P_BOOL, NULL, NULL, NULL},
         {0,0,0,0,0,0,0}
 };
 
@@ -97,6 +99,8 @@ static void create_trayicon_prefs_page(PrefsPage *page,
        GtkTooltips *hide_at_startup_tooltip;
         GtkWidget *close_to_tray_checkbox;
        GtkTooltips *close_to_tray_tooltip;
+        GtkWidget *hide_when_iconified_checkbox;
+       GtkTooltips *hide_when_iconified_tooltip;
 
         vbox = gtk_vbox_new(FALSE, 3);
         gtk_container_set_border_width(GTK_CONTAINER(vbox), VBOX_BORDER);
@@ -122,8 +126,19 @@ static void create_trayicon_prefs_page(PrefsPage *page,
        gtk_tooltips_set_tip(GTK_TOOLTIPS(close_to_tray_tooltip), close_to_tray_checkbox,
                             _("Hide Claws Mail using the tray icon instead of closing it\nwhen the window close button is clicked"), NULL);
 
+       hide_when_iconified_tooltip = gtk_tooltips_new();
+        hide_when_iconified_checkbox = gtk_check_button_new_with_label
+                               (_("Minimize to tray"));
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hide_when_iconified_checkbox),
+                                     trayicon_prefs.hide_when_iconified);
+        gtk_box_pack_start(GTK_BOX(vbox), hide_when_iconified_checkbox, FALSE, FALSE, 0);
+        gtk_widget_show(hide_when_iconified_checkbox);
+       gtk_tooltips_set_tip(GTK_TOOLTIPS(hide_when_iconified_tooltip), hide_when_iconified_checkbox,
+                            _("Hide Claws Mail using the tray icon instead of minimizing it"), NULL);
+
         prefs_page->hide_at_startup = hide_at_startup_checkbox;
         prefs_page->close_to_tray = close_to_tray_checkbox;
+        prefs_page->hide_when_iconified = hide_when_iconified_checkbox;
         prefs_page->page.widget = vbox;
 }
 
@@ -143,6 +158,8 @@ static void save_trayicon_prefs(PrefsPage *page)
                                (GTK_TOGGLE_BUTTON(prefs_page->hide_at_startup));
         trayicon_prefs.close_to_tray = gtk_toggle_button_get_active
                                (GTK_TOGGLE_BUTTON(prefs_page->close_to_tray));
+        trayicon_prefs.hide_when_iconified = gtk_toggle_button_get_active
+                               (GTK_TOGGLE_BUTTON(prefs_page->hide_when_iconified));
         
         pref_file = prefs_write_open(rc_file_path);
         g_free(rc_file_path);
index 003d23b6f4e38346f01ffc267c45dc013f83f32b..25e84ef03ae5e7331af8c8f6f95ab81ee9c22099 100644 (file)
@@ -28,6 +28,7 @@ struct _TrayIconPrefs
 {
        gboolean hide_at_startup;       /**< hide main-window at startup */
        gboolean close_to_tray; /**< hide main-window when [X] is clicked */
+       gboolean hide_when_iconified;   /**< hide main-window when it got iconified */
 };
 
 extern TrayIconPrefs trayicon_prefs;