annotate src/ui_utildlg.c @ 289:6a7298988a7a

Simplify and unify gtk_window creation with the help of the new window_new() function, that wraps gtk_window_new() call. Subclass, title and icon are set in the same call.
author zas_
date Wed, 09 Apr 2008 16:37:54 +0000
parents 9995c5fb202a
children 4b2d7f9af171
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2 * (SLIK) SimpLIstic sKin functions
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12 #ifdef HAVE_CONFIG_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 # include "config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include <stdio.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include <string.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include <sys/types.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include <gtk/gtk.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 254
diff changeset
25 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27
232
985a9a09c9d1 Fix missing header include (filelist.h).
zas_
parents: 138
diff changeset
28 #include "filelist.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include "ui_pathsel.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 * generic dialog
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 void generic_dialog_close(GenericDialog *gd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 gtk_widget_destroy(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 g_free(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 static void generic_dialog_click_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 void (*func)(GenericDialog *, gpointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 gint auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 func = g_object_get_data(G_OBJECT(widget), "dialog_function");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 auto_close = gd->auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 if (func) func(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 if (auto_close) generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 static gint generic_dialog_default_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 if (event->keyval == GDK_Return && GTK_WIDGET_HAS_FOCUS(widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 && gd->default_cb)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 gint auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 auto_close = gd->auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 gd->default_cb(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 if (auto_close) generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 void generic_dialog_attach_default(GenericDialog *gd, GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 if (!gd || !widget) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 g_signal_connect(G_OBJECT(widget), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 G_CALLBACK(generic_dialog_default_key_press_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 static gint generic_dialog_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 if (event->keyval == GDK_Escape)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 if (gd->cancel_cb) gd->cancel_cb(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 if (gd->auto_close) generic_dialog_click_cb(widget, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 static gint generic_dialog_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 gint auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 auto_close = gd->auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 if (gd->cancel_cb) gd->cancel_cb(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 if (auto_close) generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 static void generic_dialog_show_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 if (gd->cancel_button)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 gtk_box_reorder_child(GTK_BOX(gd->hbox), gd->cancel_button, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 g_signal_handlers_disconnect_by_func(G_OBJECT(widget),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 G_CALLBACK(generic_dialog_show_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 gint generic_dialog_get_alternative_button_order(GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 GtkSettings *settings;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 GObjectClass *klass;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 gint alternative_order = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 settings = gtk_settings_get_for_screen(gtk_widget_get_screen(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 klass = G_OBJECT_CLASS(GTK_SETTINGS_GET_CLASS(settings));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 if (g_object_class_find_property(klass, "gtk-alternative-button-order"))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 g_object_get(settings, "gtk-alternative-button-order", &alternative_order, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 return alternative_order;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 GtkWidget *generic_dialog_add_button(GenericDialog *gd, const gchar *stock_id, const gchar *text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 void (*func_cb)(GenericDialog *, gpointer), gint is_default)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 gint alternative_order;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 button = pref_button_new(NULL, stock_id, text, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 G_CALLBACK(generic_dialog_click_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 g_object_set_data(G_OBJECT(button), "dialog_function", func_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 gtk_container_add(GTK_CONTAINER(gd->hbox), button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 alternative_order = generic_dialog_get_alternative_button_order(gd->hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 if (is_default)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 gtk_widget_grab_default(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 gtk_widget_grab_focus(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 gd->default_cb = func_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 if (!alternative_order) gtk_box_reorder_child(GTK_BOX(gd->hbox), button, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 if (!alternative_order) gtk_box_reorder_child(GTK_BOX(gd->hbox), button, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 return button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 GtkWidget *generic_dialog_add_message(GenericDialog *gd, const gchar *icon_stock_id,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 const gchar *heading, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 if (icon_stock_id)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 GtkWidget *image;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 image = gtk_image_new_from_stock(icon_stock_id, GTK_ICON_SIZE_DIALOG);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 gtk_widget_show(image);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 vbox = pref_box_new(hbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 if (heading)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 label = pref_label_new(vbox, heading);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 pref_label_bold(label, TRUE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 label = pref_label_new(vbox, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
15
3263965d5f9e ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
202 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 return vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 static void generic_dialog_setup(GenericDialog *gd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 GtkWidget *parent, gint auto_close,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 gd->auto_close = auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 gd->data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 gd->cancel_cb = cancel_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219
289
6a7298988a7a Simplify and unify gtk_window creation with the help of
zas_
parents: 281
diff changeset
220 gd->dialog = window_new(GTK_WINDOW_TOPLEVEL, wmsubclass, NULL, NULL, title);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 gtk_window_set_type_hint(GTK_WINDOW(gd->dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
289
6a7298988a7a Simplify and unify gtk_window creation with the help of
zas_
parents: 281
diff changeset
222
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 if (parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 GtkWindow *window = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 if (GTK_IS_WINDOW(parent))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 window = GTK_WINDOW(parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 GtkWidget *top;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 top = gtk_widget_get_toplevel(parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 if (GTK_IS_WINDOW(top) && GTK_WIDGET_TOPLEVEL(top)) window = GTK_WINDOW(top);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 if (window) gtk_window_set_transient_for(GTK_WINDOW(gd->dialog), window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 g_signal_connect(G_OBJECT(gd->dialog), "delete_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 G_CALLBACK(generic_dialog_delete_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 g_signal_connect(G_OBJECT(gd->dialog), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 G_CALLBACK(generic_dialog_key_press_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 gtk_window_set_resizable(GTK_WINDOW(gd->dialog), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 gtk_container_set_border_width(GTK_CONTAINER(gd->dialog), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 vbox = gtk_vbox_new(FALSE, PREF_PAD_BUTTON_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 gtk_container_add(GTK_CONTAINER(gd->dialog), vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 gd->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 gtk_box_pack_start(GTK_BOX(vbox), gd->vbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 gtk_widget_show(gd->vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 gd->hbox = gtk_hbutton_box_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 gtk_button_box_set_layout(GTK_BUTTON_BOX(gd->hbox), GTK_BUTTONBOX_END);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 gtk_box_set_spacing(GTK_BOX(gd->hbox), PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 gtk_box_pack_start(GTK_BOX(vbox), gd->hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 gtk_widget_show(gd->hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 if (gd->cancel_cb)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 gd->cancel_button = generic_dialog_add_button(gd, GTK_STOCK_CANCEL, NULL, gd->cancel_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 gd->cancel_button = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 if (generic_dialog_get_alternative_button_order(gd->hbox))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 g_signal_connect(G_OBJECT(gd->dialog), "show",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 G_CALLBACK(generic_dialog_show_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 gd->default_cb = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 GenericDialog *generic_dialog_new(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 GtkWidget *parent, gint auto_close,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 gd = g_new0(GenericDialog, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 generic_dialog_setup(gd, title, wmclass, wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 parent, auto_close, cancel_cb, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 * simple warning dialog
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 static void warning_dialog_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 /* no op */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 GenericDialog *warning_dialog(const gchar *heading, const gchar *text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 const gchar *icon_stock_id, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 232
diff changeset
310 gd = generic_dialog_new(heading, GQ_WMCLASS, "warning", parent, TRUE, NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, warning_dialog_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 generic_dialog_add_message(gd, icon_stock_id, heading, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 * generic file ops dialog routines
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
326 void file_dialog_close(FileDialog *fdlg)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
328 file_data_unref(fdlg->source_fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
329 g_free(fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
330 if (fdlg->source_list) filelist_free(fdlg->source_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
332 generic_dialog_close(GENERIC_DIALOG(fdlg));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 FileDialog *file_dialog_new(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 GtkWidget *parent,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 void (*cancel_cb)(FileDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
340 FileDialog *fdlg = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
342 fdlg = g_new0(FileDialog, 1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
344 generic_dialog_setup(GENERIC_DIALOG(fdlg), title,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 wmclass, wmsubclass, parent, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 (void *)cancel_cb, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
348 return fdlg;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
351 GtkWidget *file_dialog_add_button(FileDialog *fdlg, const gchar *stock_id, const gchar *text,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 void (*func_cb)(FileDialog *, gpointer), gint is_default)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
354 return generic_dialog_add_button(GENERIC_DIALOG(fdlg), stock_id, text,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 (void *)func_cb, is_default);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 static void file_dialog_entry_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
360 FileDialog *fdlg = data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
361 g_free(fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
362 fdlg->dest_path = remove_trailing_slash(gtk_entry_get_text(GTK_ENTRY(fdlg->entry)));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 static void file_dialog_entry_enter_cb(const gchar *path, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 file_dialog_entry_cb(NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 if (gd->default_cb) gd->default_cb(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
374 void file_dialog_add_path_widgets(FileDialog *fdlg, const gchar *default_path, const gchar *path,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 const gchar *history_key, const gchar *filter, const gchar *filter_desc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 GtkWidget *tabcomp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 GtkWidget *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
380 if (fdlg->entry) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
382 tabcomp = tab_completion_new_with_history(&fdlg->entry, NULL,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
383 history_key, -1, file_dialog_entry_enter_cb, fdlg);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
384 gtk_box_pack_end(GTK_BOX(GENERIC_DIALOG(fdlg)->vbox), tabcomp, FALSE, FALSE, 0);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
385 generic_dialog_attach_default(GENERIC_DIALOG(fdlg), fdlg->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 gtk_widget_show(tabcomp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 if (path && path[0] == '/')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
390 fdlg->dest_path = g_strdup(path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 const gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
396 base = tab_completion_set_to_last_history(fdlg->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 if (!base) base = default_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 if (!base) base = homedir();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 if (path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
403 fdlg->dest_path = concat_dir_and_file(base, path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
407 fdlg->dest_path = g_strdup(base);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
411 list = path_selection_new_with_files(fdlg->entry, fdlg->dest_path, filter, filter_desc);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
412 path_selection_add_select_func(fdlg->entry, file_dialog_entry_enter_cb, fdlg);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
413 gtk_box_pack_end(GTK_BOX(GENERIC_DIALOG(fdlg)->vbox), list, TRUE, TRUE, 0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 gtk_widget_show(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
416 gtk_widget_grab_focus(fdlg->entry);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
417 if (fdlg->dest_path)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
419 gtk_entry_set_text(GTK_ENTRY(fdlg->entry), fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
420 gtk_editable_set_position(GTK_EDITABLE(fdlg->entry), strlen(fdlg->dest_path));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
423 g_signal_connect(G_OBJECT(fdlg->entry), "changed",
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
424 G_CALLBACK(file_dialog_entry_cb), fdlg);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
427 void file_dialog_add_filter(FileDialog *fdlg, const gchar *filter, const gchar *filter_desc, gint set)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
429 if (!fdlg->entry) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
430 path_selection_add_filter(fdlg->entry, filter, filter_desc, set);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
433 void file_dialog_clear_filter(FileDialog *fdlg)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
435 if (!fdlg->entry) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
436 path_selection_clear_filter(fdlg->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
439 void file_dialog_sync_history(FileDialog *fdlg, gint dir_only)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
441 if (!fdlg->dest_path) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 if (!dir_only ||
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
444 (dir_only && isdir(fdlg->dest_path)) )
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
446 tab_completion_append_to_history(fdlg->entry, fdlg->dest_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
450 gchar *buf = remove_level_from_path(fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
451 tab_completion_append_to_history(fdlg->entry, buf);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456