annotate src/desktop_file.c @ 1752:843c4eb46e09

fixed incorrect translation
author nadvornik
date Sun, 13 Sep 2009 21:03:17 +0000
parents a0e47436b552
children 650915809048
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
1 /*
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
2 * Geeqie
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
3 * (C) 2004 John Ellis
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
5 *
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
6 * Author: Vladimir Nadvornik
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
7 *
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
11 */
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
12
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
13 #include "main.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
14 #include "desktop_file.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
15
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
16 #include "editors.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
17 #include "filedata.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
18 #include "misc.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
19 #include "ui_misc.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
20 #include "ui_fileops.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
21 #include "ui_utildlg.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
22 #include "pixbuf_util.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
23 #include "window.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
24 #include "utilops.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
25 #include "layout_util.h"
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
26
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
27 #define CONFIG_WINDOW_DEF_WIDTH 700
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
28 #define CONFIG_WINDOW_DEF_HEIGHT 400
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
29
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
30
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
31
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
32 typedef struct _EditorWindow EditorWindow;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
33 struct _EditorWindow
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
34 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
35 GtkWidget *window;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
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
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
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
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
41 };
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
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
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
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
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
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
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
59
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
60 static gboolean editor_window_save(EditorWindow *ew)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
61 {
1641
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
62 gchar *dir;
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
63 gchar *path;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
64 gchar *text;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
65 GtkTextIter start, end;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
66 GError *error = NULL;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
67 gboolean ret = TRUE;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
68 const gchar *name = gtk_entry_get_text(GTK_ENTRY(ew->entry));
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
69
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
70 if (!name || !name[0])
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
71 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
72 file_util_warning_dialog(_("Can't save"), _("Please specify file name."), GTK_STOCK_DIALOG_ERROR, NULL);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
73 return FALSE;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
74 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
75
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
76 gtk_text_buffer_get_bounds(ew->buffer, &start, &end);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
77 text = gtk_text_buffer_get_text(ew->buffer, &start, &end, FALSE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
78
1641
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
79 dir = g_build_filename(get_rc_dir(), "applications", NULL);
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
80 path = g_build_filename(dir, name, NULL);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
81
1641
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
82 if (!recursive_mkdir_if_not_exists(dir, 0755))
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
83 {
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
84 file_util_warning_dialog(_("Can't save"), _("Could not create directory"), GTK_STOCK_DIALOG_ERROR, NULL);
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
85 ret = FALSE;
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
86 }
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
87
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
88 if (ret && !g_file_set_contents(path, text, -1, &error))
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
89 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
90 file_util_warning_dialog(_("Can't save"), error->message, GTK_STOCK_DIALOG_ERROR, NULL);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
91 g_error_free(error);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
92 ret = FALSE;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
93 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
94
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
95 g_free(path);
1641
c8252313dcfa make sure that a directory exists on saving desktop files
nadvornik
parents: 1624
diff changeset
96 g_free(dir);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
97 g_free(text);
1736
8e64965c1d92 load desktop files in idle time
nadvornik
parents: 1641
diff changeset
98 layout_editors_reload_start();
8e64965c1d92 load desktop files in idle time
nadvornik
parents: 1641
diff changeset
99 /* idle function is not needed, everything should be cached */
8e64965c1d92 load desktop files in idle time
nadvornik
parents: 1641
diff changeset
100 layout_editors_reload_finish();
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
101 return ret;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
102 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
103
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
104 static void editor_window_close_cb(GtkWidget *widget, gpointer data)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
105 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
106 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
107
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 g_free(ew->desktop_name);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
109 gtk_widget_destroy(ew->window);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
110 g_free(ew);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
111 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
112
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
113 static gint editor_window_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
114 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
115 editor_window_close_cb(w, data);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
116 return TRUE;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
117 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
118
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 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
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 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
122
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
123 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
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 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
126 }
1569
6245009414c9 small fixes
nadvornik
parents: 1499
diff changeset
127
6245009414c9 small fixes
nadvornik
parents: 1499
diff changeset
128 gtk_widget_set_sensitive(ew->save_button, FALSE);
1746
a0e47436b552 editor fixes
nadvornik
parents: 1736
diff changeset
129 gtk_text_buffer_set_modified(ew->buffer, FALSE);
1569
6245009414c9 small fixes
nadvornik
parents: 1499
diff changeset
130 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
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
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
133 static void editor_window_text_modified_cb(GtkWidget *widget, gpointer data)
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
134 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
135 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
136
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
137 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
138 {
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
139 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
140 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
141 }
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
142 }
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
143
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 static void editor_window_entry_changed_cb(GtkWidget *widget, gpointer data)
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
145 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
146 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
147 const gchar *content = gtk_entry_get_text(GTK_ENTRY(ew->entry));
1491
f057c235426f Fix up previous patch.
zas_
parents: 1490
diff changeset
148 gboolean modified = ew->modified;
f057c235426f Fix up previous patch.
zas_
parents: 1490
diff changeset
149
f057c235426f Fix up previous patch.
zas_
parents: 1490
diff changeset
150 if (!modified)
f057c235426f Fix up previous patch.
zas_
parents: 1490
diff changeset
151 {
f057c235426f Fix up previous patch.
zas_
parents: 1490
diff changeset
152 modified = (!ew->desktop_name && *content);
f057c235426f Fix up previous patch.
zas_
parents: 1490
diff changeset
153 }
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
154
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
155 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
156 {
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
157 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
158 }
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
159
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
160 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
161 ew->modified = modified;
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
162 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
163
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
164 static void editor_window_new(const gchar *src_path, const gchar *desktop_name)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
165 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
166 EditorWindow *ew;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
167 GtkWidget *win_vbox;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
168 GtkWidget *hbox;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
169 GtkWidget *button;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
170 GtkWidget *ct_button;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
171 GtkWidget *button_hbox;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
172 GtkWidget *scrolled;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
173 GtkWidget *text_view;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
174 gchar *text;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
175 gsize size;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
176
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
177 ew = g_new0(EditorWindow, 1);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
178
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
179
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
180 ew->window = window_new(GTK_WINDOW_TOPLEVEL, "Desktop", PIXBUF_INLINE_ICON_CONFIG, NULL, _("Desktop file"));
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
181 gtk_window_set_type_hint(GTK_WINDOW(ew->window), GDK_WINDOW_TYPE_HINT_DIALOG);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
182
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
183 g_signal_connect(G_OBJECT(ew->window), "delete_event",
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
184 G_CALLBACK(editor_window_delete_cb), ew);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
185
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
186 gtk_window_set_default_size(GTK_WINDOW(ew->window), CONFIG_WINDOW_DEF_WIDTH, CONFIG_WINDOW_DEF_HEIGHT);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
187 gtk_window_set_resizable(GTK_WINDOW(ew->window), TRUE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
188 gtk_container_set_border_width(GTK_CONTAINER(ew->window), PREF_PAD_BORDER);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
189
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
190 win_vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
191 gtk_container_add(GTK_CONTAINER(ew->window), win_vbox);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
192 gtk_widget_show(win_vbox);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
193
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
194 hbox = gtk_hbox_new(FALSE, PREF_PAD_SPACE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
195 gtk_box_pack_end(GTK_BOX(win_vbox), hbox, FALSE, FALSE, 0);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
196 gtk_widget_show(hbox);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
197
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
198 ew->entry = gtk_entry_new();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
199 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
200 ew->desktop_name = NULL;
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
201 if (desktop_name)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
202 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
203 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
204 ew->desktop_name = g_strdup(desktop_name);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
205 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
206 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
207 g_signal_connect(G_OBJECT(ew->entry), "changed", G_CALLBACK(editor_window_entry_changed_cb), ew);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
208
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
209 button_hbox = gtk_hbutton_box_new();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
210 gtk_button_box_set_layout(GTK_BUTTON_BOX(button_hbox), GTK_BUTTONBOX_END);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
211 gtk_box_set_spacing(GTK_BOX(button_hbox), PREF_PAD_BUTTON_GAP);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
212 gtk_box_pack_end(GTK_BOX(hbox), button_hbox, FALSE, FALSE, 0);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
213 gtk_widget_show(button_hbox);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
214
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
215 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
216 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
217 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
218 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
219 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
220 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
221 ct_button = ew->save_button;
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
222
1569
6245009414c9 small fixes
nadvornik
parents: 1499
diff changeset
223 button = pref_button_new(NULL, GTK_STOCK_CLOSE, NULL, FALSE,
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
224 G_CALLBACK(editor_window_close_cb), ew);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
225 gtk_container_add(GTK_CONTAINER(button_hbox), button);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
226 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
227 gtk_widget_show(button);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
228
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
229 if (!generic_dialog_get_alternative_button_order(ew->window))
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
230 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
231 gtk_box_reorder_child(GTK_BOX(button_hbox), ct_button, -1);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
232 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
233
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
234
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
235 scrolled = gtk_scrolled_window_new(NULL, NULL);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
236 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
237 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
238 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
239 gtk_box_pack_start(GTK_BOX(win_vbox), scrolled, TRUE, TRUE, 5);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
240 gtk_widget_show(scrolled);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
241
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
242 text_view = gtk_text_view_new();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
243 gtk_container_add(GTK_CONTAINER(scrolled), text_view);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
244 gtk_widget_show(text_view);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
245
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
246 ew->buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
247 if (g_file_get_contents(src_path, &text, &size, NULL))
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
248 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
249 gtk_text_buffer_set_text(ew->buffer, text, size);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
250 }
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
251 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
252 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
253 G_CALLBACK(editor_window_text_modified_cb), ew);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
254
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
255 gtk_widget_show(ew->window);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
256 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
257
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
258
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
259 static void editor_list_window_close_cb(GtkWidget *widget, gpointer data)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
260 {
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
261 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
262 g_free(editor_list_window);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
263 editor_list_window = NULL;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
264 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
265
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
266 static gboolean editor_list_window_delete(GtkWidget *widget, GdkEventAny *event, gpointer data)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
267 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
268 editor_list_window_close_cb(NULL, NULL);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
269 return TRUE;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
270 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
271
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
272 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
273
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
274 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
275 {
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
276 EditorWindowDel_Data *ewdl = data;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
277
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
278 ewdl->ewl->gd = NULL;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
279 g_free(ewdl->path);
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
280 g_free(ewdl);
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
281 }
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 static void editor_list_window_delete_dlg_ok_cb(GenericDialog *gd, gpointer data)
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
284 {
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
285 EditorWindowDel_Data *ewdl = data;
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 if (!unlink_file(ewdl->path))
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 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
290 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
291 g_free(text);
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
292 }
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
293 else
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
294 {
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
295 /* refresh list */
1736
8e64965c1d92 load desktop files in idle time
nadvornik
parents: 1641
diff changeset
296 layout_editors_reload_start();
8e64965c1d92 load desktop files in idle time
nadvornik
parents: 1641
diff changeset
297 /* idle function is not needed, everything should be cached */
8e64965c1d92 load desktop files in idle time
nadvornik
parents: 1641
diff changeset
298 layout_editors_reload_finish();
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
299 }
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
300
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
301 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
302 }
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 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
305 {
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
306 EditorListWindow *ewl = data;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
307 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(ewl->view));
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
308 GtkTreeIter iter;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
309
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
310 if (gtk_tree_selection_get_selected(sel, NULL, &iter))
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
311 {
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
312 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
313 gchar *path;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
314 gchar *key;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
315 gchar *text;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
316 EditorWindowDel_Data *ewdl;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
317
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
318 gtk_tree_model_get(store, &iter,
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
319 DESKTOP_FILE_COLUMN_PATH, &path,
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
320 DESKTOP_FILE_COLUMN_KEY, &key, -1);
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
321
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
322
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
323 ewdl = g_new(EditorWindowDel_Data, 1);
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
324 ewdl->ewl = ewl;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
325 ewdl->path = path;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
326
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
327 if (ewl->gd)
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
328 {
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
329 GenericDialog *gd = ewl->gd;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
330 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
331 generic_dialog_close(gd);
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 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
335 NULL, TRUE,
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
336 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
337
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
338 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
339
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
340 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
341 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
342 _("Delete file"), text);
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
343 g_free(text);
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
344
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
345 gtk_widget_show(ewl->gd->dialog);
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
346 }
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
347 }
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
348
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
349 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
350 {
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
351 EditorListWindow *ewl = data;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
352 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
353 GtkTreeIter iter;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
354
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
355 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
356 {
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
357 GtkTreeModel *store = gtk_tree_view_get_model(GTK_TREE_VIEW(ewl->view));
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
358 gchar *path;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
359 gchar *key;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
360
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
361 gtk_tree_model_get(store, &iter,
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
362 DESKTOP_FILE_COLUMN_PATH, &path,
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
363 DESKTOP_FILE_COLUMN_KEY, &key, -1);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
364 editor_window_new(path, key);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
365 g_free(key);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
366 g_free(path);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
367 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
368 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
369
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
370 static void editor_list_window_new_cb(GtkWidget *widget, gpointer data)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
371 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
372 editor_window_new(DESKTOP_FILE_TEMPLATE, _("new.desktop"));
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
373 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
374
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
375
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 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
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 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
379 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
380
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 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
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 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
384 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
385 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
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 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
388
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 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
390 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
391
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 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
393 {
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 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
395 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
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 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
398 {
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 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
400 }
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
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 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
403 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
404 }
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 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
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 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
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 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
410
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 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
412 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
413
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 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
415 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
416 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
417 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
418 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
419 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
420 }
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
421 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
422
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
423 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
424 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
425 }
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
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
427 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
428 }
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
429
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
430 static void editor_list_window_create(void)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
431 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
432 GtkWidget *win_vbox;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
433 GtkWidget *hbox;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
434 GtkWidget *button;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
435 GtkWidget *scrolled;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
436 GtkCellRenderer *renderer;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
437 GtkTreeSelection *selection;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
438 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
439 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
440 GtkTreeSortable *sortable;
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
441 EditorListWindow *ewl;
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
442
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
443 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
444
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
445 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
446 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
447 g_signal_connect(G_OBJECT(ewl->window), "delete_event",
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
448 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
449 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
450 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
451 gtk_container_set_border_width(GTK_CONTAINER(ewl->window), PREF_PAD_BORDER);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
452
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
453 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
454 gtk_container_add(GTK_CONTAINER(ewl->window), win_vbox);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
455 gtk_widget_show(win_vbox);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
456
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
457 hbox = gtk_hbutton_box_new();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
458 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
459 gtk_box_set_spacing(GTK_BOX(hbox), PREF_PAD_BUTTON_GAP);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
460 gtk_box_pack_end(GTK_BOX(win_vbox), hbox, FALSE, FALSE, 0);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
461 gtk_widget_show(hbox);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
462
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
463
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
464 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
465 G_CALLBACK(editor_list_window_new_cb), ewl);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
466 gtk_container_add(GTK_CONTAINER(hbox), button);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
467 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
468 gtk_widget_show(button);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
469
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
470 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
471 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
472 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
473 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
474 gtk_widget_show(button);
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
475
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
476 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
477 G_CALLBACK(editor_list_window_delete_cb), ewl);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
478 gtk_container_add(GTK_CONTAINER(hbox), button);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
479 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
480 gtk_widget_show(button);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
481
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
482 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
483 G_CALLBACK(editor_list_window_close_cb), ewl);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
484 gtk_container_add(GTK_CONTAINER(hbox), button);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
485 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
486 gtk_widget_show(button);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
487
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
488 scrolled = gtk_scrolled_window_new(NULL, NULL);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
489 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
490 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
491 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
492 gtk_box_pack_start(GTK_BOX(win_vbox), scrolled, TRUE, TRUE, 5);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
493 gtk_widget_show(scrolled);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
494
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
495 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
496 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ewl->view));
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
497 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
498
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
499 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(ewl->view), FALSE);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
500
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
501 column = gtk_tree_view_column_new();
1624
dd361c680164 Change the order of columns for editors dialogue
mow
parents: 1613
diff changeset
502 gtk_tree_view_column_set_title(column, _("Name"));
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
503 gtk_tree_view_column_set_resizable(column, TRUE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
504 renderer = gtk_cell_renderer_text_new();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
505 gtk_tree_view_column_pack_start(column, renderer, FALSE);
1624
dd361c680164 Change the order of columns for editors dialogue
mow
parents: 1613
diff changeset
506 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
507 gtk_tree_view_append_column(GTK_TREE_VIEW(ewl->view), column);
1624
dd361c680164 Change the order of columns for editors dialogue
mow
parents: 1613
diff changeset
508 gtk_tree_view_column_set_sort_column_id(column, DESKTOP_FILE_COLUMN_NAME);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
509
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
510 column = gtk_tree_view_column_new();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
511 gtk_tree_view_column_set_title(column, _("Hidden"));
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
512 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
513 renderer = gtk_cell_renderer_toggle_new();
1499
56b534d71872 Make desktop window list checkboxes centered and not activatable.
zas_
parents: 1496
diff changeset
514 g_object_set(G_OBJECT(renderer),
56b534d71872 Make desktop window list checkboxes centered and not activatable.
zas_
parents: 1496
diff changeset
515 "activatable", FALSE, // not clickable for now
56b534d71872 Make desktop window list checkboxes centered and not activatable.
zas_
parents: 1496
diff changeset
516 "xalign", 0.5, // centered
56b534d71872 Make desktop window list checkboxes centered and not activatable.
zas_
parents: 1496
diff changeset
517 NULL);
56b534d71872 Make desktop window list checkboxes centered and not activatable.
zas_
parents: 1496
diff changeset
518 gtk_tree_view_column_pack_start(column, renderer, TRUE); // TRUE needed for centering
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
519 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
520 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
521 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
522 gtk_tree_view_column_set_alignment(column, 0.5);
56b534d71872 Make desktop window list checkboxes centered and not activatable.
zas_
parents: 1496
diff changeset
523
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
524 column = gtk_tree_view_column_new();
1624
dd361c680164 Change the order of columns for editors dialogue
mow
parents: 1613
diff changeset
525 gtk_tree_view_column_set_title(column, _("Desktop file"));
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
526 gtk_tree_view_column_set_resizable(column, TRUE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
527 renderer = gtk_cell_renderer_text_new();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
528 gtk_tree_view_column_pack_start(column, renderer, FALSE);
1624
dd361c680164 Change the order of columns for editors dialogue
mow
parents: 1613
diff changeset
529 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
530 gtk_tree_view_append_column(GTK_TREE_VIEW(ewl->view), column);
1624
dd361c680164 Change the order of columns for editors dialogue
mow
parents: 1613
diff changeset
531 gtk_tree_view_column_set_sort_column_id(column, DESKTOP_FILE_COLUMN_KEY);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
532
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
533 column = gtk_tree_view_column_new();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
534 gtk_tree_view_column_set_title(column, _("Path"));
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
535 gtk_tree_view_column_set_resizable(column, TRUE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
536 renderer = gtk_cell_renderer_text_new();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
537 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
538 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
539 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
540 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
541
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
542 /* set up sorting */
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
543 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
544 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
545 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
546 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
547 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
548 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
549 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
550 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
551 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
552 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
553
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
554 /* set initial sort order */
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
555 //gtk_tree_sortable_set_sort_column_id(sortable, DESKTOP_FILE_COLUMN_KEY, GTK_SORT_ASCENDING);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
556
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
557 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
558 gtk_widget_show(ewl->view);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
559
1496
03c22c05c6b6 Allow to delete an editor's desktop file from editors list window.
zas_
parents: 1491
diff changeset
560 gtk_widget_show(ewl->window);
1479
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
561 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
562
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
563 /*
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
564 *-----------------------------------------------------------------------------
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
565 * config window show (public)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
566 *-----------------------------------------------------------------------------
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
567 */
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
568
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
569 void show_editor_list_window(void)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
570 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
571 if (editor_list_window)
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
572 {
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
573 gtk_window_present(GTK_WINDOW(editor_list_window));
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
574 return;
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
575 }
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
576
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
577 editor_list_window_create();
d062522699dc added simple desktop file editor
nadvornik
parents:
diff changeset
578 }
1613
30c98d03efae Add missing vim modeline.
zas_
parents: 1569
diff changeset
579 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */