4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2005, the ROX-Filer team.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
22 /* infobox.c - code for showing a file's attributes */
29 #include <sys/param.h>
31 #include <libxml/parser.h>
39 #include "gui_support.h"
44 #include "dnd.h" /* For xa_string */
45 #include "run.h" /* For show_help_files() */
51 typedef struct _FileStatus FileStatus
;
53 /* This is for the 'file(1) says...' thing */
56 int fd
; /* FD to read from, -1 if closed */
57 int input
; /* Input watcher tag if fd valid */
58 GtkLabel
*label
; /* Widget to output to */
59 gchar
*text
; /* String so far */
70 typedef struct _Permissions Permissions
;
79 /* Static prototypes */
80 static void refresh_info(GObject
*window
);
81 static GtkWidget
*make_vbox(const guchar
*path
, GObject
*window
);
82 static GtkWidget
*make_details(const guchar
*path
, DirItem
*item
,
84 static GtkWidget
*make_about(const guchar
*path
, XMLwrapper
*ai
);
85 static GtkWidget
*make_file_says(const guchar
*path
);
86 static GtkWidget
*make_permissions(const gchar
*path
, DirItem
*item
);
87 static void add_file_output(FileStatus
*fs
,
88 gint source
, GdkInputCondition condition
);
89 static const gchar
*pretty_type(DirItem
*file
, const guchar
*path
);
90 static void got_response(GObject
*window
, gint response
, gpointer data
);
91 static void file_info_destroyed(GtkWidget
*widget
, FileStatus
*fs
);
93 /****************************************************************
94 * EXTERNAL INTERFACE *
95 ****************************************************************/
97 /* Open each item in a new infobox. Confirms if there are a large
98 * number of items to show.
100 void infobox_show_list(GList
*paths
)
104 n
= g_list_length(paths
);
111 message
= g_strdup_printf(
112 _("Are you sure you want to open %d windows?"), n
);
113 ok
= confirm(message
, GTK_STOCK_YES
, _("Show Info"));
119 g_list_foreach(paths
, (GFunc
) infobox_new
, NULL
);
122 /* Create and display a new info box showing details about this item */
123 void infobox_new(const gchar
*pathname
)
125 GtkWidget
*window
, *details
;
129 g_return_if_fail(pathname
!= NULL
);
131 path
= g_strdup(pathname
); /* Gets attached to window & freed later */
133 window
= gtk_dialog_new_with_buttons(
134 g_utf8_validate(path
, -1, NULL
) ? path
136 NULL
, GTK_DIALOG_NO_SEPARATOR
,
137 GTK_STOCK_CLOSE
, GTK_RESPONSE_CANCEL
,
138 GTK_STOCK_REFRESH
, GTK_RESPONSE_APPLY
,
141 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_MOUSE
);
143 owindow
= G_OBJECT(window
);
144 details
= make_vbox(path
, owindow
);
145 gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(window
)->vbox
),
148 g_object_set_data(owindow
, "details", details
);
149 g_object_set_data_full(owindow
, "path", path
, g_free
);
151 g_signal_connect(window
, "response", G_CALLBACK(got_response
), NULL
);
154 gtk_widget_show_all(window
);
157 /****************************************************************
158 * INTERNAL FUNCTIONS *
159 ****************************************************************/
161 static void got_response(GObject
*window
, gint response
, gpointer data
)
163 if (response
== GTK_RESPONSE_APPLY
)
164 refresh_info(window
);
167 gtk_widget_destroy(GTK_WIDGET(window
));
172 static void refresh_info(GObject
*window
)
174 GtkWidget
*details
, *vbox
;
177 path
= g_object_get_data(window
, "path");
178 details
= g_object_get_data(window
, "details");
179 g_return_if_fail(details
!= NULL
);
180 g_return_if_fail(path
!= NULL
);
182 vbox
= details
->parent
;
183 gtk_widget_destroy(details
);
185 details
= make_vbox(path
, window
);
186 g_object_set_data(window
, "details", details
);
187 gtk_box_pack_start_defaults(GTK_BOX(vbox
), details
);
188 gtk_widget_show_all(details
);
191 static void add_frame(GtkBox
*vbox
, GtkWidget
*list
)
195 frame
= gtk_frame_new(NULL
);
196 gtk_frame_set_shadow_type(GTK_FRAME(frame
), GTK_SHADOW_IN
);
197 gtk_container_add(GTK_CONTAINER(frame
), list
);
198 gtk_box_pack_start_defaults(vbox
, frame
);
201 /* Create the VBox widget that contains the details.
202 * Note that 'path' must not be freed until the vbox is destroyed.
204 static GtkWidget
*make_vbox(const guchar
*path
, GObject
*window
)
209 xmlNode
*about
= NULL
;
211 GtkWidget
*hbox
, *name
, *label
;
213 g_return_val_if_fail(path
[0] == '/', NULL
);
215 item
= diritem_new(g_basename(path
));
216 diritem_restat(path
, item
, NULL
);
218 ai
= appinfo_get(path
, item
);
220 about
= xml_get_section(ai
, NULL
, "About");
222 vbox
= GTK_BOX(gtk_vbox_new(FALSE
, 4));
223 gtk_container_set_border_width(GTK_CONTAINER(vbox
), 4);
225 /* Heading, with icon and name */
226 hbox
= gtk_hbox_new(FALSE
, 4);
227 gtk_box_pack_start(vbox
, hbox
, FALSE
, TRUE
, 0);
228 gtk_box_pack_start(GTK_BOX(hbox
),
229 gtk_image_new_from_pixbuf(di_image(item
)->pixbuf
),
232 if (g_utf8_validate(item
->leafname
, -1, NULL
))
233 name
= gtk_label_new(item
->leafname
);
238 u8
= to_utf8(item
->leafname
);
239 name
= gtk_label_new(u8
);
242 gtk_label_set_selectable(GTK_LABEL(name
), TRUE
);
243 gtk_box_pack_start(GTK_BOX(hbox
), name
, FALSE
, TRUE
, 4);
245 make_heading(name
, PANGO_SCALE_X_LARGE
);
247 /* List of file attributes */
248 add_frame(vbox
, make_details(path
, item
, window
));
250 help_dir
= g_strconcat(path
, "/Help", NULL
);
252 if (access(help_dir
, F_OK
) == 0)
254 GtkWidget
*button
, *align
;
256 align
= gtk_alignment_new(0.5, 0.5, 0, 0);
258 button
= button_new_mixed(GTK_STOCK_JUMP_TO
,
259 _("Show _Help Files"));
260 gtk_box_pack_start(vbox
, align
, FALSE
, TRUE
, 0);
261 gtk_container_add(GTK_CONTAINER(align
), button
);
262 g_signal_connect_swapped(button
, "clicked",
263 G_CALLBACK(show_help_files
),
268 if (!(item
->flags
& ITEM_FLAG_SYMLINK
))
270 label
= gtk_label_new(NULL
);
271 gtk_label_set_markup(GTK_LABEL(label
),
272 _("<b>Permissions</b>"));
273 gtk_misc_set_alignment(GTK_MISC(label
), 0, 1);
274 gtk_box_pack_start(vbox
, label
, FALSE
, TRUE
, 2);
276 gtk_box_pack_start(vbox
, make_permissions(path
, item
),
281 add_frame(vbox
, make_about(path
, ai
));
282 else if (item
->base_type
== TYPE_FILE
)
284 label
= gtk_label_new(NULL
);
285 gtk_label_set_markup(GTK_LABEL(label
),
286 _("<b>Contents indicate...</b>"));
287 gtk_misc_set_alignment(GTK_MISC(label
), 0, 1);
288 gtk_box_pack_start(vbox
, label
, FALSE
, TRUE
, 2);
290 gtk_box_pack_start_defaults(vbox
, make_file_says(path
));
298 return (GtkWidget
*) vbox
;
301 /* The selection has changed - grab or release the primary selection */
302 static void set_selection(GtkTreeView
*view
, gpointer data
)
304 static GtkClipboard
*primary
= NULL
;
306 GtkTreePath
*path
= NULL
;
310 gtk_tree_view_get_cursor(view
, &path
, NULL
);
315 primary
= gtk_clipboard_get(gdk_atom_intern("PRIMARY", FALSE
));
317 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(view
));
319 gtk_tree_model_get_iter(model
, &iter
, path
);
320 gtk_tree_path_free(path
);
322 gtk_tree_model_get(model
, &iter
, 1, &text
, -1);
324 gtk_clipboard_set_text(primary
, text
, -1);
329 /* Returns a GtkTreePath for the item */
330 static const gchar
*add_row(GtkListStore
*store
, const gchar
*label
,
336 static gchar
*last
= NULL
;
338 if (!g_utf8_validate(data
, -1, NULL
))
341 gtk_list_store_append(store
, &iter
);
342 gtk_list_store_set(store
, &iter
, 0, label
, 1, u8
? u8
: data
, -1);
346 tpath
= gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &iter
);
349 last
= gtk_tree_path_to_string(tpath
);
350 gtk_tree_path_free(tpath
);
355 static void add_row_and_free(GtkListStore
*store
,
356 const gchar
*label
, gchar
*data
)
358 add_row(store
, label
, data
);
362 /* Create an empty list view, ready to place some data in */
363 static void make_list(GtkListStore
**list_store
, GtkWidget
**list_view
,
364 GCallback cell_edited
)
368 GtkCellRenderer
*cell_renderer
;
370 /* Field name, value, editable */
371 store
= gtk_list_store_new(3, G_TYPE_STRING
, G_TYPE_STRING
,
373 view
= GTK_TREE_VIEW(
374 gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
)));
375 g_object_unref(G_OBJECT(store
));
376 gtk_tree_view_set_headers_visible(view
, FALSE
);
378 cell_renderer
= gtk_cell_renderer_text_new();
379 g_object_set(G_OBJECT(cell_renderer
), "xalign", 1.0, NULL
);
380 gtk_tree_view_insert_column_with_attributes(view
,
381 0, NULL
, cell_renderer
, "text", 0, NULL
);
383 cell_renderer
= gtk_cell_renderer_text_new();
384 gtk_tree_view_insert_column_with_attributes(view
,
385 1, NULL
, cell_renderer
, "text", 1, "editable", 2, NULL
);
388 g_signal_connect(G_OBJECT(cell_renderer
), "edited",
389 G_CALLBACK(cell_edited
), store
);
392 g_signal_connect(view
, "cursor_changed",
393 G_CALLBACK(set_selection
), NULL
);
396 *list_view
= (GtkWidget
*) view
;
399 static void set_cell(GtkListStore
*store
, const gchar
*path
,
404 gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(store
),
406 gtk_list_store_set(store
, &iter
, 1, ctext
, -1);
409 static void insert_size(DU
*du
, const char *line
)
414 #ifdef LARGE_FILE_SUPPORT
415 size
= strtoll(line
, NULL
, 10);
417 size
= strtol(line
, NULL
, 10);
419 size
<<= 10; /* Because du reports in K */
420 cell
= (size
>= PRETTY_SIZE_LIMIT
)
421 ? g_strdup_printf("%s (%" SIZE_FMT
" %s)",
424 : g_strdup(format_size(size
));
426 set_cell(du
->store
, du
->path
, cell
);
431 static gboolean
read_du_output(GIOChannel
*source
, GIOCondition cond
, DU
*du
)
437 line
= g_string_new("");
438 stat
= g_io_channel_read_line_string(source
, line
, NULL
, &err
);
441 case G_IO_STATUS_NORMAL
:
442 insert_size(du
, line
->str
);
444 case G_IO_STATUS_EOF
:
445 set_cell(du
->store
, du
->path
,
446 _("Failed to read size"));
448 case G_IO_STATUS_AGAIN
:
449 g_string_free(line
, TRUE
);
451 case G_IO_STATUS_ERROR
:
452 set_cell(du
->store
, du
->path
, err
->message
);
455 g_string_free(line
, TRUE
);
460 static void kill_du_output(GtkWidget
*widget
, DU
*du
)
462 g_source_remove(du
->watch
);
463 g_io_channel_shutdown(du
->chan
, FALSE
, NULL
);
464 g_io_channel_unref(du
->chan
);
465 kill((pid_t
) du
->child
, SIGTERM
);
466 g_object_unref(G_OBJECT(du
->store
));
471 static gboolean
refresh_info_idle(gpointer data
)
473 GObject
*window
= G_OBJECT(data
);
475 refresh_info(window
);
476 g_object_unref(window
);
480 static void cell_edited(GtkCellRendererText
*cell
,
481 const gchar
*path_string
,
482 const gchar
*new_text
,
485 GtkTreeModel
*model
= (GtkTreeModel
*) data
;
489 const char *fullpath
;
492 window
= g_object_get_data(G_OBJECT(model
), "rox_window");
493 g_return_if_fail(window
!= NULL
);
495 fullpath
= g_object_get_data(window
, "path");
496 g_return_if_fail(fullpath
!= NULL
);
498 path
= gtk_tree_path_new_from_string(path_string
);
499 gtk_tree_model_get_iter(model
, &iter
, path
);
500 gtk_tree_path_free(path
);
502 oldlink
= readlink_dup(fullpath
);
504 report_error(_("'%s' is no longer a symlink"), fullpath
);
507 if (strcmp(oldlink
, new_text
) == 0)
508 return; /* No change */
510 if (unlink(fullpath
)) {
511 report_error(_("Failed to unlink '%s':\n%s"),
512 fullpath
, g_strerror(errno
));
515 if (symlink(new_text
, fullpath
)) {
516 report_error(_("Failed to create symlink from '%s':\n%s\n"
517 "(note: old link has been deleted)"));
521 g_object_ref(window
);
522 g_idle_add(refresh_info_idle
, window
);
525 /* Create the TreeView widget with the file's details */
526 static GtkWidget
*make_details(const guchar
*path
, DirItem
*item
,
533 make_list(&store
, &view
, G_CALLBACK(cell_edited
));
534 g_object_set_data(G_OBJECT(store
), "rox_window", window
);
536 /* For a symlink to an error, don't show the error */
537 if (item
->base_type
== TYPE_ERROR
&& item
->lstat_errno
)
539 add_row(store
, _("Error:"), g_strerror(item
->lstat_errno
));
543 tmp
= g_path_get_dirname(path
);
545 if (strcmp(tmp
, tmp2
) != 0)
546 add_row_and_free(store
, _("Real directory:"), tmp2
);
549 add_row_and_free(store
, _("Owner, Group:"),
550 g_strdup_printf("%s, %s",
551 user_name(item
->uid
),
552 group_name(item
->gid
)));
554 if (item
->base_type
!= TYPE_DIRECTORY
)
556 add_row_and_free(store
, _("Size:"),
557 item
->size
>= PRETTY_SIZE_LIMIT
558 ? g_strdup_printf("%s (%" SIZE_FMT
" %s)",
559 format_size(item
->size
),
560 item
->size
, _("bytes"))
561 : g_strdup(format_size(item
->size
)));
567 if(item
->flags
& ITEM_FLAG_MOUNTED
)
568 stt
=mount_get_fs_size(path
);
571 add_row_and_free(store
, _("Size:"), stt
);
576 gchar
*args
[] = {"du", "-sk", "", NULL
};
580 du
->path
= g_strdup(add_row(store
, _("Size:"),
583 args
[2] = (gchar
*) path
;
584 if (g_spawn_async_with_pipes(NULL
, args
, NULL
,
586 NULL
, NULL
, &du
->child
,
590 du
->chan
= g_io_channel_unix_new(out
);
591 du
->watch
= g_io_add_watch(du
->chan
,
592 G_IO_IN
|G_IO_ERR
|G_IO_HUP
,
593 (GIOFunc
) read_du_output
, du
);
594 g_object_ref(G_OBJECT(du
->store
));
595 g_signal_connect(G_OBJECT(view
),
597 G_CALLBACK(kill_du_output
),
602 set_cell(store
, du
->path
, _("Failed to scan"));
609 add_row_and_free(store
, _("Change time:"), pretty_time(&item
->ctime
));
611 add_row_and_free(store
, _("Modify time:"), pretty_time(&item
->mtime
));
613 add_row_and_free(store
, _("Access time:"), pretty_time(&item
->atime
));
615 add_row(store
, _("Type:"), pretty_type(item
, path
));
618 add_row(store
, "", mime_type_comment(item
->mime_type
));
620 if (xtype_supported(NULL
)) {
621 add_row(store
, _("Extended attributes:"),
622 (item
->flags
& ITEM_FLAG_HAS_XATTR
)
624 : xtype_supported(path
) ? _("None")
625 : _("Not supported"));
628 if (item
->flags
& ITEM_FLAG_SYMLINK
)
631 GtkTreeModel
*model
= GTK_TREE_MODEL(store
);
634 target
= readlink_dup(path
);
636 target
= g_strdup(g_strerror(errno
));
637 add_row_and_free(store
, _("Link target:"), target
);
639 /* Make cell editable */
640 gtk_tree_model_iter_nth_child(model
, &iter
,
641 NULL
, gtk_tree_model_iter_n_children(model
, NULL
) - 1);
643 gtk_list_store_set(store
, &iter
, 2, TRUE
, -1);
646 if (item
->base_type
!= TYPE_DIRECTORY
)
648 if (EXECUTABLE_FILE(item
))
649 add_row(store
, _("Run action:"), _("Execute file"));
652 add_row_and_free(store
, _("Run action:"),
653 describe_current_command(item
->mime_type
));
660 /* Create the TreeView widget with the application's details */
661 static GtkWidget
*make_about(const guchar
*path
, XMLwrapper
*ai
)
666 xmlNode
*about
, *about_trans
;
667 GHashTable
*translate
;
669 g_return_val_if_fail(ai
!= NULL
, NULL
);
671 about_trans
= xml_get_section(ai
, NULL
, "About");
673 about
= xmlDocGetRootElement(ai
->doc
)->xmlChildrenNode
;
674 for (; about
; about
= about
->next
)
676 if (about
->type
!= XML_ELEMENT_NODE
)
678 if (about
->ns
== NULL
&& strcmp(about
->name
, "About") == 0)
682 g_return_val_if_fail(about
!= NULL
, NULL
);
684 make_list(&store
, &view
, NULL
);
686 /* Add each field in about to the list, but overriding each element
687 * with about_trans if a translation is supplied.
689 translate
= g_hash_table_new(g_str_hash
, g_str_equal
);
690 if (about_trans
!= about
)
693 for (p
= about_trans
->xmlChildrenNode
; p
; p
= p
->next
)
695 if (p
->type
!= XML_ELEMENT_NODE
)
697 g_hash_table_insert(translate
, (char *) p
->name
, p
);
700 for (prop
= about
->xmlChildrenNode
; prop
; prop
= prop
->next
)
702 if (prop
->type
== XML_ELEMENT_NODE
)
709 trans
= g_hash_table_lookup(translate
, prop
->name
);
713 tmp
= xmlGetProp(trans
, "label");
714 label
= g_strconcat(tmp
? tmp
715 : (char *) trans
->name
,
718 value
= xmlNodeListGetString(trans
->doc
,
719 trans
->xmlChildrenNode
, 1);
721 value
= xmlNodeListGetString(prop
->doc
,
722 prop
->xmlChildrenNode
, 1);
724 value
= g_strdup("-");
725 add_row_and_free(store
, label
, value
);
730 g_hash_table_destroy(translate
);
735 static GtkWidget
*make_file_says(const guchar
*path
)
737 GtkWidget
*w_file_label
;
738 GtkLabel
*l_file_label
;
740 char *argv
[] = {"file", "-b", NULL
, NULL
};
741 FileStatus
*fs
= NULL
;
744 w_file_label
= gtk_label_new(_("<nothing yet>"));
745 l_file_label
= GTK_LABEL(w_file_label
);
746 gtk_label_set_line_wrap(l_file_label
, TRUE
);
750 tmp
= g_strdup_printf("pipe(): %s", g_strerror(errno
));
751 gtk_label_set_text(l_file_label
, tmp
);
759 tmp
= g_strdup_printf("pipe(): %s", g_strerror(errno
));
760 gtk_label_set_text(l_file_label
, tmp
);
766 /* We are the child */
768 dup2(file_data
[1], STDOUT_FILENO
);
769 dup2(file_data
[1], STDERR_FILENO
);
771 argv
[2] = (char *) path
;
773 argv
[1] = (char *) g_basename(path
);
774 chdir(g_path_get_dirname(path
));
776 if (execvp(argv
[0], argv
))
777 fprintf(stderr
, "execvp() error: %s\n",
781 /* We are the parent */
783 fs
= g_new(FileStatus
, 1);
784 fs
->label
= l_file_label
;
785 fs
->fd
= file_data
[0];
786 fs
->text
= g_strdup("");
787 fs
->input
= gdk_input_add_full(fs
->fd
, GDK_INPUT_READ
,
788 (GdkInputFunction
) add_file_output
,
790 g_signal_connect(w_file_label
, "destroy",
791 G_CALLBACK(file_info_destroyed
), fs
);
798 /* Got some data from file(1) - stick it in the window. */
799 static void add_file_output(FileStatus
*fs
,
800 gint source
, GdkInputCondition condition
)
806 got
= read(source
, buffer
, sizeof(buffer
) - 1);
810 g_source_remove(fs
->input
);
814 delayed_error(_("file(1) says... %s"),
820 str
= g_strconcat(fs
->text
, buffer
, NULL
);
824 str
= to_utf8(fs
->text
);
826 gtk_label_set_text(fs
->label
, str
);
830 static void file_info_destroyed(GtkWidget
*widget
, FileStatus
*fs
)
834 g_source_remove(fs
->input
);
842 static void permissions_destroyed(GtkWidget
*widget
, Permissions
*perm
)
845 diritem_free(perm
->item
);
850 static void permissions_apply(GtkWidget
*widget
, Permissions
*perm
)
857 for (i
= 0; i
< 9; i
++)
859 GtkToggleButton
*bit
= GTK_TOGGLE_BUTTON(perm
->bits
[i
]);
860 if (gtk_toggle_button_get_active(bit
))
863 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm
->bits
[9])))
865 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm
->bits
[10])))
867 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm
->bits
[11])))
870 if (chmod(perm
->path
, nmode
))
871 report_error(_("Could not change permissions: %s"),
875 static GtkWidget
*make_permissions(const gchar
*path
, DirItem
*item
)
879 GtkWidget
*tick
, *label
;
882 perm
= g_new(Permissions
, 1);
884 perm
->path
= g_strdup(path
);
885 perm
->item
= diritem_new(path
);
887 table
= gtk_table_new(4, 5, TRUE
);
889 label
= gtk_label_new(_("Owner"));
890 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 0, 1, 1, 2);
891 label
= gtk_label_new(_("Group"));
892 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 0, 1, 2, 3);
893 label
= gtk_label_new(_("World"));
894 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 0, 1, 3, 4);
896 label
= gtk_label_new(_("Read"));
897 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 1, 2, 0, 1);
898 label
= gtk_label_new(_("Write"));
899 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 2, 3, 0, 1);
900 label
= gtk_label_new(_("Exec"));
901 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 3, 4, 0, 1);
903 for (i
= 0; i
< 9; i
++)
907 perm
->bits
[i
] = tick
= gtk_check_button_new();
908 gtk_table_attach_defaults(GTK_TABLE(table
), tick
,
910 if (item
->mode
& (1 << i
))
911 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tick
),
913 g_signal_connect(tick
, "toggled",
914 G_CALLBACK(permissions_apply
), perm
);
917 tick
= gtk_check_button_new_with_label(_("SUID"));
918 gtk_table_attach_defaults(GTK_TABLE(table
), tick
, 4, 5, 1, 2);
919 if (item
->mode
& S_ISUID
)
920 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tick
), TRUE
);
921 g_signal_connect(tick
, "toggled", G_CALLBACK(permissions_apply
), perm
);
922 perm
->bits
[9] = tick
;
924 tick
= gtk_check_button_new_with_label(_("SGID"));
925 gtk_table_attach_defaults(GTK_TABLE(table
), tick
, 4, 5, 2, 3);
926 if (item
->mode
& S_ISGID
)
927 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tick
), TRUE
);
928 g_signal_connect(tick
, "toggled", G_CALLBACK(permissions_apply
), perm
);
929 perm
->bits
[10] = tick
;
931 tick
= gtk_check_button_new_with_label(_("Sticky"));
932 gtk_table_attach_defaults(GTK_TABLE(table
), tick
, 4, 5, 3, 4);
933 if (item
->mode
& S_ISVTX
)
934 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tick
), TRUE
);
935 g_signal_connect(tick
, "toggled", G_CALLBACK(permissions_apply
), perm
);
936 perm
->bits
[11] = tick
;
938 g_signal_connect(table
, "destroy",
939 G_CALLBACK(permissions_destroyed
), perm
);
941 gtk_widget_show_all(table
);
945 /* Don't g_free() the result */
946 static const gchar
*pretty_type(DirItem
*file
, const guchar
*path
)
948 static gchar
*text
= NULL
;
952 if (file
->flags
& ITEM_FLAG_SYMLINK
)
953 return _("Symbolic link");
955 if (file
->flags
& ITEM_FLAG_APPDIR
)
956 return _("ROX application");
958 if (file
->flags
& ITEM_FLAG_MOUNT_POINT
)
961 const gchar
*mounted
;
963 mounted
= mount_is_mounted(path
, NULL
, NULL
)
964 ? _("mounted") : _("unmounted");
966 mp
= g_hash_table_lookup(fstab_mounts
, path
);
968 text
= g_strdup_printf(_("Mount point for %s (%s)"),
971 text
= g_strdup_printf(_("Mount point (%s)"), mounted
);
977 text
= g_strconcat(file
->mime_type
->media_type
, "/",
978 file
->mime_type
->subtype
, NULL
);