From 8d2169d463ad00cf3e8ef74ec35b1651ea1dd634 Mon Sep 17 00:00:00 2001 From: infirit Date: Mon, 28 Jul 2014 12:45:17 +0200 Subject: Workaround GtkIconView breakage By moving initialization code to the constructed() method. See Eog #639139. https://bugzilla.gnome.org/show_bug.cgi?id=639139 Based on eog commit 0b98b8cc1903142112dd67ecde6a914583087da5 From Claudio Saavedra --- src/eom-thumb-view.c | 137 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 51 deletions(-) (limited to 'src/eom-thumb-view.c') diff --git a/src/eom-thumb-view.c b/src/eom-thumb-view.c index eac2922..0c35382 100644 --- a/src/eom-thumb-view.c +++ b/src/eom-thumb-view.c @@ -51,6 +51,30 @@ static EomImage* eom_thumb_view_get_image_from_path (EomThumbView *thumbvie static void eom_thumb_view_popup_menu (EomThumbView *widget, GdkEventButton *event); +static gboolean +thumbview_on_query_tooltip_cb (GtkWidget *widget, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip *tooltip, + gpointer user_data); +static void +thumbview_on_parent_set_cb (GtkWidget *widget, +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *old_parent, +#else + GtkObject *oldparent, +#endif + gpointer user_data); + +static void +thumbview_on_drag_data_get_cb (GtkWidget *widget, + GdkDragContext *drag_context, + GtkSelectionData *data, + guint info, + guint time, + gpointer user_data); + struct _EomThumbViewPrivate { gint start_thumb; /* the first visible thumbnail */ gint end_thumb; /* the last visible thumbnail */ @@ -60,6 +84,67 @@ struct _EomThumbViewPrivate { /* Drag 'n Drop */ +static void +eom_thumb_view_constructed (GObject *object) +{ + EomThumbView *thumbview; + + if (G_OBJECT_CLASS (eom_thumb_view_parent_class)->constructed) + G_OBJECT_CLASS (eom_thumb_view_parent_class)->constructed (object); + + thumbview = EOM_THUMB_VIEW (object); + + thumbview->priv->pixbuf_cell = gtk_cell_renderer_pixbuf_new (); + + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (thumbview), + thumbview->priv->pixbuf_cell, + FALSE); + + g_object_set (thumbview->priv->pixbuf_cell, + "follow-state", FALSE, + "height", 100, + "width", 115, + "yalign", 0.5, + "xalign", 0.5, + NULL); + + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (thumbview), + thumbview->priv->pixbuf_cell, + "pixbuf", EOM_LIST_STORE_THUMBNAIL, + NULL); + + gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (thumbview), + GTK_SELECTION_MULTIPLE); + + gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (thumbview), + EOM_THUMB_VIEW_SPACING); + + gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (thumbview), + EOM_THUMB_VIEW_SPACING); + + g_object_set (thumbview, "has-tooltip", TRUE, NULL); + + g_signal_connect (thumbview, + "query-tooltip", + G_CALLBACK (thumbview_on_query_tooltip_cb), + NULL); + + thumbview->priv->start_thumb = 0; + thumbview->priv->end_thumb = 0; + thumbview->priv->menu = NULL; + + g_signal_connect (G_OBJECT (thumbview), "parent-set", + G_CALLBACK (thumbview_on_parent_set_cb), NULL); + + gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (thumbview), 0, + NULL, 0, + GDK_ACTION_COPY); + gtk_drag_source_add_uri_targets (GTK_WIDGET (thumbview)); + + g_signal_connect (G_OBJECT (thumbview), "drag-data-get", + G_CALLBACK (thumbview_on_drag_data_get_cb), NULL); +} + static void eom_thumb_view_finalize (GObject *object) { @@ -97,7 +182,7 @@ eom_thumb_view_class_init (EomThumbViewClass *class) #else GtkObjectClass *object_class = GTK_OBJECT_CLASS (class); #endif - + gobject_class->constructed = eom_thumb_view_constructed; gobject_class->finalize = eom_thumb_view_finalize; #if GTK_CHECK_VERSION(3, 0, 0) widget_class->destroy = eom_thumb_view_destroy; @@ -519,56 +604,6 @@ static void eom_thumb_view_init (EomThumbView *thumbview) { thumbview->priv = EOM_THUMB_VIEW_GET_PRIVATE (thumbview); - - thumbview->priv->pixbuf_cell = gtk_cell_renderer_pixbuf_new (); - - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (thumbview), - thumbview->priv->pixbuf_cell, - FALSE); - - g_object_set (thumbview->priv->pixbuf_cell, - "follow-state", FALSE, - "height", 100, - "width", 115, - "yalign", 0.5, - "xalign", 0.5, - NULL); - - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (thumbview), - thumbview->priv->pixbuf_cell, - "pixbuf", EOM_LIST_STORE_THUMBNAIL, - NULL); - - gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (thumbview), - GTK_SELECTION_MULTIPLE); - - gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (thumbview), - EOM_THUMB_VIEW_SPACING); - - gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (thumbview), - EOM_THUMB_VIEW_SPACING); - - g_object_set (thumbview, "has-tooltip", TRUE, NULL); - - g_signal_connect (thumbview, - "query-tooltip", - G_CALLBACK (thumbview_on_query_tooltip_cb), - NULL); - - thumbview->priv->start_thumb = 0; - thumbview->priv->end_thumb = 0; - thumbview->priv->menu = NULL; - - g_signal_connect (G_OBJECT (thumbview), "parent-set", - G_CALLBACK (thumbview_on_parent_set_cb), NULL); - - gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (thumbview), 0, - NULL, 0, - GDK_ACTION_COPY); - gtk_drag_source_add_uri_targets (GTK_WIDGET (thumbview)); - - g_signal_connect (G_OBJECT (thumbview), "drag-data-get", - G_CALLBACK (thumbview_on_drag_data_get_cb), NULL); } /** -- cgit v1.2.1