Skip to content
Permalink
Browse files

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
  • Loading branch information...
Felix Riemann authored and raveit65 committed Oct 3, 2011
1 parent 14a755c commit a5ba9a2b15d0677bc19fea2deb5c239eb851756e
Showing with 76 additions and 16 deletions.
  1. +31 −7 data/eom-image-properties-dialog.ui
  2. +45 −9 src/eom-properties-dialog.c
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<requires lib="gtk+" version="3.22"/>
<object class="GtkDialog" id="eom_image_properties_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Image Properties</property>
<property name="icon_name">gtk-properties</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="image-properties-dialog-vbox">
<property name="visible">True</property>
@@ -189,6 +192,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="label" translatable="yes">Name:</property>
<property name="justify">right</property>
<attributes>
@@ -206,6 +211,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="label" translatable="yes">Width:</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -222,6 +229,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="label" translatable="yes">Height:</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -238,6 +247,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="label" translatable="yes">Type:</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -254,6 +265,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="label" translatable="yes">Bytes:</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -270,6 +283,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="label" translatable="yes">Location:</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -299,6 +314,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">9</property>
<property name="margin_bottom">7</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -312,6 +329,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">9</property>
<property name="margin_bottom">7</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -325,6 +344,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">9</property>
<property name="margin_bottom">7</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -338,6 +359,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">9</property>
<property name="margin_bottom">7</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -351,6 +374,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">9</property>
<property name="margin_bottom">7</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -360,12 +385,11 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="location_label">
<object class="GtkButton" id="folder_button">
<property name="label">button</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -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

0 comments on commit a5ba9a2

Please sign in to comment.
You can’t perform that action at this time.