From a5ba9a2b15d0677bc19fea2deb5c239eb851756e Mon Sep 17 00:00:00 2001 From: Felix Riemann Date: Mon, 3 Oct 2011 23:01:50 +0200 Subject: Make the URI-label in the properties dialog a button showing the folder This should avoid the label being cut-off while still being informative enough. Clicking the button opens the folder in the file manager. https://bugzilla.gnome.org/show_bug.cgi?id=614869 origin commit: https://gitlab.gnome.org/GNOME/eog/commit/81acc92 --- data/eom-image-properties-dialog.ui | 38 +++++++++++++++++++++----- src/eom-properties-dialog.c | 54 ++++++++++++++++++++++++++++++------- 2 files changed, 76 insertions(+), 16 deletions(-) diff --git a/data/eom-image-properties-dialog.ui b/data/eom-image-properties-dialog.ui index d0711d6..3c54692 100644 --- a/data/eom-image-properties-dialog.ui +++ b/data/eom-image-properties-dialog.ui @@ -1,13 +1,16 @@ - + - + False 5 Image Properties gtk-properties dialog + + + True @@ -189,6 +192,8 @@ True False start + 8 + 8 Name: right @@ -206,6 +211,8 @@ True False start + 8 + 8 Width: @@ -222,6 +229,8 @@ True False start + 8 + 8 Height: @@ -238,6 +247,8 @@ True False start + 8 + 8 Type: @@ -254,6 +265,8 @@ True False start + 8 + 8 Bytes: @@ -270,6 +283,8 @@ True False start + 8 + 8 Location: @@ -299,6 +314,8 @@ True False start + 9 + 7 True @@ -312,6 +329,8 @@ True False start + 9 + 7 True @@ -325,6 +344,8 @@ True False start + 9 + 7 True @@ -338,6 +359,8 @@ True False start + 9 + 7 True @@ -351,6 +374,8 @@ True False start + 9 + 7 True @@ -360,12 +385,11 @@ - + + button True - False - start - True - end + True + True False diff --git a/src/eom-properties-dialog.c b/src/eom-properties-dialog.c index 00bada5..299e056 100644 --- a/src/eom-properties-dialog.c +++ b/src/eom-properties-dialog.c @@ -80,7 +80,8 @@ struct _EomPropertiesDialogPrivate { GtkWidget *height_label; GtkWidget *type_label; GtkWidget *bytes_label; - GtkWidget *location_label; + GtkWidget *folder_button; + gchar *folder_button_uri; GtkWidget *created_label; GtkWidget *modified_label; #ifdef HAVE_EXIF @@ -115,9 +116,9 @@ static void pd_update_general_tab (EomPropertiesDialog *prop_dlg, EomImage *image) { - gchar *bytes_str, *dir_str, *uri_str; + gchar *bytes_str, *dir_str; gchar *width_str, *height_str; - GFile *file; + GFile *file, *parent_file; GFileInfo *file_info; const char *mime_str; char *type_str; @@ -165,15 +166,21 @@ pd_update_general_tab (EomPropertiesDialog *prop_dlg, gtk_label_set_text (GTK_LABEL (prop_dlg->priv->bytes_label), bytes_str); - uri_str = eom_image_get_uri_for_display (image); - dir_str = g_path_get_dirname (uri_str); - gtk_label_set_text (GTK_LABEL (prop_dlg->priv->location_label), - dir_str); + parent_file = g_file_get_parent (file); + if (parent_file == NULL) { + /* file is root directory itself */ + parent_file = g_object_ref (file); + } + dir_str = g_file_get_basename (parent_file); + gtk_button_set_label (GTK_BUTTON (prop_dlg->priv->folder_button), + dir_str); + g_free (prop_dlg->priv->folder_button_uri); + prop_dlg->priv->folder_button_uri = g_file_get_uri (parent_file); + g_object_unref (parent_file); g_free (type_str); g_free (bytes_str); g_free (dir_str); - g_free (uri_str); } #if HAVE_EXEMPI @@ -401,6 +408,23 @@ pd_close_button_clicked_cb (GtkButton *button, eom_dialog_hide (EOM_DIALOG (user_data)); } +static void +pd_folder_button_clicked_cb (GtkButton *button, gpointer data) +{ + EomPropertiesDialogPrivate *priv = EOM_PROPERTIES_DIALOG (data)->priv; + GdkScreen *screen; + guint32 timestamp; + + + if (!priv->folder_button_uri) + return; + + screen = gtk_widget_get_screen (GTK_WIDGET (button)); + timestamp = gtk_get_current_event_time (); + + gtk_show_uri (screen, priv->folder_button_uri, timestamp, NULL); +} + static gboolean eom_properties_dialog_page_switch (GtkNotebook *notebook, gpointer page, @@ -531,6 +555,9 @@ eom_properties_dialog_dispose (GObject *object) priv->thumbview = NULL; } + g_free (priv->folder_button_uri); + priv->folder_button_uri = NULL; + G_OBJECT_CLASS (eom_properties_dialog_parent_class)->dispose (object); } @@ -600,7 +627,7 @@ eom_properties_dialog_init (EomPropertiesDialog *prop_dlg) "height_label", &priv->height_label, "type_label", &priv->type_label, "bytes_label", &priv->bytes_label, - "location_label", &priv->location_label, + "folder_button", &priv->folder_button, "created_label", &priv->created_label, "modified_label", &priv->modified_label, #ifdef HAVE_EXIF @@ -645,6 +672,15 @@ eom_properties_dialog_init (EomPropertiesDialog *prop_dlg) G_CALLBACK (pd_close_button_clicked_cb), prop_dlg); + g_signal_connect (priv->folder_button, + "clicked", + G_CALLBACK (pd_folder_button_clicked_cb), + prop_dlg); + gtk_widget_set_tooltip_text (GTK_WIDGET (priv->folder_button), + _("Show the folder which contains this " + "file in the file manager")); + priv->folder_button_uri = NULL; + gtk_widget_set_size_request (priv->thumbnail_image, 100, 100); #ifdef HAVE_METADATA -- cgit v1.2.1