X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=cut-n-paste%2Ftoolbar-editor%2Fegg-editable-toolbar.c;h=5cf6c31ec619ea5a3c227b1f1da5c78a8ac9c7bf;hb=f9c2880d31bb2f5d4411849b9207c5d26a5c616a;hp=2b26b4eaaabba0c3479b8379a5c04e5cb3b6b32d;hpb=88f0701b10f70b8aede0f7e23014875ab72c2e26;p=evince.git diff --git a/cut-n-paste/toolbar-editor/egg-editable-toolbar.c b/cut-n-paste/toolbar-editor/egg-editable-toolbar.c index 2b26b4ea..5cf6c31e 100644 --- a/cut-n-paste/toolbar-editor/egg-editable-toolbar.c +++ b/cut-n-paste/toolbar-editor/egg-editable-toolbar.c @@ -25,31 +25,10 @@ #include "egg-toolbars-model.h" #include "egg-toolbar-editor.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include -static void egg_editable_toolbar_class_init (EggEditableToolbarClass *klass); -static void egg_editable_toolbar_init (EggEditableToolbar *etoolbar); static GdkPixbuf * new_separator_pixbuf (void); #define MIN_TOOLBAR_HEIGHT 20 @@ -78,8 +57,6 @@ enum static guint egg_editable_toolbar_signals[LAST_SIGNAL] = { 0 }; -static GObjectClass *parent_class = NULL; - #define EGG_EDITABLE_TOOLBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbarPrivate)) struct _EggEditableToolbarPrivate @@ -104,32 +81,7 @@ struct _EggEditableToolbarPrivate GtkToolItem *dnd_toolitem; }; -GType -egg_editable_toolbar_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) - { - static const GTypeInfo our_info = { - sizeof (EggEditableToolbarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) egg_editable_toolbar_class_init, - NULL, - NULL, /* class_data */ - sizeof (EggEditableToolbar), - 0, /* n_preallocs */ - (GInstanceInitFunc) egg_editable_toolbar_init - }; - - type = g_type_register_static (GTK_TYPE_VBOX, - "EggEditableToolbar", - &our_info, 0); - } - - return type; -} +G_DEFINE_TYPE (EggEditableToolbar, egg_editable_toolbar, GTK_TYPE_VBOX); static int get_dock_position (EggEditableToolbar *etoolbar, @@ -248,7 +200,12 @@ drag_begin_cb (GtkWidget *widget, gtk_widget_hide (widget); - action = g_object_get_data (G_OBJECT (widget), "gtk-action"); +#if GTK_CHECK_VERSION (2, 16, 0) + action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (widget)); +#else +action = gtk_widget_get_action (widget); +#endif + if (action == NULL) return; flags = egg_toolbars_model_get_name_flags (etoolbar->priv->model, @@ -274,7 +231,12 @@ drag_end_cb (GtkWidget *widget, { gtk_widget_show (widget); - action = g_object_get_data (G_OBJECT (widget), "gtk-action"); +#if GTK_CHECK_VERSION (2, 16, 0) + action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (widget)); +#else + action = gtk_widget_get_action (widget); +#endif + if (action == NULL) return; flags = egg_toolbars_model_get_name_flags (etoolbar->priv->model, @@ -463,9 +425,13 @@ configure_item_cursor (GtkToolItem *item, if (priv->edit_mode > 0) { GdkCursor *cursor; + GdkScreen *screen; GdkPixbuf *pixbuf = NULL; - - cursor = gdk_cursor_new (GDK_HAND2); + + screen = gtk_widget_get_screen (GTK_WIDGET (etoolbar)); + + cursor = gdk_cursor_new_for_display (gdk_screen_get_display (screen), + GDK_HAND2); gdk_window_set_cursor (widget->window, cursor); gdk_cursor_unref (cursor); @@ -541,9 +507,14 @@ configure_item_cursor (GtkToolItem *item, static void configure_item_tooltip (GtkToolItem *item) { - GtkAction *action = g_object_get_data (G_OBJECT (item), - "gtk-action"); - + GtkAction *action; + +#if GTK_CHECK_VERSION (2, 16, 0) + action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (item)); +#else + action = gtk_widget_get_action (GTK_WIDGET (item)); +#endif + if (action != NULL) { g_object_notify (G_OBJECT (action), "tooltip"); @@ -1393,6 +1364,9 @@ egg_editable_toolbar_dispose (GObject *object) priv->visibility_paths = NULL; } + g_free (priv->popup_path); + priv->popup_path = NULL; + if (priv->manager != NULL) { if (priv->visibility_id) @@ -1412,7 +1386,7 @@ egg_editable_toolbar_dispose (GObject *object) priv->model = NULL; } - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (egg_editable_toolbar_parent_class)->dispose (object); } static void @@ -1584,8 +1558,6 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->dispose = egg_editable_toolbar_dispose; object_class->set_property = egg_editable_toolbar_set_property; object_class->get_property = egg_editable_toolbar_get_property; @@ -1791,10 +1763,13 @@ new_pixbuf_from_widget (GtkWidget *widget) GdkVisual *visual; gint icon_width; gint icon_height; + GdkScreen *screen; icon_width = DEFAULT_ICON_WIDTH; - if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_default (), + screen = gtk_widget_get_screen (widget); + + if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen), GTK_ICON_SIZE_LARGE_TOOLBAR, NULL, &icon_height)) @@ -1848,7 +1823,7 @@ new_pixbuf_from_widget (GtkWidget *widget) } static GdkPixbuf * -new_separator_pixbuf () +new_separator_pixbuf (void) { GtkWidget *separator; GdkPixbuf *pixbuf;