2007-01-26 [wwp] 2.7.2cvs2
[claws.git] / src / plugins / trayicon / trayicon.c
index 15fdfbdb9150a66850bd5eeceb9f647c4366459b..b68ec70448700cd2bc622d49c93189bd421b40ef 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 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
@@ -27,7 +27,7 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-#include "common/sylpheed.h"
+#include "common/claws.h"
 #include "common/version.h"
 #include "plugin.h"
 #include "utils.h"
@@ -45,6 +45,8 @@
 
 #include "eggtrayicon.h"
 
+#include "trayicon_prefs.h"
+
 #include "newmarkedmail.xpm"
 #include "unreadmarkedmail.xpm"
 #include "newmail.xpm"
@@ -56,6 +58,8 @@
 #include "unreadmail.offline.xpm"
 #include "nomail.offline.xpm"
 
+#define PLUGIN_NAME (_("Trayicon"))
+
 static guint item_hook_id;
 static guint folder_hook_id;
 static guint offline_hook_id;
@@ -102,14 +106,14 @@ static void resize_cb                 (GtkWidget *widget, GtkRequisition *req, gpointer use
 static GtkItemFactoryEntry trayicon_popup_menu_entries[] =
 {
        {N_("/_Get Mail"),              NULL, trayicon_get_all_cb,              0, NULL},
-       {N_("/---"),                    NULL, NULL,                             0, "<Separator>"},
+       {"/---",                        NULL, NULL,                             0, "<Separator>"},
        {N_("/_Email"),                 NULL, trayicon_compose_cb,              0, NULL},
        {N_("/_Email from account"),    NULL, NULL,                             0, "<Branch>"},
-       {N_("/---"),                    NULL, NULL,                             0, "<Separator>"},
+       {"/---",                        NULL, NULL,                             0, "<Separator>"},
        {N_("/Open A_ddressbook"),      NULL, trayicon_addressbook_cb,          0, NULL},
-       {N_("/---"),                    NULL, NULL,                             0, "<Separator>"},
+       {"/---",                        NULL, NULL,                             0, "<Separator>"},
        {N_("/_Work Offline"),          NULL, trayicon_toggle_offline_cb,       0, "<CheckItem>"},
-       {N_("/---"),                    NULL, NULL,                             0, "<Separator>"},
+       {"/---",                        NULL, NULL,                             0, "<Separator>"},
        {N_("/E_xit Claws Mail"),       NULL, trayicon_exit_cb,                 0, NULL}
 };
 
@@ -335,7 +339,6 @@ static void create_trayicon()
                G_CALLBACK(click_cb), NULL);
 
        tooltips = gtk_tooltips_new();
-       gtk_tooltips_set_delay(tooltips, 1000);
        gtk_tooltips_enable(tooltips);
 
        n_entries = sizeof(trayicon_popup_menu_entries) /
@@ -351,15 +354,9 @@ static void create_trayicon()
 
 int plugin_init(gchar **error)
 {
-       if ((sylpheed_get_version() > VERSION_NUMERIC)) {
-               *error = g_strdup(_("Your version of Claws Mail is newer than the version the Trayicon plugin was built with"));
+       if (!check_plugin_version(MAKE_NUMERIC_VERSION(0, 9, 3, 86),
+                               VERSION_NUMERIC, PLUGIN_NAME, error))
                return -1;
-       }
-
-       if ((sylpheed_get_version() < MAKE_NUMERIC_VERSION(0, 9, 3, 86))) {
-               *error = g_strdup(_("Your version of Claws Mail is too old for the Trayicon plugin"));
-               return -1;
-       }
 
        item_hook_id = hooks_register_hook (FOLDER_ITEM_UPDATE_HOOKLIST, folder_item_update_hook, NULL);
        if (item_hook_id == -1) {
@@ -388,17 +385,28 @@ 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);
        hooks_unregister_hook(ACCOUNT_LIST_CHANGED_HOOKLIST, account_hook_id);
 
-       if (sylpheed_is_exiting())
+       if (claws_is_exiting())
                return;
 
        g_signal_handler_disconnect(G_OBJECT(trayicon), destroy_signal_id);
@@ -412,7 +420,7 @@ void plugin_done(void)
 
 const gchar *plugin_name(void)
 {
-       return _("Trayicon");
+       return PLUGIN_NAME;
 }
 
 const gchar *plugin_desc(void)