3
3
* Copyright (c) 2005-2007 Benedikt Meurer <benny@xfce.org>
4
4
* Copyright (c) 2009-2011 Jannis Pohlmann <jannis@xfce.org>
5
* Copyright (c) 2012 Nick Schermer <nick@xfce.org>
6
* This program is free software; you can redistribute it and/or
7
* This program is free software; you can redistribute it and/or
7
8
* modify it under the terms of the GNU General Public License as
8
* published by the Free Software Foundation; either version 2 of
9
* published by the Free Software Foundation; either version 2 of
9
10
* the License, or (at your option) any later version.
11
12
* This program is distributed in the hope that it will be useful,
12
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public
17
* License along with this program; if not, write to the Free
17
* You should have received a copy of the GNU General Public
18
* License along with this program; if not, write to the Free
18
19
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
20
* Boston, MA 02110-1301, USA.
246
First box (icon, name)
250
First box (icon, name) for 1 file
248
box = gtk_hbox_new (FALSE, 6);
249
gtk_table_attach (GTK_TABLE (table), box, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 3);
250
gtk_widget_show (box);
252
dialog->single_box = gtk_hbox_new (FALSE, 6);
253
gtk_table_attach (GTK_TABLE (table), dialog->single_box, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 3);
252
255
dialog->icon_button = gtk_button_new ();
253
256
g_signal_connect (G_OBJECT (dialog->icon_button), "clicked", G_CALLBACK (thunar_properties_dialog_icon_button_clicked), dialog);
254
gtk_box_pack_start (GTK_BOX (box), dialog->icon_button, FALSE, TRUE, 0);
257
gtk_box_pack_start (GTK_BOX (dialog->single_box), dialog->icon_button, FALSE, TRUE, 0);
255
258
gtk_widget_show (dialog->icon_button);
257
260
dialog->icon_image = thunar_image_new ();
258
gtk_box_pack_start (GTK_BOX (box), dialog->icon_image, FALSE, TRUE, 0);
261
gtk_box_pack_start (GTK_BOX (dialog->single_box), dialog->icon_image, FALSE, TRUE, 0);
259
262
gtk_widget_show (dialog->icon_image);
261
label = gtk_label_new (_("Name:"));
264
label = gtk_label_new_with_mnemonic (_("_Name:"));
262
265
gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ());
263
266
gtk_misc_set_alignment (GTK_MISC (label), 1.0f, 0.5f);
264
gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0);
267
gtk_box_pack_end (GTK_BOX (dialog->single_box), label, TRUE, TRUE, 0);
265
268
gtk_widget_show (label);
267
270
dialog->name_entry = g_object_new (GTK_TYPE_ENTRY, "editable", FALSE, NULL);
268
g_signal_connect (G_OBJECT (dialog->name_entry), "activate", G_CALLBACK (thunar_properties_dialog_activate), dialog);
269
g_signal_connect (G_OBJECT (dialog->name_entry), "focus-out-event", G_CALLBACK (thunar_properties_dialog_focus_out_event), dialog);
271
gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->name_entry);
272
g_signal_connect (G_OBJECT (dialog->name_entry), "activate", G_CALLBACK (thunar_properties_dialog_name_activate), dialog);
273
g_signal_connect (G_OBJECT (dialog->name_entry), "focus-out-event", G_CALLBACK (thunar_properties_dialog_name_focus_out_event), dialog);
270
274
gtk_table_attach (GTK_TABLE (table), dialog->name_entry, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
271
gtk_widget_show (dialog->name_entry);
275
exo_binding_new (G_OBJECT (dialog->single_box), "visible", G_OBJECT (dialog->name_entry), "visible");
276
spacer = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 12, NULL);
277
gtk_table_attach (GTK_TABLE (table), spacer, 0, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 3);
278
gtk_widget_show (spacer);
281
First box (icon, name) for multiple files
283
box = gtk_hbox_new (FALSE, 6);
284
gtk_table_attach (GTK_TABLE (table), box, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 3);
285
exo_binding_new_with_negation (G_OBJECT (dialog->single_box), "visible", G_OBJECT (box), "visible");
287
image = gtk_image_new_from_icon_name ("text-x-generic", GTK_ICON_SIZE_DIALOG);
288
gtk_box_pack_start (GTK_BOX (box), image, FALSE, TRUE, 0);
289
gtk_widget_show (image);
291
label = gtk_label_new (_("Names:"));
292
gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ());
293
gtk_misc_set_alignment (GTK_MISC (label), 1.0f, 0.5f);
294
gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0);
295
gtk_widget_show (label);
297
dialog->names_label = gtk_label_new ("");
298
gtk_misc_set_alignment (GTK_MISC (dialog->names_label), 0.0f, 0.5f);
299
gtk_table_attach (GTK_TABLE (table), dialog->names_label, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
300
gtk_label_set_ellipsize (GTK_LABEL (dialog->names_label), PANGO_ELLIPSIZE_END);
301
gtk_label_set_selectable (GTK_LABEL (dialog->names_label), TRUE);
302
exo_binding_new (G_OBJECT (box), "visible", G_OBJECT (dialog->names_label), "visible");
308
label = gtk_label_new (_("Open With:"));
332
label = gtk_label_new_with_mnemonic (_("_Open With:"));
309
333
gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ());
310
334
gtk_misc_set_alignment (GTK_MISC (label), 1.0f, 0.5f);
311
335
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 3);
312
336
gtk_widget_show (label);
314
338
dialog->openwith_chooser = thunar_chooser_button_new ();
315
exo_binding_new (G_OBJECT (dialog), "file", G_OBJECT (dialog->openwith_chooser), "file");
339
gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->openwith_chooser);
316
340
exo_binding_new (G_OBJECT (dialog->openwith_chooser), "visible", G_OBJECT (label), "visible");
317
341
gtk_table_attach (GTK_TABLE (table), dialog->openwith_chooser, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
318
342
gtk_widget_show (dialog->openwith_chooser);
378
label = gtk_label_new (_("Location:"));
379
gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ());
380
gtk_misc_set_alignment (GTK_MISC (label), 1.0f, 0.5f);
381
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 3);
382
gtk_widget_show (label);
384
dialog->location_label = g_object_new (GTK_TYPE_LABEL, "ellipsize", PANGO_ELLIPSIZE_START, "xalign", 0.0f, NULL);
385
gtk_label_set_selectable (GTK_LABEL (dialog->location_label), TRUE);
386
exo_binding_new (G_OBJECT (dialog->location_label), "visible", G_OBJECT (label), "visible");
387
gtk_table_attach (GTK_TABLE (table), dialog->location_label, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
388
gtk_widget_show (dialog->location_label);
355
393
spacer = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 12, NULL);
356
394
gtk_table_attach (GTK_TABLE (table), spacer, 0, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 3);
480
518
label = gtk_label_new (_("Emblems"));
481
519
chooser = thunar_emblem_chooser_new ();
482
exo_binding_new (G_OBJECT (dialog), "file", G_OBJECT (chooser), "file");
520
exo_binding_new (G_OBJECT (dialog), "files", G_OBJECT (chooser), "files");
483
521
gtk_notebook_append_page (GTK_NOTEBOOK (dialog->notebook), chooser, label);
484
522
gtk_widget_show (chooser);
485
523
gtk_widget_show (label);
489
526
Permissions chooser
491
528
label = gtk_label_new (_("Permissions"));
492
529
dialog->permissions_chooser = thunar_permissions_chooser_new ();
493
exo_binding_new (G_OBJECT (dialog), "file", G_OBJECT (dialog->permissions_chooser), "file");
530
exo_binding_new (G_OBJECT (dialog), "files", G_OBJECT (dialog->permissions_chooser), "files");
494
531
gtk_notebook_append_page (GTK_NOTEBOOK (dialog->notebook), dialog->permissions_chooser, label);
495
532
gtk_widget_show (dialog->permissions_chooser);
496
533
gtk_widget_show (label);
499
/* place the initial focus on the name entry widget */
500
gtk_widget_grab_focus (dialog->name_entry);
674
thunar_properties_dialog_activate (GtkWidget *entry,
675
ThunarPropertiesDialog *dialog)
692
thunar_properties_dialog_name_activate (GtkWidget *entry,
693
ThunarPropertiesDialog *dialog)
677
695
const gchar *old_name;
700
_thunar_return_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog));
681
702
/* check if we still have a valid file and if the user is allowed to rename */
682
if (G_UNLIKELY (dialog->file == NULL || !GTK_WIDGET_SENSITIVE (dialog->name_entry)))
703
if (G_UNLIKELY (!gtk_widget_get_sensitive (dialog->name_entry)
704
|| g_list_length (dialog->files) != 1))
685
707
/* determine new and old name */
708
file = THUNAR_FILE (dialog->files->data);
686
709
new_name = gtk_editable_get_chars (GTK_EDITABLE (dialog->name_entry), 0, -1);
687
old_name = thunar_file_get_display_name (dialog->file);
710
old_name = thunar_file_get_display_name (file);
688
711
if (g_utf8_collate (new_name, old_name) != 0)
690
job = thunar_io_jobs_rename_file (dialog->file, new_name);
713
job = thunar_io_jobs_rename_file (file, new_name);
693
716
g_signal_connect (job, "error", G_CALLBACK (thunar_properties_dialog_rename_error), dialog);
713
736
thunar_properties_dialog_icon_button_clicked (GtkWidget *button,
714
737
ThunarPropertiesDialog *dialog)
741
const gchar *custom_icon;
722
746
_thunar_return_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog));
723
747
_thunar_return_if_fail (GTK_IS_BUTTON (button));
748
_thunar_return_if_fail (g_list_length (dialog->files) == 1);
725
750
/* make sure we still have a file */
726
if (G_UNLIKELY (dialog->file == NULL))
751
if (G_UNLIKELY (dialog->files == NULL))
754
file = THUNAR_FILE (dialog->files->data);
729
756
/* allocate the icon chooser */
730
title = g_strdup_printf (_("Select an Icon for \"%s\""), thunar_file_get_display_name (dialog->file));
757
title = g_strdup_printf (_("Select an Icon for \"%s\""), thunar_file_get_display_name (file));
731
758
chooser = exo_icon_chooser_dialog_new (title, GTK_WINDOW (dialog),
732
759
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
733
760
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
739
766
/* use the custom_icon of the file as default */
740
custom_icon = thunar_file_get_custom_icon (dialog->file);
767
custom_icon = thunar_file_get_custom_icon (file);
741
768
if (G_LIKELY (custom_icon != NULL && *custom_icon != '\0'))
742
769
exo_icon_chooser_dialog_set_icon (EXO_ICON_CHOOSER_DIALOG (chooser), custom_icon);
743
g_free (custom_icon);
745
771
/* run the icon chooser dialog and make sure the dialog still has a file */
746
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT && dialog->file != NULL)
772
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT && file != NULL)
748
774
/* determine the selected icon and use it for the file */
749
775
icon = exo_icon_chooser_dialog_get_icon (EXO_ICON_CHOOSER_DIALOG (chooser));
750
if (!thunar_file_set_custom_icon (dialog->file, icon, &err))
776
if (!thunar_file_set_custom_icon (file, icon, &err))
752
778
/* hide the icon chooser dialog first */
753
779
gtk_widget_hide (chooser);
755
781
/* tell the user that we failed to change the icon of the .desktop file */
756
thunar_dialogs_show_error (GTK_WIDGET (dialog), err, _("Failed to change icon of \"%s\""), thunar_file_get_display_name (dialog->file));
782
thunar_dialogs_show_error (GTK_WIDGET (dialog), err,
783
_("Failed to change icon of \"%s\""),
784
thunar_file_get_display_name (file));
757
785
g_error_free (err);
823
847
const gchar *name;
824
848
const gchar *path;
830
853
gchar *display_name;
833
856
gchar *volume_name;
858
ThunarFile *parent_file;
859
gboolean show_chooser;
835
861
_thunar_return_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog));
836
_thunar_return_if_fail (THUNAR_IS_FILE (dialog->file));
838
/* cancel any pending thumbnail requests */
839
if (dialog->thumbnail_request > 0)
841
thunar_thumbnailer_dequeue (dialog->thumbnailer, dialog->thumbnail_request);
842
dialog->thumbnail_request = 0;
845
if (dialog->file != NULL)
847
/* queue a new thumbnail request */
848
thunar_thumbnailer_queue_file (dialog->thumbnailer, dialog->file,
849
&dialog->thumbnail_request);
862
_thunar_return_if_fail (g_list_length (dialog->files) == 1);
863
_thunar_return_if_fail (THUNAR_IS_FILE (dialog->files->data));
865
/* whether the dialog shows a single file or a group of files */
866
file = THUNAR_FILE (dialog->files->data);
868
/* hide the permissions chooser for trashed files */
869
gtk_widget_set_visible (dialog->permissions_chooser, !thunar_file_is_trashed (file));
871
/* queue a new thumbnail request */
872
thunar_thumbnailer_queue_file (dialog->thumbnailer, file,
873
&dialog->thumbnail_request);
852
875
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (dialog)));
853
876
icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme);
856
879
g_object_get (G_OBJECT (dialog->preferences), "misc-date-style", &date_style, NULL);
858
881
/* update the properties dialog title */
859
str = g_strdup_printf (_("%s - Properties"), thunar_file_get_display_name (dialog->file));
882
str = g_strdup_printf (_("%s - Properties"), thunar_file_get_display_name (file));
860
883
gtk_window_set_title (GTK_WINDOW (dialog), str);
863
886
/* update the preview image */
864
thunar_image_set_file (THUNAR_IMAGE (dialog->icon_image), dialog->file);
887
thunar_image_set_file (THUNAR_IMAGE (dialog->icon_image), file);
866
889
/* check if the icon may be changed (only for writable .desktop files) */
867
890
g_object_ref (G_OBJECT (dialog->icon_image));
868
891
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (dialog->icon_image)), dialog->icon_image);
869
if (thunar_file_is_writable (dialog->file) && thunar_file_is_desktop_file (dialog->file))
892
if (thunar_file_is_writable (file)
893
&& thunar_file_is_desktop_file (file, NULL))
871
895
gtk_container_add (GTK_CONTAINER (dialog->icon_button), dialog->icon_image);
872
896
gtk_widget_show (dialog->icon_button);
1081
thunar_properties_dialog_update_multiple (ThunarPropertiesDialog *dialog)
1084
GString *names_string;
1085
gboolean first_file = TRUE;
1087
const gchar *content_type = NULL;
1090
GVolume *volume = NULL;
1091
GVolume *tmp_volume;
1094
gchar *display_name;
1095
ThunarFile *parent_file = NULL;
1096
ThunarFile *tmp_parent;
1097
gboolean has_trashed_files = FALSE;
1099
_thunar_return_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog));
1100
_thunar_return_if_fail (g_list_length (dialog->files) > 1);
1102
/* update the properties dialog title */
1103
gtk_window_set_title (GTK_WINDOW (dialog), _("Properties"));
1105
/* widgets not used with > 1 file selected */
1106
gtk_widget_hide (dialog->deleted_label);
1107
gtk_widget_hide (dialog->modified_label);
1108
gtk_widget_hide (dialog->accessed_label);
1109
gtk_widget_hide (dialog->freespace_label);
1110
gtk_widget_hide (dialog->origin_label);
1111
gtk_widget_hide (dialog->openwith_chooser);
1112
gtk_widget_hide (dialog->link_label);
1114
names_string = g_string_new (NULL);
1116
/* collect data of the selected files */
1117
for (lp = dialog->files; lp != NULL; lp = lp->next)
1119
_thunar_assert (THUNAR_IS_FILE (lp->data));
1120
file = THUNAR_FILE (lp->data);
1122
/* append the name */
1124
g_string_append (names_string, ", ");
1125
g_string_append (names_string, thunar_file_get_display_name (file));
1127
/* update the content type */
1130
content_type = thunar_file_get_content_type (file);
1132
else if (content_type != NULL)
1134
/* check the types match */
1135
tmp = thunar_file_get_content_type (file);
1136
if (tmp == NULL || !g_content_type_equals (content_type, tmp))
1137
content_type = NULL;
1140
/* check if all selected files are on the same volume */
1141
tmp_volume = thunar_file_get_volume (file);
1144
volume = tmp_volume;
1146
else if (tmp_volume != NULL)
1148
/* we only display information if the files are on the same volume */
1149
if (tmp_volume != volume)
1152
g_object_unref (G_OBJECT (volume));
1156
g_object_unref (G_OBJECT (tmp_volume));
1159
/* check if all files have the same parent */
1160
tmp_parent = thunar_file_get_parent (file, NULL);
1163
parent_file = tmp_parent;
1165
else if (tmp_parent != NULL)
1167
/* we only display the location if they are all equal */
1168
if (!g_file_equal (thunar_file_get_file (parent_file), thunar_file_get_file (tmp_parent)))
1170
if (parent_file != NULL)
1171
g_object_unref (G_OBJECT (parent_file));
1175
g_object_unref (G_OBJECT (tmp_parent));
1178
if (thunar_file_is_trashed (file))
1179
has_trashed_files = TRUE;
1184
/* set the labels string */
1185
gtk_label_set_text (GTK_LABEL (dialog->names_label), names_string->str);
1186
gtk_widget_set_tooltip_text (dialog->names_label, names_string->str);
1187
g_string_free (names_string, TRUE);
1189
/* hide the permissions chooser for trashed files */
1190
gtk_widget_set_visible (dialog->permissions_chooser, !has_trashed_files);
1192
/* update the content type */
1193
if (content_type != NULL
1194
&& !g_content_type_equals (content_type, "inode/symlink"))
1196
str = g_content_type_get_description (content_type);
1197
gtk_widget_set_tooltip_text (dialog->kind_ebox, content_type);
1198
gtk_label_set_text (GTK_LABEL (dialog->kind_label), str);
1203
gtk_label_set_text (GTK_LABEL (dialog->kind_label), _("mixed"));
1206
/* update the file or folder location (parent) */
1207
if (G_UNLIKELY (parent_file != NULL))
1209
display_name = g_file_get_parse_name (thunar_file_get_file (parent_file));
1210
gtk_label_set_text (GTK_LABEL (dialog->location_label), display_name);
1211
gtk_widget_show (dialog->location_label);
1212
g_object_unref (G_OBJECT (parent_file));
1213
g_free (display_name);
1217
gtk_widget_hide (dialog->location_label);
1220
/* update the volume */
1221
if (G_LIKELY (volume != NULL))
1223
gicon = g_volume_get_icon (volume);
1224
gtk_image_set_from_gicon (GTK_IMAGE (dialog->volume_image), gicon, GTK_ICON_SIZE_MENU);
1225
if (G_LIKELY (gicon != NULL))
1226
g_object_unref (gicon);
1228
volume_name = g_volume_get_name (volume);
1229
gtk_label_set_text (GTK_LABEL (dialog->volume_label), volume_name);
1230
gtk_widget_show (dialog->volume_label);
1231
g_free (volume_name);
1233
g_object_unref (G_OBJECT (volume));
1237
gtk_widget_hide (dialog->volume_label);
1244
thunar_properties_dialog_update (ThunarPropertiesDialog *dialog)
1246
_thunar_return_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog));
1247
_thunar_return_if_fail (dialog->files != NULL);
1249
/* cancel any pending thumbnail requests */
1250
if (dialog->thumbnail_request > 0)
1252
thunar_thumbnailer_dequeue (dialog->thumbnailer, dialog->thumbnail_request);
1253
dialog->thumbnail_request = 0;
1256
if (dialog->files->next == NULL)
1258
/* show single file name box */
1259
gtk_widget_show (dialog->single_box);
1261
/* update the properties for a dialog showing 1 file */
1262
thunar_properties_dialog_update_single (dialog);
1264
/* place the initial focus on the name entry widget */
1265
gtk_widget_grab_focus (dialog->name_entry);
1269
/* show multiple files box */
1270
gtk_widget_hide (dialog->single_box);
1272
/* update the properties for a dialog showing multiple files */
1273
thunar_properties_dialog_update_multiple (dialog);
1039
1280
* thunar_properties_dialog_new:
1281
* @parent: transient window or NULL;
1041
1283
* Allocates a new #ThunarPropertiesDialog instance,
1042
1284
* that is not associated with any #ThunarFile.
1048
thunar_properties_dialog_new (void)
1290
thunar_properties_dialog_new (GtkWindow *parent)
1050
return g_object_new (THUNAR_TYPE_PROPERTIES_DIALOG, NULL);
1292
_thunar_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
1293
return g_object_new (THUNAR_TYPE_PROPERTIES_DIALOG,
1294
"transient-for", parent,
1295
"destroy-with-parent", parent != NULL,
1056
* thunar_properties_dialog_get_file:
1302
* thunar_properties_dialog_get_files:
1057
1303
* @dialog : a #ThunarPropertiesDialog.
1059
1305
* Returns the #ThunarFile currently being displayed
1060
1306
* by @dialog or %NULL if @dialog doesn't display
1061
1307
* any file right now.
1063
* Return value: the #ThunarFile displayed by @dialog
1309
* Return value: list of #ThunarFile's displayed by @dialog
1067
thunar_properties_dialog_get_file (ThunarPropertiesDialog *dialog)
1313
thunar_properties_dialog_get_files (ThunarPropertiesDialog *dialog)
1069
1315
_thunar_return_val_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog), NULL);
1070
return dialog->file;
1316
return dialog->files;
1076
* thunar_properties_dialog_set_file:
1322
* thunar_properties_dialog_set_files:
1077
1323
* @dialog : a #ThunarPropertiesDialog.
1078
* @file : a #ThunarFile or %NULL.
1324
* @files : a GList of #ThunarFile's or %NULL.
1080
1326
* Sets the #ThunarFile that is displayed by @dialog
1084
thunar_properties_dialog_set_file (ThunarPropertiesDialog *dialog,
1330
thunar_properties_dialog_set_files (ThunarPropertiesDialog *dialog,
1087
1336
_thunar_return_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog));
1088
_thunar_return_if_fail (file == NULL || THUNAR_IS_FILE (file));
1090
/* check if we already display that file */
1091
if (G_UNLIKELY (dialog->file == file))
1338
/* check if the same lists are used (or null) */
1339
if (G_UNLIKELY (dialog->files == files))
1094
/* disconnect from any previously set file */
1095
if (dialog->file != NULL)
1342
/* disconnect from any previously set files */
1343
for (lp = dialog->files; lp != NULL; lp = lp->next)
1345
file = THUNAR_FILE (lp->data);
1097
1347
/* unregister our file watch */
1098
thunar_file_unwatch (dialog->file);
1348
thunar_file_unwatch (file);
1100
1350
/* unregister handlers */
1101
g_signal_handlers_disconnect_by_func (G_OBJECT (dialog->file), thunar_properties_dialog_update, dialog);
1102
g_signal_handlers_disconnect_by_func (G_OBJECT (dialog->file), gtk_widget_destroy, dialog);
1351
g_signal_handlers_disconnect_by_func (G_OBJECT (file), thunar_properties_dialog_update, dialog);
1352
g_signal_handlers_disconnect_by_func (G_OBJECT (file), gtk_widget_destroy, dialog);
1104
g_object_unref (G_OBJECT (dialog->file));
1354
g_object_unref (G_OBJECT (file));
1107
/* activate the new file */
1108
dialog->file = file;
1110
/* connect to the new file */
1356
g_list_free (dialog->files);
1358
/* activate the new list */
1359
dialog->files = g_list_copy (files);
1361
/* connect to the new files */
1362
for (lp = dialog->files; lp != NULL; lp = lp->next)
1113
g_object_ref (G_OBJECT (file));
1364
_thunar_assert (THUNAR_IS_FILE (lp->data));
1365
file = g_object_ref (G_OBJECT (lp->data));
1115
1367
/* watch the file for changes */
1116
1368
thunar_file_watch (file);
1118
1370
/* install signal handlers */
1119
1371
g_signal_connect_swapped (G_OBJECT (file), "changed", G_CALLBACK (thunar_properties_dialog_update), dialog);
1120
1372
g_signal_connect_swapped (G_OBJECT (file), "destroy", G_CALLBACK (gtk_widget_destroy), dialog);
1375
/* update the dialog contents */
1376
if (dialog->files != NULL)
1122
1378
/* update the UI for the new file */
1123
1379
thunar_properties_dialog_update (dialog);
1125
1381
/* update the provider property pages */
1126
1382
thunar_properties_dialog_update_providers (dialog);
1128
/* hide the permissions chooser for trashed files */
1129
if (thunar_file_is_trashed (file))
1130
gtk_widget_hide (dialog->permissions_chooser);
1132
gtk_widget_show (dialog->permissions_chooser);
1135
1385
/* tell everybody that we have a new file here */
1136
g_object_notify (G_OBJECT (dialog), "file");
1386
g_object_notify (G_OBJECT (dialog), "files");
1392
* thunar_properties_dialog_set_file:
1393
* @dialog : a #ThunarPropertiesDialog.
1394
* @file : a #ThunarFile or %NULL.
1396
* Sets the #ThunarFile that is displayed by @dialog
1400
thunar_properties_dialog_set_file (ThunarPropertiesDialog *dialog,
1405
_thunar_return_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog));
1406
_thunar_return_if_fail (file == NULL || THUNAR_IS_FILE (file));
1410
thunar_properties_dialog_set_files (dialog, NULL);
1414
/* create a fake list */
1419
thunar_properties_dialog_set_files (dialog, &foo);