Fixed crash when using '%p' Actions on displayed images + code clean up
authorMelvin Hadasht <melvin.hadasht@free.fr>
Tue, 7 Jan 2003 22:17:35 +0000 (22:17 +0000)
committerMelvin Hadasht <melvin.hadasht@free.fr>
Tue, 7 Jan 2003 22:17:35 +0000 (22:17 +0000)
ChangeLog.claws
configure.in
src/prefs_actions.c

index 3f3f797ba095c0d37bf1fa65c8225e475a2ceb14..657c754d6d08e07d87a26045f22cd2b40cbeea0b 100644 (file)
@@ -1,3 +1,11 @@
+2003-01-°7 [melvin]    0.8.8claws64
+
+       * src/prefs_actions.c
+               Fixed bug where an '%p' Action on a displayed image crashed 
+                       Sylpheed
+               Code clean up (get rid of duplicated code and removed unnecessary 
+                               structure member)
+
 2003-01-07 [christoph] 0.8.8claws63
 
        * src/compose.c
index 9f39a9211484f8a9896f311d56558c8eac89659b..48bab4c6b8d1b657fa012bac5653609ffe30c0d1 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws63
+EXTRA_VERSION=claws64
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 0c7497c9e0937f4c5139734377561be16cb5354e..1d2a3fbe659095ae9525025c28d104545d1806ba 100644 (file)
@@ -84,7 +84,6 @@ typedef struct _ChildInfo ChildInfo;
 
 struct _Children
 {
-       GtkWidget       *window;
        GtkWidget       *dialog;
        GtkWidget       *text;
        GtkWidget       *input_entry;
@@ -159,19 +158,21 @@ static void update_actions_menu           (GtkItemFactory *ifactory,
                                         gchar          *branch_path,
                                         gpointer        callback,
                                         gpointer        data);
-static void mainwin_actions_execute_cb         (MainWindow     *mainwin,
-                                        guint           action_nb,
-                                        GtkWidget      *widget);
 static void compose_actions_execute_cb (Compose        *compose,
                                         guint           action_nb,
                                         GtkWidget      *widget);
+static void mainwin_actions_execute_cb         (MainWindow     *mainwin,
+                                        guint           action_nb,
+                                        GtkWidget      *widget);
 static void msgview_actions_execute_cb (MessageView    *msgview, 
                                         guint           action_nb,
                                         GtkWidget      *widget);
+static void message_actions_execute    (MessageView    *msgview,
+                                        guint           action_nb,
+                                        GtkCTree       *ctree);
 static guint get_action_type           (gchar          *action);
 
 static gboolean execute_actions                (gchar          *action, 
-                                        GtkWidget      *window,
                                         GtkCTree       *ctree, 
                                         GtkWidget      *text,
                                         GdkFont        *msgfont,
@@ -1074,59 +1075,33 @@ static void compose_actions_execute_cb(Compose *compose, guint action_nb,
                return;
        }
 
-       execute_actions(action, compose->window, NULL, compose->text, NULL, 0,
-                       NULL);
+       execute_actions(action, NULL, compose->text, NULL, 0, NULL);
 }
 
 static void mainwin_actions_execute_cb(MainWindow *mainwin, guint action_nb,
                                       GtkWidget *widget)
 {
-       MessageView *messageview = mainwin->messageview;
-       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 (messageview->type) {
-       case MVIEW_TEXT:
-               if (messageview->textview && messageview->textview->text)
-                       textview = messageview->textview;
-               break;
-       case MVIEW_MIME:
-               if (messageview->mimeview) {
-                       mimeview = messageview->mimeview;
-                       if (messageview->mimeview->type == MIMEVIEW_TEXT &&
-                                       messageview->mimeview->textview &&
-                                       messageview->mimeview->textview->text)
-                               textview = messageview->mimeview->textview;
-               } 
-               break;
-       }
-
-       execute_actions(action, mainwin->window,
-                       GTK_CTREE(mainwin->summaryview->ctree), textview->text,
-                       textview->msgfont, textview->body_pos, mimeview);
+       message_actions_execute(mainwin->messageview, action_nb,
+                               GTK_CTREE(mainwin->summaryview->ctree));
 }
 
-/* FIXME: Code duplication mainwindow_actions_execute_cb
- */
 static void msgview_actions_execute_cb(MessageView *msgview, guint action_nb,
                                       GtkWidget *widget)
+{
+       message_actions_execute(msgview, action_nb, NULL);
+       
+}
+
+static void message_actions_execute(MessageView *msgview, guint action_nb,
+                                   GtkCTree *ctree)
 {
        TextView    *textview = NULL;
        gchar       *buf,
                    *action;
        MimeView    *mimeview = NULL;
+       GdkFont     *msgfont  = NULL;
+       guint        body_pos = 0;
+       GtkWidget   *text     = NULL;
 
        g_return_if_fail(action_nb < g_slist_length(prefs_common.actions_list));
 
@@ -1154,14 +1129,21 @@ static void msgview_actions_execute_cb(MessageView *msgview, guint action_nb,
                break;
        }
 
-       execute_actions(action, msgview->window, NULL, textview->text,
-                       textview->msgfont, textview->body_pos, mimeview);
+       if (textview) {
+               text     = textview->text;
+               msgfont  = textview->msgfont;
+               body_pos = textview->body_pos;
+       }
+       
+       execute_actions(action, ctree, text, msgfont, body_pos, mimeview);
 }
 
-static gboolean execute_actions(gchar *action, GtkWidget *window,
-                               GtkCTree *ctree, GtkWidget *text, 
-                               GdkFont *msgfont, gint body_pos,
-                               MimeView *mimeview)
+static gboolean execute_actions(gchar    *action, 
+                               GtkCTree  *ctree,
+                               GtkWidget *text, 
+                               GdkFont   *msgfont,
+                               gint       body_pos,
+                               MimeView  *mimeview)
 {
        GList *cur, *selection = NULL;
        GSList *children_list = NULL;
@@ -1249,7 +1231,6 @@ static gboolean execute_actions(gchar *action, GtkWidget *window,
                GSList *cur;
 
                children->action  = g_strdup(action);
-               children->window  = window;
                children->dialog  = NULL;
                children->list    = children_list;
                children->nb      = g_slist_length(children_list);