2011-10-31 [paul] 3.7.10cvs62
[claws.git] / src / compose.c
index 2211ea0e30b49a39c98df99e882f6d79f24b15c3..c6bf6627e6d72b703e702c80c20bed6d159418b4 100644 (file)
 #include "codeconv.h"
 #include "utils.h"
 #include "gtkutils.h"
+#include "gtkshruler.h"
 #include "socket.h"
 #include "alertpanel.h"
 #include "manage_window.h"
-#if !GTK_CHECK_VERSION(2, 24, 0)
-#include "gtkshruler.h"
-#endif
 #include "folder.h"
 #include "addr_compl.h"
 #include "quote_fmt.h"
@@ -353,11 +351,9 @@ static void compose_add_field_list ( Compose *compose,
 
 /* callback functions */
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
 static gboolean compose_edit_size_alloc (GtkEditable   *widget,
                                         GtkAllocation  *allocation,
                                         GtkSHRuler     *shruler);
-#endif
 static void account_activated          (GtkComboBox *optmenu,
                                         gpointer        data);
 static void attach_selected            (GtkTreeView    *tree_view, 
@@ -441,10 +437,8 @@ static void compose_toggle_autowrap_cb     (GtkToggleAction *action,
 static void compose_toggle_autoindent_cb(GtkToggleAction *action,
                                         gpointer        data);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
 static void compose_toggle_ruler_cb    (GtkToggleAction *action,
                                         gpointer        data);
-#endif
 static void compose_toggle_sign_cb     (GtkToggleAction *action,
                                         gpointer        data);
 static void compose_toggle_encrypt_cb  (GtkToggleAction *action,
@@ -586,7 +580,7 @@ static GtkActionEntry compose_entries[] =
        {"Edit/Copy",                   NULL, N_("_Copy"), "<control>C", NULL, G_CALLBACK(compose_copy_cb) },
        {"Edit/Paste",                  NULL, N_("_Paste"), "<control>V", NULL, G_CALLBACK(compose_paste_cb) },
 
-       {"Edit/SpecialPaste",           NULL, N_("Special paste") },
+       {"Edit/SpecialPaste",           NULL, N_("_Special paste") },
        {"Edit/SpecialPaste/AsQuotation",       NULL, N_("as _quotation"), NULL, NULL, G_CALLBACK(compose_paste_as_quote_cb) },
        {"Edit/SpecialPaste/Wrapped",   NULL, N_("_wrapped"), NULL, NULL, G_CALLBACK(compose_paste_wrap_cb) },
        {"Edit/SpecialPaste/Unwrapped", NULL, N_("_unwrapped"), NULL, NULL, G_CALLBACK(compose_paste_no_wrap_cb) },
@@ -674,9 +668,7 @@ static GtkToggleActionEntry compose_toggle_entries[] =
        {"Options/Encrypt",             NULL, N_("_Encrypt"), NULL, NULL, G_CALLBACK(compose_toggle_encrypt_cb) }, /* Toggle */
        {"Options/RequestRetRcpt",      NULL, N_("_Request Return Receipt"), NULL, NULL, G_CALLBACK(compose_toggle_return_receipt_cb) }, /* TOGGLE */
        {"Options/RemoveReferences",    NULL, N_("Remo_ve references"), NULL, NULL, G_CALLBACK(compose_toggle_remove_refs_cb) }, /* TOGGLE */
-#if !GTK_CHECK_VERSION(2, 24, 0)
        {"Tools/ShowRuler",             NULL, N_("Show _ruler"), NULL, NULL, G_CALLBACK(compose_toggle_ruler_cb) }, /* Toggle */
-#endif
 };
 
 static GtkRadioActionEntry compose_radio_rm_entries[] =
@@ -797,9 +789,9 @@ static void compose_create_tags(GtkTextView *text, Compose *compose)
 #if !GTK_CHECK_VERSION(2, 24, 0)
        GdkColormap *cmap;
        gboolean success[8];
+       int i;
 #endif
        GdkColor color[8];
-       int i;
 
        buffer = gtk_text_view_get_buffer(text);
 
@@ -2436,9 +2428,7 @@ Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo,
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Message/InsertSig", FALSE);
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Edit", FALSE);
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options", FALSE);
-#if !GTK_CHECK_VERSION(2, 24, 0)
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Tools/ShowRuler", FALSE);
-#endif
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Tools/Actions", FALSE);
        
        if (compose->toolbar->draft_btn)
@@ -2547,7 +2537,7 @@ void compose_entry_append(Compose *compose, const gchar *address,
 
 static void compose_entry_mark_default_to(Compose *compose, const gchar *mailto)
 {
-#if !GTK_CHECK_VERSION(2, 24, 0)
+#if !GTK_CHECK_VERSION(3, 0, 0)
        static GdkColor yellow;
        static GdkColor black;
        static gboolean yellow_initialised = FALSE;
@@ -2558,7 +2548,7 @@ static void compose_entry_mark_default_to(Compose *compose, const gchar *mailto)
        GSList *h_list;
        GtkEntry *entry;
                
-#if !GTK_CHECK_VERSION(2, 24, 0)
+#if !GTK_CHECK_VERSION(3, 0, 0)
        if (!yellow_initialised) {
                gdk_color_parse("#f5f6be", &yellow);
                gdk_color_parse("#000000", &black);
@@ -2573,7 +2563,7 @@ static void compose_entry_mark_default_to(Compose *compose, const gchar *mailto)
                entry = GTK_ENTRY(((ComposeHeaderEntry *)h_list->data)->entry);
                if (gtk_entry_get_text(entry) && 
                    !g_utf8_collate(gtk_entry_get_text(entry), mailto)) {
-#if !GTK_CHECK_VERSION(2, 24, 0)
+#if !GTK_CHECK_VERSION(3, 0, 0)
                        if (yellow_initialised) {
 #endif
                                gtk_widget_modify_base(
@@ -2582,7 +2572,7 @@ static void compose_entry_mark_default_to(Compose *compose, const gchar *mailto)
                                gtk_widget_modify_text(
                                        GTK_WIDGET(((ComposeHeaderEntry *)h_list->data)->entry),
                                        GTK_STATE_NORMAL, &black);
-#if !GTK_CHECK_VERSION(2, 24, 0)
+#if !GTK_CHECK_VERSION(3, 0, 0)
                        }
 #endif
                }
@@ -5013,10 +5003,10 @@ gint compose_send(Compose *compose)
        }
        if (msgpath == NULL) {
                msgpath = folder_item_fetch_msg(folder, msgnum);
-               val = procmsg_send_message_queue(msgpath, &errstr, folder, msgnum, &queued_removed);
+               val = procmsg_send_message_queue_with_lock(msgpath, &errstr, folder, msgnum, &queued_removed);
                g_free(msgpath);
        } else {
-               val = procmsg_send_message_queue(msgpath, &errstr, folder, msgnum, &queued_removed);
+               val = procmsg_send_message_queue_with_lock(msgpath, &errstr, folder, msgnum, &queued_removed);
                claws_unlink(msgpath);
                g_free(msgpath);
        }
@@ -7084,15 +7074,12 @@ static Compose *compose_create(PrefsAccount *account,
        GtkWidget *paned;
 
        GtkWidget *edit_vbox;
-#if !GTK_CHECK_VERSION(2, 24, 0)
        GtkWidget *ruler_hbox;
        GtkWidget *ruler;
-#endif
        GtkWidget *scrolledwin;
        GtkWidget *text;
        GtkTextBuffer *buffer;
        GtkClipboard *clipboard;
-       CLAWS_TIP_DECL();
 
        UndoMain *undostruct;
 
@@ -7343,9 +7330,7 @@ static Compose *compose_create(PrefsAccount *account,
 /* phew. */
 
 /* Tools menu */
-#if !GTK_CHECK_VERSION(2, 24, 0)
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Tools", "ShowRuler", "Tools/ShowRuler", GTK_UI_MANAGER_MENUITEM)
-#endif
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Tools", "AddressBook", "Tools/AddressBook", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Tools", "Template", "Tools/Template", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Tools/Template", "PlaceHolder", "Tools/Template/PlaceHolder", GTK_UI_MANAGER_MENUITEM)
@@ -7447,16 +7432,14 @@ static Compose *compose_create(PrefsAccount *account,
 
        gtk_box_pack_start(GTK_BOX(edit_vbox), subject_hbox, FALSE, FALSE, 0);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
        /* ruler */
        ruler_hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(edit_vbox), ruler_hbox, FALSE, FALSE, 0);
 
-       ruler = gtk_shruler_new();
-       gtk_ruler_set_range(GTK_RULER(ruler), 0.0, 100.0, 1.0, 100.0);
+       ruler = gtk_shruler_new(GTK_ORIENTATION_HORIZONTAL);
+       gtk_shruler_set_range(GTK_SHRULER(ruler), 0.0, 100.0, 1.0);
        gtk_box_pack_start(GTK_BOX(ruler_hbox), ruler, TRUE, TRUE,
                           BORDER_WIDTH);
-#endif
 
        /* text widget */
        scrolledwin = gtk_scrolled_window_new(NULL, NULL);
@@ -7480,11 +7463,9 @@ static Compose *compose_create(PrefsAccount *account,
        gtk_text_buffer_add_selection_clipboard(buffer, clipboard);
        
        gtk_container_add(GTK_CONTAINER(scrolledwin), text);
-#if !GTK_CHECK_VERSION(2, 24, 0)
        g_signal_connect_after(G_OBJECT(text), "size_allocate",
                               G_CALLBACK(compose_edit_size_alloc),
                               ruler);
-#endif
        g_signal_connect(G_OBJECT(buffer), "changed",
                         G_CALLBACK(compose_changed_cb), compose);
        g_signal_connect(G_OBJECT(text), "grab_focus",
@@ -7578,10 +7559,8 @@ static Compose *compose_create(PrefsAccount *account,
 
        compose->notebook      = notebook;
        compose->edit_vbox     = edit_vbox;
-#if !GTK_CHECK_VERSION(2, 24, 0)
        compose->ruler_hbox    = ruler_hbox;
        compose->ruler         = ruler;
-#endif
        compose->scrolledwin   = scrolledwin;
        compose->text          = text;
 
@@ -7700,12 +7679,10 @@ static Compose *compose_create(PrefsAccount *account,
 
        compose_list = g_list_append(compose_list, compose);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
        if (!prefs_common.show_ruler)
                gtk_widget_hide(ruler_hbox);
                
        cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Tools/ShowRuler", prefs_common.show_ruler);
-#endif
 
        /* Priority */
        compose->priority = PRIORITY_NORMAL;
@@ -9149,7 +9126,6 @@ static void compose_undo_state_changed(UndoMain *undostruct, gint undo_state,
  * includes "non-client" (windows-izm) in calculation, so this calculation
  * may not be accurate.
  */
-#if !GTK_CHECK_VERSION(2, 24, 0)
 static gboolean compose_edit_size_alloc(GtkEditable *widget,
                                        GtkAllocation *allocation,
                                        GtkSHRuler *shruler)
@@ -9164,14 +9140,12 @@ static gboolean compose_edit_size_alloc(GtkEditable *widget,
                        (allocation->width - allocation->x) / char_width;
 
                /* got the maximum */
-               gtk_ruler_set_range(GTK_RULER(shruler),
-                                   0.0, line_width_in_chars, 0,
-                                   /*line_width_in_chars*/ char_width);
+               gtk_shruler_set_range(GTK_SHRULER(shruler),
+                                   0.0, line_width_in_chars, 0);
        }
 
        return TRUE;
 }
-#endif
 
 typedef struct {
        gchar                   *header;
@@ -10013,7 +9987,7 @@ static void compose_cut_cb(GtkAction *action, gpointer data)
        Compose *compose = (Compose *)data;
        if (compose->focused_editable 
 #ifndef GENERIC_UMPC
-           && gtkut_widget_has_focus(compose->focused_editable)
+           && gtk_widget_has_focus(compose->focused_editable)
 #endif
            )
                entry_cut_clipboard(compose->focused_editable);
@@ -10024,7 +9998,7 @@ static void compose_copy_cb(GtkAction *action, gpointer data)
        Compose *compose = (Compose *)data;
        if (compose->focused_editable 
 #ifndef GENERIC_UMPC
-           && gtkut_widget_has_focus(compose->focused_editable)
+           && gtk_widget_has_focus(compose->focused_editable)
 #endif
            )
                entry_copy_clipboard(compose->focused_editable);
@@ -10037,14 +10011,14 @@ static void compose_paste_cb(GtkAction *action, gpointer data)
        GtkTextBuffer *buffer;
        BLOCK_WRAP();
        if (compose->focused_editable &&
-           gtkut_widget_has_focus(compose->focused_editable))
+           gtk_widget_has_focus(compose->focused_editable))
                entry_paste_clipboard(compose, compose->focused_editable, 
                                prefs_common.linewrap_pastes,
                                GDK_SELECTION_CLIPBOARD, NULL);
        UNBLOCK_WRAP();
 
 #ifdef USE_ENCHANT
-       if (gtkut_widget_has_focus(compose->text) &&
+       if (gtk_widget_has_focus(compose->text) &&
            compose->gtkaspell && 
             compose->gtkaspell->check_while_typing)
                gtkaspell_highlight_all(compose->gtkaspell);
@@ -10057,7 +10031,7 @@ static void compose_paste_as_quote_cb(GtkAction *action, gpointer data)
        gint wrap_quote = prefs_common.linewrap_quote;
        if (compose->focused_editable 
 #ifndef GENERIC_UMPC
-           && gtkut_widget_has_focus(compose->focused_editable)
+           && gtk_widget_has_focus(compose->focused_editable)
 #endif
            ) {
                /* let text_insert() (called directly or at a later time
@@ -10086,7 +10060,7 @@ static void compose_paste_no_wrap_cb(GtkAction *action, gpointer data)
        BLOCK_WRAP();
        if (compose->focused_editable 
 #ifndef GENERIC_UMPC
-           && gtkut_widget_has_focus(compose->focused_editable)
+           && gtk_widget_has_focus(compose->focused_editable)
 #endif
            )
                entry_paste_clipboard(compose, compose->focused_editable, FALSE,
@@ -10094,7 +10068,7 @@ static void compose_paste_no_wrap_cb(GtkAction *action, gpointer data)
        UNBLOCK_WRAP();
 
 #ifdef USE_ENCHANT
-       if (gtkut_widget_has_focus(compose->text) &&
+       if (gtk_widget_has_focus(compose->text) &&
            compose->gtkaspell && 
             compose->gtkaspell->check_while_typing)
                gtkaspell_highlight_all(compose->gtkaspell);
@@ -10109,7 +10083,7 @@ static void compose_paste_wrap_cb(GtkAction *action, gpointer data)
        BLOCK_WRAP();
        if (compose->focused_editable 
 #ifndef GENERIC_UMPC
-           && gtkut_widget_has_focus(compose->focused_editable)
+           && gtk_widget_has_focus(compose->focused_editable)
 #endif
            )
                entry_paste_clipboard(compose, compose->focused_editable, TRUE,
@@ -10117,7 +10091,7 @@ static void compose_paste_wrap_cb(GtkAction *action, gpointer data)
        UNBLOCK_WRAP();
 
 #ifdef USE_ENCHANT
-       if (gtkut_widget_has_focus(compose->text) &&
+       if (gtk_widget_has_focus(compose->text) &&
            compose->gtkaspell &&
             compose->gtkaspell->check_while_typing)
                gtkaspell_highlight_all(compose->gtkaspell);
@@ -10129,7 +10103,7 @@ static void compose_allsel_cb(GtkAction *action, gpointer data)
        Compose *compose = (Compose *)data;
        if (compose->focused_editable 
 #ifndef GENERIC_UMPC
-           && gtkut_widget_has_focus(compose->focused_editable)
+           && gtk_widget_has_focus(compose->focused_editable)
 #endif
            )
                entry_allsel(compose->focused_editable);
@@ -10433,7 +10407,7 @@ static void compose_advanced_action_cb(GtkAction *gaction, gpointer data)
                {textview_delete_to_line_end}
        };
 
-       if (!gtkut_widget_has_focus(GTK_WIDGET(text))) return;
+       if (!gtk_widget_has_focus(GTK_WIDGET(text))) return;
 
        if (action >= COMPOSE_CALL_ADVANCED_ACTION_MOVE_BEGINNING_OF_LINE &&
            action <= COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END) {
@@ -10593,7 +10567,6 @@ static void activate_privacy_system(Compose *compose, PrefsAccount *account, gbo
        compose_update_privacy_system_menu_item(compose, warn);
 }
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
 static void compose_toggle_ruler_cb(GtkToggleAction *action, gpointer data)
 {
        Compose *compose = (Compose *)data;
@@ -10607,7 +10580,6 @@ static void compose_toggle_ruler_cb(GtkToggleAction *action, gpointer data)
                prefs_common.show_ruler = FALSE;
        }
 }
-#endif
 
 static void compose_attach_drag_received_cb (GtkWidget         *widget,
                                             GdkDragContext     *context,
@@ -11018,7 +10990,7 @@ static void compose_check_all(GtkAction *action, gpointer data)
        if (!compose->gtkaspell)
                return;
                
-       if (gtkut_widget_has_focus(compose->subject_entry))
+       if (gtk_widget_has_focus(compose->subject_entry))
                claws_spell_entry_check_all(
                        CLAWS_SPELL_ENTRY(compose->subject_entry));             
        else
@@ -11043,7 +11015,7 @@ static void compose_check_backwards(GtkAction *action, gpointer data)
                return;
        }
 
-       if (gtkut_widget_has_focus(compose->subject_entry))
+       if (gtk_widget_has_focus(compose->subject_entry))
                claws_spell_entry_check_backwards(
                        CLAWS_SPELL_ENTRY(compose->subject_entry));
        else
@@ -11058,7 +11030,7 @@ static void compose_check_forwards_go(GtkAction *action, gpointer data)
                return;
        }
 
-       if (gtkut_widget_has_focus(compose->subject_entry))
+       if (gtk_widget_has_focus(compose->subject_entry))
                claws_spell_entry_check_forwards_go(
                        CLAWS_SPELL_ENTRY(compose->subject_entry));
        else