Mercurial > geeqie
annotate src/desktop_file.c @ 1631:2349fa90226d
better implementation of tree_view_row_get_visibility,
gtk_tree_view_set_cursor is not sufficient in some cases, call also
tree_view_row_make_visible
author | nadvornik |
---|---|
date | Sat, 06 Jun 2009 16:14:07 +0000 |
parents | dd361c680164 |
children | c8252313dcfa |
rev | line source |
---|---|
1479 | 1 /* |
2 * Geeqie | |
3 * (C) 2004 John Ellis | |
4 * Copyright (C) 2008 - 2009 The Geeqie Team | |
5 * | |
6 * Author: Vladimir Nadvornik | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
13 #include "main.h" | |
14 #include "desktop_file.h" | |
15 | |
16 #include "editors.h" | |
17 #include "filedata.h" | |
18 #include "misc.h" | |
19 #include "ui_misc.h" | |
20 #include "ui_fileops.h" | |
21 #include "ui_utildlg.h" | |
22 #include "pixbuf_util.h" | |
23 #include "window.h" | |
24 #include "utilops.h" | |
25 #include "layout_util.h" | |
26 | |
27 #define CONFIG_WINDOW_DEF_WIDTH 700 | |
28 #define CONFIG_WINDOW_DEF_HEIGHT 400 | |
29 | |
30 | |
31 | |
32 typedef struct _EditorWindow EditorWindow; | |
33 struct _EditorWindow | |
34 { | |
35 GtkWidget *window; | |
36 GtkWidget *entry; | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
37 GtkWidget *save_button; |
1479 | 38 GtkTextBuffer *buffer; |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
39 gchar *desktop_name; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
40 gboolean modified; |
1479 | 41 }; |
42 | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
43 typedef struct _EditorListWindow EditorListWindow; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
44 struct _EditorListWindow |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
45 { |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
46 GtkWidget *window; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
47 GtkWidget *view; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
48 GenericDialog *gd; /* any open confirm dialogs ? */ |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
49 }; |
1479 | 50 |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
51 typedef struct _EditorWindowDel_Data EditorWindowDel_Data; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
52 struct _EditorWindowDel_Data |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
53 { |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
54 EditorListWindow *ewl; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
55 gchar *path; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
56 }; |
1479 | 57 |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
58 static EditorListWindow *editor_list_window = NULL; |
1479 | 59 |
60 static gboolean editor_window_save(EditorWindow *ew) | |
61 { | |
62 gchar *path; | |
63 gchar *text; | |
64 GtkTextIter start, end; | |
65 GError *error = NULL; | |
66 gboolean ret = TRUE; | |
67 const gchar *name = gtk_entry_get_text(GTK_ENTRY(ew->entry)); | |
68 | |
69 if (!name || !name[0]) | |
70 { | |
71 file_util_warning_dialog(_("Can't save"), _("Please specify file name."), GTK_STOCK_DIALOG_ERROR, NULL); | |
72 return FALSE; | |
73 } | |
74 | |
75 gtk_text_buffer_get_bounds(ew->buffer, &start, &end); | |
76 text = gtk_text_buffer_get_text(ew->buffer, &start, &end, FALSE); | |
77 | |
78 path = g_build_filename(get_rc_dir(), "applications", name, NULL); | |
79 | |
80 if (!g_file_set_contents(path, text, -1, &error)) | |
81 { | |
82 file_util_warning_dialog(_("Can't save"), error->message, GTK_STOCK_DIALOG_ERROR, NULL); | |
83 g_error_free(error); | |
84 ret = FALSE; | |
85 } | |
86 | |
87 g_free(path); | |
88 g_free(text); | |
89 layout_editors_reload_all(); | |
90 return ret; | |
91 } | |
92 | |
93 static void editor_window_close_cb(GtkWidget *widget, gpointer data) | |
94 { | |
95 EditorWindow *ew = data; | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
96 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
97 g_free(ew->desktop_name); |
1479 | 98 gtk_widget_destroy(ew->window); |
99 g_free(ew); | |
100 } | |
101 | |
102 static gint editor_window_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data) | |
103 { | |
104 editor_window_close_cb(w, data); | |
105 return TRUE; | |
106 } | |
107 | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
108 static void editor_window_save_cb(GtkWidget *widget, gpointer data) |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
109 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
110 EditorWindow *ew = data; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
111 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
112 if (ew->modified) |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
113 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
114 editor_window_save(ew); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
115 } |
1569 | 116 |
117 gtk_widget_set_sensitive(ew->save_button, FALSE); | |
118 ew->modified = FALSE; | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
119 } |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
120 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
121 static void editor_window_text_modified_cb(GtkWidget *widget, gpointer data) |
1479 | 122 { |
123 EditorWindow *ew = data; | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
124 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
125 if (gtk_text_buffer_get_modified(ew->buffer)) |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
126 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
127 gtk_widget_set_sensitive(ew->save_button, TRUE); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
128 ew->modified = TRUE; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
129 } |
1479 | 130 } |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
131 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
132 static void editor_window_entry_changed_cb(GtkWidget *widget, gpointer data) |
1479 | 133 { |
134 EditorWindow *ew = data; | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
135 const gchar *content = gtk_entry_get_text(GTK_ENTRY(ew->entry)); |
1491 | 136 gboolean modified = ew->modified; |
137 | |
138 if (!modified) | |
139 { | |
140 modified = (!ew->desktop_name && *content); | |
141 } | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
142 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
143 if (!modified) |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
144 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
145 modified = strcmp(ew->desktop_name, content); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
146 } |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
147 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
148 gtk_widget_set_sensitive(ew->save_button, modified); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
149 ew->modified = modified; |
1479 | 150 } |
151 | |
152 static void editor_window_new(const gchar *src_path, const gchar *desktop_name) | |
153 { | |
154 EditorWindow *ew; | |
155 GtkWidget *win_vbox; | |
156 GtkWidget *hbox; | |
157 GtkWidget *button; | |
158 GtkWidget *ct_button; | |
159 GtkWidget *button_hbox; | |
160 GtkWidget *scrolled; | |
161 GtkWidget *text_view; | |
162 gchar *text; | |
163 gsize size; | |
164 | |
165 ew = g_new0(EditorWindow, 1); | |
166 | |
167 | |
168 ew->window = window_new(GTK_WINDOW_TOPLEVEL, "Desktop", PIXBUF_INLINE_ICON_CONFIG, NULL, _("Desktop file")); | |
169 gtk_window_set_type_hint(GTK_WINDOW(ew->window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
170 | |
171 g_signal_connect(G_OBJECT(ew->window), "delete_event", | |
172 G_CALLBACK(editor_window_delete_cb), ew); | |
173 | |
174 gtk_window_set_default_size(GTK_WINDOW(ew->window), CONFIG_WINDOW_DEF_WIDTH, CONFIG_WINDOW_DEF_HEIGHT); | |
175 gtk_window_set_resizable(GTK_WINDOW(ew->window), TRUE); | |
176 gtk_container_set_border_width(GTK_CONTAINER(ew->window), PREF_PAD_BORDER); | |
177 | |
178 win_vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE); | |
179 gtk_container_add(GTK_CONTAINER(ew->window), win_vbox); | |
180 gtk_widget_show(win_vbox); | |
181 | |
182 hbox = gtk_hbox_new(FALSE, PREF_PAD_SPACE); | |
183 gtk_box_pack_end(GTK_BOX(win_vbox), hbox, FALSE, FALSE, 0); | |
184 gtk_widget_show(hbox); | |
185 | |
186 ew->entry = gtk_entry_new(); | |
187 gtk_box_pack_start(GTK_BOX(hbox), ew->entry, TRUE, TRUE, 0); | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
188 ew->desktop_name = NULL; |
1479 | 189 if (desktop_name) |
190 { | |
191 gtk_entry_set_text(GTK_ENTRY(ew->entry), desktop_name); | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
192 ew->desktop_name = g_strdup(desktop_name); |
1479 | 193 } |
194 gtk_widget_show(ew->entry); | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
195 g_signal_connect(G_OBJECT(ew->entry), "changed", G_CALLBACK(editor_window_entry_changed_cb), ew); |
1479 | 196 |
197 button_hbox = gtk_hbutton_box_new(); | |
198 gtk_button_box_set_layout(GTK_BUTTON_BOX(button_hbox), GTK_BUTTONBOX_END); | |
199 gtk_box_set_spacing(GTK_BOX(button_hbox), PREF_PAD_BUTTON_GAP); | |
200 gtk_box_pack_end(GTK_BOX(hbox), button_hbox, FALSE, FALSE, 0); | |
201 gtk_widget_show(button_hbox); | |
202 | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
203 ew->save_button = pref_button_new(NULL, GTK_STOCK_SAVE, NULL, FALSE, |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
204 G_CALLBACK(editor_window_save_cb), ew); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
205 gtk_container_add(GTK_CONTAINER(button_hbox), ew->save_button); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
206 GTK_WIDGET_SET_FLAGS(ew->save_button, GTK_CAN_DEFAULT); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
207 gtk_widget_set_sensitive(ew->save_button, FALSE); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
208 gtk_widget_show(ew->save_button); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
209 ct_button = ew->save_button; |
1479 | 210 |
1569 | 211 button = pref_button_new(NULL, GTK_STOCK_CLOSE, NULL, FALSE, |
1479 | 212 G_CALLBACK(editor_window_close_cb), ew); |
213 gtk_container_add(GTK_CONTAINER(button_hbox), button); | |
214 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
215 gtk_widget_show(button); | |
216 | |
217 if (!generic_dialog_get_alternative_button_order(ew->window)) | |
218 { | |
219 gtk_box_reorder_child(GTK_BOX(button_hbox), ct_button, -1); | |
220 } | |
221 | |
222 | |
223 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
224 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
225 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
226 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
227 gtk_box_pack_start(GTK_BOX(win_vbox), scrolled, TRUE, TRUE, 5); | |
228 gtk_widget_show(scrolled); | |
229 | |
230 text_view = gtk_text_view_new(); | |
231 gtk_container_add(GTK_CONTAINER(scrolled), text_view); | |
232 gtk_widget_show(text_view); | |
233 | |
234 ew->buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view)); | |
235 if (g_file_get_contents(src_path, &text, &size, NULL)) | |
236 { | |
237 gtk_text_buffer_set_text(ew->buffer, text, size); | |
238 } | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
239 gtk_text_buffer_set_modified(ew->buffer, FALSE); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
240 g_signal_connect(G_OBJECT(ew->buffer), "modified-changed", |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
241 G_CALLBACK(editor_window_text_modified_cb), ew); |
1479 | 242 |
243 gtk_widget_show(ew->window); | |
244 } | |
245 | |
246 | |
247 static void editor_list_window_close_cb(GtkWidget *widget, gpointer data) | |
248 { | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
249 gtk_widget_destroy(editor_list_window->window); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
250 g_free(editor_list_window); |
1479 | 251 editor_list_window = NULL; |
252 } | |
253 | |
254 static gboolean editor_list_window_delete(GtkWidget *widget, GdkEventAny *event, gpointer data) | |
255 { | |
256 editor_list_window_close_cb(NULL, NULL); | |
257 return TRUE; | |
258 } | |
259 | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
260 static void editor_list_window_delete_dlg_cancel(GenericDialog *gd, gpointer data); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
261 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
262 static void editor_list_window_delete_dlg_cancel(GenericDialog *gd, gpointer data) |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
263 { |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
264 EditorWindowDel_Data *ewdl = data; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
265 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
266 ewdl->ewl->gd = NULL; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
267 g_free(ewdl->path); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
268 g_free(ewdl); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
269 } |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
270 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
271 static void editor_list_window_delete_dlg_ok_cb(GenericDialog *gd, gpointer data) |
1479 | 272 { |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
273 EditorWindowDel_Data *ewdl = data; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
274 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
275 if (!unlink_file(ewdl->path)) |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
276 { |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
277 gchar *text = g_strdup_printf(_("Unable to delete file:\n%s"), ewdl->path); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
278 warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_WARNING, NULL); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
279 g_free(text); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
280 } |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
281 else |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
282 { |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
283 /* refresh list */ |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
284 layout_editors_reload_all(); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
285 } |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
286 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
287 editor_list_window_delete_dlg_cancel(gd, data); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
288 } |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
289 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
290 static void editor_list_window_delete_cb(GtkWidget *widget, gpointer data) |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
291 { |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
292 EditorListWindow *ewl = data; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
293 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(ewl->view)); |
1479 | 294 GtkTreeIter iter; |
295 | |
296 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
297 { | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
298 GtkTreeModel *store = gtk_tree_view_get_model(GTK_TREE_VIEW(ewl->view)); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
299 gchar *path; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
300 gchar *key; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
301 gchar *text; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
302 EditorWindowDel_Data *ewdl; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
303 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
304 gtk_tree_model_get(store, &iter, |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
305 DESKTOP_FILE_COLUMN_PATH, &path, |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
306 DESKTOP_FILE_COLUMN_KEY, &key, -1); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
307 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
308 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
309 ewdl = g_new(EditorWindowDel_Data, 1); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
310 ewdl->ewl = ewl; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
311 ewdl->path = path; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
312 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
313 if (ewl->gd) |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
314 { |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
315 GenericDialog *gd = ewl->gd; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
316 editor_list_window_delete_dlg_cancel(ewl->gd, ewl->gd->data); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
317 generic_dialog_close(gd); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
318 } |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
319 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
320 ewl->gd = generic_dialog_new(_("Delete file"), "dlg_confirm", |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
321 NULL, TRUE, |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
322 editor_list_window_delete_dlg_cancel, ewdl); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
323 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
324 generic_dialog_add_button(ewl->gd, GTK_STOCK_DELETE, NULL, editor_list_window_delete_dlg_ok_cb, TRUE); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
325 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
326 text = g_strdup_printf(_("About to delete the file:\n %s"), path); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
327 generic_dialog_add_message(ewl->gd, GTK_STOCK_DIALOG_QUESTION, |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
328 _("Delete file"), text); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
329 g_free(text); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
330 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
331 gtk_widget_show(ewl->gd->dialog); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
332 } |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
333 } |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
334 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
335 static void editor_list_window_edit_cb(GtkWidget *widget, gpointer data) |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
336 { |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
337 EditorListWindow *ewl = data; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
338 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(ewl->view)); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
339 GtkTreeIter iter; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
340 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
341 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
342 { |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
343 GtkTreeModel *store = gtk_tree_view_get_model(GTK_TREE_VIEW(ewl->view)); |
1479 | 344 gchar *path; |
345 gchar *key; | |
346 | |
347 gtk_tree_model_get(store, &iter, | |
348 DESKTOP_FILE_COLUMN_PATH, &path, | |
349 DESKTOP_FILE_COLUMN_KEY, &key, -1); | |
350 editor_window_new(path, key); | |
351 g_free(key); | |
352 g_free(path); | |
353 } | |
354 } | |
355 | |
356 static void editor_list_window_new_cb(GtkWidget *widget, gpointer data) | |
357 { | |
358 editor_window_new(DESKTOP_FILE_TEMPLATE, _("new.desktop")); | |
359 } | |
360 | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
361 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
362 static gint editor_list_window_sort_cb(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data) |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
363 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
364 gint n = GPOINTER_TO_INT(data); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
365 gint ret = 0; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
366 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
367 switch (n) |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
368 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
369 case DESKTOP_FILE_COLUMN_KEY: |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
370 case DESKTOP_FILE_COLUMN_NAME: |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
371 case DESKTOP_FILE_COLUMN_PATH: |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
372 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
373 gchar *s1, *s2; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
374 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
375 gtk_tree_model_get(model, a, n, &s1, -1); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
376 gtk_tree_model_get(model, b, n, &s2, -1); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
377 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
378 if (!s1 || !s2) |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
379 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
380 if (!s1 && !s2) break; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
381 ret = s1 ? 1 : -1; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
382 } |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
383 else |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
384 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
385 ret = g_utf8_collate(s1, s2); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
386 } |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
387 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
388 g_free(s1); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
389 g_free(s2); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
390 } |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
391 break; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
392 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
393 case DESKTOP_FILE_COLUMN_HIDDEN: |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
394 { |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
395 gint *v1, *v2; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
396 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
397 gtk_tree_model_get(model, a, n, &v1, -1); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
398 gtk_tree_model_get(model, b, n, &v2, -1); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
399 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
400 if (v1 == v2) |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
401 ret = 0; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
402 else if (v1 < v2) |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
403 ret = 1; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
404 else |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
405 ret = -1; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
406 } |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
407 break; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
408 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
409 default: |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
410 g_return_val_if_reached(0); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
411 } |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
412 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
413 return ret; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
414 } |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
415 |
1479 | 416 static void editor_list_window_create(void) |
417 { | |
418 GtkWidget *win_vbox; | |
419 GtkWidget *hbox; | |
420 GtkWidget *button; | |
421 GtkWidget *scrolled; | |
422 GtkCellRenderer *renderer; | |
423 GtkTreeSelection *selection; | |
424 GtkTreeViewColumn *column; | |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
425 GtkTreeModel *store; |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
426 GtkTreeSortable *sortable; |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
427 EditorListWindow *ewl; |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
428 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
429 editor_list_window = ewl = g_new0(EditorListWindow, 1); |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
430 |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
431 ewl->window = window_new(GTK_WINDOW_TOPLEVEL, "editors", PIXBUF_INLINE_ICON_CONFIG, NULL, _("Editors")); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
432 gtk_window_set_type_hint(GTK_WINDOW(ewl->window), GDK_WINDOW_TYPE_HINT_DIALOG); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
433 g_signal_connect(G_OBJECT(ewl->window), "delete_event", |
1479 | 434 G_CALLBACK(editor_list_window_delete), NULL); |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
435 gtk_window_set_default_size(GTK_WINDOW(ewl->window), CONFIG_WINDOW_DEF_WIDTH, CONFIG_WINDOW_DEF_HEIGHT); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
436 gtk_window_set_resizable(GTK_WINDOW(ewl->window), TRUE); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
437 gtk_container_set_border_width(GTK_CONTAINER(ewl->window), PREF_PAD_BORDER); |
1479 | 438 |
439 win_vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE); | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
440 gtk_container_add(GTK_CONTAINER(ewl->window), win_vbox); |
1479 | 441 gtk_widget_show(win_vbox); |
442 | |
443 hbox = gtk_hbutton_box_new(); | |
444 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END); | |
445 gtk_box_set_spacing(GTK_BOX(hbox), PREF_PAD_BUTTON_GAP); | |
446 gtk_box_pack_end(GTK_BOX(win_vbox), hbox, FALSE, FALSE, 0); | |
447 gtk_widget_show(hbox); | |
448 | |
449 | |
450 button = pref_button_new(NULL, GTK_STOCK_NEW, NULL, FALSE, | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
451 G_CALLBACK(editor_list_window_new_cb), ewl); |
1479 | 452 gtk_container_add(GTK_CONTAINER(hbox), button); |
453 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
454 gtk_widget_show(button); | |
455 | |
456 button = pref_button_new(NULL, GTK_STOCK_EDIT, NULL, FALSE, | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
457 G_CALLBACK(editor_list_window_edit_cb), ewl); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
458 gtk_container_add(GTK_CONTAINER(hbox), button); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
459 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
460 gtk_widget_show(button); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
461 |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
462 button = pref_button_new(NULL, GTK_STOCK_DELETE, NULL, FALSE, |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
463 G_CALLBACK(editor_list_window_delete_cb), ewl); |
1479 | 464 gtk_container_add(GTK_CONTAINER(hbox), button); |
465 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
466 gtk_widget_show(button); | |
467 | |
468 button = pref_button_new(NULL, GTK_STOCK_CLOSE, NULL, FALSE, | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
469 G_CALLBACK(editor_list_window_close_cb), ewl); |
1479 | 470 gtk_container_add(GTK_CONTAINER(hbox), button); |
471 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
472 gtk_widget_show(button); | |
473 | |
474 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
475 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
476 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
477 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
478 gtk_box_pack_start(GTK_BOX(win_vbox), scrolled, TRUE, TRUE, 5); | |
479 gtk_widget_show(scrolled); | |
480 | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
481 ewl->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(desktop_file_list)); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
482 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ewl->view)); |
1479 | 483 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE); |
484 | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
485 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(ewl->view), FALSE); |
1479 | 486 |
487 column = gtk_tree_view_column_new(); | |
1624 | 488 gtk_tree_view_column_set_title(column, _("Name")); |
1479 | 489 gtk_tree_view_column_set_resizable(column, TRUE); |
490 renderer = gtk_cell_renderer_text_new(); | |
491 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1624 | 492 gtk_tree_view_column_add_attribute(column, renderer, "text", DESKTOP_FILE_COLUMN_NAME); |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
493 gtk_tree_view_append_column(GTK_TREE_VIEW(ewl->view), column); |
1624 | 494 gtk_tree_view_column_set_sort_column_id(column, DESKTOP_FILE_COLUMN_NAME); |
1479 | 495 |
496 column = gtk_tree_view_column_new(); | |
497 gtk_tree_view_column_set_title(column, _("Hidden")); | |
498 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
499 renderer = gtk_cell_renderer_toggle_new(); | |
1499
56b534d71872
Make desktop window list checkboxes centered and not activatable.
zas_
parents:
1496
diff
changeset
|
500 g_object_set(G_OBJECT(renderer), |
56b534d71872
Make desktop window list checkboxes centered and not activatable.
zas_
parents:
1496
diff
changeset
|
501 "activatable", FALSE, // not clickable for now |
56b534d71872
Make desktop window list checkboxes centered and not activatable.
zas_
parents:
1496
diff
changeset
|
502 "xalign", 0.5, // centered |
56b534d71872
Make desktop window list checkboxes centered and not activatable.
zas_
parents:
1496
diff
changeset
|
503 NULL); |
56b534d71872
Make desktop window list checkboxes centered and not activatable.
zas_
parents:
1496
diff
changeset
|
504 gtk_tree_view_column_pack_start(column, renderer, TRUE); // TRUE needed for centering |
1479 | 505 gtk_tree_view_column_add_attribute(column, renderer, "active", DESKTOP_FILE_COLUMN_HIDDEN); |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
506 gtk_tree_view_append_column(GTK_TREE_VIEW(ewl->view), column); |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
507 gtk_tree_view_column_set_sort_column_id(column, DESKTOP_FILE_COLUMN_HIDDEN); |
1499
56b534d71872
Make desktop window list checkboxes centered and not activatable.
zas_
parents:
1496
diff
changeset
|
508 gtk_tree_view_column_set_alignment(column, 0.5); |
56b534d71872
Make desktop window list checkboxes centered and not activatable.
zas_
parents:
1496
diff
changeset
|
509 |
1479 | 510 column = gtk_tree_view_column_new(); |
1624 | 511 gtk_tree_view_column_set_title(column, _("Desktop file")); |
1479 | 512 gtk_tree_view_column_set_resizable(column, TRUE); |
513 renderer = gtk_cell_renderer_text_new(); | |
514 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1624 | 515 gtk_tree_view_column_add_attribute(column, renderer, "text", DESKTOP_FILE_COLUMN_KEY); |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
516 gtk_tree_view_append_column(GTK_TREE_VIEW(ewl->view), column); |
1624 | 517 gtk_tree_view_column_set_sort_column_id(column, DESKTOP_FILE_COLUMN_KEY); |
1479 | 518 |
519 column = gtk_tree_view_column_new(); | |
520 gtk_tree_view_column_set_title(column, _("Path")); | |
521 gtk_tree_view_column_set_resizable(column, TRUE); | |
522 renderer = gtk_cell_renderer_text_new(); | |
523 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
524 gtk_tree_view_column_add_attribute(column, renderer, "text", DESKTOP_FILE_COLUMN_PATH); | |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
525 gtk_tree_view_append_column(GTK_TREE_VIEW(ewl->view), column); |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
526 gtk_tree_view_column_set_sort_column_id(column, DESKTOP_FILE_COLUMN_PATH); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
527 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
528 /* set up sorting */ |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
529 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ewl->view)); |
1490
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
530 sortable = GTK_TREE_SORTABLE(store); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
531 gtk_tree_sortable_set_sort_func(sortable, DESKTOP_FILE_COLUMN_KEY, editor_list_window_sort_cb, |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
532 GINT_TO_POINTER(DESKTOP_FILE_COLUMN_KEY), NULL); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
533 gtk_tree_sortable_set_sort_func(sortable, DESKTOP_FILE_COLUMN_HIDDEN, editor_list_window_sort_cb, |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
534 GINT_TO_POINTER(DESKTOP_FILE_COLUMN_HIDDEN), NULL); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
535 gtk_tree_sortable_set_sort_func(sortable, DESKTOP_FILE_COLUMN_NAME, editor_list_window_sort_cb, |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
536 GINT_TO_POINTER(DESKTOP_FILE_COLUMN_NAME), NULL); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
537 gtk_tree_sortable_set_sort_func(sortable, DESKTOP_FILE_COLUMN_PATH, editor_list_window_sort_cb, |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
538 GINT_TO_POINTER(DESKTOP_FILE_COLUMN_PATH), NULL); |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
539 |
b924293cf6c8
Desktop files window: make columns sortable, replace Apply and OK buttons by one Save button which is made sensitive when needed.
zas_
parents:
1479
diff
changeset
|
540 /* set initial sort order */ |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
541 //gtk_tree_sortable_set_sort_column_id(sortable, DESKTOP_FILE_COLUMN_KEY, GTK_SORT_ASCENDING); |
1479 | 542 |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
543 gtk_container_add(GTK_CONTAINER(scrolled), ewl->view); |
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
544 gtk_widget_show(ewl->view); |
1479 | 545 |
1496
03c22c05c6b6
Allow to delete an editor's desktop file from editors list window.
zas_
parents:
1491
diff
changeset
|
546 gtk_widget_show(ewl->window); |
1479 | 547 } |
548 | |
549 /* | |
550 *----------------------------------------------------------------------------- | |
551 * config window show (public) | |
552 *----------------------------------------------------------------------------- | |
553 */ | |
554 | |
555 void show_editor_list_window(void) | |
556 { | |
557 if (editor_list_window) | |
558 { | |
559 gtk_window_present(GTK_WINDOW(editor_list_window)); | |
560 return; | |
561 } | |
562 | |
563 editor_list_window_create(); | |
564 } | |
1613 | 565 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |