4 * ROX-Filer, filer for the ROX desktop project
5 * By Thomas Leonard, <tal197@ecs.soton.ac.uk>.
8 /* newdir.c - code for handling creation of new directories */
11 #include <sys/types.h>
19 #include "gui_support.h"
23 static GtkWidget
*window
, *pathname_entry
;
24 static FilerWindow
*filer_window
;
26 /* Static prototypes */
27 static void create_dir(GtkWidget
*widget
, gpointer data
);
31 GtkWidget
*table
, *label
, *sep
;
34 window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
35 gtk_window_set_default_size(GTK_WINDOW(window
), 300, 0);
36 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_MOUSE
);
37 gtk_window_set_title(GTK_WINDOW(window
), "Create directory");
38 gtk_signal_connect(GTK_OBJECT(window
), "delete_event",
39 GTK_SIGNAL_FUNC(hide_dialog_event
), window
);
40 gtk_container_set_border_width(GTK_CONTAINER(window
), 8);
42 table
= gtk_table_new(4, 2, TRUE
);
43 gtk_container_add(GTK_CONTAINER(window
), table
);
45 label
= gtk_label_new("Create new directory:");
46 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 0, 2, 0, 1);
48 pathname_entry
= gtk_entry_new();
49 gtk_table_attach_defaults(GTK_TABLE(table
),
50 pathname_entry
, 0, 2, 1, 2);
51 gtk_signal_connect(GTK_OBJECT(pathname_entry
), "activate",
52 GTK_SIGNAL_FUNC(create_dir
), NULL
);
54 sep
= gtk_hseparator_new();
55 gtk_table_attach_defaults(GTK_TABLE(table
), sep
, 0, 2, 2, 3);
57 button
= gtk_button_new_with_label("Create");
58 gtk_table_attach_defaults(GTK_TABLE(table
), button
, 0, 1, 3, 4);
59 gtk_signal_connect(GTK_OBJECT(button
), "clicked",
60 GTK_SIGNAL_FUNC(create_dir
), NULL
);
62 button
= gtk_button_new_with_label("Cancel");
63 gtk_table_attach_defaults(GTK_TABLE(table
), button
, 1, 2, 3, 4);
64 gtk_signal_connect_object(GTK_OBJECT(button
), "clicked",
65 GTK_SIGNAL_FUNC(gtk_widget_hide
), GTK_OBJECT(window
));
68 void newdir_show(FilerWindow
*fw
)
74 if (GTK_WIDGET_MAPPED(window
))
75 gtk_widget_hide(window
);
78 path
= g_string_new(NULL
);
80 g_string_sprintf(path
, "%s/", filer_window
->path
);
82 gtk_entry_set_text(GTK_ENTRY(pathname_entry
), path
->str
);
84 gtk_widget_grab_focus(pathname_entry
);
85 gtk_widget_show_all(window
);
88 static void create_dir(GtkWidget
*widget
, gpointer data
)
92 path
= gtk_entry_get_text(GTK_ENTRY(pathname_entry
));
94 if (mkdir(path
, S_IRWXU
| S_IRWXG
| S_IRWXO
))
95 report_error("mkdir", g_strerror(errno
));
98 gtk_widget_hide(window
);
99 scan_dir(filer_window
);