2012-04-01 [colin] 3.8.0cvs36
[claws.git] / src / toolbar.c
index 4aeb5f67b2d1cbb078103162c3a966d7592f54a7..c6a782bd049b65c5b7346e72cbbb1a8e2457a1b8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2009 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 2001-2011 Hiroyuki Yamamoto and 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
@@ -57,6 +57,9 @@
 #include "prefs_toolbar.h"
 #include "alertpanel.h"
 #include "imap.h"
+#ifdef USE_NEW_ADDRBOOK
+       #include "addressbook-dbus.h"
+#endif
 
 /* elements */
 #define TOOLBAR_TAG_INDEX        "toolbar"
@@ -177,8 +180,8 @@ struct {
        gchar *index_str;
        const gchar *descr;
 } toolbar_text [] = {
-       { "A_RECEIVE_ALL",      N_("Receive Mail on all Accounts")         },
-       { "A_RECEIVE_CUR",      N_("Receive Mail on current Account")      },
+       { "A_RECEIVE_ALL",      N_("Receive Mail from all Accounts")       },
+       { "A_RECEIVE_CUR",      N_("Receive Mail from current Account")    },
        { "A_SEND_QUEUED",      N_("Send Queued Messages")                 },
        { "A_COMPOSE_EMAIL",    N_("Compose Email")                        },
        { "A_COMPOSE_NEWS",     N_("Compose News")                         },
@@ -361,7 +364,7 @@ static void toolbar_parse_item(XMLFile *file, ToolbarType source)
                        g_free(item->file);
                        item->file = g_strdup("trash_btn");
                        g_free(item->text);
-                       item->text = g_strdup(_("Trash"));
+                       item->text = g_strdup(Q_("Toolbar|Trash"));
                        rewrite = TRUE;
                }
                if (item->index == -1 && !strcmp(value, "A_SYL_ACTIONS")) {
@@ -393,10 +396,10 @@ const gchar *toolbar_get_short_text(int action) {
        case A_COMPOSE_NEWS:    return Q_("Toolbar|Compose");
        case A_REPLY_MESSAGE:   return _("Reply");
        case A_REPLY_ALL:       return _("All");
-       case A_REPLY_SENDER:    return _("Sender");
+       case A_REPLY_SENDER:    return Q_("Toolbar|Sender");
        case A_REPLY_ML:        return _("List");
        case A_FORWARD:         return _("Forward");
-       case A_TRASH:           return _("Trash");
+       case A_TRASH:           return Q_("Toolbar|Trash");
        case A_DELETE_REAL:     return _("Delete");
        case A_LEARN_SPAM:      return _("Spam");
        case A_GOTO_PREV:       return _("Prev");
@@ -812,40 +815,52 @@ static void toolbar_action_execute(GtkWidget    *widget,
                            gpointer     data,
                            gint         source) 
 {
-       GSList *cur, *lop;
-       gchar *action, *action_p;
-       gboolean found = FALSE;
+       GSList *cur;
        gint i = 0;
 
        for (cur = action_list; cur != NULL;  cur = cur->next) {
                ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
 
                if (widget == act->widget) {
-                       
-                       for (lop = prefs_common.actions_list; lop != NULL; lop = lop->next) {
-                               action = g_strdup((gchar*)lop->data);
-
-                               action_p = strstr(action, ": ");
-                               action_p[0] = 0x00;
-                               if (g_utf8_collate(act->name, action) == 0) {
-                                       found = TRUE;
-                                       g_free(action);
-                                       break;
-                               } else 
-                                       i++;
-                               g_free(action);
-                       }
-                       if (found) 
+                       i = prefs_actions_find_by_name(act->name);
+
+                       if (i != -1) 
                                break;
                }
        }
 
-       if (found
+       if (i != -1
                actions_execute(data, i, widget, source);
        else
                g_warning ("Error: did not find Claws Action to execute");
 }
 
+gboolean toolbar_check_action_btns(ToolbarType type)
+{
+       GSList *temp, *curr, *list = toolbar_config[type].item_list;
+       gboolean modified = FALSE;
+       
+       curr = list;
+       while (curr != NULL) {
+               ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
+               temp = curr;
+               curr = curr->next;
+               
+               if (toolbar_item->index != A_CLAWS_ACTIONS)
+                       continue;
+
+               if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
+                       list = g_slist_delete_link(list, temp);
+                       g_free(toolbar_item->file);
+                       g_free(toolbar_item->text);
+                       g_free(toolbar_item);
+                       modified = TRUE;
+               }
+       }
+       
+       return modified;
+}
+
 #if !(GTK_CHECK_VERSION(2,12,0))
 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
        gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(widget), GTK_TOOLTIPS(toolbar_tips),    \
@@ -1303,7 +1318,17 @@ static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
        default:
                return;
        }
+#ifndef USE_NEW_ADDRBOOK
        addressbook_open(compose);
+#else
+       GError* error = NULL;
+       addressbook_connect_signals(compose);
+       addressbook_dbus_open(TRUE, &error);
+       if (error) {
+               g_warning("%s", error->message);
+               g_error_free(error);
+       }
+#endif
 }
 
 
@@ -1896,12 +1921,12 @@ Toolbar *toolbar_create(ToolbarType      type,
                        break;
                case A_RECEIVE_ALL:
                        TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
-                               _("Receive Mail on all Accounts"),
-                               _("Receive Mail on selected Account"));
+                               _("Receive Mail from all Accounts"),
+                               _("Receive Mail from selected Account"));
                        toolbar_data->getall_btn = item;
                        break;
                case A_RECEIVE_CUR:
-                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Receive Mail on current Account"));
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Receive Mail from current Account"));
                        toolbar_data->get_btn = item;
                        break;
                case A_SEND_QUEUED:
@@ -2348,11 +2373,11 @@ void toolbar_main_set_sensitive(gpointer data)
        
        if (toolbar->get_btn)
                SET_WIDGET_COND(toolbar->get_btn, 
-                       M_HAVE_ACCOUNT|M_UNLOCKED);
+                       M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_RETRIEVABLE_ACCOUNT);
 
        if (toolbar->getall_btn) {
                SET_WIDGET_COND(toolbar->getall_btn, 
-                       M_HAVE_ACCOUNT|M_UNLOCKED);
+                       M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
        }
        if (toolbar->send_btn) {
                SET_WIDGET_COND(toolbar->send_btn,