1
/* Nautilus Actions configuration tool
2
4
* Copyright (C) 2005 The GNOME Foundation
5
* Frederic Ruaudel (grumz@grumz.net)
5
* Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
6
* Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
7
8
* This Program is free software; you can redistribute it and/or
8
9
* modify it under the terms of the GNU General Public License as
9
* published by the Free Software Foundation; either version 2 of the
10
* License, or (at your option) any later version.
10
* published by the Free Software Foundation; either version 2 of
11
* the License, or (at your option) any later version.
12
13
* This Program is distributed in the hope that it will be useful,
13
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* General Public License for more details.
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
18
* You should have received a copy of the GNU General Public
18
19
* License along with this Library; see the file COPYING. If not,
19
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
20
* write to the Free Software Foundation, Inc., 59 Temple Place,
21
* Suite 330, Boston, MA 02111-1307, USA.
24
* Frederic Ruaudel <grumz@grumz.net>
25
* Rodrigo Moya <rodrigo@gnome-db.org>
26
* Pierre Wieser <pwieser@trychlos.org>
27
* ... and many others (see AUTHORS)
23
30
#include <config.h>
111
118
g_object_unref (gui);
114
gboolean nact_utils_get_action_schemes_list (GtkTreeModel* scheme_model, GtkTreePath *path,
121
gboolean nact_utils_get_action_schemes_list (GtkTreeModel* scheme_model, GtkTreePath *path,
115
122
GtkTreeIter* iter, gpointer data)
124
static const char *thisfn = "nact_utils_get_action_schemes_list";
117
125
GSList** list = data;
118
126
gboolean toggle_state;
121
gtk_tree_model_get (scheme_model, iter, SCHEMES_CHECKBOX_COLUMN, &toggle_state,
129
gtk_tree_model_get (scheme_model, iter, SCHEMES_CHECKBOX_COLUMN, &toggle_state,
122
130
SCHEMES_KEYWORD_COLUMN, &scheme, -1);
124
132
if (toggle_state)
134
g_debug( "%s: adding '%s' scheme", thisfn, scheme );
126
135
(*list) = g_slist_append ((*list), scheme);
190
200
gchar* ex_host_default = _("test.example.net");
191
201
gchar* ex_one_file = _("file.txt");
192
202
gchar* ex_one_dir = _("folder");
203
gchar* ex_one = NULL;
204
gchar* ex_list = NULL;
205
gchar* ex_path_list = NULL;
196
206
gchar* ex_scheme;
199
const gchar* param_template = gtk_entry_get_text (GTK_ENTRY (nact_get_glade_widget_from ("CommandParamsEntry",
200
GLADE_EDIT_DIALOG_WIDGET)));
209
const gchar* param_template = gtk_entry_get_text (GTK_ENTRY (nact_get_glade_widget_from ("CommandParamsEntry", dialog )));
201
210
gchar* iter = g_strdup (param_template);
202
211
gchar* old_iter = iter;
206
215
GSList* scheme_list = NULL;
208
const gchar* command = gtk_entry_get_text (GTK_ENTRY (nact_get_glade_widget_from ("CommandPathEntry",
209
GLADE_EDIT_DIALOG_WIDGET)));
217
const gchar* command = gtk_entry_get_text (GTK_ENTRY (nact_get_glade_widget_from ("CommandPathEntry", dialog )));
211
219
g_string_append_printf (tmp_string, "%s ", command);
213
gboolean is_file = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nact_get_glade_widget_from ("OnlyFilesButton",
214
GLADE_EDIT_DIALOG_WIDGET)));
215
gboolean is_dir = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nact_get_glade_widget_from ("OnlyFoldersButton",
216
GLADE_EDIT_DIALOG_WIDGET)));
217
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nact_get_glade_widget_from ("BothButton",
218
GLADE_EDIT_DIALOG_WIDGET))))
221
gboolean is_file = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nact_get_glade_widget_from ("OnlyFilesButton", dialog )));
222
gboolean is_dir = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nact_get_glade_widget_from ("OnlyFoldersButton", dialog )));
223
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nact_get_glade_widget_from ("BothButton", dialog ))))
223
gboolean accept_multiple = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nact_get_glade_widget_from ("AcceptMultipleButton",
224
GLADE_EDIT_DIALOG_WIDGET)));
226
GtkTreeModel* scheme_model = gtk_tree_view_get_model (GTK_TREE_VIEW (nact_get_glade_widget_from ("SchemesTreeView",
227
GLADE_EDIT_DIALOG_WIDGET)));
228
gboolean accept_multiple = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nact_get_glade_widget_from ("AcceptMultipleButton", dialog )));
230
GtkTreeModel* scheme_model = gtk_tree_view_get_model (GTK_TREE_VIEW (nact_get_glade_widget_from ("SchemesTreeView", dialog )));
228
231
gtk_tree_model_foreach (scheme_model, (GtkTreeModelForeachFunc)nact_utils_get_action_schemes_list, &scheme_list);
230
233
separator = g_strdup_printf (" %s/", ex_path);
291
294
ex_scheme = ex_scheme_default;
295
298
while ((iter = g_strstr_len (iter, strlen (iter), "%")))
297
300
tmp_string = g_string_append_len (tmp_string, old_iter, strlen (old_iter) - strlen (iter));
300
case 'u': // gnome-vfs URI
303
case 'u': /* gnome-vfs URI */
301
304
tmp = g_strjoin (NULL, ex_scheme, "://", ex_path, "/", ex_one, NULL);
302
305
tmp_string = g_string_append (tmp_string, tmp);
305
case 'd': // base dir of the selected file(s)/folder(s)
308
case 'd': /* base dir of the selected file(s)/folder(s) */
306
309
tmp_string = g_string_append (tmp_string, ex_path);
308
case 'f': // the basename of the selected file/folder or the 1st one if many are selected
311
case 'f': /* the basename of the selected file/folder or the 1st one if many are selected */
309
312
tmp_string = g_string_append (tmp_string, ex_one);
311
case 'm': // list of the basename of the selected files/directories separated by space
314
case 'm': /* list of the basename of the selected files/directories separated by space */
312
315
tmp_string = g_string_append (tmp_string, ex_list);
314
case 'M': // list of the selected files/directories with their complete path separated by space.
317
case 'M': /* list of the selected files/directories with their complete path separated by space. */
315
318
tmp_string = g_string_append (tmp_string, ex_path_list);
317
case 's': // scheme of the gnome-vfs URI
320
case 's': /* scheme of the gnome-vfs URI */
318
321
tmp_string = g_string_append (tmp_string, ex_scheme);
320
case 'h': // hostname of the gnome-vfs URI
323
case 'h': /* hostname of the gnome-vfs URI */
321
324
tmp_string = g_string_append (tmp_string, ex_host);
323
case 'U': // username of the gnome-vfs URI
326
case 'U': /* username of the gnome-vfs URI */
324
327
tmp_string = g_string_append (tmp_string, "root");
326
case '%': // a percent sign
329
case '%': /* a percent sign */
327
330
tmp_string = g_string_append_c (tmp_string, '%');
330
iter+=2; // skip the % sign and the character after.
331
old_iter = iter; // store the new start of the string
333
iter+=2; /* skip the % sign and the character after. */
334
old_iter = iter; /* store the new start of the string */
333
336
tmp_string = g_string_append_len (tmp_string, old_iter, strlen (old_iter));
335
338
g_free (ex_list);
336
339
g_free (ex_path_list);
339
retv = g_string_free (tmp_string, FALSE); // return the content of the GString
342
retv = g_string_free (tmp_string, FALSE); /* return the content of the GString */
344
// vim:ts=3:sw=3:tw=1024:cin