Remove commented out code.
[geeqie.git] / src / ui_misc.c
index b092aef..d6df839 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * (SLIK) SimpLIstic sKin functions
  * (C) 2004 John Ellis
- * Copyright (C) 2008 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
@@ -25,7 +25,7 @@
 #include "main.h"
 #include "ui_misc.h"
 
-#include "ui_bookmark.h"
+#include "history_list.h"
 
 
 /*
@@ -34,8 +34,8 @@
  *-----------------------------------------------------------------------------
  */
 
-GtkWidget *pref_box_new(GtkWidget *parent_box, gint fill,
-                       GtkOrientation orientation, gint padding)
+GtkWidget *pref_box_new(GtkWidget *parent_box, gboolean fill,
+                       GtkOrientation orientation, gboolean padding)
 {
        GtkWidget *box;
 
@@ -54,7 +54,7 @@ GtkWidget *pref_box_new(GtkWidget *parent_box, gint fill,
        return box;
 }
 
-GtkWidget *pref_group_new(GtkWidget *parent_box, gint fill,
+GtkWidget *pref_group_new(GtkWidget *parent_box, gboolean fill,
                          const gchar *text, GtkOrientation orientation)
 {
        GtkWidget *box;
@@ -65,9 +65,14 @@ GtkWidget *pref_group_new(GtkWidget *parent_box, gint fill,
        vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
 
        /* add additional spacing if necessary */
-       if (GTK_IS_VBOX(parent_box) && GTK_BOX(parent_box)->children != NULL)
+       if (GTK_IS_VBOX(parent_box))
                {
-               pref_spacer(vbox, PREF_PAD_GROUP - PREF_PAD_GAP);
+               GList *list = gtk_container_get_children(GTK_CONTAINER(parent_box));
+               if (list)
+                       {
+                       pref_spacer(vbox, PREF_PAD_GROUP - PREF_PAD_GAP);
+                       }
+               g_list_free(list);
                }
 
        gtk_box_pack_start(GTK_BOX(parent_box), vbox, fill, fill, 0);
@@ -121,9 +126,9 @@ GtkWidget *pref_group_parent(GtkWidget *child)
        return child;
 }
 
-GtkWidget *pref_frame_new(GtkWidget *parent_box, gint fill,
+GtkWidget *pref_frame_new(GtkWidget *parent_box, gboolean fill,
                          const gchar *text,
-                         GtkOrientation orientation, gint padding)
+                         GtkOrientation orientation, gboolean padding)
 {
        GtkWidget *box;
        GtkWidget *frame = NULL;
@@ -147,7 +152,7 @@ GtkWidget *pref_frame_new(GtkWidget *parent_box, gint fill,
        return box;
 }
 
-GtkWidget *pref_spacer(GtkWidget *parent_box, gint padding)
+GtkWidget *pref_spacer(GtkWidget *parent_box, gboolean padding)
 {
        GtkWidget *spacer;
 
@@ -158,7 +163,7 @@ GtkWidget *pref_spacer(GtkWidget *parent_box, gint padding)
        return spacer;
 }
 
-GtkWidget *pref_line(GtkWidget *parent_box, gint padding)
+GtkWidget *pref_line(GtkWidget *parent_box, gboolean padding)
 {
        GtkWidget *spacer;
 
@@ -200,7 +205,7 @@ GtkWidget *pref_label_new_mnemonic(GtkWidget *parent_box, const gchar *text, Gtk
        return label;
 }
 
-void pref_label_bold(GtkWidget *label, gint bold, gint increase_size)
+void pref_label_bold(GtkWidget *label, gboolean bold, gboolean increase_size)
 {
        PangoAttrList *pal;
        PangoAttribute *pa;
@@ -230,7 +235,7 @@ void pref_label_bold(GtkWidget *label, gint bold, gint increase_size)
 }
 
 GtkWidget *pref_button_new(GtkWidget *parent_box, const gchar *stock_id,
-                          const gchar *text, gint hide_stock_text,
+                          const gchar *text, gboolean hide_stock_text,
                           GCallback func, gpointer data)
 {
        GtkWidget *button;
@@ -298,8 +303,8 @@ GtkWidget *pref_button_new(GtkWidget *parent_box, const gchar *stock_id,
        return button;
 }
 
-static GtkWidget *real_pref_checkbox_new(GtkWidget *parent_box, const gchar *text, gint mnemonic_text,
-                                        gint active, GCallback func, gpointer data)
+static GtkWidget *real_pref_checkbox_new(GtkWidget *parent_box, const gchar *text, gboolean mnemonic_text,
+                                        gboolean active, GCallback func, gpointer data)
 {
        GtkWidget *button;
 
@@ -320,13 +325,13 @@ static GtkWidget *real_pref_checkbox_new(GtkWidget *parent_box, const gchar *tex
        return button;
 }
 
-GtkWidget *pref_checkbox_new(GtkWidget *parent_box, const gchar *text, gint active,
+GtkWidget *pref_checkbox_new(GtkWidget *parent_box, const gchar *text, gboolean active,
                             GCallback func, gpointer data)
 {
        return real_pref_checkbox_new(parent_box, text, FALSE, active, func, data);
 }
 
-GtkWidget *pref_checkbox_new_mnemonic(GtkWidget *parent_box, const gchar *text, gint active,
+GtkWidget *pref_checkbox_new_mnemonic(GtkWidget *parent_box, const gchar *text, gboolean active,
                                      GCallback func, gpointer data)
 {
        return real_pref_checkbox_new(parent_box, text, TRUE, active, func, data);
@@ -334,13 +339,13 @@ GtkWidget *pref_checkbox_new_mnemonic(GtkWidget *parent_box, const gchar *text,
 
 static void pref_checkbox_int_cb(GtkWidget *widget, gpointer data)
 {
-       gint *result = data;
+       gboolean *result = data;
 
        *result = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 }
 
-GtkWidget *pref_checkbox_new_int(GtkWidget *parent_box, const gchar *text, gint active,
-                                gint *result)
+GtkWidget *pref_checkbox_new_int(GtkWidget *parent_box, const gchar *text, gboolean active,
+                                gboolean *result)
 {
        GtkWidget *button;
 
@@ -382,11 +387,11 @@ void pref_checkbox_link_sensitivity_swap(GtkWidget *button, GtkWidget *widget)
 }
 
 static GtkWidget *real_pref_radiobutton_new(GtkWidget *parent_box, GtkWidget *sibling,
-                                           const gchar *text, gint mnemonic_text, gint active,
+                                           const gchar *text, gboolean mnemonic_text, gboolean active,
                                            GCallback func, gpointer data)
 {
        GtkWidget *button;
-       GSListgroup;
+       GSList *group;
 
        if (sibling)
                {
@@ -416,14 +421,14 @@ static GtkWidget *real_pref_radiobutton_new(GtkWidget *parent_box, GtkWidget *si
 }
 
 GtkWidget *pref_radiobutton_new(GtkWidget *parent_box, GtkWidget *sibling,
-                               const gchar *text, gint active,
+                               const gchar *text, gboolean active,
                                GCallback func, gpointer data)
 {
        return real_pref_radiobutton_new(parent_box, sibling, text, FALSE, active, func, data);
 }
 
 GtkWidget *pref_radiobutton_new_mnemonic(GtkWidget *parent_box, GtkWidget *sibling,
-                                        const gchar *text, gint active,
+                                        const gchar *text, gboolean active,
                                         GCallback func, gpointer data)
 {
        return real_pref_radiobutton_new(parent_box, sibling, text, TRUE, active, func, data);
@@ -433,7 +438,7 @@ GtkWidget *pref_radiobutton_new_mnemonic(GtkWidget *parent_box, GtkWidget *sibli
 
 static void pref_radiobutton_int_cb(GtkWidget *widget, gpointer data)
 {
-       gint *result = data;
+       gboolean *result = data;
 
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
                {
@@ -442,8 +447,8 @@ static void pref_radiobutton_int_cb(GtkWidget *widget, gpointer data)
 }
 
 GtkWidget *pref_radiobutton_new_int(GtkWidget *parent_box, GtkWidget *sibling,
-                                   const gchar *text, gint active,
-                                   gint *result, gint value,
+                                   const gchar *text, gboolean active,
+                                   gboolean *result, gboolean value,
                                    GCallback func, gpointer data)
 {
        GtkWidget *button;
@@ -457,7 +462,7 @@ GtkWidget *pref_radiobutton_new_int(GtkWidget *parent_box, GtkWidget *sibling,
 }
 
 static GtkWidget *real_pref_spin_new(GtkWidget *parent_box, const gchar *text, const gchar *suffix,
-                                    gint mnemonic_text,
+                                    gboolean mnemonic_text,
                                     gdouble min, gdouble max, gdouble step, gint digits,
                                     gdouble value,
                                     GCallback func, gpointer data)
@@ -538,20 +543,11 @@ GtkWidget *pref_spin_new_int(GtkWidget *parent_box, const gchar *text, const gch
                             G_CALLBACK(pref_spin_int_cb), value_var);
 }
 
-#if 0
-void pref_spin_set_blocking(GtkWidget *spin, gdouble value, gpointer block_data)
-{
-       g_signal_handlers_block_matched(G_OBJECT(spin), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, block_data);
-       gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), value);
-       g_signal_handlers_unblock_matched(G_OBJECT(spin), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, block_data);
-}
-#endif
-
 static void pref_link_sensitivity_cb(GtkWidget *watch, GtkStateType prev_state, gpointer data)
 {
        GtkWidget *widget = data;
 
-       gtk_widget_set_sensitive(widget, GTK_WIDGET_IS_SENSITIVE(watch));
+       gtk_widget_set_sensitive(widget, gtk_widget_is_sensitive(watch));
 }
 
 void pref_link_sensitivity(GtkWidget *widget, GtkWidget *watch)
@@ -573,11 +569,11 @@ void pref_signal_unblock_data(GtkWidget *widget, gpointer data)
 }
 
 GtkWidget *pref_table_new(GtkWidget *parent_box, gint columns, gint rows,
-                         gint homogenious, gint fill)
+                         gboolean homogeneous, gboolean fill)
 {
        GtkWidget *table;
 
-       table = gtk_table_new(rows, columns, homogenious);
+       table = gtk_table_new(rows, columns, homogeneous);
        gtk_table_set_row_spacings(GTK_TABLE(table), PREF_PAD_GAP);
        gtk_table_set_col_spacings(GTK_TABLE(table), PREF_PAD_SPACE);
 
@@ -640,7 +636,7 @@ GtkWidget *pref_table_label(GtkWidget *table, gint column, gint row,
 }
 
 GtkWidget *pref_table_button(GtkWidget *table, gint column, gint row,
-                            const gchar *stock_id, const gchar *text, gint hide_stock_text,
+                            const gchar *stock_id, const gchar *text, gboolean hide_stock_text,
                             GCallback func, gpointer data)
 {
        GtkWidget *button;
@@ -653,25 +649,6 @@ GtkWidget *pref_table_button(GtkWidget *table, gint column, gint row,
        return button;
 }
 
-#if 0
-static GtkWidget *pref_table_checkbox(GtkWidget *table, gint column, gint row,
-                                     const gchar *text, gint active,
-                                     GCallback func, gpointer data)
-{
-       GtkWidget *button;
-
-       button = gtk_check_button_new_with_label(text);
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
-       if (func) g_signal_connect(G_OBJECT(button), "clicked", func, data);
-
-       gtk_table_attach(GTK_TABLE(table), button, column, column + 1, row, row + 1,
-                        GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-       gtk_widget_show(button);
-
-       return button;
-}
-#endif
-
 GtkWidget *pref_table_spin(GtkWidget *table, gint column, gint row,
                           const gchar *text, const gchar *suffix,
                           gdouble min, gdouble max, gdouble step, gint digits,
@@ -718,18 +695,24 @@ GtkWidget *pref_table_spin(GtkWidget *table, gint column, gint row,
        return spin;
 }
 
-static void pref_toolbar_destroy_cb(GtkWidget *widget, gpointer data)
+GtkWidget *pref_table_spin_new_int(GtkWidget *table, gint column, gint row,
+                                  const gchar *text, const gchar *suffix,
+                                  gint min, gint max, gint step,
+                                  gint value, gint *value_var)
 {
-       GtkTooltips *tips = data;
-
-       g_object_unref(G_OBJECT(tips));
+       *value_var = value;
+       return pref_table_spin(table, column, row,
+                              text, suffix,
+                              (gdouble)min, (gdouble)max, (gdouble)step, 0,
+                              value,
+                              G_CALLBACK(pref_spin_int_cb), value_var);
 }
 
+
 GtkWidget *pref_toolbar_new(GtkWidget *parent_box, GtkToolbarStyle style)
 {
        GtkWidget *tbar;
-       GtkTooltips *tips;
-
+       
        tbar = gtk_toolbar_new();
        gtk_toolbar_set_style(GTK_TOOLBAR(tbar), style);
 
@@ -738,30 +721,11 @@ GtkWidget *pref_toolbar_new(GtkWidget *parent_box, GtkToolbarStyle style)
                gtk_box_pack_start(GTK_BOX(parent_box), tbar, FALSE, FALSE, 0);
                gtk_widget_show(tbar);
                }
-
-       tips = gtk_tooltips_new();
-
-       /* take ownership of tooltips */
-#ifdef GTK_OBJECT_FLOATING
-       /* GTK+ < 2.10 */
-       g_object_ref(G_OBJECT(tips));
-       gtk_object_sink(GTK_OBJECT(tips));
-#else
-       /* GTK+ >= 2.10 */
-       g_object_ref_sink(G_OBJECT(tips));
-#endif
-
-       g_object_set_data(G_OBJECT(tbar), "tooltips", tips);
-       g_signal_connect(G_OBJECT(tbar), "destroy",
-                        G_CALLBACK(pref_toolbar_destroy_cb), tips);
-
-       gtk_tooltips_enable(tips);
-
        return tbar;
 }
 
 GtkWidget *pref_toolbar_button(GtkWidget *toolbar,
-                              const gchar *stock_id, const gchar *label, gint toggle,
+                              const gchar *stock_id, const gchar *label, gboolean toggle,
                               const gchar *description,
                               GCallback func, gpointer data)
 {
@@ -799,10 +763,7 @@ GtkWidget *pref_toolbar_button(GtkWidget *toolbar,
 
        if (description)
                {
-               GtkTooltips *tips;
-
-               tips = g_object_get_data(G_OBJECT(toolbar), "tooltips");
-               gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(item), tips, description, NULL);
+               gtk_widget_set_tooltip_text(item, description);
                }
 
        return item;
@@ -861,7 +822,7 @@ static void date_selection_popup_hide(DateSelection *ds)
 {
        if (!ds->window) return;
 
-       if (GTK_WIDGET_HAS_GRAB(ds->window))
+       if (gtk_widget_has_grab(ds->window))
                {
                gtk_grab_remove(ds->window);
                gdk_keyboard_ungrab(GDK_CURRENT_TIME);
@@ -877,7 +838,7 @@ static void date_selection_popup_hide(DateSelection *ds)
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ds->button), FALSE);
 }
 
-static gint date_selection_popup_release_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
+static gboolean date_selection_popup_release_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
 {
        DateSelection *ds = data;
 
@@ -885,18 +846,21 @@ static gint date_selection_popup_release_cb(GtkWidget *widget, GdkEventButton *e
        return TRUE;
 }
 
-static gint date_selection_popup_press_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
+static gboolean date_selection_popup_press_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
 {
        DateSelection *ds = data;
        gint x, y;
        gint w, h;
        gint xr, yr;
+       GdkWindow *window;
 
        xr = (gint)event->x_root;
        yr = (gint)event->y_root;
 
-       gdk_window_get_origin(ds->window->window, &x, &y);
-       gdk_drawable_get_size(ds->window->window, &w, &h);
+       window = gtk_widget_get_window(ds->window);
+       gdk_window_get_origin(window, &x, &y);
+       w = gdk_window_get_width(window);
+       h = gdk_window_get_height(window);
 
        if (xr < x || yr < y || xr > x + w || yr > y + h)
                {
@@ -916,20 +880,20 @@ static void date_selection_popup_sync(DateSelection *ds)
        date_selection_set(ds->box, day, month + 1, year);
 }
 
-static gint date_selection_popup_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+static gboolean date_selection_popup_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
        DateSelection *ds = data;
 
        switch (event->keyval)
                {
-               case GDK_Return:
-               case GDK_KP_Enter:
-               case GDK_Tab:
-               case GDK_ISO_Left_Tab:
+               case GDK_KEY_Return:
+               case GDK_KEY_KP_Enter:
+               case GDK_KEY_Tab:
+               case GDK_KEY_ISO_Left_Tab:
                        date_selection_popup_sync(ds);
                        date_selection_popup_hide(ds);
                        break;
-               case GDK_Escape:
+               case GDK_KEY_Escape:
                        date_selection_popup_hide(ds);
                        break;
                default:
@@ -958,6 +922,8 @@ static void date_selection_popup(DateSelection *ds)
        gint x, y;
        gint wx, wy;
        gint day, month, year;
+       GtkAllocation button_allocation;
+       GtkAllocation window_allocation;
 
        if (ds->window) return;
 
@@ -983,14 +949,17 @@ static void date_selection_popup(DateSelection *ds)
 
        gtk_widget_realize(ds->window);
 
-       gdk_window_get_origin(ds->button->window, &wx, &wy);
+       gdk_window_get_origin(gtk_widget_get_window(ds->button), &wx, &wy);
 
-       x = wx + ds->button->allocation.x + ds->button->allocation.width - ds->window->allocation.width;
-       y = wy + ds->button->allocation.y + ds->button->allocation.height;
+       gtk_widget_get_allocation(ds->button, &button_allocation);
+       gtk_widget_get_allocation(ds->window, &window_allocation);
+       
+       x = wx + button_allocation.x + button_allocation.width - window_allocation.width;
+       y = wy + button_allocation.y + button_allocation.height;
 
-       if (y + ds->window->allocation.height > gdk_screen_height())
+       if (y + window_allocation.height > gdk_screen_height())
                {
-               y = wy + ds->button->allocation.y - ds->window->allocation.height;
+               y = wy + button_allocation.y - window_allocation.height;
                }
        if (x < 0) x = 0;
        if (y < 0) y = 0;
@@ -999,10 +968,10 @@ static void date_selection_popup(DateSelection *ds)
        gtk_widget_show(ds->window);
 
        gtk_widget_grab_focus(ds->calendar);
-       gdk_pointer_grab(ds->window->window, TRUE,
+       gdk_pointer_grab(gtk_widget_get_window(ds->window), TRUE,
                         GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK,
                         NULL, NULL, GDK_CURRENT_TIME);
-       gdk_keyboard_grab(ds->window->window, TRUE, GDK_CURRENT_TIME);
+       gdk_keyboard_grab(gtk_widget_get_window(ds->window), TRUE, GDK_CURRENT_TIME);
        gtk_grab_add(ds->window);
 
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ds->button), TRUE);
@@ -1021,15 +990,19 @@ static void date_selection_button_cb(GtkWidget *widget, gpointer data)
 static void button_size_allocate_cb(GtkWidget *button, GtkAllocation *allocation, gpointer data)
 {
        GtkWidget *spin = data;
+       GtkRequisition spin_requisition;
+       gtk_widget_get_requisition(spin, &spin_requisition);
 
-       if (allocation->height > spin->requisition.height)
+       if (allocation->height > spin_requisition.height)
                {
                GtkAllocation button_allocation;
+               GtkAllocation spin_allocation;
 
-               button_allocation = button->allocation;
-               button_allocation.height = spin->requisition.height;
-               button_allocation.y = spin->allocation.y +
-                       (spin->allocation.height - spin->requisition.height) / 2;
+               gtk_widget_get_allocation(button, &button_allocation);
+               gtk_widget_get_allocation(spin, &spin_allocation);
+               button_allocation.height = spin_requisition.height;
+               button_allocation.y = spin_allocation.y +
+                       (spin_allocation.height - spin_requisition.height) / 2;
                gtk_widget_size_allocate(button, &button_allocation);
                }
 }
@@ -1163,13 +1136,13 @@ struct _SizerData
        gint vsize_min;
        gint vsize_max;
 
-       gint in_drag;
+       gboolean in_drag;
        gint press_x;
        gint press_y;
        gint press_width;
        gint press_height;
 
-       gint handle_prelit;
+       gboolean handle_prelit;
 };
 
 
@@ -1190,11 +1163,12 @@ static gint sizer_default_handle_size(void)
        return handle_size;
 }
 
-static gint sizer_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+static gboolean sizer_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 {
        SizerData *sd = data;
        gint x, y;
        gint w, h;
+       GtkAllocation parent_allocation;
 
        if (!sd->in_drag) return FALSE;
 
@@ -1227,29 +1201,37 @@ static gint sizer_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer
 
        if (sd->bounding_widget)
                {
-               w = CLAMP(w, sd->sizer->allocation.width, sd->bounding_widget->allocation.width);
-               h = CLAMP(h, sd->sizer->allocation.height, sd->bounding_widget->allocation.height);
+               GtkAllocation sizer_allocation;
+               GtkAllocation bounding_allocation;
+               gtk_widget_get_allocation(sd->sizer, &sizer_allocation);
+               gtk_widget_get_allocation(sd->bounding_widget, &bounding_allocation);
+               w = CLAMP(w, sizer_allocation.width, bounding_allocation.width);
+               h = CLAMP(h, sizer_allocation.height, bounding_allocation.height);
                }
        else
                {
-               if (w < sd->sizer->allocation.width) w = sd->sizer->allocation.width;
-               if (h < sd->sizer->allocation.height) h = sd->sizer->allocation.height;
+               GtkAllocation sizer_allocation;
+               gtk_widget_get_allocation(sd->sizer, &sizer_allocation);
+               if (w < sizer_allocation.width) w = sizer_allocation.width;
+               if (h < sizer_allocation.height) h = sizer_allocation.height;
                }
 
        if (sd->hsize_max >= 0) w = MIN(w, sd->hsize_max);
        if (sd->vsize_max >= 0) h = MIN(h, sd->vsize_max);
 
-       if (w == sd->parent->allocation.width) w = -1;
-       if (h == sd->parent->allocation.height) h = -1;
+       gtk_widget_get_allocation(sd->parent, &parent_allocation);
+       if (w == parent_allocation.width) w = -1;
+       if (h == parent_allocation.height) h = -1;
 
        if (w > 0 || h > 0) gtk_widget_set_size_request(sd->parent, w, h);
 
        return TRUE;
 }
 
-static gint sizer_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+static gboolean sizer_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 {
        SizerData *sd = data;
+       GtkAllocation parent_allocation;
 
        if (bevent->button != MOUSE_BUTTON_LEFT) return FALSE;
 
@@ -1257,10 +1239,11 @@ static gint sizer_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer d
        sd->press_x = bevent->x_root;
        sd->press_y = bevent->y_root;
 
-       sd->press_width = sd->parent->allocation.width;
-       sd->press_height = sd->parent->allocation.height;
+       gtk_widget_get_allocation(sd->parent, &parent_allocation);
+       sd->press_width = parent_allocation.width;
+       sd->press_height = parent_allocation.height;
 
-       gdk_pointer_grab(sd->sizer->window, FALSE,
+       gdk_pointer_grab(gtk_widget_get_window(sd->sizer), FALSE,
                         GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
                         NULL, NULL, bevent->time);
        gtk_grab_add(sd->sizer);
@@ -1268,13 +1251,13 @@ static gint sizer_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer d
        return TRUE;
 }
 
-static gint sizer_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+static gboolean sizer_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 {
        SizerData *sd = data;
 
        if (bevent->button != MOUSE_BUTTON_LEFT) return FALSE;
 
-       if (gdk_pointer_is_grabbed() && GTK_WIDGET_HAS_GRAB(sd->sizer))
+       if (gdk_pointer_is_grabbed() && gtk_widget_has_grab(sd->sizer))
                {
                gtk_grab_remove(sd->sizer);
                gdk_pointer_ungrab(bevent->time);
@@ -1285,14 +1268,17 @@ static gint sizer_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer
        return TRUE;
 }
 
-static void sizer_set_prelight(SizerData *sd, gint prelit)
+static void sizer_set_prelight(SizerData *sd, gboolean prelit)
 {
+       GtkAllocation sizer_allocation;
+       gtk_widget_get_allocation(sd->sizer, &sizer_allocation);
+
        sd->handle_prelit = prelit;
        gtk_widget_queue_draw_area(sd->sizer, 0, 0,
-                                  sd->sizer->allocation.width, sd->sizer->allocation.height);
+                                  sizer_allocation.width, sizer_allocation.height);
 }
 
-static gint sizer_enter_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
+static gboolean sizer_enter_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
 {
        SizerData *sd = data;
 
@@ -1300,7 +1286,7 @@ static gint sizer_enter_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer
        return TRUE;
 }
 
-static gint sizer_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
+static gboolean sizer_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
 {
        SizerData *sd = data;
 
@@ -1308,14 +1294,26 @@ static gint sizer_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer
        return TRUE;
 }
 
-static gint sizer_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
+static gboolean sizer_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
 {
+#if GTK_CHECK_VERSION(3,0,0)
+       GtkAllocation allocation;
+
+       gtk_widget_get_allocation(widget, &allocation);
+
+       cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+       gtk_render_handle (gtk_widget_get_style_context (widget),
+                          cr, allocation.x, allocation.y, allocation.width, allocation.height);
+       cairo_destroy(cr);
+#else
        SizerData *sd = data;
        GdkRectangle clip;
        GtkOrientation orientation;
        GtkStateType state;
+       GtkAllocation allocation;
 
-       gdk_region_get_clipbox(event->region, &clip);
+       gtk_widget_get_allocation(widget, &allocation);
 
        if (sd->position & SIZER_POS_LEFT || sd->position & SIZER_POS_RIGHT)
                {
@@ -1332,14 +1330,17 @@ static gint sizer_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer d
                }
        else
                {
-               state = widget->state;
+               state = gtk_widget_get_state(widget);
                }
 
-       gtk_paint_handle(widget->style, widget->window, state,
+       gdk_region_get_clipbox(event->region, &clip);
+
+       gtk_paint_handle(gtk_widget_get_style(widget), gtk_widget_get_window(widget), state,
                         GTK_SHADOW_NONE, &clip, widget, "paned",
                         0, 0,
-                        widget->allocation.width, widget->allocation.height,
+                        allocation.width, allocation.height,
                         orientation);
+#endif
 
        return TRUE;
 }
@@ -1359,11 +1360,11 @@ static void sizer_realize_cb(GtkWidget *widget, gpointer data)
                n = (n != 0) ? GDK_FLEUR : GDK_SB_H_DOUBLE_ARROW;
                }
 
-       if (n != 0 && widget->window)
+       if (n != 0 && gtk_widget_get_window(widget))
                {
                GdkCursor *cursor;
                cursor = gdk_cursor_new(n);
-               gdk_window_set_cursor(widget->window, cursor);
+               gdk_window_set_cursor(gtk_widget_get_window(widget), cursor);
                gdk_cursor_unref(cursor);
                }
 }
@@ -1479,11 +1480,11 @@ static GList *pref_list_find(const gchar *group, const gchar *token)
        return NULL;
 }
 
-static gint pref_list_get(const gchar *group, const gchar *key, const gchar *marker, const gchar **result)
+static gboolean pref_list_get(const gchar *group, const gchar *key, const gchar *marker, const gchar **result)
 {
        gchar *token;
        GList *work;
-       gint ret;
+       gboolean ret;
 
        if (!group || !key || !marker)
                {
@@ -1557,7 +1558,7 @@ void pref_list_int_set(const gchar *group, const gchar *key, gint value)
        g_free(text);
 }
 
-gint pref_list_int_get(const gchar *group, const gchar *key, gint *result)
+gboolean pref_list_int_get(const gchar *group, const gchar *key, gint *result)
 {
        const gchar *text;
 
@@ -1585,7 +1586,7 @@ void pref_list_double_set(const gchar *group, const gchar *key, gdouble value)
        pref_list_set(group, key, PREF_LIST_MARKER_DOUBLE, text);
 }
 
-gint pref_list_double_get(const gchar *group, const gchar *key, gdouble *result)
+gboolean pref_list_double_get(const gchar *group, const gchar *key, gdouble *result)
 {
        const gchar *text;
 
@@ -1610,7 +1611,7 @@ void pref_list_string_set(const gchar *group, const gchar *key, const gchar *val
        pref_list_set(group, key, PREF_LIST_MARKER_STRING, value);
 }
 
-gint pref_list_string_get(const gchar *group, const gchar *key, const gchar **result)
+gboolean pref_list_string_get(const gchar *group, const gchar *key, const gchar **result)
 {
        return pref_list_get(group, key, PREF_LIST_MARKER_STRING, result);
 }
@@ -1663,3 +1664,34 @@ GtkWidget *pref_color_button_new(GtkWidget *parent_box,
 
        return button;
 }
+
+/*
+ *-----------------------------------------------------------------------------
+ * text widget
+ *-----------------------------------------------------------------------------
+ */
+
+gchar *text_widget_text_pull(GtkWidget *text_widget)
+{
+       if (GTK_IS_TEXT_VIEW(text_widget))
+               {
+               GtkTextBuffer *buffer;
+               GtkTextIter start, end;
+
+               buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_widget));
+               gtk_text_buffer_get_bounds(buffer, &start, &end);
+
+               return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+               }
+       else if (GTK_IS_ENTRY(text_widget))
+               {
+               return g_strdup(gtk_entry_get_text(GTK_ENTRY(text_widget)));
+               }
+       else
+               {
+               return NULL;
+               }
+
+}
+
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */