remove all gtk3 conditionals
[claws.git] / src / prefs_filtering_action.c
index 34817764cec93b7aea2abf4ccdd3384fda5b7ec7..5dc58db9db46e8c198fdf72be3f53676c2bf98e2 100644 (file)
@@ -33,9 +33,7 @@
 #include <string.h>
 #include <errno.h>
 
-#if !GTK_CHECK_VERSION(3, 0, 0)
 #include "gtkcmoptionmenu.h"
-#endif
 #include "main.h"
 #include "prefs_gtk.h"
 #include "prefs_filtering_action.h"
@@ -56,7 +54,7 @@
 #include "colorlabel.h"
 #include "combobox.h"
 #include "account.h"
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
        #include "addressbook.h"
 #endif
 
@@ -81,7 +79,7 @@ static gint prefs_filtering_action_deleted(GtkWidget *widget,
 static void prefs_filtering_action_type_selection_changed(GtkWidget *widget,
     gpointer user_data);
 static void prefs_filtering_action_select_dest(void);
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
 static void prefs_filtering_action_select_addressbook(void);
 #endif
 static void prefs_filtering_action_up(void);
@@ -122,12 +120,10 @@ static struct FilteringAction_ {
        GtkWidget *dest_entry;
        GtkWidget *dest_btn;
        GtkWidget *exec_btn;
-#if !GTK_CHECK_VERSION(3, 0, 0)
        GtkWidget *color_optmenu;
-#endif
        GtkWidget *header_combo;
        GtkWidget *header_entry;
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
        GtkWidget *addressbook_btn;
 #endif
        GtkWidget *score_entry;
@@ -185,9 +181,7 @@ static struct {
        { N_("Message flags"),  N_("Mark as spam"),             ACTION_MARK_AS_SPAM },
        { N_("Message flags"),  N_("Mark as ham"),              ACTION_MARK_AS_HAM },
        { NULL,                 N_("Execute"),                  ACTION_EXECUTE },
-#if !GTK_CHECK_VERSION(3, 0, 0)
        { NULL,                 N_("Color label"),              ACTION_COLOR },
-#endif
        { N_("Resend"),         N_("Forward"),                  ACTION_FORWARD },
        { N_("Resend"),         N_("Forward as attachment"),    ACTION_FORWARD_AS_ATTACHMENT },
        { N_("Resend"),         N_("Redirect"),                 ACTION_REDIRECT },
@@ -285,11 +279,9 @@ void prefs_filtering_action_open(GSList *action_list,
        if (!filtering_action.window) {
                prefs_filtering_action_create();
        } else {
-#if !GTK_CHECK_VERSION(3, 0, 0)
                /* update color label menu */
                gtk_cmoption_menu_set_menu(GTK_CMOPTION_MENU(filtering_action.color_optmenu),
                                colorlabel_create_color_menu());
-#endif
        }
 
        manage_window_set_transient(GTK_WINDOW(filtering_action.window));
@@ -350,7 +342,7 @@ static void prefs_filtering_action_create(void)
        GtkWidget *account_combo;
        GtkWidget *header_combo;
        GtkWidget *header_entry;
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
        GtkWidget *addressbook_btn;
 #endif
        GtkWidget *dest_entry;
@@ -375,9 +367,7 @@ static void prefs_filtering_action_create(void)
 
        GtkWidget *exec_btn;
 
-#if !GTK_CHECK_VERSION(3, 0, 0)
        GtkWidget *color_optmenu;
-#endif
 
        static GdkGeometry geometry;
 
@@ -488,22 +478,14 @@ static void prefs_filtering_action_create(void)
        gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 1, 2, 
                         GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       account_combo = gtk_combo_box_new_text ();
-#else
        account_combo = gtk_combo_box_text_new ();
-#endif
        gtk_size_group_add_widget(size_action, account_combo);
 
        for (accounts = account_get_list() ; accounts != NULL;
             accounts = accounts->next) {
                PrefsAccount *ac = (PrefsAccount *)accounts->data;
                gchar *name = g_strdup(ac->account_name);
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               gtk_combo_box_append_text(GTK_COMBO_BOX(account_combo), (gpointer) name);
-#else
                gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(account_combo), (gpointer) name);
-#endif
                g_free(name);
        }
 
@@ -532,31 +514,21 @@ static void prefs_filtering_action_create(void)
        score_entry = gtk_spin_button_new_with_range(-1000, 1000, 1);
        gtk_box_pack_start(GTK_BOX(hbox1), score_entry, FALSE, FALSE, 0);
        
-#if !GTK_CHECK_VERSION(3, 0, 0)
        color_optmenu = gtk_cmoption_menu_new();
        gtk_size_group_add_widget(size_action, color_optmenu);
        gtk_cmoption_menu_set_menu(GTK_CMOPTION_MENU(color_optmenu),
                                 colorlabel_create_color_menu());
        prefs_filtering_action_check_widget_width(color_optmenu);
        gtk_box_pack_start(GTK_BOX(hbox1), color_optmenu, FALSE, FALSE, 0);
-#endif
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       tags_combo = gtk_combo_box_new_text ();
-#else
        tags_combo = gtk_combo_box_text_new ();
-#endif
        gtk_size_group_add_widget(size_action, tags_combo);
 
        for (tmp = tags = tags_get_list() ; tmp != NULL;
             tmp = tmp->next) {
                gchar *name = g_strdup(tags_get_tag(GPOINTER_TO_INT(tmp->data)));
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               gtk_combo_box_append_text(GTK_COMBO_BOX(tags_combo), (gpointer) name);
-#else
                gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(tags_combo), (gpointer) name);
-#endif
                g_free(name);
        }
        g_slist_free(tags);
@@ -576,7 +548,7 @@ static void prefs_filtering_action_create(void)
                          G_CALLBACK(prefs_filtering_action_select_dest),
                          NULL);
 
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
        addressbook_btn = gtk_button_new_with_label (_("Select..."));
        gtk_box_pack_start (GTK_BOX (hbox1), addressbook_btn, FALSE, FALSE, 0);
        g_signal_connect (G_OBJECT (addressbook_btn), "clicked",
@@ -613,7 +585,7 @@ static void prefs_filtering_action_create(void)
                         G_CALLBACK(prefs_filtering_action_substitute_cb),
                         NULL);
 
-       del_btn = gtk_button_new_with_mnemonic (_("Re_move"));
+       del_btn = gtk_button_new_with_mnemonic (_("D_elete"));
        gtk_button_set_image(GTK_BUTTON(del_btn),
                        gtk_image_new_from_stock(GTK_STOCK_REMOVE,GTK_ICON_SIZE_BUTTON));
        gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
@@ -659,6 +631,9 @@ static void prefs_filtering_action_create(void)
        gtk_widget_set_size_request(window, prefs_common.filteringactionwin_width,
                                    prefs_common.filteringactionwin_height);
 
+       g_object_unref(G_OBJECT(size_group));
+       g_object_unref(G_OBJECT(size_action));
+
        gtk_widget_show_all(window);
 
        filtering_action.window    = window;
@@ -671,13 +646,11 @@ static void prefs_filtering_action_create(void)
        filtering_action.dest_entry = dest_entry;
        filtering_action.dest_btn = dest_btn;
        filtering_action.exec_btn = exec_btn;
-#if !GTK_CHECK_VERSION(3, 0, 0)
        filtering_action.color_optmenu = color_optmenu;
-#endif
        filtering_action.score_entry = score_entry;
        filtering_action.header_combo = header_combo;
        filtering_action.header_entry = header_entry;
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
        filtering_action.addressbook_btn = addressbook_btn;
 #endif
        filtering_action.ok_btn = ok_btn;
@@ -874,10 +847,8 @@ static gint prefs_filtering_action_get_matching_from_action(Action action_id)
                return MATCHACTION_REDIRECT;
        case ACTION_EXECUTE:
                return MATCHACTION_EXECUTE;
-#if !GTK_CHECK_VERSION(3, 0, 0)
        case ACTION_COLOR:
                return MATCHACTION_COLOR;
-#endif
        case ACTION_HIDE:
                return MATCHACTION_HIDE;
        case ACTION_IGNORE:
@@ -949,13 +920,11 @@ static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
                        return NULL;
                }
                break;
-#if !GTK_CHECK_VERSION(3, 0, 0)
        case ACTION_COLOR:
                labelcolor = colorlabel_get_color_menu_active_item(
                        gtk_cmoption_menu_get_menu(GTK_CMOPTION_MENU(filtering_action.color_optmenu)));
                destination = NULL;     
                break;
-#endif
         case ACTION_CHANGE_SCORE:
         case ACTION_SET_SCORE:
                score = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(
@@ -984,11 +953,7 @@ static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
                break;
        case ACTION_SET_TAG:
        case ACTION_UNSET_TAG:
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               destination = gtk_combo_box_get_active_text(GTK_COMBO_BOX(filtering_action.tags_combo));
-#else
                destination = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(filtering_action.tags_combo));
-#endif
                if (!destination || *destination == '\0') {
                        if (alert)
                                 alertpanel_error(_("Tag name is empty."));
@@ -1293,7 +1258,8 @@ static void prefs_filtering_action_select_dest(void)
        FolderItem *dest;
        gchar * path;
 
-       dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE);
+       dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE,
+                       _("Select destination folder"));
        if (!dest) return;
 
        path = folder_item_get_identifier(dest);
@@ -1302,7 +1268,7 @@ static void prefs_filtering_action_select_dest(void)
        g_free(path);
 }
 
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
 static void prefs_filtering_action_select_addressbook(void)
 {
        const gchar *folderpath = NULL;
@@ -1323,20 +1289,14 @@ static void prefs_filtering_action_enable_widget(GtkWidget* widget, const gboole
 
        if(enable == TRUE)
        {
-#if !GTK_CHECK_VERSION(2,24,0)
-               if(GTK_IS_COMBO_BOX(widget) || GTK_IS_COMBO_BOX_ENTRY(widget))
-#else
                if(GTK_IS_COMBO_BOX(widget))
-#endif
                        gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
                else if(GTK_IS_SPIN_BUTTON(widget))
                        gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), 0);
                else if(GTK_IS_ENTRY(widget))
                        gtk_entry_set_text(GTK_ENTRY(widget), "");
-#if !GTK_CHECK_VERSION(3, 0, 0)
                else if(GTK_IS_CMOPTION_MENU(widget))
                        gtk_cmoption_menu_set_history(GTK_CMOPTION_MENU(widget), 0);
-#endif
                
                gtk_widget_set_sensitive(widget, TRUE);
                gtk_widget_show(widget);
@@ -1400,14 +1360,12 @@ static void prefs_filtering_action_type_selection_changed(GtkWidget *combo,
        prefs_filtering_action_enable_widget(filtering_action.exec_btn,
                                                (value == ACTION_EXECUTE));
 
-#if !GTK_CHECK_VERSION(3, 0, 0)
        prefs_filtering_action_enable_widget(filtering_action.color_optmenu,
                                                (value == ACTION_COLOR));
-#endif
 
        prefs_filtering_action_enable_widget(filtering_action.header_combo,
                                        (value == ACTION_ADD_TO_ADDRESSBOOK));  
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
        prefs_filtering_action_enable_widget(filtering_action.addressbook_btn,
                                        (value == ACTION_ADD_TO_ADDRESSBOOK));
 #endif
@@ -1429,11 +1387,9 @@ static void prefs_filtering_action_type_selection_changed(GtkWidget *combo,
        case ACTION_MOVE:
                gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Destination"));
                break;
-#if !GTK_CHECK_VERSION(3, 0, 0)
        case ACTION_COLOR:
                gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Color"));
                break;
-#endif
        case ACTION_EXECUTE:
                gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Execute"));
                break;
@@ -1637,7 +1593,6 @@ static gboolean prefs_filtering_actions_selected
                combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
                                     ACTION_EXECUTE);
                break;
-#if !GTK_CHECK_VERSION(3, 0, 0)
        case MATCHACTION_COLOR:
                combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
                                     ACTION_COLOR);
@@ -1647,7 +1602,6 @@ static gboolean prefs_filtering_actions_selected
                                                filtering_action.color_optmenu));
                g_signal_emit_by_name(G_OBJECT(menu), "selection-done", menu);
                break;
-#endif
        case MATCHACTION_CHANGE_SCORE:
                combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
                                     ACTION_CHANGE_SCORE);
@@ -1701,7 +1655,7 @@ static gboolean prefs_filtering_actions_selected
                                     ACTION_CLEAR_TAGS);
                break;
        default:
-               g_warning("unhandled case !\n");
+               g_warning("unhandled action type");
        }
        if (action->destination)
                gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), action->destination);