2007-01-26 [wwp] 2.7.2cvs2
authorTristan Chabredier <wwp@claws-mail.org>
Fri, 26 Jan 2007 10:16:22 +0000 (10:16 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Fri, 26 Jan 2007 10:16:22 +0000 (10:16 +0000)
* src/plugins/trayicon/Makefile.am
* src/plugins/trayicon/trayicon.c
* src/plugins/trayicon/trayicon_prefs.c
* src/plugins/trayicon/trayicon_prefs.h
Add a new TrayIcon option to hide the main window at
start-up.
Fix trayicon.c copyright header.

ChangeLog
PATCHSETS
configure.ac
src/plugins/trayicon/Makefile.am
src/plugins/trayicon/trayicon.c
src/plugins/trayicon/trayicon_prefs.c [new file with mode: 0644]
src/plugins/trayicon/trayicon_prefs.h [new file with mode: 0644]

index d9d10f89039f2979240d1592abcedce7a4e647dc..8c6cae584e1d862b3ec764edc4c1bd46c6db32b0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-01-26 [wwp]       2.7.2cvs2
+
+       * src/plugins/trayicon/Makefile.am
+       * src/plugins/trayicon/trayicon.c
+       * src/plugins/trayicon/trayicon_prefs.c
+       * src/plugins/trayicon/trayicon_prefs.h
+               Add a new TrayIcon option to hide the main window at
+               start-up.
+               Fix trayicon.c copyright header.
+
 2007-01-26 [paul]      2.7.2cvs1
 
        * NEWS
index deebfd2705033030769d11d8fdf97b60877b06a4..d0b502d0fa3a9ba373770780b3be179ab51b11f9 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.75.2.35 -r 1.75.2.36 src/matcher.c;  ) > 2.7.1cvs59.patchset
 ( cvs diff -u -r 1.60.2.41 -r 1.60.2.42 po/es.po;  ) > 2.7.1cvs60.patchset
 ( cvs diff -u -r 1.42.2.26 -r 1.42.2.27 NEWS;  cvs diff -u -r 1.8.2.30 -r 1.8.2.31 README;  cvs diff -u -r 1.1.2.15 -r 1.1.2.16 RELEASE_NOTES;  cvs diff -u -r 1.654.2.2372 -r 1.654.2.2373 configure.ac;  ) > 2.7.2cvs1.patchset
+( cvs diff -u -r 1.4.2.8 -r 1.4.2.9 src/plugins/trayicon/Makefile.am;  cvs diff -u -r 1.14.2.47 -r 1.14.2.48 src/plugins/trayicon/trayicon.c;  diff -u /dev/null src/plugins/trayicon/trayicon_prefs.c;  diff -u /dev/null src/plugins/trayicon/trayicon_prefs.h;  ) > 2.7.2cvs2.patchset
index 6711ac079803749ba0aa5939d319f353e62604fd..ac0014c3f50faca79345d33b6c3dcf298d42e16d 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=1
+EXTRA_VERSION=2
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index c1f32a42032a47517a8732460667d55b83cbe31b..99281e9c593dfd0a5c8ccfd8a1d46a7a99cbdf27 100644 (file)
@@ -11,7 +11,9 @@ cygwin_export_lib =
 endif 
 
 trayicon_la_SOURCES = \
-       trayicon.c
+       trayicon.c \
+       trayicon_prefs.c \
+       trayicon_prefs.h
 
 trayicon_la_LDFLAGS = \
        -avoid-version -module -no-undefined
index a261707e498df8ba6500dd1e3dfd427c55beff85..b68ec70448700cd2bc622d49c93189bd421b40ef 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail Team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2003-2007 the Claws Mail Team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -45,6 +45,8 @@
 
 #include "eggtrayicon.h"
 
+#include "trayicon_prefs.h"
+
 #include "newmarkedmail.xpm"
 #include "unreadmarkedmail.xpm"
 #include "newmail.xpm"
@@ -383,11 +385,22 @@ int plugin_init(gchar **error)
        create_trayicon();
        trayicon_set_accounts_hook(NULL, NULL);
 
+       trayicon_prefs_init();
+
+       if (trayicon_prefs.hide_at_startup && claws_is_starting()) {
+               MainWindow *mainwin = mainwindow_get_mainwindow();
+
+               if (GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
+                       main_window_hide(mainwin);
+       }
+
        return 0;
 }
 
 void plugin_done(void)
 {
+       trayicon_prefs_done();
+
        hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, item_hook_id);
        hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, folder_hook_id);
        hooks_unregister_hook(OFFLINE_SWITCH_HOOKLIST, offline_hook_id);
diff --git a/src/plugins/trayicon/trayicon_prefs.c b/src/plugins/trayicon/trayicon_prefs.c
new file mode 100644 (file)
index 0000000..b9c7808
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2007 the Claws Mail Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, 
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "defs.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "gtkutils.h"
+#include "utils.h"
+#include "prefs.h"
+#include "prefs_gtk.h"
+#include "prefswindow.h"
+
+#include "trayicon_prefs.h"
+
+TrayIconPrefs trayicon_prefs;
+
+typedef struct _TrayIconPage TrayIconPage;
+
+struct _TrayIconPage {
+        PrefsPage page;
+        GtkWidget *hide_at_startup;
+};
+
+static PrefParam param[] = {
+        {"hide_at_startup", "FALSE", &trayicon_prefs.hide_at_startup, P_BOOL, NULL, NULL, NULL},
+        {0,0,0,0,0,0,0}
+};
+
+static TrayIconPage prefs_page;
+
+static void create_trayicon_prefs_page (PrefsPage *page,
+                                        GtkWindow *window,
+                                        gpointer   data);
+static void destroy_trayicon_prefs_page        (PrefsPage *page);
+static void save_trayicon_prefs                (PrefsPage *page);
+
+void trayicon_prefs_init(void)
+{
+       static gchar *path[3];
+       gchar *rcpath;
+
+       path[0] = _("Plugins");
+       path[1] = _("TrayIcon");
+       path[2] = NULL;
+
+        prefs_set_default(param);
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+        prefs_read_config(param, "TrayIcon", rcpath, NULL);
+       g_free(rcpath);
+        
+        prefs_page.page.path = path;
+        prefs_page.page.create_widget = create_trayicon_prefs_page;
+        prefs_page.page.destroy_widget = destroy_trayicon_prefs_page;
+        prefs_page.page.save_page = save_trayicon_prefs;
+
+        prefs_gtk_register_page((PrefsPage *) &prefs_page);
+}
+
+void trayicon_prefs_done(void)
+{
+        prefs_gtk_unregister_page((PrefsPage *) &prefs_page);
+}
+
+static void create_trayicon_prefs_page(PrefsPage *page,
+                                   GtkWindow *window,
+                                    gpointer data)
+{
+        TrayIconPage *prefs_page = (TrayIconPage *) page;
+
+        GtkWidget *vbox;
+        GtkWidget *hide_at_startup_checkbox;
+       GtkTooltips *hide_at_startup_tooltip;
+
+        vbox = gtk_vbox_new(FALSE, 3);
+        gtk_container_set_border_width(GTK_CONTAINER(vbox), VBOX_BORDER);
+        gtk_widget_show(vbox);
+        
+       hide_at_startup_tooltip = gtk_tooltips_new();
+        hide_at_startup_checkbox = gtk_check_button_new_with_label
+                               (_("Hide at start-up"));
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hide_at_startup_checkbox),
+                                     trayicon_prefs.hide_at_startup);
+        gtk_box_pack_start(GTK_BOX(vbox), hide_at_startup_checkbox, FALSE, FALSE, 0);
+        gtk_widget_show(hide_at_startup_checkbox);
+       gtk_tooltips_set_tip(GTK_TOOLTIPS(hide_at_startup_tooltip), hide_at_startup_checkbox,
+                            _("Hide Claws Mail at start-up"), NULL);
+        
+        prefs_page->hide_at_startup = hide_at_startup_checkbox;
+        prefs_page->page.widget = vbox;
+}
+
+static void destroy_trayicon_prefs_page(PrefsPage *page)
+{
+       /* Do nothing! */
+}
+
+static void save_trayicon_prefs(PrefsPage *page)
+{
+        TrayIconPage *prefs_page = (TrayIconPage *) page;
+        PrefFile *pref_file;
+        gchar *rc_file_path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+                                          COMMON_RC, NULL);
+        
+        trayicon_prefs.hide_at_startup = gtk_toggle_button_get_active
+                               (GTK_TOGGLE_BUTTON(prefs_page->hide_at_startup));
+        
+        pref_file = prefs_write_open(rc_file_path);
+        g_free(rc_file_path);
+        
+        if (!(pref_file) ||
+           (prefs_set_block_label(pref_file, "TrayIcon") < 0))
+          return;
+        
+        if (prefs_write_param(param, pref_file->fp) < 0) {
+          g_warning("failed to write TrayIcon Plugin configuration\n");
+          prefs_file_close_revert(pref_file);
+          return;
+        }
+        fprintf(pref_file->fp, "\n");
+        prefs_file_close(pref_file);
+}
diff --git a/src/plugins/trayicon/trayicon_prefs.h b/src/plugins/trayicon/trayicon_prefs.h
new file mode 100644 (file)
index 0000000..6936170
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2007 the Claws Mail Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, 
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef TRAYICONPREFS_H
+#define TRAYICONPREFS_H
+
+#include <glib.h>
+
+typedef struct _TrayIconPrefs  TrayIconPrefs;
+
+struct _TrayIconPrefs
+{
+       gboolean hide_at_startup;       /**< hide when  */
+};
+
+extern TrayIconPrefs trayicon_prefs;
+
+void trayicon_prefs_init(void);
+void trayicon_prefs_done(void);
+
+#endif