Skip to content

Commit 4185e8c

Browse files
fxriraveit65
authored andcommitted
EomPropertiesDialog: Use standard::display-name when showing the parent
This simply adapts the changes from commit fff55c6a to the properties dialog, which shares some code with the EogMetadataSidebar. origin commit: https://gitlab.gnome.org/GNOME/eog/commit/68a5a0
1 parent 0e708c5 commit 4185e8c

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

src/eom-properties-dialog.c

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,38 @@ struct _EomPropertiesDialogPrivate {
110110

111111
G_DEFINE_TYPE_WITH_PRIVATE (EomPropertiesDialog, eom_properties_dialog, GTK_TYPE_DIALOG);
112112

113+
static void
114+
parent_file_display_name_query_info_cb (GObject *source_object,
115+
GAsyncResult *res,
116+
gpointer user_data)
117+
{
118+
EomPropertiesDialog *prop_dlg = EOM_PROPERTIES_DIALOG (user_data);
119+
GFile *parent_file = G_FILE (source_object);
120+
GFileInfo *file_info;
121+
gchar *display_name;
122+
123+
124+
file_info = g_file_query_info_finish (parent_file, res, NULL);
125+
if (file_info == NULL) {
126+
display_name = g_file_get_basename (parent_file);
127+
} else {
128+
display_name = g_strdup (
129+
g_file_info_get_display_name (file_info));
130+
g_object_unref (file_info);
131+
}
132+
gtk_button_set_label (GTK_BUTTON (prop_dlg->priv->folder_button),
133+
display_name);
134+
gtk_widget_set_sensitive (prop_dlg->priv->folder_button, TRUE);
135+
136+
g_free (display_name);
137+
g_object_unref (prop_dlg);
138+
}
139+
113140
static void
114141
pd_update_general_tab (EomPropertiesDialog *prop_dlg,
115142
EomImage *image)
116143
{
117-
gchar *bytes_str, *dir_str, *dir_str_long;
144+
gchar *bytes_str, *dir_str_long;
118145
gchar *width_str, *height_str;
119146
GFile *file, *parent_file;
120147
GFileInfo *file_info;
@@ -169,21 +196,29 @@ pd_update_general_tab (EomPropertiesDialog *prop_dlg,
169196
/* file is root directory itself */
170197
parent_file = g_object_ref (file);
171198
}
172-
dir_str = g_file_get_basename (parent_file);
173-
gtk_button_set_label (GTK_BUTTON (prop_dlg->priv->folder_button),
174-
dir_str);
199+
200+
gtk_widget_set_sensitive (prop_dlg->priv->folder_button, FALSE);
201+
gtk_button_set_label (GTK_BUTTON (prop_dlg->priv->folder_button), NULL);
175202

176203
dir_str_long = g_file_get_path (parent_file);
177204
gtk_widget_set_tooltip_text (GTK_WIDGET (prop_dlg->priv->folder_button),
178205
dir_str_long);
179206

180207
g_free (prop_dlg->priv->folder_button_uri);
181208
prop_dlg->priv->folder_button_uri = g_file_get_uri (parent_file);
209+
210+
g_file_query_info_async (parent_file,
211+
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
212+
G_FILE_QUERY_INFO_NONE,
213+
G_PRIORITY_DEFAULT,
214+
NULL,
215+
parent_file_display_name_query_info_cb,
216+
g_object_ref (prop_dlg));
217+
182218
g_object_unref (parent_file);
183219

184220
g_free (type_str);
185221
g_free (bytes_str);
186-
g_free (dir_str);
187222
g_free (dir_str_long);
188223
}
189224

0 commit comments

Comments
 (0)