~ubuntu-branches/ubuntu/lucid/nautilus-actions/lucid

« back to all changes in this revision

Viewing changes to nact/nact.c

  • Committer: Bazaar Package Importer
  • Author(s): Christine Spang
  • Date: 2006-05-02 21:15:03 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060502211503-ygoa8zap193bi9gq
Tags: 1.2-1
* New upstream release.
  - Add support for filtering using mimetypes of selected files
  - Add support for choice about case sensitiveness of file patterns
  - New Tango style icons
  - Grammar and spelling errors fixed
  - Fix segfault when defining an action with an empty file pattern
  - Fix a crash when selecting a cdrom drive with Nautilus 2.14
  - Added Bengali translation; others updated
  - Other minor bugfixes
* Bumped standards version to 2.7.0.0; no change.
* Added debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 */
23
23
 
24
24
#include <config.h>
 
25
#include <stdlib.h>
25
26
#include <glib/gi18n.h>
26
27
#include <gtk/gtkbutton.h>
27
28
#include <gtk/gtkliststore.h>
33
34
#include <libnautilus-actions/nautilus-actions-config-gconf-writer.h>
34
35
#include "nact-utils.h"
35
36
#include "nact.h"
 
37
#include "nact-editor.h"
 
38
#include "nact-import-export.h"
 
39
#include "nact-prefs.h"
36
40
 
37
41
static NautilusActionsConfigGconfWriter *config = NULL;
38
42
 
 
43
gint actions_list_sort_by_label (gconstpointer a1, gconstpointer a2)
 
44
{
 
45
        NautilusActionsConfigAction* action1 = (NautilusActionsConfigAction*)a1;
 
46
        NautilusActionsConfigAction* action2 = (NautilusActionsConfigAction*)a2;
 
47
 
 
48
        return g_utf8_collate (action1->label, action2->label);
 
49
}
 
50
 
39
51
void nact_fill_actions_list (GtkWidget *list)
40
52
{
41
53
        GSList *actions, *l;
42
 
        GtkListStore *model = gtk_tree_view_get_model (GTK_TREE_VIEW (list));
 
54
        GtkListStore *model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW (list)));
43
55
 
44
56
        gtk_list_store_clear (model);
45
57
 
46
58
        actions = nautilus_actions_config_get_actions (NAUTILUS_ACTIONS_CONFIG (config));
 
59
        actions = g_slist_sort (actions, (GCompareFunc)actions_list_sort_by_label);
47
60
        for (l = actions; l != NULL; l = l->next) {
48
61
                GtkTreeIter iter;
49
62
                GtkStockItem item;
76
89
        nautilus_actions_config_free_actions_list (actions);
77
90
}
78
91
 
 
92
void 
79
93
nautilus_actions_display_error (const gchar *msg)
80
94
{
81
95
}
116
130
}
117
131
 
118
132
void
 
133
duplicate_button_clicked_cb (GtkButton *button, gpointer user_data)
 
134
{
 
135
        GtkTreeSelection *selection;
 
136
        GtkTreeIter iter;
 
137
        GtkWidget *nact_actions_list;
 
138
        GtkTreeModel* model;
 
139
 
 
140
        nact_actions_list = nact_get_glade_widget ("ActionsList");
 
141
 
 
142
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (nact_actions_list));
 
143
 
 
144
        if (gtk_tree_selection_get_selected (selection, &model, &iter)) 
 
145
        {
 
146
                gchar *uuid;
 
147
                NautilusActionsConfigAction *action;
 
148
                NautilusActionsConfigAction* new_action;
 
149
 
 
150
                gtk_tree_model_get (model, &iter, UUID_COLUMN, &uuid, -1);
 
151
 
 
152
                action = nautilus_actions_config_get_action (NAUTILUS_ACTIONS_CONFIG (config), uuid);
 
153
                new_action = nautilus_actions_config_action_dup_new (action);
 
154
                if (new_action) 
 
155
                {
 
156
                        if (nautilus_actions_config_add_action (NAUTILUS_ACTIONS_CONFIG (config), new_action))
 
157
                        {
 
158
                                nact_fill_actions_list (nact_actions_list);
 
159
                        }
 
160
                }
 
161
 
 
162
                g_free (uuid);
 
163
        }
 
164
}
 
165
 
 
166
void
119
167
delete_button_clicked_cb (GtkButton *button, gpointer user_data)
120
168
{
121
169
        GtkTreeSelection *selection;
174
222
{
175
223
        GtkWidget *nact_edit_button;
176
224
        GtkWidget *nact_delete_button;
 
225
        GtkWidget *nact_duplicate_button;
177
226
        
178
227
        nact_edit_button = nact_get_glade_widget ("EditActionButton");
179
228
        nact_delete_button = nact_get_glade_widget ("DeleteActionButton");
 
229
        nact_duplicate_button = nact_get_glade_widget ("DuplicateActionButton");
180
230
 
181
231
        if (gtk_tree_selection_count_selected_rows (selection) > 0) {
182
232
                gtk_widget_set_sensitive (nact_edit_button, TRUE);
183
233
                gtk_widget_set_sensitive (nact_delete_button, TRUE);
 
234
                gtk_widget_set_sensitive (nact_duplicate_button, TRUE);
184
235
        } else {
185
236
                gtk_widget_set_sensitive (nact_edit_button, FALSE);
186
237
                gtk_widget_set_sensitive (nact_delete_button, FALSE);
 
238
                gtk_widget_set_sensitive (nact_duplicate_button, FALSE);
187
239
        }
188
240
}
189
241
 
221
273
        gint width, height, x, y;
222
274
        GtkWidget *nact_dialog;
223
275
        GtkWidget *nact_actions_list;
 
276
        GtkWidget* nact_edit_button;
224
277
        GladeXML *gui = nact_get_glade_xml_object (GLADE_MAIN_WIDGET);
225
278
        if (!gui) {
226
279
                nautilus_actions_display_error (_("Could not load interface for Nautilus Actions Config Tool"));
247
300
        nact_prefs_get_main_dialog_position (&x, &y);
248
301
 
249
302
        gtk_window_move (GTK_WINDOW (nact_dialog), x, y);
250
 
        
 
303
 
 
304
#if ((GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION == 4))      
 
305
        /* Fix a stock icon bug with GTK+ 2.4 */
 
306
        nact_edit_button = nact_get_glade_widget ("EditActionButton");
 
307
        gtk_button_set_use_stock (GTK_BUTTON (nact_edit_button), FALSE);
 
308
        gtk_button_set_use_underline (GTK_BUTTON (nact_edit_button), TRUE);
 
309
        gtk_button_set_label (GTK_BUTTON (nact_edit_button), "_Edit");
 
310
#endif
 
311
 
251
312
        /* display the dialog */
252
313
        gtk_widget_show (nact_dialog);
253
314
        g_object_unref (gui);
268
329
        gtk_init (&argc, &argv);
269
330
 
270
331
        config = nautilus_actions_config_gconf_writer_get ();
 
332
        g_set_application_name (PACKAGE);
 
333
        gtk_window_set_default_icon_name (PACKAGE);
271
334
 
272
335
        /* create main dialog */
273
336
        init_dialog ();
274
337
 
275
338
        /* run the application */
276
339
        gtk_main ();
 
340
        return 0;
277
341
}
278
342
 
279
343
// vim:ts=3:sw=3:tw=1024:cin