4 * ROX-Filer, filer for the ROX desktop project
5 * By Thomas Leonard, <tal197@ecs.soton.ac.uk>.
8 /* savebox.c - code for handling those Newdir/Copy/Rename boxes */
14 #include "gui_support.h"
18 static GtkWidget
*window
, *pathname_entry
;
19 static GtkWidget
*icon
= NULL
;
20 static FilerWindow
*filer_window
;
21 static SaveBoxCallback
*callback
;
22 static GtkWidget
*icon_frame
;
23 static char *initial
= NULL
;
25 /* Static prototypes */
26 static void do_callback(GtkWidget
*widget
, gpointer data
);
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_signal_connect(GTK_OBJECT(window
), "delete_event",
38 GTK_SIGNAL_FUNC(hide_dialog_event
), window
);
39 gtk_container_set_border_width(GTK_CONTAINER(window
), 8);
41 table
= gtk_table_new(4, 2, FALSE
);
42 gtk_container_add(GTK_CONTAINER(window
), table
);
44 icon_frame
= gtk_frame_new(NULL
);
45 gtk_container_set_border_width(GTK_CONTAINER(icon_frame
), 8);
46 gtk_frame_set_shadow_type(GTK_FRAME(icon_frame
), GTK_SHADOW_NONE
);
47 gtk_table_attach_defaults(GTK_TABLE(table
), icon_frame
, 0, 2, 0, 1);
49 pathname_entry
= gtk_entry_new();
50 gtk_table_attach_defaults(GTK_TABLE(table
),
51 pathname_entry
, 0, 2, 1, 2);
52 gtk_signal_connect(GTK_OBJECT(pathname_entry
), "activate",
53 GTK_SIGNAL_FUNC(do_callback
), NULL
);
55 sep
= gtk_hseparator_new();
56 gtk_table_attach(GTK_TABLE(table
), sep
, 0, 2, 2, 3,
57 GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 4);
59 button
= gtk_button_new_with_label("OK");
60 gtk_table_attach_defaults(GTK_TABLE(table
), button
, 0, 1, 3, 4);
61 gtk_signal_connect(GTK_OBJECT(button
), "clicked",
62 GTK_SIGNAL_FUNC(do_callback
), NULL
);
64 button
= gtk_button_new_with_label("Cancel");
65 gtk_table_attach_defaults(GTK_TABLE(table
), button
, 1, 2, 3, 4);
66 gtk_signal_connect_object(GTK_OBJECT(button
), "clicked",
67 GTK_SIGNAL_FUNC(gtk_widget_hide
), GTK_OBJECT(window
));
70 void savebox_show(FilerWindow
*fw
, char *title
, char *path
, char *leaf
,
71 MaskedPixmap
*image
, SaveBoxCallback
*cb
)
76 tmp
= make_path(path
, leaf
);
79 initial
= g_strdup(tmp
->str
);
81 if (GTK_WIDGET_MAPPED(window
))
82 gtk_widget_hide(window
);
83 gtk_window_set_title(GTK_WINDOW(window
), title
);
86 gtk_pixmap_set(GTK_PIXMAP(icon
), image
->pixmap
, image
->mask
);
89 icon
= gtk_pixmap_new(image
->pixmap
, image
->mask
);
90 gtk_container_add(GTK_CONTAINER(icon_frame
), icon
);
95 gtk_entry_set_text(GTK_ENTRY(pathname_entry
), tmp
->str
);
96 gtk_entry_select_region(GTK_ENTRY(pathname_entry
),
97 tmp
->len
- strlen(leaf
), -1);
99 gtk_widget_grab_focus(pathname_entry
);
100 gtk_widget_show_all(window
);
103 static void do_callback(GtkWidget
*widget
, gpointer data
)
107 g_return_if_fail(callback
!= NULL
);
108 g_return_if_fail(initial
!= NULL
);
110 path
= gtk_entry_get_text(GTK_ENTRY(pathname_entry
));
112 if (callback(initial
, path
))
114 gtk_widget_hide(window
);
115 scan_dir(filer_window
);