enable addressbook and actions
authorOliver Haertel <o.h.a@gmx.net>
Thu, 26 Dec 2002 21:23:13 +0000 (21:23 +0000)
committerOliver Haertel <o.h.a@gmx.net>
Thu, 26 Dec 2002 21:23:13 +0000 (21:23 +0000)
ChangeLog.claws
configure.in
src/prefs_actions.c
src/toolbar.c

index 5d0826aa8098b22e226ab6b3f1e302b9f296f963..a12876e6849f003f6eb30f71246f9f892d8ecbf1 100644 (file)
@@ -1,3 +1,10 @@
+2002-12-26 [oliver]    0.8.8claws5
+       
+       * src/toolbar.c 
+               enable Addressbook for Main and Messageview
+       * src/prefs_actions.c
+               enable actions in Messageview
+
 2002-12-26 [christoph] 0.8.8claws4
 
        * src/common/plugin.c
index 58c29ac57db48232299f968bf1527c9a1266a474..1dc392750e387cbad3023fb8c1d3246e1a0650d2 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws4
+EXTRA_VERSION=claws5
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index c1db9f10f299770cb2b6606276d8dd5068c14ddd..ad2e13284a26044c2b8a11492a0a35c029a120f4 100644 (file)
@@ -164,6 +164,9 @@ static void mainwin_actions_execute_cb      (MainWindow     *mainwin,
 static void compose_actions_execute_cb (Compose        *compose,
                                         guint           action_nb,
                                         GtkWidget      *widget);
+static void msgview_actions_execute_cb (MessageView    *msgview, 
+                                        guint           action_nb,
+                                        GtkWidget      *widget);
 static guint get_action_type           (gchar          *action);
 
 static gboolean execute_actions                (gchar          *action, 
@@ -1017,6 +1020,7 @@ void update_compose_actions_menu(GtkItemFactory *ifactory,
                            compose);
 }
 
+
 void actions_execute(gpointer data, 
                     guint action_nb,
                     GtkWidget *widget,
@@ -1024,9 +1028,10 @@ void actions_execute(gpointer data,
 {
        if (source == TOOLBAR_MAIN) 
                mainwin_actions_execute_cb((MainWindow*)data, action_nb, widget);
-
        else if (source == TOOLBAR_COMPOSE)
                compose_actions_execute_cb((Compose*)data, action_nb, widget);
+       else if (source == TOOLBAR_MSGVIEW)
+               msgview_actions_execute_cb((MessageView*)data, action_nb, widget);      
 }
 
 
@@ -1144,6 +1149,46 @@ static void mainwin_actions_execute_cb(MainWindow *mainwin, guint action_nb,
                        textview->msgfont, textview->body_pos, mimeview);
 }
 
+/* FIXME: Code duplication mainwindow_actions_execute_cb
+ */
+static void msgview_actions_execute_cb(MessageView *msgview, guint action_nb,
+                                      GtkWidget *widget)
+{
+       TextView    *textview = NULL;
+       gchar       *buf,
+                   *action;
+       MimeView    *mimeview = NULL;
+
+       g_return_if_fail(action_nb < g_slist_length(prefs_common.actions_list));
+
+       buf = (gchar *)g_slist_nth_data(prefs_common.actions_list, action_nb);
+
+       g_return_if_fail(buf);
+       g_return_if_fail(action = strstr(buf, ": "));
+
+       /* Point to the beginning of the command-line */
+       action += 2;
+
+       switch (msgview->type) {
+       case MVIEW_TEXT:
+               if (msgview->textview && msgview->textview->text)
+                       textview = msgview->textview;
+               break;
+       case MVIEW_MIME:
+               if (msgview->mimeview) {
+                       mimeview = msgview->mimeview;
+                       if (msgview->mimeview->type == MIMEVIEW_TEXT &&
+                           msgview->mimeview->textview &&
+                           msgview->mimeview->textview->text)
+                               textview = msgview->mimeview->textview;
+               } 
+               break;
+       }
+
+       execute_actions(action, msgview->window, NULL, textview->text,
+                       textview->msgfont, textview->body_pos, mimeview);
+}
+
 static gboolean execute_actions(gchar *action, GtkWidget *window,
                                GtkCTree *ctree, GtkWidget *text, 
                                GdkFont *msgfont, gint body_pos,
index c78741d9868dbc20be30bda2a11b7483ccb0f0d9..0937cca77b1eb1cadab212e5a3e485dfb7107d04 100644 (file)
@@ -264,17 +264,21 @@ gboolean toolbar_is_duplicate(gint action, ToolbarType source)
        return FALSE;
 }
 
+/* depending on toolbar type this function 
+   returns a list of available toolbar events being 
+   displayed by prefs_toolbar
+*/
 GList *toolbar_get_action_items(ToolbarType source)
 {
        GList *items = NULL;
        gint i = 0;
        
        if (source == TOOLBAR_MAIN) {
-               gint main_items[13] = { A_RECEIVE_ALL,   A_RECEIVE_CUR,   A_SEND_QUEUED,
+               gint main_items[14] = { A_RECEIVE_ALL,   A_RECEIVE_CUR,   A_SEND_QUEUED,
                                        A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,  
                                        A_REPLY_ALL,     A_REPLY_ML,      A_FORWARD,       
                                        A_DELETE,        A_EXECUTE,       A_GOTO_NEXT,      
-                                       A_SYL_ACTIONS };
+                                       A_ADDRBOOK,      A_SYL_ACTIONS };
 
                for (i = 0; i < sizeof(main_items)/sizeof(main_items[0]); i++) 
                        items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
@@ -289,9 +293,10 @@ GList *toolbar_get_action_items(ToolbarType source)
                        items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
        }
        else if (source == TOOLBAR_MSGVIEW) {
-               gint msgv_items[8] = { A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
-                                      A_REPLY_ALL,     A_REPLY_ML,      A_FORWARD,
-                                      A_DELETE,        A_GOTO_NEXT };  
+               gint msgv_items[10] = { A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
+                                       A_REPLY_ALL,     A_REPLY_ML,      A_FORWARD,
+                                       A_DELETE,        A_GOTO_NEXT,     A_ADDRBOOK,
+                                       A_SYL_ACTIONS };        
 
                for (i = 0; i < sizeof(msgv_items)/sizeof(msgv_items[0]); i++) 
                        items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
@@ -1261,11 +1266,15 @@ static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
        g_return_if_fail(toolbar_item != NULL);
 
        switch (toolbar_item->type) {
+       case TOOLBAR_MAIN:
+       case TOOLBAR_MSGVIEW:
+               compose = NULL;
+               break;
        case TOOLBAR_COMPOSE:
                compose = (Compose *)toolbar_item->parent;
                break;
        default:
-               compose = NULL;
+               return;
        }
        addressbook_open(compose);
 }
@@ -1388,25 +1397,29 @@ static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
        GSList *action_list;
        MainWindow *mainwin;
        Compose *compose;
+       MessageView *msgview;
+       gpointer parent = toolbar_item->parent;
 
        g_return_if_fail(toolbar_item != NULL);
 
        switch (toolbar_item->type) {
        case TOOLBAR_MAIN:
-               mainwin = (MainWindow*)toolbar_item->parent;
+               mainwin = (MainWindow*)parent;
                action_list = mainwin->toolbar->action_list;
                break;
        case TOOLBAR_COMPOSE:
-               compose = (Compose*)toolbar_item->parent;
+               compose = (Compose*)parent;
                action_list = compose->toolbar->action_list;
                break;
-               /* case TOOLBAR_MSGVIEW: not supported yet */
+       case TOOLBAR_MSGVIEW:
+               msgview = (MessageView*)parent;
+               action_list = msgview->toolbar->action_list;
+               break;
        default:
                debug_print("toolbar event not supported\n");
                return;
        }
-
-       toolbar_action_execute(widget, action_list, toolbar_item->parent, toolbar_item->type);
+       toolbar_action_execute(widget, action_list, parent, toolbar_item->type);        
 }
 
 static MainWindow *get_mainwin(gpointer data)