annotate src/ui_utildlg.c @ 1811:f405ec9b696b default tip

Some small logic mistakes Use boolean operators for booleans and bitwise otherwise only.
author mow
date Mon, 10 May 2010 11:33:13 +0000
parents c416d099a3dc
children
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
1802
956aab097ea7 added 2010 to copyright text
nadvornik
parents: 1451
diff changeset
4 * Copyright (C) 2008 - 2010 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * 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
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 #ifdef HAVE_CONFIG_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 # include "config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include <stdio.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include <string.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include <sys/types.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include <gtk/gtk.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 254
diff changeset
26 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 512
diff changeset
29 #include "filedata.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 #include "ui_pathsel.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #include "ui_tabcomp.h"
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents: 586
diff changeset
34 #include "window.h"
9
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 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 * generic dialog
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 *-----------------------------------------------------------------------------
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 289
diff changeset
40 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 void generic_dialog_close(GenericDialog *gd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 gtk_widget_destroy(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 g_free(gd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 static void generic_dialog_click_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 void (*func)(GenericDialog *, gpointer);
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
52 gboolean auto_close;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 func = g_object_get_data(G_OBJECT(widget), "dialog_function");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 auto_close = gd->auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 if (func) func(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 if (auto_close) generic_dialog_close(gd);
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
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
61 static gboolean generic_dialog_default_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64
1810
c416d099a3dc GTK marks several functions as deprecated
mow
parents: 1807
diff changeset
65 #if GTK_CHECK_VERSION(2,20,0)
c416d099a3dc GTK marks several functions as deprecated
mow
parents: 1807
diff changeset
66 if (event->keyval == GDK_Return && gtk_widget_has_focus(widget)
c416d099a3dc GTK marks several functions as deprecated
mow
parents: 1807
diff changeset
67 #else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 if (event->keyval == GDK_Return && GTK_WIDGET_HAS_FOCUS(widget)
1810
c416d099a3dc GTK marks several functions as deprecated
mow
parents: 1807
diff changeset
69 #endif
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 && gd->default_cb)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 {
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
72 gboolean auto_close;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 auto_close = gd->auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 gd->default_cb(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 if (auto_close) generic_dialog_close(gd);
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 return TRUE;
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 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 void generic_dialog_attach_default(GenericDialog *gd, GtkWidget *widget)
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 if (!gd || !widget) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 g_signal_connect(G_OBJECT(widget), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 G_CALLBACK(generic_dialog_default_key_press_cb), gd);
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
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
90 static gboolean generic_dialog_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 if (event->keyval == GDK_Escape)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 if (gd->cancel_cb) gd->cancel_cb(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 if (gd->auto_close) generic_dialog_click_cb(widget, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 return TRUE;
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 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
103 static gboolean generic_dialog_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data)
9
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 GenericDialog *gd = data;
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
106 gboolean auto_close;
9
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 auto_close = gd->auto_close;
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 if (gd->cancel_cb) gd->cancel_cb(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 if (auto_close) generic_dialog_close(gd);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 }
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 static void generic_dialog_show_cb(GtkWidget *widget, gpointer data)
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 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 if (gd->cancel_button)
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 289
diff changeset
120 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 gtk_box_reorder_child(GTK_BOX(gd->hbox), gd->cancel_button, -1);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 g_signal_handlers_disconnect_by_func(G_OBJECT(widget),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 G_CALLBACK(generic_dialog_show_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
128 gboolean generic_dialog_get_alternative_button_order(GtkWidget *widget)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 GtkSettings *settings;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 GObjectClass *klass;
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1284
diff changeset
132 gboolean alternative_order = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 settings = gtk_settings_get_for_screen(gtk_widget_get_screen(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 klass = G_OBJECT_CLASS(GTK_SETTINGS_GET_CLASS(settings));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 if (g_object_class_find_property(klass, "gtk-alternative-button-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 g_object_get(settings, "gtk-alternative-button-order", &alternative_order, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 return alternative_order;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 GtkWidget *generic_dialog_add_button(GenericDialog *gd, const gchar *stock_id, const gchar *text,
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
145 void (*func_cb)(GenericDialog *, gpointer), gboolean is_default)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 GtkWidget *button;
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
148 gboolean alternative_order;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 button = pref_button_new(NULL, stock_id, text, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 G_CALLBACK(generic_dialog_click_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 475
diff changeset
153 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 g_object_set_data(G_OBJECT(button), "dialog_function", func_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 gtk_container_add(GTK_CONTAINER(gd->hbox), button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 alternative_order = generic_dialog_get_alternative_button_order(gd->hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 if (is_default)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 gtk_widget_grab_default(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 gtk_widget_grab_focus(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 gd->default_cb = func_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 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
167 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 else
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 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
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 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 return button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 GtkWidget *generic_dialog_add_message(GenericDialog *gd, const gchar *icon_stock_id,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 const gchar *heading, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184
1807
3a2aff957816 Allow scrollview to grow when generic dialog is resized (ie. Metadata write ? dialog). Do not force scrollbar if not needed.
zas_
parents: 1802
diff changeset
185 hbox = pref_box_new(gd->vbox, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 if (icon_stock_id)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 GtkWidget *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 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
191 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 gtk_widget_show(image);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 vbox = pref_box_new(hbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 if (heading)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 label = pref_label_new(vbox, heading);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 pref_label_bold(label, TRUE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 if (text)
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 label = pref_label_new(vbox, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 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
207 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 return vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 static void generic_dialog_setup(GenericDialog *gd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 const gchar *title,
1175
2518a4a73d89 Rename wmsubclass and name to role, which corresponds better to the purpose of the parameter as it ends to be passed to gtk_window_set_role().
zas_
parents: 1174
diff changeset
215 const gchar *role,
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
216 GtkWidget *parent, gboolean auto_close,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 gd->auto_close = auto_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 gd->data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 gd->cancel_cb = cancel_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224
1175
2518a4a73d89 Rename wmsubclass and name to role, which corresponds better to the purpose of the parameter as it ends to be passed to gtk_window_set_role().
zas_
parents: 1174
diff changeset
225 gd->dialog = window_new(GTK_WINDOW_TOPLEVEL, role, NULL, NULL, title);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 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
227
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 if (parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 GtkWindow *window = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 if (GTK_IS_WINDOW(parent))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 window = GTK_WINDOW(parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 else
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 GtkWidget *top;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 top = gtk_widget_get_toplevel(parent);
1810
c416d099a3dc GTK marks several functions as deprecated
mow
parents: 1807
diff changeset
241 #if GTK_CHECK_VERSION(2,20,0)
c416d099a3dc GTK marks several functions as deprecated
mow
parents: 1807
diff changeset
242 if (GTK_IS_WINDOW(top) && gtk_widget_is_toplevel(top)) window = GTK_WINDOW(top);
c416d099a3dc GTK marks several functions as deprecated
mow
parents: 1807
diff changeset
243 #else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 if (GTK_IS_WINDOW(top) && GTK_WIDGET_TOPLEVEL(top)) window = GTK_WINDOW(top);
1810
c416d099a3dc GTK marks several functions as deprecated
mow
parents: 1807
diff changeset
245 #endif
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 if (window) gtk_window_set_transient_for(GTK_WINDOW(gd->dialog), window);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 g_signal_connect(G_OBJECT(gd->dialog), "delete_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 G_CALLBACK(generic_dialog_delete_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 g_signal_connect(G_OBJECT(gd->dialog), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 G_CALLBACK(generic_dialog_key_press_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 gtk_window_set_resizable(GTK_WINDOW(gd->dialog), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 gtk_container_set_border_width(GTK_CONTAINER(gd->dialog), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 vbox = gtk_vbox_new(FALSE, PREF_PAD_BUTTON_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 gtk_container_add(GTK_CONTAINER(gd->dialog), vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 gd->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 gtk_box_pack_start(GTK_BOX(vbox), gd->vbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 gtk_widget_show(gd->vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 gd->hbox = gtk_hbutton_box_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 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
269 gtk_box_set_spacing(GTK_BOX(gd->hbox), PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 gtk_box_pack_start(GTK_BOX(vbox), gd->hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 gtk_widget_show(gd->hbox);
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 (gd->cancel_cb)
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 289
diff changeset
274 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 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
276 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 else
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->cancel_button = 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 if (generic_dialog_get_alternative_button_order(gd->hbox))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 g_signal_connect(G_OBJECT(gd->dialog), "show",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 G_CALLBACK(generic_dialog_show_cb), gd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 gd->default_cb = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 GenericDialog *generic_dialog_new(const gchar *title,
1175
2518a4a73d89 Rename wmsubclass and name to role, which corresponds better to the purpose of the parameter as it ends to be passed to gtk_window_set_role().
zas_
parents: 1174
diff changeset
292 const gchar *role,
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
293 GtkWidget *parent, gboolean auto_close,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
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 GenericDialog *gd;
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 gd = g_new0(GenericDialog, 1);
1175
2518a4a73d89 Rename wmsubclass and name to role, which corresponds better to the purpose of the parameter as it ends to be passed to gtk_window_set_role().
zas_
parents: 1174
diff changeset
299 generic_dialog_setup(gd, title, role,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 parent, auto_close, cancel_cb, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 }
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 * simple warning dialog
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 *-----------------------------------------------------------------------------
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 289
diff changeset
307 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 static void warning_dialog_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 /* no op */
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 GenericDialog *warning_dialog(const gchar *heading, const gchar *text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 const gchar *icon_stock_id, GtkWidget *parent)
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 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1055
diff changeset
319 gd = generic_dialog_new(heading, "warning", parent, TRUE, NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 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
321
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 generic_dialog_add_message(gd, icon_stock_id, heading, text);
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 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 * generic file ops dialog routines
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 *-----------------------------------------------------------------------------
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 289
diff changeset
333 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
335 void file_dialog_close(FileDialog *fdlg)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
337 file_data_unref(fdlg->source_fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
338 g_free(fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
339 if (fdlg->source_list) filelist_free(fdlg->source_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
341 generic_dialog_close(GENERIC_DIALOG(fdlg));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 FileDialog *file_dialog_new(const gchar *title,
1175
2518a4a73d89 Rename wmsubclass and name to role, which corresponds better to the purpose of the parameter as it ends to be passed to gtk_window_set_role().
zas_
parents: 1174
diff changeset
345 const gchar *role,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 GtkWidget *parent,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 void (*cancel_cb)(FileDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
349 FileDialog *fdlg = NULL;
9
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 fdlg = g_new0(FileDialog, 1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
353 generic_dialog_setup(GENERIC_DIALOG(fdlg), title,
1175
2518a4a73d89 Rename wmsubclass and name to role, which corresponds better to the purpose of the parameter as it ends to be passed to gtk_window_set_role().
zas_
parents: 1174
diff changeset
354 role, parent, FALSE,
1002
3096a47232ec Use gpointer instead of void *.
zas_
parents: 726
diff changeset
355 (gpointer)cancel_cb, data);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
357 return fdlg;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 }
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 GtkWidget *file_dialog_add_button(FileDialog *fdlg, const gchar *stock_id, const gchar *text,
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
361 void (*func_cb)(FileDialog *, gpointer), gboolean is_default)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
363 return generic_dialog_add_button(GENERIC_DIALOG(fdlg), stock_id, text,
1002
3096a47232ec Use gpointer instead of void *.
zas_
parents: 726
diff changeset
364 (gpointer)func_cb, is_default);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 }
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 static void file_dialog_entry_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
369 FileDialog *fdlg = data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
370 g_free(fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
371 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
372 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 static void file_dialog_entry_enter_cb(const gchar *path, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 file_dialog_entry_cb(NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 if (gd->default_cb) gd->default_cb(gd, gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
383 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
384 const gchar *history_key, const gchar *filter, const gchar *filter_desc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 GtkWidget *tabcomp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 GtkWidget *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
389 if (fdlg->entry) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
391 tabcomp = tab_completion_new_with_history(&fdlg->entry, NULL,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
392 history_key, -1, file_dialog_entry_enter_cb, fdlg);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
393 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
394 generic_dialog_attach_default(GENERIC_DIALOG(fdlg), fdlg->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 gtk_widget_show(tabcomp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396
726
a1dcef8cd1ae Use G_DIR_SEPARATOR where applicable.
zas_
parents: 702
diff changeset
397 if (path && path[0] == G_DIR_SEPARATOR)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
399 fdlg->dest_path = g_strdup(path);
9
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 const gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
405 base = tab_completion_set_to_last_history(fdlg->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 if (!base) base = default_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 if (!base) base = homedir();
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 if (path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 {
702
e07895754e65 Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents: 648
diff changeset
412 fdlg->dest_path = g_build_filename(base, path, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 else
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 fdlg->dest_path = g_strdup(base);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
420 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
421 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
422 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
423 gtk_widget_show(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
425 gtk_widget_grab_focus(fdlg->entry);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
426 if (fdlg->dest_path)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
428 gtk_entry_set_text(GTK_ENTRY(fdlg->entry), fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
429 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
430 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
432 g_signal_connect(G_OBJECT(fdlg->entry), "changed",
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
433 G_CALLBACK(file_dialog_entry_cb), fdlg);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
436 void file_dialog_add_filter(FileDialog *fdlg, const gchar *filter, const gchar *filter_desc, gboolean set)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
438 if (!fdlg->entry) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
439 path_selection_add_filter(fdlg->entry, filter, filter_desc, set);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
442 void file_dialog_clear_filter(FileDialog *fdlg)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
444 if (!fdlg->entry) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
445 path_selection_clear_filter(fdlg->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447
1451
0e67a5992d51 gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
448 void file_dialog_sync_history(FileDialog *fdlg, gboolean dir_only)
9
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 if (!fdlg->dest_path) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 if (!dir_only ||
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
453 (dir_only && isdir(fdlg->dest_path)) )
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
455 tab_completion_append_to_history(fdlg->entry, fdlg->dest_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
459 gchar *buf = remove_level_from_path(fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 15
diff changeset
460 tab_completion_append_to_history(fdlg->entry, buf);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1002
diff changeset
464 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */