* src/matcher.[ch]
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 12 Jul 2003 22:20:19 +0000 (22:20 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 12 Jul 2003 22:20:19 +0000 (22:20 +0000)
* src/matcher_parser_parse.y
* src/prefs_filtering.c
* src/filtering.c
add "Lock" filter action to lock messages;

re-organize matcher part 9:

* src/filtering.c
        remove debug_print()
* src/prefs_filtering.c
make action text entries easily extendible;
merge widget selection for ACTION_MARK, ACTION_UNMARK, ACTION_LOCK,
ACTION_UNLOCK, ACTION_MARK_AS_READ, ACTION_MARK_AS_UNREAD

ChangeLog.claws
configure.ac
src/filtering.c
src/matcher.c
src/matcher.h
src/matcher_parser_parse.y
src/prefs_filtering.c

index 8df3666b623021ef11ed05cddead124fca233ef8..464625c7b292d5082b3284752f7b42bedba20c61 100644 (file)
@@ -1,3 +1,20 @@
+
+2003-07-12 [alfons]    0.9.3claws1
+
+       * src/matcher.[ch]
+       * src/matcher_parser_parse.y
+       * src/prefs_filtering.c
+       * src/filtering.c
+               add "Lock" filter action to lock messages;
+
+       * src/filtering.c       
+               remove debug_print()    
+       * src/prefs_filtering.c
+               re-organize matcher part 9: 
+               make action text entries easily extendible;
+               merge widget selection for ACTION_MARK, ACTION_UNMARK, ACTION_LOCK,
+               ACTION_UNLOCK, ACTION_MARK_AS_READ, ACTION_MARK_AS_UNREAD
+
 2003-07-12 [paul]
 
        * tools/README
index 639d0831ec829c3918f2756bb329c13ce4d13a77..827031751821dae080f1af207a073269a9500acf 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws
+EXTRA_VERSION=claws1
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 7a97d0caa8dd1cff638de865c69e6af1927e8b89..934eb08d437e165bde2e91f8ac382f19f25014be 100644 (file)
@@ -187,13 +187,20 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
        case MATCHACTION_UNMARK:
                procmsg_msginfo_unset_flags(info, MSG_MARKED, 0);
                return TRUE;
+
+       case MATCHACTION_LOCK:
+               procmsg_msginfo_set_flags(info, MSG_LOCKED, 0);
+               return TRUE;
+
+       case MATCHACTION_UNLOCK:
+               procmsg_msginfo_unset_flags(info, MSG_LOCKED, 0);       
+               return TRUE;
                
        case MATCHACTION_MARK_AS_READ:
                procmsg_msginfo_unset_flags(info, MSG_UNREAD | MSG_NEW, 0);
                return TRUE;
 
        case MATCHACTION_MARK_AS_UNREAD:
-               debug_print("*** setting unread flags\n");
                procmsg_msginfo_set_flags(info, MSG_UNREAD | MSG_NEW, 0);
                return TRUE;
        
@@ -311,8 +318,10 @@ static gboolean filtering_is_final_action(FilteringProp *filtering)
        case MATCHACTION_EXECUTE:
        case MATCHACTION_COPY:
        case MATCHACTION_MARK:
-       case MATCHACTION_MARK_AS_READ:
        case MATCHACTION_UNMARK:
+       case MATCHACTION_LOCK:
+       case MATCHACTION_UNLOCK:
+       case MATCHACTION_MARK_AS_READ:
        case MATCHACTION_MARK_AS_UNREAD:
        case MATCHACTION_FORWARD:
        case MATCHACTION_FORWARD_AS_ATTACHMENT:
@@ -374,6 +383,8 @@ gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *act
        case MATCHACTION_DELETE:
        case MATCHACTION_MARK:
        case MATCHACTION_UNMARK:
+       case MATCHACTION_LOCK:
+       case MATCHACTION_UNLOCK:
        case MATCHACTION_MARK_AS_READ:
        case MATCHACTION_MARK_AS_UNREAD:
                g_snprintf(dest, destlen, "%s", command_str);
index f47abd58a975682326475966681ec46256917d5d..9a1585ac3ba3c9ae084ef3fe7442bd311d992632 100644 (file)
@@ -116,6 +116,8 @@ static const MatchParser matchparser_tab[] = {
        {MATCHACTION_DELETE, "delete"},
        {MATCHACTION_MARK, "mark"},
        {MATCHACTION_UNMARK, "unmark"},
+       {MATCHACTION_LOCK, "lock"},
+       {MATCHACTION_UNLOCK, "unlock"},
        {MATCHACTION_MARK_AS_READ, "mark_as_read"},
        {MATCHACTION_MARK_AS_UNREAD, "mark_as_unread"},
        {MATCHACTION_FORWARD, "forward"},
index e62da4a06c5e80826f8b466c938e357569ffd05d..a145f65fe817d3afad639f140104eaca0387548d 100644 (file)
@@ -111,6 +111,8 @@ enum {
        MA_(DELETE),
        MA_(MARK),
        MA_(UNMARK),
+       MA_(LOCK),
+       MA_(UNLOCK),
        MA_(MARK_AS_READ),
        MA_(MARK_AS_UNREAD),
        MA_(FORWARD),
index 915498c306848e5a4f9da15f1488a965f11f4200..559f680d6eba63ef1ae2a24d97c1e7cc8024a1b9 100644 (file)
@@ -212,7 +212,7 @@ int matcher_parserwrap(void)
 %token MATCHER_NOT_MESSAGE  MATCHER_BODY_PART  MATCHER_NOT_BODY_PART
 %token MATCHER_EXECUTE  MATCHER_NOT_EXECUTE  MATCHER_MATCHCASE  MATCHER_MATCH
 %token MATCHER_REGEXPCASE  MATCHER_REGEXP  MATCHER_SCORE  MATCHER_MOVE
-%token MATCHER_COPY  MATCHER_DELETE  MATCHER_MARK  MATCHER_UNMARK
+%token MATCHER_COPY  MATCHER_DELETE  MATCHER_MARK  MATCHER_UNMARK MATCHER_LOCK MATCHER_UNLOCK
 %token MATCHER_MARK_AS_READ  MATCHER_MARK_AS_UNREAD  MATCHER_FORWARD
 %token MATCHER_FORWARD_AS_ATTACHMENT  MATCHER_EOL  MATCHER_STRING  
 %token MATCHER_OR MATCHER_AND  
@@ -887,6 +887,20 @@ MATCHER_EXECUTE MATCHER_STRING
        action_type = MATCHACTION_UNMARK;
        action = filteringaction_new(action_type, 0, NULL, 0);
 }
+| MATCHER_LOCK
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_LOCK;
+       action = filteringaction_new(action_type, 0, NULL, 0);
+}
+| MATCHER_UNLOCK
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_UNLOCK;
+       action = filteringaction_new(action_type, 0, NULL, 0);
+}
 | MATCHER_MARK_AS_READ
 {
        gint action_type = 0;
index ebf83dd986c69ea5823bb5fd3c6fc461ca64e4e9..d555a53df06806385cab72b442bdd2f2b41e702f 100644 (file)
@@ -87,13 +87,12 @@ static void prefs_filtering_set_dialog      (const gchar *header,
 static void prefs_filtering_set_list   (void);
 
 /* callback functions */
-/* static void prefs_filtering_select_dest_cb  (void); */
 static void prefs_filtering_register_cb        (void);
 static void prefs_filtering_substitute_cb      (void);
 static void prefs_filtering_delete_cb  (void);
 static void prefs_filtering_up         (void);
-static void prefs_filtering_down               (void);
-static void prefs_filtering_select             (GtkCList       *clist,
+static void prefs_filtering_down       (void);
+static void prefs_filtering_select     (GtkCList       *clist,
                                         gint            row,
                                         gint            column,
                                         GdkEvent       *event);
@@ -104,39 +103,72 @@ static gint prefs_filtering_deleted       (GtkWidget      *widget,
 static void prefs_filtering_key_pressed        (GtkWidget      *widget,
                                         GdkEventKey    *event,
                                         gpointer        data);
-static void prefs_filtering_cancel             (void);
+static void prefs_filtering_cancel     (void);
 static void prefs_filtering_ok         (void);
 
 static void prefs_filtering_condition_define   (void);
-static gint prefs_filtering_clist_set_row(gint row, FilteringProp * prop);
-static void prefs_filtering_select_dest(void);
-static void prefs_filtering_action_select(GtkList *list,
-                                         GtkWidget *widget, 
-                                         gpointer user_data);
+static gint prefs_filtering_clist_set_row      (gint row, FilteringProp * prop);
+static void prefs_filtering_select_dest                (void);
+static void prefs_filtering_action_select      (GtkList *list,
+                                                GtkWidget *widget, 
+                                                gpointer user_data);
+
 static void prefs_filtering_action_selection_changed(GtkList *list,
                                                     gpointer user_data);
                                          
-static void prefs_filtering_reset_dialog(void);
+static void prefs_filtering_reset_dialog       (void);
 static gboolean prefs_filtering_rename_path_func(GNode *node, gpointer data);
 static gboolean prefs_filtering_delete_path_func(GNode *node, gpointer data);
 
-static FolderItem * cur_item = NULL;
-
-enum {
-       ACTION_MOVE = 0,
-       ACTION_COPY = 1,
-       ACTION_DELETE = 2,
-       ACTION_MARK = 3,
-       ACTION_UNMARK = 4,
-       ACTION_MARK_AS_READ = 5,
-       ACTION_MARK_AS_UNREAD = 6,
-       ACTION_FORWARD = 7,
-       ACTION_FORWARD_AS_ATTACHMENT = 8,
-       ACTION_REDIRECT = 9,
-       ACTION_EXECUTE = 10,
-       ACTION_COLOR = 11,
+static FolderItem * cur_item = NULL; /* folder (if dialog opened for processing) */
+
+typedef enum Action_ {
+       ACTION_MOVE,
+       ACTION_COPY,
+       ACTION_DELETE,
+       ACTION_MARK,
+       ACTION_UNMARK,
+       ACTION_LOCK,
+       ACTION_UNLOCK,
+       ACTION_MARK_AS_READ,
+       ACTION_MARK_AS_UNREAD,
+       ACTION_FORWARD,
+       ACTION_FORWARD_AS_ATTACHMENT,
+       ACTION_REDIRECT,
+       ACTION_EXECUTE,
+       ACTION_COLOR,
+       /* add other action constants */
+} Action;
+
+static struct {
+       gchar *text;
+       Action action;
+} action_text [] = {
+       { N_("Move"),                   ACTION_MOVE     },      
+       { N_("Copy"),                   ACTION_COPY     },
+       { N_("Delete"),                 ACTION_DELETE   },
+       { N_("Mark"),                   ACTION_MARK     },
+       { N_("Unmark"),                 ACTION_UNMARK   },
+       { N_("Lock"),                   ACTION_LOCK     },
+       { N_("Unlock"),                 ACTION_UNLOCK   },
+       { N_("Mark as read"),           ACTION_MARK_AS_READ },
+       { N_("Mark as unread"),         ACTION_MARK_AS_UNREAD },
+       { N_("Forward"),                ACTION_FORWARD  },
+       { N_("Forward as attachment"),  ACTION_FORWARD_AS_ATTACHMENT },
+       { N_("Redirect"),               ACTION_REDIRECT },
+       { N_("Execute"),                ACTION_EXECUTE  },
+       { N_("Color"),                  ACTION_COLOR    }
 };
 
+static const gchar *get_action_text(Action action)
+{
+       int n;
+       for (n = 0; n < sizeof action_text / sizeof action_text[0]; n++)
+               if (action_text[n].action == action)
+                       return action_text[n].text;
+       return "";                      
+}
+
 static gint get_sel_from_list(GtkList * list)
 {
        gint row = 0;
@@ -188,9 +220,9 @@ static gint get_list_id_from_account_id(gint account_id)
        return 0;
 }
 
-static gint prefs_filtering_get_matching_from_action(gint action_id)
+static gint prefs_filtering_get_matching_from_action(Action action_id)
 {
-       switch(action_id) {
+       switch (action_id) {
        case ACTION_MOVE:
                return MATCHACTION_MOVE;
        case ACTION_COPY:
@@ -201,6 +233,10 @@ static gint prefs_filtering_get_matching_from_action(gint action_id)
                return MATCHACTION_MARK;
        case ACTION_UNMARK:
                return MATCHACTION_UNMARK;
+       case ACTION_LOCK:
+               return MATCHACTION_LOCK;
+       case ACTION_UNLOCK:
+               return MATCHACTION_UNLOCK;
        case ACTION_MARK_AS_READ:
                return MATCHACTION_MARK_AS_READ;
        case ACTION_MARK_AS_UNREAD:
@@ -220,21 +256,6 @@ static gint prefs_filtering_get_matching_from_action(gint action_id)
        }
 }
 
-static gchar * action_text [] = {
-       N_("Move"),     
-       N_("Copy"), 
-       N_("Delete"),
-       N_("Mark"), 
-       N_("Unmark"), 
-       N_("Mark as read"), 
-       N_("Mark as unread"),
-       N_("Forward"), 
-       N_("Forward as attachment"), 
-       N_("Redirect"), 
-       N_("Execute"),
-       N_("Color"),
-};
-
 void prefs_filtering_open(FolderItem * item,
                          const gchar *header,
                          const gchar *key)
@@ -399,12 +420,9 @@ static void prefs_filtering_create(void)
                               FALSE);
 
        combo_items = NULL;
-
-       for(i = 0 ; i < (gint) (sizeof(action_text) / sizeof(gchar *)) ;
-           i++) {
-               combo_items = g_list_append(combo_items,
-                                           (gpointer) _(action_text[i]));
-       }
+       for (i = 0; i < sizeof action_text / sizeof action_text[0]; i++)
+               combo_items = g_list_append
+                       (combo_items, (gpointer) _(action_text[i].text));
        gtk_combo_set_popdown_strings(GTK_COMBO(action_combo), combo_items);
 
        g_list_free(combo_items);
@@ -960,7 +978,7 @@ static FilteringProp * prefs_filtering_dialog_to_filtering(gboolean alert)
        FilteringProp * prop;
        FilteringAction * action;
        gint list_id;
-       gint action_id;
+       Action action_id;
        gint action_type;
        gint account_id;
        gchar * destination;
@@ -1109,10 +1127,10 @@ static void prefs_filtering_down(void)
        }
 }
 
-static void prefs_filtering_select_set(FilteringProp * prop)
+static void prefs_filtering_select_set(FilteringProp *prop)
 {
-       FilteringAction * action;
-       gchar * matcher_str;
+       FilteringAction *action;
+       gchar *matcher_str;
        gint list_id;
 
        prefs_filtering_reset_dialog();
@@ -1153,6 +1171,14 @@ static void prefs_filtering_select_set(FilteringProp * prop)
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_UNMARK);
                break;
+       case MATCHACTION_LOCK:
+               gtk_list_select_item(GTK_LIST(filtering.action_list),
+                                    ACTION_LOCK);
+               break;
+       case MATCHACTION_UNLOCK:
+               gtk_list_select_item(GTK_LIST(filtering.action_list),
+                                    ACTION_UNLOCK);
+               break;
        case MATCHACTION_MARK_AS_READ:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_MARK_AS_READ);
@@ -1261,9 +1287,9 @@ static void prefs_filtering_action_select(GtkList *list,
                                          GtkWidget *widget,
                                          gpointer user_data)
 {
-       gint value;
+       Action value;
 
-       value = get_sel_from_list(GTK_LIST(filtering.action_list));
+       value = (Action) get_sel_from_list(GTK_LIST(filtering.action_list));
 
        switch (value) {
        case ACTION_MOVE:
@@ -1315,53 +1341,10 @@ static void prefs_filtering_action_select(GtkList *list,
                gtk_widget_hide(filtering.color_label);
                break;
        case ACTION_MARK:
-               gtk_widget_show(filtering.account_label);
-               gtk_widget_set_sensitive(filtering.account_label, FALSE);
-               gtk_widget_set_sensitive(filtering.account_combo, FALSE);
-               gtk_widget_show(filtering.dest_entry);
-               gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
-               gtk_widget_show(filtering.dest_btn);
-               gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
-               gtk_widget_show(filtering.dest_label);
-               gtk_widget_set_sensitive(filtering.dest_label, FALSE);
-               gtk_widget_hide(filtering.recip_label);
-               gtk_widget_hide(filtering.exec_label);
-               gtk_widget_hide(filtering.exec_btn);
-               gtk_widget_hide(filtering.color_optmenu);
-               gtk_widget_hide(filtering.color_label);
-               break;
        case ACTION_UNMARK:
-               gtk_widget_show(filtering.account_label);
-               gtk_widget_set_sensitive(filtering.account_label, FALSE);
-               gtk_widget_set_sensitive(filtering.account_combo, FALSE);
-               gtk_widget_show(filtering.dest_entry);
-               gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
-               gtk_widget_show(filtering.dest_btn);
-               gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
-               gtk_widget_show(filtering.dest_label);
-               gtk_widget_set_sensitive(filtering.dest_label, FALSE);
-               gtk_widget_hide(filtering.recip_label);
-               gtk_widget_hide(filtering.exec_label);
-               gtk_widget_hide(filtering.exec_btn);
-               gtk_widget_hide(filtering.color_optmenu);
-               gtk_widget_hide(filtering.color_label);
-               break;
+       case ACTION_LOCK:
+       case ACTION_UNLOCK:
        case ACTION_MARK_AS_READ:
-               gtk_widget_show(filtering.account_label);
-               gtk_widget_set_sensitive(filtering.account_label, FALSE);
-               gtk_widget_set_sensitive(filtering.account_combo, FALSE);
-               gtk_widget_show(filtering.dest_entry);
-               gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
-               gtk_widget_show(filtering.dest_btn);
-               gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
-               gtk_widget_show(filtering.dest_label);
-               gtk_widget_set_sensitive(filtering.dest_label, FALSE);
-               gtk_widget_hide(filtering.recip_label);
-               gtk_widget_hide(filtering.exec_label);
-               gtk_widget_hide(filtering.exec_btn);
-               gtk_widget_hide(filtering.color_optmenu);
-               gtk_widget_hide(filtering.color_label);
-               break;
        case ACTION_MARK_AS_UNREAD:
                gtk_widget_show(filtering.account_label);
                gtk_widget_set_sensitive(filtering.account_label, FALSE);