From 2f3549b038f5dfab747c4aa104d2135fb1ae7f96 Mon Sep 17 00:00:00 2001 From: Crispin Flowerday Date: Sat, 22 May 2004 10:46:37 +0000 Subject: Set the drag icon on realize, otherwise the current icon theme isn't used, 2004-05-22 Crispin Flowerday * libegg/toolbareditor/egg-toolbar-editor.c (event_box_realize_cb), (editor_create_item): Set the drag icon on realize, otherwise the current icon theme isn't used, and it falls back to the default theme. --- lib/egg/egg-toolbar-editor.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'lib') diff --git a/lib/egg/egg-toolbar-editor.c b/lib/egg/egg-toolbar-editor.c index 93b0a7928..031bb118a 100755 --- a/lib/egg/egg-toolbar-editor.c +++ b/lib/egg/egg-toolbar-editor.c @@ -419,9 +419,28 @@ set_drag_cursor (GtkWidget *widget) } static void -event_box_realize_cb (GtkWidget *widget) +event_box_realize_cb (GtkWidget *widget, GtkImage *icon) { - set_drag_cursor (widget); + GtkImageType type; + + set_drag_cursor (widget); + + type = gtk_image_get_storage_type (icon); + if (type == GTK_IMAGE_STOCK) + { + gchar *stock_id; + GdkPixbuf *pixbuf; + gtk_image_get_stock (icon, &stock_id, NULL); + pixbuf = gtk_widget_render_icon (widget, stock_id, + GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); + gtk_drag_source_set_icon_pixbuf (widget, pixbuf); + g_object_unref (pixbuf); + } + else if (type == GTK_IMAGE_PIXBUF) + { + GdkPixbuf *pixbuf = gtk_image_get_pixbuf (icon); + gtk_drag_source_set_icon_pixbuf (widget, pixbuf); + } } static GtkWidget * @@ -434,7 +453,6 @@ editor_create_item (EggToolbarEditor *editor, GtkWidget *vbox; GtkWidget *label; gchar *label_no_mnemonic = NULL; - GtkImageType type; event_box = gtk_event_box_new (); gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE); @@ -447,7 +465,7 @@ editor_create_item (EggToolbarEditor *editor, g_signal_connect (event_box, "drag_data_delete", G_CALLBACK (editor_drag_data_delete_cb), editor); g_signal_connect_after (event_box, "realize", - G_CALLBACK (event_box_realize_cb), NULL); + G_CALLBACK (event_box_realize_cb), icon); if (action == GDK_ACTION_MOVE) { @@ -457,23 +475,6 @@ editor_create_item (EggToolbarEditor *editor, G_CALLBACK (drag_end_cb), NULL); } - type = gtk_image_get_storage_type (icon); - if (type == GTK_IMAGE_STOCK) - { - gchar *stock_id; - GdkPixbuf *pixbuf; - gtk_image_get_stock (icon, &stock_id, NULL); - pixbuf = gtk_widget_render_icon (event_box, stock_id, - GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); - gtk_drag_source_set_icon_pixbuf (event_box, pixbuf); - g_object_unref (pixbuf); - } - else if (type == GTK_IMAGE_PIXBUF) - { - GdkPixbuf *pixbuf = gtk_image_get_pixbuf (icon); - gtk_drag_source_set_icon_pixbuf (event_box, pixbuf); - } - vbox = gtk_vbox_new (0, FALSE); gtk_widget_show (vbox); gtk_container_add (GTK_CONTAINER (event_box), vbox); -- cgit v1.2.3