[balsa] GSEAL cleanup



commit 9f825a097d1dc174a4473b1211e2a64861c010fb
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu Oct 15 21:08:24 2009 -0400

    GSEAL cleanup

 ChangeLog                         |   66 +++++++++++++++++
 configure.in                      |    8 ++-
 libbalsa/address-view.c           |    2 +-
 libbalsa/address.c                |    6 +-
 libbalsa/html.c                   |   13 +++-
 libbalsa/identity.c               |   21 ++++--
 libbalsa/libbalsa.c               |    3 +-
 libbalsa/misc.c                   |    2 +-
 libbalsa/rfc3156.c                |   12 ++-
 libbalsa/send.c                   |   13 ++--
 libbalsa/smtp-server.c            |    4 +-
 libbalsa/source-viewer.c          |    9 ++-
 libinit_balsa/assistant_helper.c  |    7 ++-
 src/ab-main.c                     |    9 ++-
 src/ab-window.c                   |    2 +-
 src/address-book-config.c         |   17 +++--
 src/balsa-app.c                   |   12 ++--
 src/balsa-index.c                 |   22 ++++--
 src/balsa-mblist.c                |    9 ++-
 src/balsa-message.c               |   73 +++++++++++++------
 src/balsa-mime-widget-callbacks.c |   46 +++++-------
 src/balsa-mime-widget-image.c     |   18 +++++-
 src/balsa-mime-widget-message.c   |   22 +++---
 src/balsa-mime-widget-text.c      |   12 +++-
 src/balsa-mime-widget.c           |    2 +-
 src/filter-edit-callbacks.c       |   25 ++++---
 src/filter-edit-dialog.c          |    5 +-
 src/filter-export-dialog.c        |    3 +-
 src/filter-run-dialog.c           |    2 +-
 src/folder-conf.c                 |   16 +++--
 src/information-dialog.c          |    6 +-
 src/mailbox-conf.c                |    8 ++-
 src/main-window.c                 |   76 +++++++++++++++------
 src/message-window.c              |    8 ++-
 src/pref-manager.c                |  139 ++++++++++++++++++++++++-------------
 src/print-gtk.c                   |   16 +++--
 src/sendmsg-window.c              |   79 +++++++++++++++------
 src/spell-check.c                 |   23 +++---
 src/store-address.c               |    2 +-
 src/toolbar-factory.c             |   17 ++++-
 src/toolbar-prefs.c               |   12 ++--
 41 files changed, 578 insertions(+), 269 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8ad52e0..2e479af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,71 @@
 2009-10-15  Peter Bloomfield
 
+	GSEAL cleanup
+
+	* configure.in: enable GSEAL if gtk version >= 2.18.
+	* libbalsa/address-view.c (lbav_entry_changed_cb):
+	* libbalsa/address.c (addrlist_drag_received_cb):
+	* libbalsa/html.c (lbh_size_request_cb):
+	* libbalsa/identity.c (libbalsa_identity_select_dialog),
+	(md_sig_path_changed_cb), (ident_dialog_get_path),
+	(libbalsa_identity_config_dialog):
+	* libbalsa/libbalsa.c (ask_cert_real):
+	* libbalsa/misc.c (lb_create_size_group_func):
+	* libbalsa/rfc3156.c (select_key_from_list), (get_passphrase_real):
+	* libbalsa/send.c (ensure_send_progress_dialog):
+	* libbalsa/smtp-server.c (libbalsa_smtp_server_dialog):
+	* libbalsa/source-viewer.c (lsv_size_allocate_cb),
+	(libbalsa_show_message_source):
+	* libinit_balsa/assistant_helper.c (entry_changed_cb):
+	* src/ab-main.c (edit_new_entry_cb), (addrlist_drag_get_cb):
+	* src/ab-window.c (balsa_ab_window_init):
+	* src/address-book-config.c (create_generic_dialog),
+	(create_externq_dialog), (create_ldap_dialog), (create_gpe_dialog):
+	* src/balsa-app.c (ask_password_real):
+	* src/balsa-index.c (bndx_drag_cb), (bndx_mailbox_changed_cb),
+	(bndx_popup_position_func), (bndx_expand_to_row),
+	(balsa_index_pipe), (balsa_index_ensure_visible):
+	* src/balsa-mblist.c (bmbl_drag_cb), (bmbl_mru_show_tree):
+	* src/balsa-message.c (bm_on_set_style), (bm_find_scroll_to_iter),
+	(bm_find_pass_to_entry), (gtk_tree_hide_func), (select_part),
+	(scroll_set), (balsa_get_parent_window),
+	(balsa_message_grab_focus):
+	* src/balsa-mime-widget-callbacks.c (scroll_change),
+	(balsa_mime_widget_key_press_event):
+	* src/balsa-mime-widget-image.c (balsa_mime_widget_new_image),
+	(img_check_size):
+	* src/balsa-mime-widget-message.c (bm_header_widget_realized):
+	* src/balsa-mime-widget-text.c (gtk_widget_destroy_insensitive),
+	(draw_cite_bar_real):
+	* src/balsa-mime-widget.c (vadj_change_cb):
+	* src/filter-edit-callbacks.c (condition_validate),
+	(fill_condition_widgets), (build_condition_dialog):
+	* src/filter-edit-dialog.c (filters_edit_dialog):
+	* src/filter-export-dialog.c (filters_export_dialog):
+	* src/filter-run-dialog.c (balsa_filter_run_dialog_init):
+	* src/folder-conf.c (folder_conf_imap_node), (browse_button_cb),
+	(subfolder_conf_clicked_ok), (folder_conf_imap_sub_node):
+	* src/information-dialog.c (balsa_information_list):
+	* src/mailbox-conf.c (create_pop_mailbox_dialog),
+	(create_imap_mailbox_dialog):
+	* src/main-window.c (bw_quit_nicely):
+	* src/message-window.c (size_alloc_cb):
+	* src/pref-manager.c (open_preferences_manager), (apply_prefs),
+	(set_prefs), (timer_modified_cb),
+	(mailbox_close_timer_modified_cb), (imap_toggled_cb),
+	(convert_8bit_cb):
+	* src/print-gtk.c (check_margins), (message_prefs_apply):
+	* src/sendmsg-window.c (sw_size_alloc_cb), (sw_get_user_codeset),
+	(attachments_add), (sw_scroll_size_request), (drag_data_quote),
+	(quote_parts_select_dlg), (subject_not_empty),
+	(check_suggest_encryption):
+	* src/spell-check.c (balsa_spell_check_init):
+	* src/store-address.c (store_address_dialog):
+	* src/toolbar-factory.c (tm_popup_position_func):
+	* src/toolbar-prefs.c (customize_dialog_cb), (wrap_toggled_cb):
+
+2009-10-15  Peter Bloomfield
+
 	Re-implement BalsaCiteBar as a GTK_NO_WINDOW widget
 
 	* src/balsa-cite-bar.h: make BalsaCiteBar opaque.
diff --git a/configure.in b/configure.in
index 8d9e322..b2e7bed 100644
--- a/configure.in
+++ b/configure.in
@@ -881,7 +881,10 @@ fi
 if test -d "${srcdir}/.git" ; then
 	BALSA_FROM_GIT=yes
 	BALSA_CFLAGS="$BALSA_CFLAGS -Wall -Werror"
-        BALSA_DEFS="\
+        if $PKG_CONFIG --atleast-version=2.18 gtk+-2.0; then
+            BALSA_DEFS="-DGSEAL_ENABLE"
+        fi
+        BALSA_DEFS="$BALSA_DEFS \
 -DG_DISABLE_DEPRECATED \
 -DGDK_DISABLE_DEPRECATED \
 -DGDK_PIXBUF_DISABLE_DEPRECATED \
@@ -891,7 +894,8 @@ if test -d "${srcdir}/.git" ; then
 -DGNOME_VFS_DISABLE_DEPRECATED \
 -DGTK_DISABLE_DEPRECATED \
 -DPANGO_DISABLE_DEPRECATED \
--D_FORTIFY_SOURCE=2"
+-D_FORTIFY_SOURCE=2 \
+"
 else
 	BALSA_FROM_GIT=no
 fi
diff --git a/libbalsa/address-view.c b/libbalsa/address-view.c
index 4a5a856..1abbffe 100644
--- a/libbalsa/address-view.c
+++ b/libbalsa/address-view.c
@@ -567,7 +567,7 @@ lbav_entry_changed_cb(GtkEntry * entry, LibBalsaAddressView * address_view)
 
     completion = gtk_entry_get_completion(entry);
 
-    if (GTK_WIDGET_REALIZED(GTK_WIDGET(entry)))
+    if (gtk_widget_get_window(GTK_WIDGET(entry)))
         lbav_entry_setup_matches(address_view, entry, completion,
                                  LIBBALSA_ADDRESS_VIEW_MATCH_FAST);
 }
diff --git a/libbalsa/address.c b/libbalsa/address.c
index 6ab024e..08402a6 100644
--- a/libbalsa/address.c
+++ b/libbalsa/address.c
@@ -878,10 +878,12 @@ addrlist_drag_received_cb(GtkWidget * widget, GdkDragContext * context,
 
     printf("drag_received:\n");
     /* Deal with what we are given from source */
-    if((selection_data != NULL) && (selection_data-> length >= 0)) {        
+    if(selection_data
+       && gtk_selection_data_get_length(selection_data) >= 0) {
         switch (target_type) {
         case LIBBALSA_ADDRESS_TRG_ADDRESS:
-            addr = *(LibBalsaAddress**)selection_data->data;
+            addr = *(LibBalsaAddress **)
+                gtk_selection_data_get_data(selection_data);
             if(addr && addr->address_list) {
                 g_print ("string: %s\n", (gchar*)addr->address_list->data);
                 gtk_list_store_insert_with_values(GTK_LIST_STORE(model),
diff --git a/libbalsa/html.c b/libbalsa/html.c
index 81b1acf..d8ad72a 100644
--- a/libbalsa/html.c
+++ b/libbalsa/html.c
@@ -106,8 +106,8 @@ lbh_size_request_cb(GtkWidget      * widget,
 {
     LibBalsaWebKitInfo *info = data;
 
-    requisition->width  = info->hadj->upper;
-    requisition->height = info->vadj->upper;
+    requisition->width  = gtk_adjustment_get_upper(info->hadj);
+    requisition->height = gtk_adjustment_get_upper(info->vadj);
 }
 
 static WebKitNavigationResponse
@@ -272,8 +272,13 @@ lbh_size_request_cb(GtkWidget      * widget,
                     GtkRequisition * requisition,
                     gpointer         data)
 {
-    requisition->width  = GTK_LAYOUT(widget)->hadjustment->upper;
-    requisition->height = GTK_LAYOUT(widget)->vadjustment->upper;
+    GtkLayout *layout = GTK_LAYOUT(widget);
+    GtkAdjustment *adjustment;
+
+    adjustment = gtk_layout_get_hadjustment(layout);
+    requisition->width = gtk_adjustment_get_upper(adjustment);
+    adjustment = gtk_layout_get_vadjustment(layout);
+    requisition->height = gtk_adjustment_get_upper(adjustment);
 }
 
 # ifdef HAVE_GTKHTML3
diff --git a/libbalsa/identity.c b/libbalsa/identity.c
index 4e3c43c..66c1a9c 100644
--- a/libbalsa/identity.c
+++ b/libbalsa/identity.c
@@ -506,7 +506,8 @@ libbalsa_identity_select_dialog(GtkWindow * parent,
     identity_list_update_real(GTK_TREE_VIEW(tree), identities, initial_id);
 
     frame = gtk_frame_new(NULL);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
+    gtk_box_pack_start(GTK_BOX
+                       (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
                        frame, TRUE, TRUE, 0);
     gtk_container_add(GTK_CONTAINER(frame), tree);
     gtk_container_set_border_width(GTK_CONTAINER(frame), padding);
@@ -970,7 +971,8 @@ struct {
 };
 
 #define LIBBALSA_IDENTITY_CHECK "libbalsa-identity-check"
-static void md_sig_path_changed_cb(GtkWidget *sig_button, GObject *dialog);
+static void md_sig_path_changed_cb(GtkToggleButton * sig_button,
+                                   GObject * dialog);
 
 #if ENABLE_ESMTP
 static GtkWidget*
@@ -1292,10 +1294,9 @@ md_sig_path_changed(gboolean active, GObject * dialog)
 }
 
 static void
-md_sig_path_changed_cb(GtkWidget *sig_button, GObject *dialog)
+md_sig_path_changed_cb(GtkToggleButton *sig_button, GObject *dialog)
 {
-    md_sig_path_changed(GTK_TOGGLE_BUTTON(sig_button)->active,
-                        dialog);
+    md_sig_path_changed(gtk_toggle_button_get_active(sig_button), dialog);
 }
 
 #define LIBBALSA_IDENTITY_INFO "libbalsa-identity-info"
@@ -1554,8 +1555,13 @@ ident_dialog_get_path(GObject * dialog, const gchar * key)
     GtkWidget *chooser;
 
     chooser = g_object_get_data(dialog, key);
+#if GTK_CHECK_VERSION(2, 18, 0)
+    if (!gtk_widget_get_sensitive(chooser))
+        return NULL;
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     if (!GTK_WIDGET_SENSITIVE(chooser))
         return NULL;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
     return gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
 }
@@ -1718,7 +1724,7 @@ libbalsa_identity_config_dialog(GtkWindow *parent, GList **identities,
 
     /* Show only one dialog at a time. */
     if (dialog) {
-        gdk_window_raise(dialog->window);
+        gtk_window_present(GTK_WINDOW(dialog));
         return;
     }
 
@@ -1747,7 +1753,8 @@ libbalsa_identity_config_dialog(GtkWindow *parent, GList **identities,
                                     IDENTITY_RESPONSE_CLOSE);
 
     hbox = gtk_hbox_new(FALSE, padding);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), 
+    gtk_box_pack_start(GTK_BOX
+                       (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
                        hbox, TRUE, TRUE, 0);
 
     gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, FALSE, 0);
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index 180402e..61cd7ff 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -579,7 +579,8 @@ ask_cert_real(void *data)
     label = gtk_label_new(str->str);
     g_string_free(str, TRUE);
     gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
+    gtk_box_pack_start(GTK_BOX
+                       (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
                        label, TRUE, TRUE, 1);
     gtk_widget_show(label);
 
diff --git a/libbalsa/misc.c b/libbalsa/misc.c
index 26f1f0d..65dcf92 100644
--- a/libbalsa/misc.c
+++ b/libbalsa/misc.c
@@ -1161,7 +1161,7 @@ libbalsa_create_entry(GtkWidget * table, GCallback changed_func,
 static void
 lb_create_size_group_func(GtkWidget * widget, gpointer data)
 {
-    if (GTK_IS_LABEL(widget) && GTK_IS_TABLE(widget->parent))
+    if (GTK_IS_LABEL(widget) && GTK_IS_TABLE(gtk_widget_get_parent(widget)))
         gtk_size_group_add_widget(GTK_SIZE_GROUP(data), widget);
     else if (GTK_IS_CONTAINER(widget))
         gtk_container_foreach(GTK_CONTAINER(widget),
diff --git a/libbalsa/rfc3156.c b/libbalsa/rfc3156.c
index 9f26a39..471afeb 100644
--- a/libbalsa/rfc3156.c
+++ b/libbalsa/rfc3156.c
@@ -1382,7 +1382,9 @@ select_key_from_list(const gchar * name, gboolean is_secret,
     libbalsa_macosx_menu_for_parent(dialog, parent);
 #endif
     vbox = gtk_vbox_new(FALSE, 12);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), vbox);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                      vbox);
     gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
     if (is_secret)
 	prompt =
@@ -1491,7 +1493,7 @@ select_key_from_list(const gchar * name, gboolean is_secret,
 
     gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view);
     gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300);
-    gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
+    gtk_widget_show_all(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
 
     if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
 	use_key = NULL;
@@ -1572,7 +1574,9 @@ get_passphrase_real(GMimeGpgmeContext * ctx, const gchar * uid_hint,
 #endif
     hbox = gtk_hbox_new(FALSE, 12);
     gtk_container_set_border_width(GTK_CONTAINER(hbox), 12);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                      hbox);
 
     vbox = gtk_vbox_new(FALSE, 12);
     gtk_container_add(GTK_CONTAINER(hbox), vbox);
@@ -1599,7 +1603,7 @@ get_passphrase_real(GMimeGpgmeContext * ctx, const gchar * uid_hint,
     entry = gtk_entry_new();
     gtk_container_add(GTK_CONTAINER(vbox), entry);
 
-    gtk_widget_show_all(GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
+    gtk_widget_show_all(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
     gtk_entry_set_width_chars(GTK_ENTRY(entry), 40);
     gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
 
diff --git a/libbalsa/send.c b/libbalsa/send.c
index 79d8d0f..7ee478e 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -246,6 +246,8 @@ static void
 ensure_send_progress_dialog()
 {
     GtkWidget* label;
+    GtkBox *content_box;
+
     if(send_dialog) return;
 
     send_dialog = gtk_dialog_new_with_buttons(_("Sending Mail..."), 
@@ -256,16 +258,15 @@ ensure_send_progress_dialog()
                                               NULL);
     gtk_window_set_wmclass(GTK_WINDOW(send_dialog), "send_dialog", "Balsa");
     label = gtk_label_new(_("Sending Mail..."));
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(send_dialog)->vbox),
-		       label, FALSE, FALSE, 0);
+    content_box =
+        GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(send_dialog)));
+    gtk_box_pack_start(content_box, label, FALSE, FALSE, 0);
 
     send_progress_message = gtk_label_new("");
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(send_dialog)->vbox),
-		       send_progress_message, FALSE, FALSE, 0);
+    gtk_box_pack_start(content_box, send_progress_message, FALSE, FALSE, 0);
 
     send_dialog_bar = gtk_progress_bar_new();
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(send_dialog)->vbox),
-		       send_dialog_bar, FALSE, FALSE, 0);
+    gtk_box_pack_start(content_box, send_dialog_bar, FALSE, FALSE, 0);
     gtk_window_set_default_size(GTK_WINDOW(send_dialog), 250, 100);
     gtk_widget_show_all(send_dialog);
     g_signal_connect(G_OBJECT(send_dialog), "response", 
diff --git a/libbalsa/smtp-server.c b/libbalsa/smtp-server.c
index 7ad8caa..7ef1406 100644
--- a/libbalsa/smtp-server.c
+++ b/libbalsa/smtp-server.c
@@ -557,7 +557,9 @@ libbalsa_smtp_server_dialog(LibBalsaSmtpServer * smtp_server,
 #define HIG_PADDING 12
     table = libbalsa_create_table(6, 2);
     gtk_container_set_border_width(GTK_CONTAINER(table), HIG_PADDING);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                      table);
 
     row = 0;
     smtp_server_add_widget(table, row, _("_Descriptive Name:"),
diff --git a/libbalsa/source-viewer.c b/libbalsa/source-viewer.c
index 3c29aa6..8b67787 100644
--- a/libbalsa/source-viewer.c
+++ b/libbalsa/source-viewer.c
@@ -235,8 +235,10 @@ static void
 lsv_size_allocate_cb(GtkWindow * window, GtkAllocation * alloc,
                      LibBalsaSourceViewerInfo * lsvi)
 {
-    if (GTK_WIDGET_REALIZED(lsvi->window)
-        && !(gdk_window_get_state(lsvi->window->window)
+    GdkWindow *gdk_window;
+
+    if ((gdk_window = gtk_widget_get_window(lsvi->window))
+        && !(gdk_window_get_state(gdk_window)
              & GDK_WINDOW_STATE_MAXIMIZED)) {
         *lsvi->width  = alloc->width;
         *lsvi->height = alloc->height;
@@ -268,8 +270,7 @@ libbalsa_show_message_source(LibBalsaMessage* msg, const gchar * font,
     gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
     gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD_CHAR);
 
-    interior = gtk_scrolled_window_new(GTK_TEXT_VIEW(text)->hadjustment,
-                                       GTK_TEXT_VIEW(text)->vadjustment);
+    interior = gtk_scrolled_window_new(NULL, NULL);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(interior),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_ALWAYS);
diff --git a/libinit_balsa/assistant_helper.c b/libinit_balsa/assistant_helper.c
index 91465e7..b04f100 100644
--- a/libinit_balsa/assistant_helper.c
+++ b/libinit_balsa/assistant_helper.c
@@ -111,7 +111,7 @@ entry_changed_cb(GtkEntry * entry, EntryData * ed)
 {
     g_assert(ed != NULL);
 
-    if (entry->text_length) {
+    if (gtk_entry_get_text_length(entry)) {
         ed->master->setbits |= (1 << ed->num);
     } else {
         ed->master->setbits &= ~(1 << ed->num);
@@ -120,8 +120,13 @@ entry_changed_cb(GtkEntry * entry, EntryData * ed)
     /* The stuff below is only when we are displayed... which is not
      * always the case.
      */
+#if GTK_CHECK_VERSION(2, 18, 0)
+    if (!gtk_widget_get_visible(GTK_WIDGET(entry)))
+        return;
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(entry)))
         return;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
     if (GTK_IS_ASSISTANT(ed->druid)) {
         /* Don't let them continue unless all entries have something. */
diff --git a/src/ab-main.c b/src/ab-main.c
index d62a9d0..7887f0f 100644
--- a/src/ab-main.c
+++ b/src/ab-main.c
@@ -497,8 +497,8 @@ edit_new_entry_cb(GtkAction * action, gpointer user_data)
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW
                                             (contacts_app.entry_list));
     gtk_tree_selection_unselect_all(selection);
-    gtk_widget_grab_focus(GTK_CONTAINER(contacts_app.edit_widget)->
-                          focus_child);
+    gtk_widget_grab_focus(gtk_container_get_focus_child
+                          (GTK_CONTAINER(contacts_app.edit_widget)));
 }
 
 static LibBalsaABErr
@@ -769,8 +769,9 @@ addrlist_drag_get_cb(GtkWidget* widget, GdkDragContext* drag_context,
             return;
         gtk_tree_model_get_value(model, &iter, LIST_COLUMN_ADDRESS, &gv);
         address = LIBBALSA_ADDRESS(g_value_get_object(&gv));
-        gtk_selection_data_set(sel_data, sel_data->target, 8,
-                               (const guchar *) &address,
+        gtk_selection_data_set(sel_data,
+                               gtk_selection_data_get_target(sel_data),
+                               8, (const guchar *) &address,
                                sizeof(LibBalsaAddress*));
         break;
     case LIBBALSA_ADDRESS_TRG_STRING:
diff --git a/src/ab-window.c b/src/ab-window.c
index 78df7ca..272ff25 100644
--- a/src/ab-window.c
+++ b/src/ab-window.c
@@ -233,7 +233,7 @@ balsa_ab_window_init(BalsaAbWindow *ab)
     g_signal_connect(G_OBJECT(ab), "response",
 		     G_CALLBACK(balsa_ab_window_response_cb), NULL);
 
-    vbox = GTK_DIALOG(ab)->vbox;
+    vbox = gtk_dialog_get_content_area(GTK_DIALOG(ab));
 
     gtk_window_set_wmclass(GTK_WINDOW(ab), "addressbook", "Balsa");
 
diff --git a/src/address-book-config.c b/src/address-book-config.c
index 62f1584..aab3e78 100644
--- a/src/address-book-config.c
+++ b/src/address-book-config.c
@@ -349,8 +349,9 @@ create_generic_dialog(AddressBookConfig * abc, const gchar * type)
     libbalsa_macosx_menu_for_parent(dialog, abc->parent);
 #endif
     gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
-    gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),
-                                   12);
+    gtk_container_set_border_width(GTK_CONTAINER
+                                   (gtk_dialog_get_content_area
+                                    (GTK_DIALOG(dialog))), 12);
     g_signal_connect(G_OBJECT(dialog), "response",
                      G_CALLBACK(edit_book_response), abc);
 
@@ -414,7 +415,9 @@ create_externq_dialog(AddressBookConfig * abc)
     }
 
     dialog = create_generic_dialog(abc, "Extern");
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                      table);
     return dialog;
 }
 
@@ -479,7 +482,9 @@ create_ldap_dialog(AddressBookConfig * abc)
     g_free(host);
     
     dialog = create_generic_dialog(abc, "LDAP");
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                      table);
     return dialog;
 }
 #endif
@@ -508,7 +513,9 @@ create_gpe_dialog(AddressBookConfig * abc)
     add_radio_buttons(table, 1, abc);
 
     dialog = create_generic_dialog(abc, "GPE");
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                      table);
     return dialog;
 }
 #endif
diff --git a/src/balsa-app.c b/src/balsa-app.c
index ad7a8f2..a230b1e 100644
--- a/src/balsa-app.c
+++ b/src/balsa-app.c
@@ -72,6 +72,7 @@ static gchar *
 ask_password_real(LibBalsaServer * server, LibBalsaMailbox * mbox)
 {
     GtkWidget *dialog, *entry, *rememb;
+    GtkWidget *content_area;
     gchar *prompt, *passwd = NULL;
 #if defined(HAVE_GNOME_KEYRING)
     static const gchar *remember_password_message =
@@ -101,21 +102,22 @@ ask_password_real(LibBalsaServer * server, LibBalsaMailbox * mbox)
 #if HAVE_MACOSX_DESKTOP
     libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(balsa_app.main_window));
 #endif
-    gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), HIG_PADDING);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),
+    content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+    gtk_box_set_spacing(GTK_BOX(content_area), HIG_PADDING);
+    gtk_container_add(GTK_CONTAINER(content_area),
                       gtk_label_new_with_mnemonic(prompt));
     g_free(prompt);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),
+    gtk_container_add(GTK_CONTAINER(content_area),
                       entry = gtk_entry_new());
     gtk_entry_set_width_chars(GTK_ENTRY(entry), 20);
     gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
 
     rememb =  gtk_check_button_new_with_mnemonic(_(remember_password_message));
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), rememb);
+    gtk_container_add(GTK_CONTAINER(content_area), rememb);
     if(server->remember_passwd)
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rememb), TRUE);
 
-    gtk_widget_show_all(GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
+    gtk_widget_show_all(content_area);
     gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
     gtk_widget_grab_focus (entry);
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 1df3ae6..709b917 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -810,8 +810,8 @@ bndx_drag_cb(GtkWidget * widget, GdkDragContext * drag_context,
 
     if (gtk_tree_selection_count_selected_rows
         (gtk_tree_view_get_selection(GTK_TREE_VIEW(index))) > 0)
-        gtk_selection_data_set(data, data->target, 8,
-                               (const guchar *) &index,
+        gtk_selection_data_set(data, gtk_selection_data_get_target(data),
+                               8, (const guchar *) &index,
                                sizeof(BalsaIndex *));
 }
 
@@ -1452,7 +1452,7 @@ bndx_mailbox_changed_cb(BalsaIndex * bindex)
     LibBalsaMailbox *mailbox = bindex->mailbox_node->mailbox;
     struct index_info *arg;
 
-    if (!GTK_WIDGET_REALIZED(GTK_WIDGET(bindex)))
+    if (!gtk_widget_get_window(GTK_WIDGET(bindex)))
         return;
 
     /* Find the next message to be shown now, not later in the idle
@@ -1949,15 +1949,23 @@ bndx_popup_position_func(GtkMenu * menu, gint * x, gint * y,
     GtkRequisition req;
     gint monitor_num;
     GdkRectangle monitor;
+#if GTK_CHECK_VERSION(2, 18, 0)
+    GtkAllocation allocation;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
-    g_return_if_fail(GTK_WIDGET_REALIZED(bindex));
+    g_return_if_fail(gtk_widget_get_window(bindex));
 
     gdk_window_get_origin(gtk_tree_view_get_bin_window
                           (GTK_TREE_VIEW(bindex)), x, y);
 
     gtk_widget_size_request(GTK_WIDGET(menu), &req);
 
+#if GTK_CHECK_VERSION(2, 18, 0)
+    gtk_widget_get_allocation(bindex, &allocation);
+    *x += (allocation.width - req.width) / 2;
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     *x += (bindex->allocation.width - req.width) / 2;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
     monitor_num = gdk_screen_get_monitor_at_point(screen, *x, *y);
     gtk_menu_set_monitor(menu, monitor_num);
@@ -2189,7 +2197,7 @@ bndx_expand_to_row(BalsaIndex * index, GtkTreePath * path)
     GtkTreePath *tmp;
     gint i, j;
 
-    if (!GTK_WIDGET_REALIZED(GTK_WIDGET(index)))
+    if (!gtk_widget_get_window(GTK_WIDGET(index)))
         return;
 
     tmp = gtk_tree_path_copy(path);
@@ -2701,7 +2709,7 @@ balsa_index_pipe(BalsaIndex * index)
     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
     gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
 
-    vbox = GTK_DIALOG(dialog)->vbox;
+    vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
     gtk_box_set_spacing(GTK_BOX(vbox), HIG_PADDING);
     gtk_container_add(GTK_CONTAINER(vbox), label =
                       gtk_label_new(_("Specify the program to run:")));
@@ -2731,7 +2739,7 @@ balsa_index_ensure_visible(BalsaIndex * index)
     GdkRectangle rect;
     GtkTreePath *path = NULL;
 
-    if (!GTK_WIDGET_REALIZED(tree_view))
+    if (!gtk_widget_get_window(GTK_WIDGET(tree_view)))
         return;
 
     if (!bndx_find_current_msgno(index, &path, NULL)) {
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index d4dc115..b3762cf 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -822,11 +822,12 @@ bmbl_drag_cb(GtkWidget * widget, GdkDragContext * context,
     BalsaIndex *orig_index;
     GArray *selected;
 
-    if (!selection_data || !selection_data->data)
+    if (!selection_data || !gtk_selection_data_get_data(selection_data))
 	/* Drag'n'drop is weird... */
 	return;
 
-    orig_index = *(BalsaIndex **) selection_data->data;
+    orig_index =
+        *(BalsaIndex **) gtk_selection_data_get_data(selection_data);
     selected = balsa_index_selected_msgnos_new(orig_index);
     if (selected->len == 0) {
 	/* it is actually possible to drag from GtkTreeView when no rows
@@ -1869,7 +1870,9 @@ bmbl_mru_show_tree(GtkWidget * widget, gpointer data)
     gtk_widget_set_size_request(GTK_WIDGET(mblist), req.width, req.height);
 
     gtk_container_add(GTK_CONTAINER(scroll), mblist);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), scroll);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                      scroll);
     gtk_widget_show_all(scroll);
 
     gtk_dialog_run(GTK_DIALOG(dialog));
diff --git a/src/balsa-message.c b/src/balsa-message.c
index afda17d..535e834 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -354,7 +354,7 @@ bm_on_set_style(GtkWidget * widget,
     GtkStyle *new_style, *text_view_style;
     int n;
 
-    new_style = gtk_style_copy(target->style);
+    new_style = gtk_style_copy(gtk_widget_get_style(target));
     text_view_style =
 	gtk_rc_get_style_by_paths(gtk_widget_get_settings(target),
 				  NULL, NULL, gtk_text_view_get_type());
@@ -424,7 +424,8 @@ bm_find_scroll_to_iter(BalsaMessage * bm,
                        GtkTextView  * text_view,
                        GtkTextIter  * iter)
 {
-    GtkAdjustment *adj = GTK_VIEWPORT(bm->cont_viewport)->vadjustment;
+    GtkAdjustment *adj =
+        gtk_viewport_get_vadjustment(GTK_VIEWPORT(bm->cont_viewport));
     GdkRectangle location;
     gdouble y;
 
@@ -595,19 +596,33 @@ bm_find_pass_to_entry(BalsaMessage * bm, GdkEventKey * event)
         bm_disable_find_entry(bm);
         return res;
     case GDK_g:
+#if GTK_CHECK_VERSION(2, 18, 0)
         if ((event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) ==
-            GDK_CONTROL_MASK && GTK_WIDGET_SENSITIVE(bm->find_next)) {
+            GDK_CONTROL_MASK && gtk_widget_get_sensitive(bm->find_next)) {
             bm_find_again(bm, bm->find_forward);
             return res;
         }
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
+        if ((event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) ==
+            GDK_CONTROL_MASK && GTK_WIDGET_IS_SENSITIVE(bm->find_next)) {
+            bm_find_again(bm, bm->find_forward);
+            return res;
+        }
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
     default:
         break;
     }
 
     res = FALSE;
+#if GTK_CHECK_VERSION(2, 18, 0)
+    if (gtk_widget_has_focus(bm->find_entry))
+        g_signal_emit_by_name(bm->find_entry, "key-press-event", event,
+                              &res, NULL);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     if (GTK_WIDGET_HAS_FOCUS(bm->find_entry))
         g_signal_emit_by_name(bm->find_entry, "key-press-event", event,
                               &res, NULL);
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
     return res;
 }
@@ -2150,12 +2165,14 @@ gtk_tree_hide_func(GtkTreeModel * model, GtkTreePath * path,
 
     gtk_tree_model_get(model, iter, PART_INFO_COLUMN, &info, -1);
     if (info) {
-        if (info->mime_widget && info->mime_widget->widget && info->mime_widget->widget->parent)
-            gtk_container_remove(GTK_CONTAINER(info->mime_widget->widget->parent),
-                                 info->mime_widget->widget);
-        g_object_unref(G_OBJECT(info));
+        GtkWidget *widget, *parent;
+
+        if (info->mime_widget && (widget = info->mime_widget->widget)
+            && (parent = gtk_widget_get_parent(widget)))
+            gtk_container_remove(GTK_CONTAINER(parent), widget);
+        g_object_unref(info);
     }
-    
+
     return FALSE;
 }
 
@@ -2202,8 +2219,10 @@ select_part(BalsaMessage * bm, BalsaPartInfo *info)
     if(bm->current_part)
         g_signal_emit(G_OBJECT(bm), balsa_message_signals[SELECT_PART], 0);
 
-    scroll_set(GTK_VIEWPORT(bm->cont_viewport)->hadjustment, 0);
-    scroll_set(GTK_VIEWPORT(bm->cont_viewport)->vadjustment, 0);
+    scroll_set(gtk_viewport_get_hadjustment
+               (GTK_VIEWPORT(bm->cont_viewport)), 0);
+    scroll_set(gtk_viewport_get_vadjustment
+               (GTK_VIEWPORT(bm->cont_viewport)), 0);
 
     gtk_widget_queue_resize(bm->cont_viewport);
 }
@@ -2211,18 +2230,14 @@ select_part(BalsaMessage * bm, BalsaPartInfo *info)
 static void
 scroll_set(GtkAdjustment * adj, gint value)
 {
-    gfloat upper;
+    gdouble upper;
 
     if (!adj)
         return;
 
-    adj->value = value;
-
-    upper = adj->upper - adj->page_size;
-    adj->value = MIN(adj->value, upper);
-    adj->value = MAX(adj->value, 0.0);
-
-    g_signal_emit_by_name(G_OBJECT(adj), "value_changed", 0);
+    upper =
+        gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj);
+    gtk_adjustment_set_value(adj, MIN((gdouble) value, upper));
 }
 
 GtkWidget *
@@ -2241,8 +2256,13 @@ balsa_get_parent_window(GtkWidget * widget)
     if (widget) {
         GtkWidget *toplevel = gtk_widget_get_toplevel(widget);
 
+#if GTK_CHECK_VERSION(2, 18, 0)
+        if (gtk_widget_is_toplevel(toplevel) && GTK_IS_WINDOW(toplevel))
+            return GTK_WINDOW(toplevel);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
         if (GTK_WIDGET_TOPLEVEL(toplevel) && GTK_IS_WINDOW(toplevel))
             return GTK_WINDOW(toplevel);
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
     }
 
     return GTK_WINDOW(balsa_app.main_window);
@@ -2274,14 +2294,21 @@ balsa_message_can_select(BalsaMessage * bmessage)
 gboolean
 balsa_message_grab_focus(BalsaMessage * bmessage)
 {
+    GtkWidget *widget;
+
     g_return_val_if_fail(bmessage != NULL, FALSE);
     g_return_val_if_fail(bmessage->current_part != NULL, FALSE);
-    g_return_val_if_fail(bmessage->current_part->mime_widget->widget != NULL,
-                         FALSE);
 
-    GTK_WIDGET_FLAGS(bmessage->current_part->mime_widget->widget)
-        |= GTK_CAN_FOCUS;
-    gtk_widget_grab_focus(bmessage->current_part->mime_widget->widget);
+    widget = bmessage->current_part->mime_widget->widget;
+    g_return_val_if_fail(widget != NULL, FALSE);
+
+#if GTK_CHECK_VERSION(2, 18, 0)
+    gtk_widget_set_can_focus(widget, TRUE);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
+    GTK_WIDGET_FLAGS(widget) |= GTK_CAN_FOCUS;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
+    gtk_widget_grab_focus(widget);
+
     return TRUE;
 }
 
diff --git a/src/balsa-mime-widget-callbacks.c b/src/balsa-mime-widget-callbacks.c
index 8c677f1..47438eb 100644
--- a/src/balsa-mime-widget-callbacks.c
+++ b/src/balsa-mime-widget-callbacks.c
@@ -175,9 +175,11 @@ balsa_mime_widget_ctx_menu_save(GtkWidget * parent_widget,
 static void
 scroll_change(GtkAdjustment * adj, gint diff, BalsaMessage * bm)
 {
-    gfloat upper = adj->upper - adj->page_size;
+    gdouble upper =
+        gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj);
+    gdouble value;
 
-    if (bm && adj->value >= upper && diff > 0) {
+    if (bm && gtk_adjustment_get_value(adj) >= upper && diff > 0) {
         if (balsa_window_next_unread(balsa_app.main_window))
             /* We're changing mailboxes, and GtkNotebook will grab the
              * focus, so we want to grab it back the next time we lose
@@ -186,12 +188,10 @@ scroll_change(GtkAdjustment * adj, gint diff, BalsaMessage * bm)
         return;
     }
 
-    adj->value += diff;
+    value = gtk_adjustment_get_value(adj);
+    value += (gdouble) diff;
 
-    adj->value = MIN(adj->value, upper);
-    adj->value = MAX(adj->value, 0.0);
-
-    g_signal_emit_by_name(G_OBJECT(adj), "value_changed", 0);
+    gtk_adjustment_set_value(adj, MIN(value, upper));
 }
 
 gint
@@ -199,45 +199,38 @@ balsa_mime_widget_key_press_event(GtkWidget * widget, GdkEventKey * event,
 				  BalsaMessage * bm)
 {
     GtkViewport *viewport;
+    GtkAdjustment *adj;
     int page_adjust;
 
     viewport = GTK_VIEWPORT(bm->cont_viewport);
+    adj = gtk_viewport_get_vadjustment(viewport);
 
-    if (balsa_app.pgdownmod) {
-            page_adjust = (viewport->vadjustment->page_size *
-                 balsa_app.pgdown_percent) / 100;
-    } else {
-            page_adjust = viewport->vadjustment->page_increment;
-    }
+    page_adjust = balsa_app.pgdownmod ?
+        (gtk_adjustment_get_page_size(adj) * balsa_app.pgdown_percent) /
+        100 : gtk_adjustment_get_page_increment(adj);
 
     switch (event->keyval) {
     case GDK_Up:
-        scroll_change(viewport->vadjustment,
-                      -viewport->vadjustment->step_increment, NULL);
+        scroll_change(adj, -gtk_adjustment_get_step_increment(adj), NULL);
         break;
     case GDK_Down:
-        scroll_change(viewport->vadjustment,
-                      viewport->vadjustment->step_increment, NULL);
+        scroll_change(adj, gtk_adjustment_get_step_increment(adj), NULL);
         break;
     case GDK_Page_Up:
-        scroll_change(viewport->vadjustment,
-                      -page_adjust, NULL);
+        scroll_change(adj, -page_adjust, NULL);
         break;
     case GDK_Page_Down:
-        scroll_change(viewport->vadjustment,
-                      page_adjust, NULL);
+        scroll_change(adj, page_adjust, NULL);
         break;
     case GDK_Home:
         if (event->state & GDK_CONTROL_MASK)
-            scroll_change(viewport->vadjustment,
-                          -viewport->vadjustment->value, NULL);
+            scroll_change(adj, -gtk_adjustment_get_value(adj), NULL);
         else
             return FALSE;
         break;
     case GDK_End:
         if (event->state & GDK_CONTROL_MASK)
-            scroll_change(viewport->vadjustment,
-                          viewport->vadjustment->upper, NULL);
+            scroll_change(adj, gtk_adjustment_get_upper(adj), NULL);
         else
             return FALSE;
         break;
@@ -257,8 +250,7 @@ balsa_mime_widget_key_press_event(GtkWidget * widget, GdkEventKey * event,
             return FALSE;
         break;
     case GDK_space:
-        scroll_change(viewport->vadjustment,
-                      page_adjust, bm);
+        scroll_change(adj, page_adjust, bm);
         break;
 
     default:
diff --git a/src/balsa-mime-widget-image.c b/src/balsa-mime-widget-image.c
index acb0ac8..7e2dea3 100644
--- a/src/balsa-mime-widget-image.c
+++ b/src/balsa-mime-widget-image.c
@@ -68,7 +68,8 @@ balsa_mime_widget_new_image(BalsaMessage * bm, LibBalsaMessageBody * mime_body,
     g_object_unref(pixbuf);
     gtk_container_add(GTK_CONTAINER(mw->widget), image);
     gtk_widget_modify_bg(mw->widget, GTK_STATE_NORMAL,
-			 &GTK_WIDGET(bm)->style->light[GTK_STATE_NORMAL]);
+                         &gtk_widget_get_style(GTK_WIDGET(bm))->
+                         light[GTK_STATE_NORMAL]);
 
     g_signal_connect(G_OBJECT(mw->widget), "button-press-event",
                      G_CALLBACK(balsa_image_button_press_cb), data);
@@ -118,6 +119,9 @@ img_check_size(GtkImage ** widget_p)
     gint orig_width;
     LibBalsaMessageBody * mime_body;
     gint curr_w, dst_w;
+#if GTK_CHECK_VERSION(2, 18, 0)
+    GtkAllocation allocation;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
     gdk_threads_enter();
 
@@ -143,9 +147,21 @@ img_check_size(GtkImage ** widget_p)
 	curr_w = gdk_pixbuf_get_width(gtk_image_get_pixbuf(widget));
     else
 	curr_w = 0;
+#if GTK_CHECK_VERSION(2, 18, 0)
+    gtk_widget_get_allocation(viewport, &allocation);
+    dst_w = allocation.width;
+    gtk_widget_get_allocation(gtk_bin_get_child(GTK_BIN(viewport)),
+                              &allocation);
+    dst_w -= allocation.width;
+    gtk_widget_get_allocation(gtk_widget_get_parent(GTK_WIDGET(widget)),
+                              &allocation);
+    dst_w += allocation.width;
+    dst_w -= 4;
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     dst_w = viewport->allocation.width - 
 	(gtk_bin_get_child(GTK_BIN(viewport))->allocation.width - 
 	 GTK_WIDGET(widget)->parent->allocation.width) - 4;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
     if (dst_w < 32)
 	dst_w = 32;
     if (dst_w > orig_width)
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index 466ec8a..a669c02 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -401,21 +401,21 @@ balsa_mime_widget_new_message_tl(BalsaMessage * bm, GtkWidget * tl_buttons)
 static void
 bm_header_widget_realized(GtkWidget * widget, BalsaMessage * bm)
 {
-    GtkWidget *tl_buttons = 
-	GTK_WIDGET(g_object_get_data(G_OBJECT(widget), "tl-buttons"));
+    GtkWidget *tl_buttons =
+        GTK_WIDGET(g_object_get_data(G_OBJECT(widget), "tl-buttons"));
+    GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(bm));
 
     gtk_widget_modify_bg(widget, GTK_STATE_NORMAL,
-			 &GTK_WIDGET(bm)->style->dark[GTK_STATE_NORMAL]);
+                         &style->dark[GTK_STATE_NORMAL]);
     gtk_widget_modify_base(bm_header_widget_get_text_view(widget),
-			   GTK_STATE_NORMAL,
-			   &GTK_WIDGET(bm)->style->mid[GTK_STATE_NORMAL]);
+                           GTK_STATE_NORMAL,
+                           &style->mid[GTK_STATE_NORMAL]);
     if (tl_buttons) {
-	/* use a fresh style here to deal with pixmap themes correctly */
-	GtkStyle *new_style = gtk_style_new();
-	new_style->bg[GTK_STATE_NORMAL] =
-	    GTK_WIDGET(bm)->style->mid[GTK_STATE_NORMAL];
-	gtk_widget_set_style(tl_buttons, new_style);
-	g_object_unref(new_style);
+        /* use a fresh style here to deal with pixmap themes correctly */
+        GtkStyle *new_style = gtk_style_new();
+        new_style->bg[GTK_STATE_NORMAL] = style->mid[GTK_STATE_NORMAL];
+        gtk_widget_set_style(tl_buttons, new_style);
+        g_object_unref(new_style);
     }
 }
 
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 9005738..6560031 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -557,9 +557,15 @@ fix_text_widget(GtkWidget *widget, gpointer data)
 static void
 gtk_widget_destroy_insensitive(GtkWidget * widget)
 {
+#if GTK_CHECK_VERSION(2, 18, 0)
+    if (!gtk_widget_get_sensitive(widget) ||
+	GTK_IS_SEPARATOR_MENU_ITEM(widget))
+	gtk_widget_destroy(widget);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     if (!GTK_WIDGET_SENSITIVE(widget) ||
 	GTK_IS_SEPARATOR_MENU_ITEM(widget))
 	gtk_widget_destroy(widget);
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 }
 
 static void
@@ -1072,8 +1078,10 @@ draw_cite_bar_real(cite_bar_t * bar, cite_bar_draw_mode_t * draw_mode)
 	bar->bar = balsa_cite_bar_new(height, bar->depth, draw_mode->dimension);
 	gtk_widget_modify_fg(bar->bar, GTK_STATE_NORMAL,
 			     &balsa_app.quoted_color[(bar->depth - 1) % MAX_QUOTED_COLOR]);
-	gtk_widget_modify_bg(bar->bar, GTK_STATE_NORMAL,
-			     &GTK_WIDGET(draw_mode->view)->style->base[GTK_STATE_NORMAL]);
+        gtk_widget_modify_bg(bar->bar, GTK_STATE_NORMAL,
+                             &gtk_widget_get_style(GTK_WIDGET
+                                                   (draw_mode->view))->
+                             base[GTK_STATE_NORMAL]);
 	gtk_widget_show(bar->bar);
 	gtk_text_view_add_child_in_window(draw_mode->view, bar->bar,
 					  GTK_TEXT_WINDOW_TEXT, 0, y_pos);
diff --git a/src/balsa-mime-widget.c b/src/balsa-mime-widget.c
index bbb6040..1d7f9a1 100644
--- a/src/balsa-mime-widget.c
+++ b/src/balsa-mime-widget.c
@@ -337,7 +337,7 @@ balsa_mime_widget_schedule_resize(GtkWidget * widget)
 static void 
 vadj_change_cb(GtkAdjustment *vadj, GtkWidget *widget)
 {
-    gdouble upper = vadj->upper;
+    gdouble upper = gtk_adjustment_get_upper(vadj);
 
     /* do nothing if it's the same widget and the height hasn't changed
      *
diff --git a/src/filter-edit-callbacks.c b/src/filter-edit-callbacks.c
index 38678bc..b64c522 100644
--- a/src/filter-edit-callbacks.c
+++ b/src/filter-edit-callbacks.c
@@ -533,8 +533,8 @@ condition_validate(LibBalsaCondition* new_cnd)
 	    CONDITION_SETMATCH(new_cnd,CONDITION_MATCH_US_HEAD);
             str =
                 gtk_editable_get_chars(GTK_EDITABLE
-                                       (GTK_BIN(fe_user_header)->child), 0,
-                                       -1);
+                                       (gtk_bin_get_child
+                                        (GTK_BIN(fe_user_header))), 0, -1);
 	    if (!str[0]) {
                 balsa_information(LIBBALSA_INFORMATION_ERROR,
                                   _("You must specify the name of the "
@@ -616,8 +616,8 @@ condition_validate(LibBalsaCondition* new_cnd)
     if (CONDITION_CHKMATCH(new_cnd,CONDITION_MATCH_US_HEAD))
         new_cnd->match.string.user_header =
             gtk_editable_get_chars(GTK_EDITABLE
-                                   (GTK_BIN(fe_user_header)->child), 0,
-                                   -1);
+                                   (gtk_bin_get_child
+                                    (GTK_BIN(fe_user_header))), 0, -1);
     /* Set the type specific fields of the condition */
     switch (new_cnd->type) {
     case CONDITION_STRING:
@@ -765,7 +765,9 @@ fill_condition_widgets(LibBalsaCondition* cnd)
     }
     else {
 	gtk_widget_set_sensitive(fe_user_header,FALSE);
-	gtk_entry_set_text(GTK_ENTRY(GTK_BIN(fe_user_header)->child),"");
+        gtk_entry_set_text(GTK_ENTRY
+                           (gtk_bin_get_child(GTK_BIN(fe_user_header))),
+                           "");
     }	
     /* Next update type specific fields */
     switch (cnd->type) {
@@ -1172,6 +1174,7 @@ void build_condition_dialog(GtkWidget * condition_dialog)
 {
     GtkWidget *label,* box;
     GtkWidget *field_frame = get_field_frame();
+    GtkBox *content_box;
 
     /* builds the toggle buttons to specify fields concerned by the
      * conditions of the filter */
@@ -1183,14 +1186,14 @@ void build_condition_dialog(GtkWidget * condition_dialog)
                              G_CALLBACK(fe_typesmenu_cb), field_frame);
     gtk_box_pack_start(GTK_BOX(box), fe_search_option_menu, FALSE, FALSE, 5);
     gtk_label_set_mnemonic_widget(GTK_LABEL(label), fe_search_option_menu);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(condition_dialog)->vbox),
-                       box, FALSE, FALSE, 2);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(condition_dialog)->vbox),
-                       field_frame, FALSE, FALSE, 2);
+
+    content_box =
+        GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(condition_dialog)));
+    gtk_box_pack_start(content_box, box, FALSE, FALSE, 2);
+    gtk_box_pack_start(content_box, field_frame, FALSE, FALSE, 2);
 
     build_type_notebook();
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(condition_dialog)->vbox),
-                       fe_type_notebook, FALSE, FALSE, 2);
+    gtk_box_pack_start(content_box, fe_type_notebook, FALSE, FALSE, 2);
 }
 
 /*
diff --git a/src/filter-edit-dialog.c b/src/filter-edit-dialog.c
index d31c984..24e8433 100644
--- a/src/filter-edit-dialog.c
+++ b/src/filter-edit-dialog.c
@@ -598,8 +598,9 @@ filters_edit_dialog(void)
 
     /* main hbox */
     hbox = gtk_hbox_new(FALSE, FILTER_EDIT_PADDING);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fe_window)->vbox),
-		       hbox, TRUE, TRUE, FILTER_EDIT_PADDING);
+    gtk_box_pack_start(GTK_BOX
+                       (gtk_dialog_get_content_area(GTK_DIALOG(fe_window))),
+                       hbox, TRUE, TRUE, FILTER_EDIT_PADDING);
     gtk_box_pack_start(GTK_BOX(hbox), piece, FALSE, FALSE,
                        FILTER_EDIT_PADDING);
 
diff --git a/src/filter-export-dialog.c b/src/filter-export-dialog.c
index 4506e5f..14061a5 100644
--- a/src/filter-export-dialog.c
+++ b/src/filter-export-dialog.c
@@ -93,7 +93,8 @@ filters_export_dialog(void)
                                  NULL, TRUE);
 
     gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(list));
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fex_window)->vbox),
+    gtk_box_pack_start(GTK_BOX
+                       (gtk_dialog_get_content_area(GTK_DIALOG(fex_window))),
                        sw, TRUE, TRUE, 2);
 
     /* Populate the list of filters */
diff --git a/src/filter-run-dialog.c b/src/filter-run-dialog.c
index c38af41..320b3cb 100644
--- a/src/filter-run-dialog.c
+++ b/src/filter-run-dialog.c
@@ -287,7 +287,7 @@ void balsa_filter_run_dialog_init(BalsaFilterRunDialog * p)
 
     hbox = gtk_hbox_new(FALSE,2);
 
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(p)->vbox),
+    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(p))),
 		       hbox, TRUE, TRUE, 0);
 
     vbox = gtk_vbox_new(FALSE, 2);
diff --git a/src/folder-conf.c b/src/folder-conf.c
index eb49cc7..703d2f9 100644
--- a/src/folder-conf.c
+++ b/src/folder-conf.c
@@ -319,7 +319,7 @@ folder_conf_imap_node(BalsaMailboxNode *mn)
     }
 
     notebook = gtk_notebook_new();
-    gtk_box_pack_start(GTK_BOX(fcw->dialog->vbox),
+    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(fcw->dialog)),
                        notebook, TRUE, TRUE, 0);
     table = libbalsa_create_table(9, 2);
     gtk_container_set_border_width(GTK_CONTAINER(table), 12);
@@ -564,8 +564,9 @@ browse_button_cb(GtkWidget * widget, SubfolderDialogData * sdd)
 #endif
     
     scroll = gtk_scrolled_window_new(NULL, NULL);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scroll,
-                       TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX
+                       (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                       scroll, TRUE, TRUE, 0);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_ALWAYS);
@@ -649,8 +650,9 @@ folder, parent);
 #if HAVE_MACOSX_DESKTOP
 		libbalsa_macosx_menu_for_parent(ask, GTK_WINDOW(sdd->dialog));
 #endif
-                gtk_container_add(GTK_CONTAINER(GTK_DIALOG(ask)->vbox),
-                                  gtk_label_new(msg));
+                gtk_container_add(GTK_CONTAINER
+                                  (gtk_dialog_get_content_area
+                                   (GTK_DIALOG(ask))), gtk_label_new(msg));
                 g_free(msg);
                 button = gtk_dialog_run(GTK_DIALOG(ask));
                 gtk_widget_destroy(ask);
@@ -748,7 +750,7 @@ folder_conf_imap_sub_node(BalsaMailboxNode * mn)
     sdd = mn ? g_object_get_data(G_OBJECT(mn), BALSA_FOLDER_CONF_IMAP_KEY)
              : sdd_new;
     if (sdd) {
-        gdk_window_raise(GTK_WIDGET(sdd->dialog)->window);
+        gtk_window_present(GTK_WINDOW(sdd->dialog));
         return;
     }
 
@@ -803,7 +805,7 @@ folder_conf_imap_sub_node(BalsaMailboxNode * mn)
 
     frame = gtk_frame_new(mn ? _("Rename or move subfolder") :
 			       _("Create subfolder"));
-    gtk_box_pack_start(GTK_BOX(sdd->dialog->vbox),
+    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(sdd->dialog)),
                        frame, TRUE, TRUE, 0);
     table = libbalsa_create_table(3, 3);
     gtk_container_set_border_width(GTK_CONTAINER(table), 12);
diff --git a/src/information-dialog.c b/src/information-dialog.c
index 7072f0e..7e14494 100644
--- a/src/information-dialog.c
+++ b/src/information-dialog.c
@@ -257,8 +257,10 @@ balsa_information_list(GtkWindow *parent, LibBalsaInformationType type,
 				       (scrolled_window),
 				       GTK_POLICY_AUTOMATIC,
 				       GTK_POLICY_AUTOMATIC);
-	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(information_dialog)->vbox),
-			   scrolled_window, TRUE, TRUE, 1);
+        gtk_box_pack_start(GTK_BOX
+                           (gtk_dialog_get_content_area
+                            (GTK_DIALOG(information_dialog))),
+                           scrolled_window, TRUE, TRUE, 1);
 	gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 6);
 	gtk_widget_show(scrolled_window);
 
diff --git a/src/mailbox-conf.c b/src/mailbox-conf.c
index bd78ec0..3f8ca16 100644
--- a/src/mailbox-conf.c
+++ b/src/mailbox-conf.c
@@ -1256,7 +1256,9 @@ create_pop_mailbox_dialog(MailboxConfWindow *mcw)
     gtk_widget_grab_focus(mcw->mailbox_name);
 
     dialog = create_generic_dialog(mcw);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), notebook);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                      notebook);
     return dialog;
 }
 
@@ -1378,7 +1380,9 @@ create_imap_mailbox_dialog(MailboxConfWindow *mcw)
                           mcw->mailbox_name : mcw->mb_data.imap.bsc.server);
 
     dialog = create_generic_dialog(mcw);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), notebook);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
+                      notebook);
 
     mcw->view_info =
         mailbox_conf_view_new_full(mcw->mailbox, GTK_WINDOW(dialog), table,
diff --git a/src/main-window.c b/src/main-window.c
index 572685d..e093a56 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -300,7 +300,7 @@ static void
 bw_quit_nicely(GtkAction * action, gpointer data)
 {
     GdkEventAny e = { GDK_DELETE, NULL, 0 };
-    e.window = GTK_WIDGET(data)->window;
+    e.window = gtk_widget_get_window(GTK_WIDGET(data));
     libbalsa_information(LIBBALSA_INFORMATION_MESSAGE,
                          _("Balsa closes files and connections. Please wait..."));
     while(gtk_events_pending())
@@ -2746,6 +2746,8 @@ bw_progress_dialog_response_cb(GtkWidget* dialog, gint response)
 static void
 ensure_check_mail_dialog(BalsaWindow * window)
 {
+    GtkBox *content_box;
+
     if (progress_dialog && GTK_IS_WIDGET(progress_dialog))
 	gtk_widget_destroy(GTK_WIDGET(progress_dialog));
     
@@ -2766,17 +2768,19 @@ ensure_check_mail_dialog(BalsaWindow * window)
     g_signal_connect(G_OBJECT(progress_dialog), "response",
 		     G_CALLBACK(bw_progress_dialog_response_cb), NULL);
     
+    content_box =
+        GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(progress_dialog)));
     progress_dialog_source = gtk_label_new(_("Checking Mail..."));
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(progress_dialog)->vbox),
-		       progress_dialog_source, FALSE, FALSE, 0);
+    gtk_box_pack_start(content_box, progress_dialog_source,
+                       FALSE, FALSE, 0);
     
     progress_dialog_message = gtk_label_new("");
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(progress_dialog)->vbox),
-		       progress_dialog_message, FALSE, FALSE, 0);
+    gtk_box_pack_start(content_box, progress_dialog_message,
+                       FALSE, FALSE, 0);
     
     progress_dialog_bar = gtk_progress_bar_new();
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(progress_dialog)->vbox),
-		       progress_dialog_bar, FALSE, FALSE, 0);
+    gtk_box_pack_start(content_box, progress_dialog_bar,
+                       FALSE, FALSE, 0);
     gtk_window_set_default_size(GTK_WINDOW(progress_dialog), 250, 100);
     gtk_widget_show_all(progress_dialog);
 }
@@ -3377,11 +3381,11 @@ bw_display_new_mail_notification(int num_new, int has_new)
         notify_notification_show(balsa_app.main_window->new_mail_note,
                                  NULL);
     } else
-        gtk_label_set_text(GTK_LABEL(GTK_MESSAGE_DIALOG(dlg)->label), msg);
+        gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dlg), msg);
 #else
 
     msg = bw_get_new_message_notification_string(num_new, num_total);
-    gtk_label_set_text(GTK_LABEL(GTK_MESSAGE_DIALOG(dlg)->label), msg);
+    gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dlg), msg);
 #endif
     g_free(msg);
 }
@@ -4050,7 +4054,7 @@ bw_find_real(BalsaWindow * window, BalsaIndex * bindex, gboolean again)
 #if HAVE_MACOSX_DESKTOP
 	libbalsa_macosx_menu_for_parent(dia, GTK_WINDOW(window));
 #endif
-        vbox = GTK_DIALOG(dia)->vbox;
+        vbox = gtk_dialog_get_content_area(GTK_DIALOG(dia));
 
 	page=gtk_table_new(2, 1, FALSE);
 	gtk_container_set_border_width(GTK_CONTAINER(page), 6);
@@ -4164,8 +4168,10 @@ bw_find_real(BalsaWindow * window, BalsaIndex * bindex, gboolean again)
             switch(ok) {
             case GTK_RESPONSE_OK:
             case FIND_RESPONSE_FILTER:
-		reverse = GTK_TOGGLE_BUTTON(reverse_button)->active;
-		wrap    = GTK_TOGGLE_BUTTON(wrap_button)->active;
+                reverse = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                                       (reverse_button));
+                wrap    = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                                       (wrap_button));
 		g_free(cnd->match.string.string);
 		cnd->match.string.string =
                     g_strdup(gtk_entry_get_text(GTK_ENTRY(search_entry)));
@@ -4608,11 +4614,15 @@ balsa_change_window_layout(BalsaWindow *window)
     g_object_ref(window->mblist);
     g_object_ref(window->preview);
  
-    gtk_container_remove(GTK_CONTAINER(window->notebook->parent), window->notebook);
-    gtk_container_remove(GTK_CONTAINER(window->mblist->parent),
-			 window->mblist);
-    gtk_container_remove(GTK_CONTAINER(window->preview->parent),
-			 window->preview);
+    gtk_container_remove(GTK_CONTAINER
+                         (gtk_widget_get_parent(window->notebook)),
+                         window->notebook);
+    gtk_container_remove(GTK_CONTAINER
+                         (gtk_widget_get_parent(window->mblist)),
+                         window->mblist);
+    gtk_container_remove(GTK_CONTAINER
+                         (gtk_widget_get_parent(window->preview)),
+                         window->preview);
 
     bw_set_panes(window);
 
@@ -4621,9 +4631,8 @@ balsa_change_window_layout(BalsaWindow *window)
     g_object_unref(window->preview);
  
     gtk_paned_set_position(GTK_PANED(window->paned_master), 
-                           balsa_app.show_mblist 
-                           ? balsa_app.mblist_width
-                           : 0);
+                           balsa_app.show_mblist ?
+                           balsa_app.mblist_width : 0);
     gtk_widget_show(window->paned_slave);
     gtk_widget_show(window->paned_master);
 
@@ -4850,15 +4859,38 @@ bw_notebook_find_page (GtkNotebook* notebook, gint x, gint y)
     gint label_y;
     gint label_width;
     gint label_height;
+#if GTK_CHECK_VERSION(2, 18, 0)
+    GtkAllocation allocation;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
     
     /* x and y are relative to the notebook, but the label allocations
      * are relative to the main window. */
+#if GTK_CHECK_VERSION(2, 18, 0)
+    gtk_widget_get_allocation(GTK_WIDGET(notebook), &allocation);
+    x += allocation.x;
+    y += allocation.y;
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     x += GTK_WIDGET(notebook)->allocation.x;
     y += GTK_WIDGET(notebook)->allocation.y;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
     while ((page = gtk_notebook_get_nth_page (notebook, page_num)) != NULL) {
         label = gtk_notebook_get_tab_label (notebook, page);
         
+#if GTK_CHECK_VERSION(2, 18, 0)
+        gtk_widget_get_allocation(label, &allocation);
+        label_x     = allocation.x;
+        label_width = allocation.width;
+
+        if (x > label_x && x < label_x + label_width) {
+            label_y      = allocation.y;
+            label_height = allocation.height;
+
+            if (y > label_y && y < label_y + label_height) {
+                return BALSA_INDEX(gtk_bin_get_child(GTK_BIN(page)));
+            }
+        }
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
         label_x = label->allocation.x;
         label_width = label->allocation.width;
         
@@ -4870,6 +4902,7 @@ bw_notebook_find_page (GtkNotebook* notebook, gint x, gint y)
                 return BALSA_INDEX(gtk_bin_get_child(GTK_BIN(page)));
             }
         }
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
         ++page_num;
     }
 
@@ -4899,7 +4932,8 @@ bw_notebook_drag_received_cb(GtkWidget * widget, GdkDragContext * context,
 	/* Drag'n'drop is weird... */
 	return;
 
-    orig_index = *(BalsaIndex **) selection_data->data;
+    orig_index =
+        *(BalsaIndex **) gtk_selection_data_get_data(selection_data);
     selected = balsa_index_selected_msgnos_new(orig_index);
     if (selected->len == 0) {
         /* it is actually possible to drag from GtkTreeView when no rows
diff --git a/src/message-window.c b/src/message-window.c
index 86d1e90..5126e28 100644
--- a/src/message-window.c
+++ b/src/message-window.c
@@ -812,12 +812,14 @@ mw_header_activate_cb(GtkAction * action, gpointer data)
 static void
 size_alloc_cb(GtkWidget * window, GtkAllocation * alloc)
 {
-    if (!GTK_WIDGET_REALIZED(window))
+    GdkWindow *gdk_window;
+
+    if (!(gdk_window = gtk_widget_get_window(window)))
         return;
 
     if (!(balsa_app.message_window_maximized =
-          gdk_window_get_state(window->window)
-          & GDK_WINDOW_STATE_MAXIMIZED)) {
+          (gdk_window_get_state(gdk_window)
+           & GDK_WINDOW_STATE_MAXIMIZED))) {
         balsa_app.message_window_height = alloc->height;
         balsa_app.message_window_width  = alloc->width;
     }
diff --git a/src/pref-manager.c b/src/pref-manager.c
index c041b19..91fc6f6 100644
--- a/src/pref-manager.c
+++ b/src/pref-manager.c
@@ -525,7 +525,9 @@ open_preferences_manager(GtkWidget * widget, gpointer data)
 #endif
 
     hbox = gtk_hbox_new(FALSE, 12);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(property_box)->vbox), hbox);
+    gtk_container_add(GTK_CONTAINER
+                      (gtk_dialog_get_content_area
+                       (GTK_DIALOG(property_box))), hbox);
 
     store = gtk_tree_store_new(PM_NUM_COLS,
                                G_TYPE_STRING,   /* PM_TEXT_COL     */
@@ -833,13 +835,16 @@ apply_prefs(GtkDialog * pbox)
      * display page 
      */
     for (i = 0; i < NUM_PWINDOW_MODES; i++)
-        if (GTK_TOGGLE_BUTTON(pui->pwindow_type[i])->active) {
+        if (gtk_toggle_button_get_active
+                (GTK_TOGGLE_BUTTON(pui->pwindow_type[i]))) {
             balsa_app.pwindow_option = pwindow_type[i];
             break;
         }
 
-    balsa_app.debug = GTK_TOGGLE_BUTTON(pui->debug)->active;
-    balsa_app.previewpane = GTK_TOGGLE_BUTTON(pui->previewpane)->active;
+    balsa_app.debug =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->debug));
+    balsa_app.previewpane =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->previewpane));
 
     save_enum = balsa_app.layout_type;
     balsa_app.layout_type =
@@ -848,14 +853,17 @@ apply_prefs(GtkDialog * pbox)
         balsa_change_window_layout(balsa_app.main_window);
 
     balsa_app.view_message_on_open =
-        GTK_TOGGLE_BUTTON(pui->view_message_on_open)->active;
-    balsa_app.pgdownmod = GTK_TOGGLE_BUTTON(pui->pgdownmod)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->view_message_on_open));
+    balsa_app.pgdownmod =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->pgdownmod));
     balsa_app.pgdown_percent =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
                                          (pui->pgdown_percent));
 
     if (balsa_app.mblist_show_mb_content_info !=
-        GTK_TOGGLE_BUTTON(pui->mblist_show_mb_content_info)->active) {
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->mblist_show_mb_content_info))) {
         balsa_app.mblist_show_mb_content_info =
             !balsa_app.mblist_show_mb_content_info;
         g_object_set(G_OBJECT(balsa_app.mblist), "show_content_info",
@@ -863,24 +871,31 @@ apply_prefs(GtkDialog * pbox)
     }
 
     balsa_app.check_mail_auto =
-        GTK_TOGGLE_BUTTON(pui->check_mail_auto)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->check_mail_auto));
     balsa_app.check_mail_timer =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
                                          (pui->check_mail_minutes));
     balsa_app.quiet_background_check =
-        GTK_TOGGLE_BUTTON(pui->quiet_background_check)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->quiet_background_check));
     balsa_app.msg_size_limit =
         gtk_spin_button_get_value(GTK_SPIN_BUTTON(pui->msg_size_limit)) *
         1024;
-    balsa_app.check_imap = GTK_TOGGLE_BUTTON(pui->check_imap)->active;
+    balsa_app.check_imap =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->check_imap));
     balsa_app.check_imap_inbox =
-        GTK_TOGGLE_BUTTON(pui->check_imap_inbox)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->check_imap_inbox));
     balsa_app.notify_new_mail_dialog =
-        GTK_TOGGLE_BUTTON(pui->notify_new_mail_dialog)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->notify_new_mail_dialog));
     balsa_app.notify_new_mail_sound =
-        GTK_TOGGLE_BUTTON(pui->notify_new_mail_sound)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->notify_new_mail_sound));
     balsa_app.notify_new_mail_icon =
-        GTK_TOGGLE_BUTTON(pui->notify_new_mail_icon)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->notify_new_mail_icon));
     balsa_app.mdn_reply_clean =
         pm_combo_box_get_level(pui->mdn_reply_clean_menu);
     balsa_app.mdn_reply_notclean =
@@ -891,26 +906,33 @@ apply_prefs(GtkDialog * pbox)
     else
         update_timer(FALSE, 0);
 
-    balsa_app.wordwrap = GTK_TOGGLE_BUTTON(pui->wordwrap)->active;
+    balsa_app.wordwrap =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->wordwrap));
     balsa_app.wraplength =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pui->wraplength));
-    balsa_app.autoquote = GTK_TOGGLE_BUTTON(pui->autoquote)->active;
+    balsa_app.autoquote =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->autoquote));
     balsa_app.reply_strip_html =
-        !GTK_TOGGLE_BUTTON(pui->reply_include_html_parts)->active;
+        !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                      (pui->reply_include_html_parts));
     balsa_app.forward_attached =
-        GTK_TOGGLE_BUTTON(pui->forward_attached)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->forward_attached));
 
     save_setting = balsa_app.always_queue_sent_mail;
     balsa_app.always_queue_sent_mail =
-        GTK_TOGGLE_BUTTON(pui->always_queue_sent_mail)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->always_queue_sent_mail));
     if (balsa_app.always_queue_sent_mail != save_setting)
         balsa_toolbar_model_changed(balsa_window_get_toolbar_model());
 
     balsa_app.copy_to_sentbox =
-        GTK_TOGGLE_BUTTON(pui->copy_to_sentbox)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->copy_to_sentbox));
 
     balsa_app.close_mailbox_auto =
-        GTK_TOGGLE_BUTTON(pui->close_mailbox_auto)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->close_mailbox_auto));
     balsa_app.close_mailbox_timeout =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
                                          (pui->close_mailbox_minutes)) *
@@ -920,7 +942,8 @@ apply_prefs(GtkDialog * pbox)
     balsa_app.expunge_on_close =
         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
                                      (pui->expunge_on_close));
-    balsa_app.expunge_auto = GTK_TOGGLE_BUTTON(pui->expunge_auto)->active;
+    balsa_app.expunge_auto =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->expunge_auto));
     balsa_app.expunge_timeout =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
                                          (pui->expunge_minutes)) * 60;
@@ -928,7 +951,8 @@ apply_prefs(GtkDialog * pbox)
         pm_combo_box_get_level(pui->action_after_move_menu);
 
     /* external editor */
-    balsa_app.edit_headers = GTK_TOGGLE_BUTTON(pui->edit_headers)->active;
+    balsa_app.edit_headers =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->edit_headers));
 
     /* arp */
     g_free(balsa_app.quote_str);
@@ -948,7 +972,8 @@ apply_prefs(GtkDialog * pbox)
     tmp = gtk_entry_get_text(GTK_ENTRY(pui->quote_pattern));
     balsa_app.quote_regex = g_strcompress(tmp);
 
-    balsa_app.browse_wrap = GTK_TOGGLE_BUTTON(pui->browse_wrap)->active;
+    balsa_app.browse_wrap =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->browse_wrap));
     /* main window view menu can also toggle balsa_app.browse_wrap
      * update_view_menu lets it know we've made a change */
     update_view_menu(balsa_app.main_window);
@@ -957,14 +982,18 @@ apply_prefs(GtkDialog * pbox)
                                          (pui->browse_wrap_length));
 
     balsa_app.display_alt_plain =
-        GTK_TOGGLE_BUTTON(pui->display_alt_plain)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->display_alt_plain));
 
     balsa_app.open_inbox_upon_startup =
-        GTK_TOGGLE_BUTTON(pui->open_inbox_upon_startup)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->open_inbox_upon_startup));
     balsa_app.check_mail_upon_startup =
-        GTK_TOGGLE_BUTTON(pui->check_mail_upon_startup)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->check_mail_upon_startup));
     balsa_app.remember_open_mboxes =
-        GTK_TOGGLE_BUTTON(pui->remember_open_mboxes)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->remember_open_mboxes));
     balsa_app.local_scan_depth =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
                                          (pui->local_scan_depth));
@@ -972,7 +1001,7 @@ apply_prefs(GtkDialog * pbox)
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
                                          (pui->imap_scan_depth));
     balsa_app.empty_trash_on_exit =
-        GTK_TOGGLE_BUTTON(pui->empty_trash)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->empty_trash));
 
 #if !HAVE_GTKSPELL
     /* spell checking */
@@ -981,9 +1010,12 @@ apply_prefs(GtkDialog * pbox)
     balsa_app.ignore_size =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
                                          (pui->ignore_length));
-    balsa_app.check_sig = GTK_TOGGLE_BUTTON(pui->spell_check_sig)->active;
+    balsa_app.check_sig =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->spell_check_sig));
     balsa_app.check_quoted =
-        GTK_TOGGLE_BUTTON(pui->spell_check_quoted)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->spell_check_quoted));
 #endif                          /* HAVE_GTKSPELL */
 
     /* date format */
@@ -1000,7 +1032,7 @@ apply_prefs(GtkDialog * pbox)
     /* quoted text color */
     for (i = 0; i < MAX_QUOTED_COLOR; i++) {
         gdk_colormap_free_colors(gdk_drawable_get_colormap
-                                 (GTK_WIDGET(pbox)->window),
+                                 (gtk_widget_get_window(GTK_WIDGET(pbox))),
                                  &balsa_app.quoted_color[i], 1);
         gtk_color_button_get_color(GTK_COLOR_BUTTON(pui->quoted_color[i]),
                                    &balsa_app.quoted_color[i]);
@@ -1008,14 +1040,14 @@ apply_prefs(GtkDialog * pbox)
 
     /* url color */
     gdk_colormap_free_colors(gdk_drawable_get_colormap
-                             (GTK_WIDGET(pbox)->window),
+                             (gtk_widget_get_window(GTK_WIDGET(pbox))),
                              &balsa_app.url_color, 1);
     gtk_color_button_get_color(GTK_COLOR_BUTTON(pui->url_color),
                                &balsa_app.url_color);
 
     /* bad address color */
     gdk_colormap_free_colors(gdk_drawable_get_colormap
-                             (GTK_WIDGET(pbox)->window),
+                             (gtk_widget_get_window(GTK_WIDGET(pbox))),
                              &balsa_app.bad_address_color, 1);
     gtk_color_button_get_color(GTK_COLOR_BUTTON(pui->bad_address_color),
                                &balsa_app.bad_address_color);
@@ -1024,7 +1056,8 @@ apply_prefs(GtkDialog * pbox)
     libbalsa_mailbox_set_sort_field(NULL, pui->sort_field_index);
     libbalsa_mailbox_set_threading_type(NULL, pui->threading_type_index);
     balsa_app.expand_tree =
-        GTK_TOGGLE_BUTTON(pui->tree_expand_check)->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->tree_expand_check));
 
     /* Information dialogs */
     balsa_app.information_message =
@@ -1038,7 +1071,8 @@ apply_prefs(GtkDialog * pbox)
 
     /* handling of 8-bit message parts without codeset header */
     balsa_app.convert_unknown_8bit =
-        GTK_TOGGLE_BUTTON(pui->convert_unknown_8bit[1])->active;
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->convert_unknown_8bit[1]));
     balsa_app.convert_unknown_8bit_codeset =
         gtk_combo_box_get_active(GTK_COMBO_BOX
                                  (pui->convert_unknown_8bit_codeset));
@@ -1085,7 +1119,8 @@ set_prefs(void)
     gtk_spin_button_set_value(GTK_SPIN_BUTTON(pui->pgdown_percent),
                               (float) balsa_app.pgdown_percent);
     gtk_widget_set_sensitive(pui->pgdown_percent,
-                             GTK_TOGGLE_BUTTON(pui->pgdownmod)->active);
+                             gtk_toggle_button_get_active
+                             (GTK_TOGGLE_BUTTON(pui->pgdownmod)));
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->debug),
                                  balsa_app.debug);
 
@@ -1130,8 +1165,8 @@ set_prefs(void)
                               (float) balsa_app.close_mailbox_timeout /
                               60);
     gtk_widget_set_sensitive(pui->close_mailbox_minutes,
-                             GTK_TOGGLE_BUTTON(pui->close_mailbox_auto)->
-                             active);
+                             gtk_toggle_button_get_active
+                             (GTK_TOGGLE_BUTTON(pui->close_mailbox_auto)));
 
     pui->filter = libbalsa_mailbox_get_filter(NULL);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->hide_deleted),
@@ -1143,10 +1178,11 @@ set_prefs(void)
     gtk_spin_button_set_value(GTK_SPIN_BUTTON(pui->expunge_minutes),
                               (float) balsa_app.expunge_timeout / 60);
     gtk_widget_set_sensitive(pui->expunge_minutes,
-                             GTK_TOGGLE_BUTTON(pui->expunge_auto)->active);
+                             gtk_toggle_button_get_active
+                             (GTK_TOGGLE_BUTTON(pui->expunge_auto)));
     gtk_widget_set_sensitive(pui->check_mail_minutes,
-                             GTK_TOGGLE_BUTTON(pui->check_mail_auto)->
-                             active);
+                             gtk_toggle_button_get_active
+                             (GTK_TOGGLE_BUTTON(pui->check_mail_auto)));
     pm_combo_box_set_level(pui->action_after_move_menu,
                            balsa_app.mw_action_after_move);
 
@@ -1168,7 +1204,8 @@ set_prefs(void)
                                  balsa_app.forward_attached);
 
     gtk_widget_set_sensitive(pui->wraplength,
-                             GTK_TOGGLE_BUTTON(pui->wordwrap)->active);
+                             gtk_toggle_button_get_active
+                             (GTK_TOGGLE_BUTTON(pui->wordwrap)));
 
     /* external editor */
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->edit_headers),
@@ -3150,7 +3187,8 @@ void
 timer_modified_cb(GtkWidget * widget, GtkWidget * pbox)
 {
     gboolean newstate = 
-	gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->check_mail_auto));
+	gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->check_mail_auto));
 
     gtk_widget_set_sensitive(GTK_WIDGET(pui->check_mail_minutes), newstate);
     properties_modified_cb(widget, pbox);
@@ -3253,8 +3291,9 @@ create_mdn_reply_menu(void)
 void
 mailbox_close_timer_modified_cb(GtkWidget * widget, GtkWidget * pbox)
 {
-    gboolean newstate =	gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
-	    pui->close_mailbox_auto));
+    gboolean newstate =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->close_mailbox_auto));
 
     gtk_widget_set_sensitive(GTK_WIDGET(pui->close_mailbox_minutes),
 			     newstate);
@@ -3300,7 +3339,7 @@ static void imap_toggled_cb(GtkWidget * widget, GtkWidget * pbox)
 {
     properties_modified_cb(widget, pbox);
 
-    if(GTK_TOGGLE_BUTTON(pui->check_imap)->active) 
+    if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->check_imap))) 
 	gtk_widget_set_sensitive(GTK_WIDGET(pui->check_imap_inbox), TRUE);
     else {
 	gtk_toggle_button_set_active(
@@ -3314,8 +3353,10 @@ convert_8bit_cb(GtkWidget * widget, GtkWidget * pbox)
 {
     properties_modified_cb(widget, pbox);
 
-    gtk_widget_set_sensitive(pui->convert_unknown_8bit_codeset,
-			     GTK_TOGGLE_BUTTON(pui->convert_unknown_8bit[1])->active);
+    gtk_widget_set_sensitive
+        (pui->convert_unknown_8bit_codeset,
+         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                      (pui->convert_unknown_8bit[1])));
 }
 
 static GtkWidget *
diff --git a/src/print-gtk.c b/src/print-gtk.c
index a8db01c..eea1c34 100644
--- a/src/print-gtk.c
+++ b/src/print-gtk.c
@@ -463,10 +463,14 @@ add_margin_spinbtn(const gchar * text, gdouble min, gdouble max, gdouble dflt,
 }
 
 static void
-check_margins(GtkAdjustment *adjustment, GtkAdjustment *other)
+check_margins(GtkAdjustment * adjustment, GtkAdjustment * other)
 {
-    if (adjustment->value + other->value > adjustment->upper)
-	gtk_adjustment_set_value(adjustment, adjustment->upper - other->value);
+    if (gtk_adjustment_get_value(adjustment) +
+        gtk_adjustment_get_value(other) >
+        gtk_adjustment_get_upper(adjustment))
+        gtk_adjustment_set_value(adjustment,
+                                 gtk_adjustment_get_upper(adjustment) -
+                                 gtk_adjustment_get_value(other));
 }
 
 static GtkWidget *
@@ -641,9 +645,11 @@ message_prefs_apply(GtkPrintOperation * operation, GtkWidget * widget,
 	g_strdup(gtk_font_button_get_font_name
 		 (GTK_FONT_BUTTON(print_prefs->footer_font)));
     balsa_app.print_highlight_cited =
-	GTK_TOGGLE_BUTTON(print_prefs->highlight_cited)->active;
+	gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (print_prefs->highlight_cited));
     balsa_app.print_highlight_phrases =
-	GTK_TOGGLE_BUTTON(print_prefs->highlight_phrases)->active;
+	gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (print_prefs->highlight_phrases));
 
     balsa_app.margin_top =
 	gtk_spin_button_get_value(GTK_SPIN_BUTTON(print_prefs->margin_top)) * 72.0;
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index eb12981..6f0ae1e 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1644,10 +1644,12 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
 static void
 sw_size_alloc_cb(GtkWidget * window, GtkAllocation * alloc)
 {
-    if (!GTK_WIDGET_REALIZED(window))
+    GdkWindow *gdk_window;
+
+    if (!(gdk_window = gtk_widget_get_window(window)))
         return;
 
-    if (!(balsa_app.sw_maximized = gdk_window_get_state(window->window)
+    if (!(balsa_app.sw_maximized = gdk_window_get_state(gdk_window)
           & GDK_WINDOW_STATE_MAXIMIZED)) {
         balsa_app.sw_height = alloc->height;
         balsa_app.sw_width  = alloc->width;
@@ -1851,16 +1853,16 @@ sw_get_user_codeset(BalsaSendmsg * bsmsg, gboolean * change_type,
          fname);
     GtkWidget *info = gtk_label_new(msg);
     GtkWidget *charset_button = libbalsa_charset_button_new();
+    GtkBox *content_box;
 
 #if HAVE_MACOSX_DESKTOP
     libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(bsmsg->window));
 #endif
 
     g_free(msg);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), info,
-                       FALSE, TRUE, 5);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), charset_button,
-                       TRUE, TRUE, 5);
+    content_box = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
+    gtk_box_pack_start(content_box, info, FALSE, TRUE, 5);
+    gtk_box_pack_start(content_box, charset_button, TRUE, TRUE, 5);
     gtk_widget_show(info);
     gtk_widget_show(charset_button);
     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
@@ -1870,8 +1872,7 @@ sw_get_user_codeset(BalsaSendmsg * bsmsg, gboolean * change_type,
         GtkWidget *hbox = gtk_hbox_new(FALSE, 5);
         combo_box = gtk_combo_box_new_text();
 
-        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox,
-                           TRUE, TRUE, 5);
+        gtk_box_pack_start(content_box, hbox, TRUE, TRUE, 5);
         gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
         gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), mime_type);
         gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box),
@@ -2490,7 +2491,8 @@ attachments_add(GtkWidget * widget,
     if (balsa_app.debug)
         printf("attachments_add: info %d\n", info);
     if (info == TARGET_MESSAGES) {
-	BalsaIndex *index = *(BalsaIndex **) selection_data->data;
+	BalsaIndex *index =
+            *(BalsaIndex **) gtk_selection_data_get_data(selection_data);
 	LibBalsaMailbox *mailbox = index->mailbox_node->mailbox;
         GArray *selected = balsa_index_selected_msgnos_new(index);
 	guint i;
@@ -2511,14 +2513,18 @@ attachments_add(GtkWidget * widget,
         }
         balsa_index_selected_msgnos_free(index, selected);
     } else if (info == TARGET_URI_LIST) {
-        GSList *uri_list = uri2gslist((gchar *) selection_data->data);
+        GSList *uri_list =
+            uri2gslist((gchar *)
+                       gtk_selection_data_get_data(selection_data));
         for (; uri_list; uri_list = g_slist_next(uri_list)) {
 	    add_attachment(bsmsg, uri_list->data, FALSE, NULL);
             g_free(uri_list->data);
         }
         g_slist_free(uri_list);
     } else if( info == TARGET_STRING) {
-	gchar *url = rfc2396_uri((gchar *) selection_data->data);
+	gchar *url =
+            rfc2396_uri((gchar *)
+                        gtk_selection_data_get_data(selection_data));
 
 	if (url)
 	    add_urlref_attachment(bsmsg, url);
@@ -2624,12 +2630,13 @@ sw_scroll_size_request(GtkWidget * widget, GtkRequisition * requisition)
     gint border_width;
     GtkPolicyType type = GTK_POLICY_NEVER;
 
-    gtk_widget_size_request(GTK_BIN(widget)->child, requisition);
+    gtk_widget_size_request(gtk_bin_get_child(GTK_BIN(widget)),
+                            requisition);
     gtk_widget_style_get(widget, "focus-line-width", &focus_width,
                          "focus-padding", &focus_pad, NULL);
 
     border_width =
-        (GTK_CONTAINER(widget)->border_width + focus_width +
+        (gtk_container_get_border_width(GTK_CONTAINER(widget)) + focus_width +
          focus_pad) * 2;
     requisition->width += border_width;
     requisition->height += border_width;
@@ -3063,7 +3070,8 @@ drag_data_quote(GtkWidget * widget,
 
     switch(info) {
     case TARGET_MESSAGES:
-	index = *(BalsaIndex **) selection_data->data;
+	index =
+            *(BalsaIndex **) gtk_selection_data_get_data(selection_data);
 	mailbox = index->mailbox_node->mailbox;
         selected = balsa_index_selected_msgnos_new(index);
 	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
@@ -3085,7 +3093,9 @@ drag_data_quote(GtkWidget * widget,
         balsa_index_selected_msgnos_free(index, selected);
         break;
     case TARGET_URI_LIST: {
-        GSList *uri_list = uri2gslist((gchar *) selection_data->data);
+        GSList *uri_list =
+            uri2gslist((gchar *)
+                       gtk_selection_data_get_data(selection_data));
         for (; uri_list; uri_list = g_slist_next(uri_list)) {
             /* Since current GtkTextView gets this signal twice for
              * every action (#150141) we need to check for duplicates,
@@ -3595,6 +3605,7 @@ quote_parts_select_dlg(GtkTreeStore *tree_store, GtkWindow * parent)
     GtkCellRenderer *renderer;
     GtkTreeIter iter;
     gboolean result;
+    GtkBox *content_box;
 
     dialog = gtk_dialog_new_with_buttons(_("Select parts for quotation"),
 					 parent,
@@ -3621,12 +3632,12 @@ quote_parts_select_dlg(GtkTreeStore *tree_store, GtkWindow * parent)
     gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, TRUE,
-		       TRUE, 0);
+    content_box = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
+    gtk_box_pack_start(content_box, hbox, TRUE, TRUE, 0);
 
     gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
     gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
-    gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 14);
+    gtk_box_set_spacing(content_box, 14);
 
     /* scrolled window for the tree view */
     scroll = gtk_scrolled_window_new(NULL, NULL);
@@ -5639,7 +5650,7 @@ subject_not_empty(BalsaSendmsg * bsmsg)
     gtk_window_set_type_hint (GTK_WINDOW (no_subj_dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
     gtk_dialog_set_has_separator (GTK_DIALOG (no_subj_dialog), FALSE);
 
-    dialog_vbox = GTK_DIALOG (no_subj_dialog)->vbox;
+    dialog_vbox = gtk_dialog_get_content_area(GTK_DIALOG(no_subj_dialog));
 
     hbox = gtk_hbox_new (FALSE, 12);
     gtk_box_pack_start (GTK_BOX (dialog_vbox), hbox, TRUE, TRUE, 0);
@@ -5673,16 +5684,25 @@ subject_not_empty(BalsaSendmsg * bsmsg)
     gtk_box_pack_start (GTK_BOX (hbox), subj_entry, TRUE, TRUE, 0);
     gtk_entry_set_activates_default (GTK_ENTRY (subj_entry), TRUE);
 
-    dialog_action_area = GTK_DIALOG (no_subj_dialog)->action_area;
+    dialog_action_area =
+        gtk_dialog_get_action_area(GTK_DIALOG(no_subj_dialog));
     gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area), GTK_BUTTONBOX_END);
 
     cnclbutton = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
     gtk_dialog_add_action_widget (GTK_DIALOG (no_subj_dialog), cnclbutton, GTK_RESPONSE_CANCEL);
+#if GTK_CHECK_VERSION(2, 18, 0)
+    gtk_widget_set_can_default(cnclbutton, TRUE);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     GTK_WIDGET_SET_FLAGS (cnclbutton, GTK_CAN_DEFAULT);
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
     okbutton = gtk_button_new ();
     gtk_dialog_add_action_widget (GTK_DIALOG (no_subj_dialog), okbutton, GTK_RESPONSE_OK);
+#if GTK_CHECK_VERSION(2, 18, 0)
+    gtk_widget_set_can_default(okbutton, TRUE);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     GTK_WIDGET_SET_FLAGS (okbutton, GTK_CAN_DEFAULT);
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
     gtk_dialog_set_default_response(GTK_DIALOG (no_subj_dialog),
                                     GTK_RESPONSE_OK);
 
@@ -5697,8 +5717,13 @@ subject_not_empty(BalsaSendmsg * bsmsg)
 
     label = gtk_label_new_with_mnemonic (_("_Send"));
     gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+#if GTK_CHECK_VERSION(2, 18, 0)
+    gtk_widget_set_can_focus(label, TRUE);
+    gtk_widget_set_can_default(label, TRUE);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     GTK_WIDGET_SET_FLAGS (label, GTK_CAN_FOCUS);
     GTK_WIDGET_SET_FLAGS (label, GTK_CAN_DEFAULT);
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
     gtk_widget_grab_focus (subj_entry);
     gtk_editable_select_region(GTK_EDITABLE(subj_entry), 0, -1);
@@ -5782,12 +5807,16 @@ check_suggest_encryption(BalsaSendmsg * bsmsg)
         libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(bsmsg->window));
 #endif
 
-	dialog_action_area = GTK_DIALOG(dialog)->action_area;
+	dialog_action_area = gtk_dialog_get_action_area(GTK_DIALOG(dialog));
 	gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area), GTK_BUTTONBOX_END);
  
 	button = gtk_button_new();
 	gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button, GTK_RESPONSE_YES);
+#if GTK_CHECK_VERSION(2, 18, 0)
+        gtk_widget_set_can_default(button, TRUE);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
 	GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 	gtk_widget_grab_focus(button);
 	alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
 	gtk_container_add(GTK_CONTAINER(button), alignment);
@@ -5802,7 +5831,11 @@ check_suggest_encryption(BalsaSendmsg * bsmsg)
 
 	button = gtk_button_new();
 	gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button, GTK_RESPONSE_NO);
+#if GTK_CHECK_VERSION(2, 18, 0)
+        gtk_widget_set_can_default(button, TRUE);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
 	GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 	alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
 	gtk_container_add(GTK_CONTAINER(button), alignment);
 
@@ -5817,7 +5850,11 @@ check_suggest_encryption(BalsaSendmsg * bsmsg)
 	button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
 	gtk_widget_show(button);
 	gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button, GTK_RESPONSE_CANCEL);
+#if GTK_CHECK_VERSION(2, 18, 0)
+        gtk_widget_set_can_default(button, TRUE);
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
 	GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
 	choice = gtk_dialog_run(GTK_DIALOG(dialog));
 	gtk_widget_destroy(dialog);
diff --git a/src/spell-check.c b/src/spell-check.c
index 1df9373..6a3c4fa 100644
--- a/src/spell-check.c
+++ b/src/spell-check.c
@@ -464,6 +464,7 @@ balsa_spell_check_init(BalsaSpellCheck * spell_check)
     GtkWidget *learn;
     GtkWidget *done;
     GtkWidget *cancel;
+    GtkBox *content_box, *action_box;
 
     const guint padding = 4;
 
@@ -482,15 +483,15 @@ balsa_spell_check_init(BalsaSpellCheck * spell_check)
     /* setup suggestion display */
     new_word_text = gtk_entry_new();
     spell_check->entry = GTK_ENTRY(new_word_text);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(spell_check)->vbox),
-                       new_word_text, FALSE, FALSE, 0);
+    content_box =
+        GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(spell_check)));
+    gtk_box_pack_start(content_box, new_word_text, FALSE, FALSE, 0);
 
     sw = gtk_scrolled_window_new(NULL, NULL);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
 				   GTK_POLICY_AUTOMATIC,
 				   GTK_POLICY_AUTOMATIC);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(spell_check)->vbox),
-                       sw, TRUE, TRUE, 0);
+    gtk_box_pack_start(content_box, sw, TRUE, TRUE, 0);
 
     /* setup suggestion list */
     store = gtk_list_store_new(1, G_TYPE_STRING);
@@ -521,8 +522,9 @@ balsa_spell_check_init(BalsaSpellCheck * spell_check)
                                 _("Replace all occurrences of the current word "
                                   "with the selected suggestion"));
     gtk_box_pack_start(GTK_BOX(vbox), change_all, FALSE, FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(spell_check)->action_area),
-                       vbox, FALSE, FALSE, 0);
+    action_box =
+        GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(spell_check)));
+    gtk_box_pack_start(action_box, vbox, FALSE, FALSE, 0);
 
     vbox = gtk_vbox_new(FALSE, padding);
     ignore = balsa_stock_button_with_label(GTK_STOCK_GO_FORWARD,
@@ -537,8 +539,7 @@ balsa_spell_check_init(BalsaSpellCheck * spell_check)
     gtk_widget_set_tooltip_text(ignore_all,
                                 _("Skip all occurrences of the current word"));
     gtk_box_pack_start(GTK_BOX(vbox), ignore_all, FALSE, FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(spell_check)->action_area),
-                       vbox, FALSE, FALSE, 0);
+    gtk_box_pack_start(action_box, vbox, FALSE, FALSE, 0);
 
     vbox = gtk_vbox_new(FALSE, padding);
     learn = balsa_stock_button_with_label(BALSA_PIXMAP_BOOK_OPEN,
@@ -546,8 +547,7 @@ balsa_spell_check_init(BalsaSpellCheck * spell_check)
     gtk_widget_set_tooltip_text(learn,
                                 _("Add the current word to your personal dictionary"));
     gtk_box_pack_start(GTK_BOX(vbox), learn, FALSE, FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(spell_check)->action_area),
-                       vbox, FALSE, FALSE, 0);
+    gtk_box_pack_start(action_box, vbox, FALSE, FALSE, 0);
 
     vbox = gtk_vbox_new(FALSE, padding);
     done = balsa_stock_button_with_label(GTK_STOCK_OK, _("_Done"));
@@ -558,8 +558,7 @@ balsa_spell_check_init(BalsaSpellCheck * spell_check)
     gtk_widget_set_tooltip_text(cancel,
                                 _("Revert all changes and finish spell checking"));
     gtk_box_pack_start(GTK_BOX(vbox), cancel, FALSE, FALSE, 0);
-    gtk_box_pack_end(GTK_BOX(GTK_DIALOG(spell_check)->action_area),
-                     vbox, FALSE, FALSE, 0);
+    gtk_box_pack_end(action_box, vbox, FALSE, FALSE, 0);
 
     /* connect signal handlers */
     g_signal_connect(G_OBJECT(selection), "changed",
diff --git a/src/store-address.c b/src/store-address.c
index 731d812..1c0b93b 100644
--- a/src/store-address.c
+++ b/src/store-address.c
@@ -208,7 +208,7 @@ store_address_dialog(StoreAddressInfo * info)
                                     GTK_STOCK_SAVE,  SA_RESPONSE_SAVE,
                                     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
                                     NULL);
-    GtkWidget *vbox = GTK_DIALOG(dialog)->vbox;
+    GtkWidget *vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
     GtkWidget *frame, *label;
 
 #if HAVE_MACOSX_DESKTOP
diff --git a/src/toolbar-factory.c b/src/toolbar-factory.c
index 4f0acb8..bab2960 100644
--- a/src/toolbar-factory.c
+++ b/src/toolbar-factory.c
@@ -656,15 +656,24 @@ tm_popup_position_func(GtkMenu * menu, gint * x, gint * y,
     GtkRequisition req;
     gint monitor_num;
     GdkRectangle monitor;
+#if GTK_CHECK_VERSION(2, 18, 0)
+    GtkAllocation allocation;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
-    g_return_if_fail(GTK_WIDGET_REALIZED(toolbar));
+    g_return_if_fail(gtk_widget_get_window(toolbar));
 
-    gdk_window_get_origin(toolbar->window, x, y);
+    gdk_window_get_origin(gtk_widget_get_window(toolbar), x, y);
 
     gtk_widget_size_request(GTK_WIDGET(menu), &req);
 
+#if GTK_CHECK_VERSION(2, 18, 0)
+    gtk_widget_get_allocation(toolbar, &allocation);
+    *x += (allocation.width - req.width) / 2;
+    *y += allocation.height;
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     *x += (toolbar->allocation.width - req.width) / 2;
     *y += toolbar->allocation.height;
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
 
     monitor_num = gdk_screen_get_monitor_at_point(screen, *x, *y);
     gtk_menu_set_monitor(menu, monitor_num);
@@ -752,7 +761,11 @@ tm_do_popup_menu(GtkWidget * toolbar, GdkEventButton * event,
         }
     }
 
+#if GTK_CHECK_VERSION(2, 18, 0)
+    if (gtk_widget_is_sensitive(toolbar)) {
+#else                           /* GTK_CHECK_VERSION(2, 18, 0) */
     if (GTK_WIDGET_IS_SENSITIVE(toolbar)) {
+#endif                          /* GTK_CHECK_VERSION(2, 18, 0) */
         /* This is a real toolbar, not the template from the
          * toolbar-prefs dialog. */
         GtkWidget *item;
diff --git a/src/toolbar-prefs.c b/src/toolbar-prefs.c
index 4618b33..db38b5b 100644
--- a/src/toolbar-prefs.c
+++ b/src/toolbar-prefs.c
@@ -126,6 +126,7 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
     BalsaToolbarModel *model;
     BalsaToolbarType   type;
     GtkUIManager * ui_manager;
+    GtkWidget *content_area;
 
     /* There can only be one */
     if (customize_widget) {
@@ -149,8 +150,9 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
                      G_CALLBACK(tp_dialog_response_cb), NULL);
 
     notebook = gtk_notebook_new();
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(customize_widget)->vbox),
-                      notebook);
+    content_area =
+        gtk_dialog_get_content_area(GTK_DIALOG(customize_widget));
+    gtk_container_add(GTK_CONTAINER(content_area), notebook);
 
     gtk_window_set_wmclass(GTK_WINDOW(customize_widget), "customize",
                            "Balsa");
@@ -181,8 +183,7 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
 
     option_frame = gtk_frame_new(_("Toolbar options"));
     gtk_container_set_border_width(GTK_CONTAINER(option_frame), 6);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(customize_widget)->vbox),
-                       option_frame, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(content_area), option_frame, FALSE, FALSE, 0);
 
     option_box = gtk_vbox_new(FALSE, 6);
     gtk_container_set_border_width(GTK_CONTAINER(option_box), 6);
@@ -282,7 +283,8 @@ wrap_toggled_cb(GtkWidget * widget, GtkNotebook * notebook)
     GtkWidget *child;
     ToolbarPage *page;
     
-    balsa_app.toolbar_wrap_button_text = GTK_TOGGLE_BUTTON(widget)->active;
+    balsa_app.toolbar_wrap_button_text =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 
     for (i = 0; (child = gtk_notebook_get_nth_page(notebook, i)); i++) {
         page = g_object_get_data(G_OBJECT(child), BALSA_KEY_TOOLBAR_PAGE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]