Skip to content

Commit a5ba9a2

Browse files
fxriraveit65
authored andcommitted
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
1 parent 14a755c commit a5ba9a2

File tree

2 files changed

+76
-16
lines changed

2 files changed

+76
-16
lines changed

data/eom-image-properties-dialog.ui

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!-- Generated with glade 3.20.0 -->
2+
<!-- Generated with glade 3.22.1 -->
33
<interface>
4-
<requires lib="gtk+" version="3.14"/>
4+
<requires lib="gtk+" version="3.22"/>
55
<object class="GtkDialog" id="eom_image_properties_dialog">
66
<property name="can_focus">False</property>
77
<property name="border_width">5</property>
88
<property name="title" translatable="yes">Image Properties</property>
99
<property name="icon_name">gtk-properties</property>
1010
<property name="type_hint">dialog</property>
11+
<child>
12+
<placeholder/>
13+
</child>
1114
<child internal-child="vbox">
1215
<object class="GtkBox" id="image-properties-dialog-vbox">
1316
<property name="visible">True</property>
@@ -189,6 +192,8 @@
189192
<property name="visible">True</property>
190193
<property name="can_focus">False</property>
191194
<property name="halign">start</property>
195+
<property name="margin_top">8</property>
196+
<property name="margin_bottom">8</property>
192197
<property name="label" translatable="yes">Name:</property>
193198
<property name="justify">right</property>
194199
<attributes>
@@ -206,6 +211,8 @@
206211
<property name="visible">True</property>
207212
<property name="can_focus">False</property>
208213
<property name="halign">start</property>
214+
<property name="margin_top">8</property>
215+
<property name="margin_bottom">8</property>
209216
<property name="label" translatable="yes">Width:</property>
210217
<attributes>
211218
<attribute name="weight" value="bold"/>
@@ -222,6 +229,8 @@
222229
<property name="visible">True</property>
223230
<property name="can_focus">False</property>
224231
<property name="halign">start</property>
232+
<property name="margin_top">8</property>
233+
<property name="margin_bottom">8</property>
225234
<property name="label" translatable="yes">Height:</property>
226235
<attributes>
227236
<attribute name="weight" value="bold"/>
@@ -238,6 +247,8 @@
238247
<property name="visible">True</property>
239248
<property name="can_focus">False</property>
240249
<property name="halign">start</property>
250+
<property name="margin_top">8</property>
251+
<property name="margin_bottom">8</property>
241252
<property name="label" translatable="yes">Type:</property>
242253
<attributes>
243254
<attribute name="weight" value="bold"/>
@@ -254,6 +265,8 @@
254265
<property name="visible">True</property>
255266
<property name="can_focus">False</property>
256267
<property name="halign">start</property>
268+
<property name="margin_top">8</property>
269+
<property name="margin_bottom">8</property>
257270
<property name="label" translatable="yes">Bytes:</property>
258271
<attributes>
259272
<attribute name="weight" value="bold"/>
@@ -270,6 +283,8 @@
270283
<property name="visible">True</property>
271284
<property name="can_focus">False</property>
272285
<property name="halign">start</property>
286+
<property name="margin_top">8</property>
287+
<property name="margin_bottom">8</property>
273288
<property name="label" translatable="yes">Location:</property>
274289
<attributes>
275290
<attribute name="weight" value="bold"/>
@@ -299,6 +314,8 @@
299314
<property name="visible">True</property>
300315
<property name="can_focus">False</property>
301316
<property name="halign">start</property>
317+
<property name="margin_top">9</property>
318+
<property name="margin_bottom">7</property>
302319
<property name="selectable">True</property>
303320
</object>
304321
<packing>
@@ -312,6 +329,8 @@
312329
<property name="visible">True</property>
313330
<property name="can_focus">False</property>
314331
<property name="halign">start</property>
332+
<property name="margin_top">9</property>
333+
<property name="margin_bottom">7</property>
315334
<property name="selectable">True</property>
316335
</object>
317336
<packing>
@@ -325,6 +344,8 @@
325344
<property name="visible">True</property>
326345
<property name="can_focus">False</property>
327346
<property name="halign">start</property>
347+
<property name="margin_top">9</property>
348+
<property name="margin_bottom">7</property>
328349
<property name="selectable">True</property>
329350
</object>
330351
<packing>
@@ -338,6 +359,8 @@
338359
<property name="visible">True</property>
339360
<property name="can_focus">False</property>
340361
<property name="halign">start</property>
362+
<property name="margin_top">9</property>
363+
<property name="margin_bottom">7</property>
341364
<property name="selectable">True</property>
342365
</object>
343366
<packing>
@@ -351,6 +374,8 @@
351374
<property name="visible">True</property>
352375
<property name="can_focus">False</property>
353376
<property name="halign">start</property>
377+
<property name="margin_top">9</property>
378+
<property name="margin_bottom">7</property>
354379
<property name="selectable">True</property>
355380
</object>
356381
<packing>
@@ -360,12 +385,11 @@
360385
</packing>
361386
</child>
362387
<child>
363-
<object class="GtkLabel" id="location_label">
388+
<object class="GtkButton" id="folder_button">
389+
<property name="label">button</property>
364390
<property name="visible">True</property>
365-
<property name="can_focus">False</property>
366-
<property name="halign">start</property>
367-
<property name="selectable">True</property>
368-
<property name="ellipsize">end</property>
391+
<property name="can_focus">True</property>
392+
<property name="receives_default">True</property>
369393
</object>
370394
<packing>
371395
<property name="expand">False</property>

src/eom-properties-dialog.c

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ struct _EomPropertiesDialogPrivate {
8080
GtkWidget *height_label;
8181
GtkWidget *type_label;
8282
GtkWidget *bytes_label;
83-
GtkWidget *location_label;
83+
GtkWidget *folder_button;
84+
gchar *folder_button_uri;
8485
GtkWidget *created_label;
8586
GtkWidget *modified_label;
8687
#ifdef HAVE_EXIF
@@ -115,9 +116,9 @@ static void
115116
pd_update_general_tab (EomPropertiesDialog *prop_dlg,
116117
EomImage *image)
117118
{
118-
gchar *bytes_str, *dir_str, *uri_str;
119+
gchar *bytes_str, *dir_str;
119120
gchar *width_str, *height_str;
120-
GFile *file;
121+
GFile *file, *parent_file;
121122
GFileInfo *file_info;
122123
const char *mime_str;
123124
char *type_str;
@@ -165,15 +166,21 @@ pd_update_general_tab (EomPropertiesDialog *prop_dlg,
165166

166167
gtk_label_set_text (GTK_LABEL (prop_dlg->priv->bytes_label), bytes_str);
167168

168-
uri_str = eom_image_get_uri_for_display (image);
169-
dir_str = g_path_get_dirname (uri_str);
170-
gtk_label_set_text (GTK_LABEL (prop_dlg->priv->location_label),
171-
dir_str);
169+
parent_file = g_file_get_parent (file);
170+
if (parent_file == NULL) {
171+
/* file is root directory itself */
172+
parent_file = g_object_ref (file);
173+
}
174+
dir_str = g_file_get_basename (parent_file);
175+
gtk_button_set_label (GTK_BUTTON (prop_dlg->priv->folder_button),
176+
dir_str);
177+
g_free (prop_dlg->priv->folder_button_uri);
178+
prop_dlg->priv->folder_button_uri = g_file_get_uri (parent_file);
179+
g_object_unref (parent_file);
172180

173181
g_free (type_str);
174182
g_free (bytes_str);
175183
g_free (dir_str);
176-
g_free (uri_str);
177184
}
178185

179186
#if HAVE_EXEMPI
@@ -401,6 +408,23 @@ pd_close_button_clicked_cb (GtkButton *button,
401408
eom_dialog_hide (EOM_DIALOG (user_data));
402409
}
403410

411+
static void
412+
pd_folder_button_clicked_cb (GtkButton *button, gpointer data)
413+
{
414+
EomPropertiesDialogPrivate *priv = EOM_PROPERTIES_DIALOG (data)->priv;
415+
GdkScreen *screen;
416+
guint32 timestamp;
417+
418+
419+
if (!priv->folder_button_uri)
420+
return;
421+
422+
screen = gtk_widget_get_screen (GTK_WIDGET (button));
423+
timestamp = gtk_get_current_event_time ();
424+
425+
gtk_show_uri (screen, priv->folder_button_uri, timestamp, NULL);
426+
}
427+
404428
static gboolean
405429
eom_properties_dialog_page_switch (GtkNotebook *notebook,
406430
gpointer page,
@@ -531,6 +555,9 @@ eom_properties_dialog_dispose (GObject *object)
531555
priv->thumbview = NULL;
532556
}
533557

558+
g_free (priv->folder_button_uri);
559+
priv->folder_button_uri = NULL;
560+
534561
G_OBJECT_CLASS (eom_properties_dialog_parent_class)->dispose (object);
535562
}
536563

@@ -600,7 +627,7 @@ eom_properties_dialog_init (EomPropertiesDialog *prop_dlg)
600627
"height_label", &priv->height_label,
601628
"type_label", &priv->type_label,
602629
"bytes_label", &priv->bytes_label,
603-
"location_label", &priv->location_label,
630+
"folder_button", &priv->folder_button,
604631
"created_label", &priv->created_label,
605632
"modified_label", &priv->modified_label,
606633
#ifdef HAVE_EXIF
@@ -645,6 +672,15 @@ eom_properties_dialog_init (EomPropertiesDialog *prop_dlg)
645672
G_CALLBACK (pd_close_button_clicked_cb),
646673
prop_dlg);
647674

675+
g_signal_connect (priv->folder_button,
676+
"clicked",
677+
G_CALLBACK (pd_folder_button_clicked_cb),
678+
prop_dlg);
679+
gtk_widget_set_tooltip_text (GTK_WIDGET (priv->folder_button),
680+
_("Show the folder which contains this "
681+
"file in the file manager"));
682+
priv->folder_button_uri = NULL;
683+
648684
gtk_widget_set_size_request (priv->thumbnail_image, 100, 100);
649685

650686
#ifdef HAVE_METADATA

0 commit comments

Comments
 (0)