~ubuntu-branches/ubuntu/jaunty/file-browser-applet/jaunty

« back to all changes in this revision

Viewing changes to src/preferences.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2008-06-01 18:59:43 UTC
  • Revision ID: james.westby@ubuntu.com-20080601185943-vwl5342pfbst8p3l
Tags: upstream-0.5.6
ImportĀ upstreamĀ versionĀ 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * File:                                preferences.c
 
3
 * Created:                             April 2006
 
4
 * Created by:                  Axel von Bertoldi
 
5
 * Last Modified:               January 2008
 
6
 * Last Modified by:    Axel von Bertoldi
 
7
 * (C) 2005-2008                Axel von Bertoldi
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or modify it
 
10
 * under the terms of the GNU General Public License as published by the Free
 
11
 * Software Foundation; either version 2 of the License, or (at your option)
 
12
 * any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
16
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 
17
 * more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License along with
 
20
 * this program; if not, write to:
 
21
 * The Free Software Foundation, Inc.,
 
22
 * 51 Franklin Street, Fifth Floor
 
23
 * Boston, MA 02110-1301, USA.
 
24
 */
 
25
 
 
26
#include "preferences.h"
 
27
#include "utils.h"
 
28
#include <gtk/gtk.h>
 
29
#include <glade/glade-xml.h>
 
30
#include <glib/gprintf.h>
 
31
#include <stdlib.h>
 
32
 
 
33
#include "vfs.h"
 
34
 
 
35
/******************************************************************************/
 
36
struct _AppletPreferencesPrivate {
 
37
        GtkWidget       *window;
 
38
        PanelApplet *applet;
 
39
        GtkWidget       *tree_view;
 
40
};
 
41
/******************************************************************************/
 
42
#define APPLET_PREFERENCES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_APPLET_PREFERENCES, AppletPreferencesPrivate))
 
43
#define DEFAULT_ICON_PATH "/usr/share/pixmaps/"
 
44
/******************************************************************************/
 
45
enum  {
 
46
        APPLET_PREFERENCES_DUMMY_PROPERTY
 
47
};
 
48
enum {
 
49
        PREFS_CHANGED,
 
50
        LAST_SIGNAL
 
51
};
 
52
enum {
 
53
        RESPONSE_REVERT
 
54
};
 
55
enum
 
56
{
 
57
   LABEL_COLUMN,
 
58
   PATH_COLUMN,
 
59
   N_COLUMNS
 
60
};
 
61
/******************************************************************************/
 
62
static guint applet_preferences_signals[LAST_SIGNAL] = { 0 };
 
63
/* this is bad, but I need to get at the button from all over the file to
 
64
 * update it's state. The other option is make it private member. */
 
65
/*static GtkWidget *revert_button = NULL;*/
 
66
/******************************************************************************/
 
67
static gpointer applet_preferences_parent_class = NULL;
 
68
static void applet_preferences_dispose (GObject *obj);
 
69
/******************************************************************************/
 
70
static void
 
71
applet_preferences_on_show_icon_pressed (GtkWidget *widget, gpointer data) {
 
72
        AppletPreferences *self = (AppletPreferences *)data;
 
73
 
 
74
        /* get the new state from the widget and update the prefs structure */
 
75
        self->menu_bar_prefs->show_icon = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 
76
 
 
77
        PrefsChangedSignalData *signal_data = g_new0 (PrefsChangedSignalData, 1);
 
78
        signal_data->signal_id = PREFS_SIGNAL_SHOW_ICON;
 
79
        signal_data->instance  = -1;
 
80
        signal_data->label        = NULL;
 
81
        signal_data->path         = NULL;
 
82
 
 
83
        /* emit the signal so the panel menu bar updates itself */
 
84
        g_signal_emit (G_OBJECT (data),
 
85
                                   applet_preferences_signals [PREFS_CHANGED],
 
86
                                   0,
 
87
                                   signal_data);
 
88
 
 
89
        /* update the state of the revert button. A pref has changed so the button
 
90
         * should now be sensitive  */
 
91
        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
92
        return;
 
93
}
 
94
/******************************************************************************/
 
95
static void
 
96
applet_preferences_on_show_hidden_pressed (GtkWidget *widget, gpointer data) {
 
97
        AppletPreferences *self = (AppletPreferences *)data;
 
98
        /* get the new state from the widget and update the prefs structure. No
 
99
         * need to let the menu bar or browser object know */
 
100
        self->menu_bar_prefs->browser_prefs->show_hidden = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 
101
 
 
102
        /* update the state of the revert button. A pref has changed so the button
 
103
         * should now be sensitive  */
 
104
        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
105
        return;
 
106
}
 
107
/******************************************************************************/
 
108
static void
 
109
applet_preferences_on_terminal_changed (GtkWidget *widget, gpointer data) {
 
110
        gchar *tmp = NULL;
 
111
        AppletPreferences *self = (AppletPreferences *)data;
 
112
        
 
113
        /* get the new state from the widget and update the prefs structure. No
 
114
         * need to let the menu bar or browser object know */
 
115
        tmp = self->menu_bar_prefs->browser_prefs->terminal;
 
116
        g_free (tmp);
 
117
        self->menu_bar_prefs->browser_prefs->terminal = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
 
118
 
 
119
        /* update the state of the revert button. A pref has changed so the button
 
120
         * should now be sensitive  */
 
121
        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
122
}       
 
123
/******************************************************************************/
 
124
static void
 
125
applet_preferences_on_editor_changed (GtkWidget *widget, gpointer data) {
 
126
        gchar *tmp = NULL;
 
127
        AppletPreferences *self = (AppletPreferences *)data;
 
128
        
 
129
        /* get the new state from the widget and update the prefs structure. No
 
130
         * need to let the menu bar or browser object know */
 
131
        tmp = self->menu_bar_prefs->browser_prefs->editor;
 
132
        g_free (tmp);
 
133
        self->menu_bar_prefs->browser_prefs->editor = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
 
134
 
 
135
        /* update the state of the revert button. A pref has changed so the button
 
136
         * should now be sensitive  */
 
137
        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
138
}       
 
139
/******************************************************************************/
 
140
static void
 
141
applet_preferences_on_icon_select (GtkWidget *button, gpointer data) {
 
142
        GtkWidget *file_chooser_dialog;
 
143
        gchar *icon_path = DEFAULT_ICON_PATH;
 
144
        AppletPreferences *self = (AppletPreferences *)data;
 
145
        /* set up a file chooser dialog so we can choose the new icon. An icon
 
146
         * chooser would be better, but that widget is deprecated in the Gnome UI
 
147
         * lib and GTK equivalent doesn't exist yet */
 
148
        file_chooser_dialog = gtk_file_chooser_dialog_new ("Select Icon",
 
149
                                                                                                           NULL,
 
150
                                                                                                           GTK_FILE_CHOOSER_ACTION_OPEN,
 
151
                                                                                                           GTK_STOCK_CANCEL,
 
152
                                                                                                           GTK_RESPONSE_CANCEL,
 
153
                                                                                                           GTK_STOCK_OPEN,
 
154
                                                                                                           GTK_RESPONSE_ACCEPT,
 
155
                                                                                                           NULL);
 
156
        /* Set the starting path */
 
157
        if (vfs_file_exists (self->menu_bar_prefs->icon)) {
 
158
                icon_path = self->menu_bar_prefs->icon;
 
159
        }
 
160
        gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog),
 
161
                                                                   icon_path);
 
162
        /* check the reply */
 
163
        if (gtk_dialog_run (GTK_DIALOG (file_chooser_dialog)) == GTK_RESPONSE_ACCEPT) {
 
164
                gchar *new_icon;
 
165
                new_icon = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser_dialog));
 
166
                /* make sure the new icon is not the same as the old one */     
 
167
                if (g_ascii_strcasecmp (new_icon, self->menu_bar_prefs->icon)) {
 
168
                        /* update the prefs structure */
 
169
                        g_free (self->menu_bar_prefs->icon);
 
170
                        self->menu_bar_prefs->icon = new_icon;
 
171
 
 
172
                        /* update the button's icon */
 
173
                        GtkWidget *icon = gtk_button_get_image (GTK_BUTTON (button));
 
174
                        gtk_widget_destroy (icon);
 
175
                        icon = utils_get_scaled_image_from_file (self->menu_bar_prefs->icon,
 
176
                                                                                                         ICON_BUTTON_SIZE);
 
177
                        if (icon == NULL) {
 
178
                                icon = gtk_image_new_from_icon_name ("user-home", GTK_ICON_SIZE_BUTTON);
 
179
                        }
 
180
                        gtk_button_set_image (GTK_BUTTON (button), icon);
 
181
 
 
182
                        PrefsChangedSignalData *signal_data = g_new0 (PrefsChangedSignalData, 1);
 
183
                        signal_data->signal_id = PREFS_SIGNAL_ICON_CHANGED;
 
184
                        signal_data->instance  = -1;
 
185
                        signal_data->label         = NULL;
 
186
                        signal_data->path          = NULL;
 
187
 
 
188
                        /* emit the signal so the panel menu bar updates itself */
 
189
                        g_signal_emit (G_OBJECT (data),
 
190
                                                   applet_preferences_signals [PREFS_CHANGED],
 
191
                                                   0,
 
192
                                                   signal_data);
 
193
                        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
194
                }
 
195
                else {
 
196
                        /* they chose the same icon again! */
 
197
                        g_free (new_icon);
 
198
                }
 
199
 
 
200
        }
 
201
        /* clean up and update the state of the revert button. A pref has changed
 
202
         * so the button should now be sensitive  */
 
203
        gtk_widget_destroy (file_chooser_dialog);
 
204
}
 
205
/******************************************************************************/
 
206
static void
 
207
applet_preferences_save_to_gconf (AppletPreferences *self) {
 
208
        PanelApplet *applet = self->priv->applet;
 
209
        GError *error = NULL;
 
210
        /* save the data in the prefs structure to the gconf schema (or whatever)*/
 
211
        /* show hidden files? */
 
212
        panel_applet_gconf_set_bool (applet,
 
213
                                                                 KEY_HIDDEN_SHOW,
 
214
                                                                 self->menu_bar_prefs->browser_prefs->show_hidden,
 
215
                                                                 &error);
 
216
        utils_check_gerror (&error);
 
217
        /* terminal */
 
218
        panel_applet_gconf_set_string (applet,
 
219
                                                                   KEY_TERMINAL,
 
220
                                                                   self->menu_bar_prefs->browser_prefs->terminal,
 
221
                                                                   &error);
 
222
        utils_check_gerror (&error);
 
223
        /* editor */
 
224
        panel_applet_gconf_set_string (applet,
 
225
                                                                   KEY_EDITOR,
 
226
                                                                   self->menu_bar_prefs->browser_prefs->editor,
 
227
                                                                   &error);
 
228
        utils_check_gerror (&error);
 
229
        /* the icon */
 
230
        panel_applet_gconf_set_string (applet,
 
231
                                                                   KEY_ICON_NAME,
 
232
                                                                   self->menu_bar_prefs->icon,
 
233
                                                                   &error);
 
234
        utils_check_gerror (&error);
 
235
        /* show the icon? */
 
236
        panel_applet_gconf_set_bool (applet,
 
237
                                                                 KEY_ICON_SHOW,
 
238
                                                                 self->menu_bar_prefs->show_icon,
 
239
                                                                 &error);
 
240
        utils_check_gerror (&error);
 
241
        /* directory list */
 
242
        panel_applet_gconf_set_list (applet,
 
243
                                                                 KEY_DIR,
 
244
                                                                 GCONF_VALUE_STRING,
 
245
                                                                 self->menu_bar_prefs->dirs,
 
246
                                                                 &error);
 
247
        utils_check_gerror (&error);
 
248
        /* labels list */
 
249
        panel_applet_gconf_set_list (applet,
 
250
                                                                 KEY_LABELS,
 
251
                                                                 GCONF_VALUE_STRING,
 
252
                                                                 self->menu_bar_prefs->labels,
 
253
                                                                 &error);
 
254
        utils_check_gerror (&error);
 
255
        return;
 
256
}
 
257
/******************************************************************************/
 
258
static void
 
259
applet_preferences_dialog_response (GtkWidget *window, gint response, gpointer data) {
 
260
        AppletPreferences *self = (AppletPreferences *)data;
 
261
        /* figure out what button closed the dialog and take the appropriate action */
 
262
        switch (response) {
 
263
                case RESPONSE_REVERT:
 
264
                        /* revert to the saved config */
 
265
                        /*gtk_widget_set_sensitive (revert_button, FALSE);*/
 
266
                        break;
 
267
 
 
268
                case GTK_RESPONSE_CLOSE:
 
269
                        /* save the current configuration */
 
270
                        applet_preferences_save_to_gconf (self);
 
271
                        /*gtk_widget_set_sensitive (revert_button, FALSE);*/
 
272
                        gtk_widget_hide (window);
 
273
                        break;
 
274
 
 
275
                case GTK_RESPONSE_DELETE_EVENT:
 
276
                        /* neither save nor revert */
 
277
                        gtk_widget_hide (window);
 
278
                        break;
 
279
        }
 
280
        return;
 
281
}
 
282
/******************************************************************************/
 
283
static void
 
284
applet_preferences_label_cell_edited (GtkCellRenderer   *cell,
 
285
                                                                          gchar                         *path_string,
 
286
                                                                          gchar                         *new_string,
 
287
                                                                          gpointer                      data){
 
288
 
 
289
        AppletPreferences       *self           = (AppletPreferences *)data;
 
290
        GtkWidget                       *tree_view      = self->priv->tree_view;
 
291
        GtkTreeModel            *model;
 
292
        GtkTreeIter                     iter;
 
293
        gchar                           *path           = NULL;
 
294
 
 
295
        /* get the model where the actual data is stored */
 
296
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
 
297
 
 
298
        /* get an iterator to the model for the currently selected cell */
 
299
        gtk_tree_model_get_iter_from_string (model,
 
300
                                                                                 &iter,
 
301
                                                                                 path_string);
 
302
        /* update the model */
 
303
        gtk_list_store_set (GTK_LIST_STORE (model), &iter,
 
304
                                                LABEL_COLUMN, new_string,
 
305
                                                -1);
 
306
 
 
307
        /* the path associated with the selection */
 
308
        gtk_tree_model_get (model,
 
309
                                                &iter,
 
310
                                                PATH_COLUMN, &path,
 
311
                                                -1);
 
312
 
 
313
        /* create the data structure with the event info to pass to panel_menu_bar */
 
314
        PrefsChangedSignalData *signal_data = g_new0 (PrefsChangedSignalData, 1);
 
315
        signal_data->signal_id = PREFS_SIGNAL_DIR_CHANGED;
 
316
        signal_data->instance  = atoi (path_string);
 
317
        signal_data->label         = g_strdup (new_string);
 
318
        signal_data->path          = path;
 
319
 
 
320
        /* update this item from the list holding the label prefs */
 
321
        GSList *tmp = NULL;
 
322
        tmp = g_slist_nth (self->menu_bar_prefs->labels, signal_data->instance);
 
323
        g_free (tmp->data);
 
324
        tmp->data = (gpointer)g_strdup (new_string);
 
325
 
 
326
        /* emit the signal so the panel menu bar updates itself */
 
327
        g_signal_emit (G_OBJECT (data),
 
328
                                   applet_preferences_signals [PREFS_CHANGED],
 
329
                                   0,
 
330
                                   signal_data);
 
331
 
 
332
        /* update the revert button*/
 
333
        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
334
        return;
 
335
}
 
336
/******************************************************************************/
 
337
static void
 
338
applet_preferences_path_cell_activated (GtkTreeView               *tree_view,
 
339
                                                                                GtkTreePath               *path,
 
340
                                                                                GtkTreeViewColumn *col,
 
341
                                                                                gpointer                   data) {
 
342
        AppletPreferences       *self   = (AppletPreferences *)data;
 
343
        GtkTreeModel *model;
 
344
        GtkTreeIter      iter;
 
345
        GtkWidget        *file_chooser_dialog;
 
346
        gchar            *old_path = NULL;
 
347
 
 
348
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
 
349
 
 
350
        /* get an iterator to the model for the currently selected cell */
 
351
        gtk_tree_model_get_iter (model,
 
352
                                                         &iter,
 
353
                                                         path);
 
354
        /* the "Path" value for the active cell */
 
355
        gtk_tree_model_get (model,
 
356
                                                &iter,
 
357
                                                PATH_COLUMN, &old_path,
 
358
                                                -1);
 
359
 
 
360
        /* make a file chooser object to select the new path */
 
361
        file_chooser_dialog = gtk_file_chooser_dialog_new ("Select New Folder To Browse",
 
362
                                                                                                           NULL,
 
363
                                                                                                           GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
 
364
                                                                                                           GTK_STOCK_CANCEL,
 
365
                                                                                                           GTK_RESPONSE_CANCEL,
 
366
                                                                                                           GTK_STOCK_OPEN,
 
367
                                                                                                           GTK_RESPONSE_ACCEPT,
 
368
                                                                                                           NULL);
 
369
        /* Set the starting path as the old path */
 
370
        gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog),
 
371
                                                                   old_path);
 
372
        g_free (old_path);
 
373
        /* run the dialog */
 
374
        if (gtk_dialog_run (GTK_DIALOG (file_chooser_dialog)) == GTK_RESPONSE_ACCEPT) {
 
375
                /* get the new path*/
 
376
                gchar *new_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser_dialog));
 
377
                /* only update data if it's not the same as the old one */
 
378
                if (g_ascii_strcasecmp (old_path, new_path)) {
 
379
                        gtk_list_store_set (GTK_LIST_STORE (model), &iter,
 
380
                                                                PATH_COLUMN, new_path,
 
381
                                                                -1);
 
382
 
 
383
 
 
384
                        /* the label associated with the selection */
 
385
                        gchar *label = NULL;
 
386
                        gtk_tree_model_get (model,
 
387
                                                                &iter,
 
388
                                                                LABEL_COLUMN, &label,
 
389
                                                                -1);
 
390
 
 
391
                        /* get the instance from the iterator */
 
392
                        gchar *instance = gtk_tree_model_get_string_from_iter (model, &iter);
 
393
 
 
394
                        /* create the data structure with the event info to pass to panel_menu_bar */
 
395
                        PrefsChangedSignalData *signal_data = g_new0 (PrefsChangedSignalData, 1);
 
396
                        signal_data->signal_id = PREFS_SIGNAL_DIR_CHANGED;
 
397
                        signal_data->instance  = atoi (instance);
 
398
                        signal_data->label         = label;
 
399
                        signal_data->path          = new_path;
 
400
                        g_free (instance);
 
401
 
 
402
                        /* update this item from the list holding the path prefs */
 
403
                        GSList *tmp = NULL;
 
404
                        tmp = g_slist_nth (self->menu_bar_prefs->dirs, signal_data->instance);
 
405
                        g_free (tmp->data);
 
406
                        tmp->data = (gpointer)g_strdup (new_path);
 
407
                        
 
408
                        /* emit the signal so the panel menu bar updates itself */
 
409
                        g_signal_emit (G_OBJECT (data),
 
410
                                                   applet_preferences_signals [PREFS_CHANGED],
 
411
                                                   0,
 
412
                                                   signal_data);
 
413
 
 
414
                        /* update the revert button*/
 
415
                        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
416
                }
 
417
        }
 
418
        gtk_widget_destroy (file_chooser_dialog);
 
419
 
 
420
        return;
 
421
}
 
422
/******************************************************************************/
 
423
static void
 
424
applet_preferences_on_add_dir_clicked (GtkWidget *widget, gpointer data) {
 
425
        GtkTreeModel *model;
 
426
        GtkTreeIter   iter;
 
427
        GtkWidget *file_chooser_dialog;
 
428
        AppletPreferences *self = (AppletPreferences *)data;
 
429
        GtkWidget *tree_view = self->priv->tree_view;
 
430
 
 
431
        file_chooser_dialog = gtk_file_chooser_dialog_new ("Select Folder To Add",
 
432
                                                                                                           NULL,
 
433
                                                                                                           GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
 
434
                                                                                                           GTK_STOCK_CANCEL,
 
435
                                                                                                           GTK_RESPONSE_CANCEL,
 
436
                                                                                                           GTK_STOCK_OPEN,
 
437
                                                                                                           GTK_RESPONSE_ACCEPT,
 
438
                                                                                                           NULL);
 
439
        /* Set the starting path */
 
440
        gchar *start_path = g_strdup_printf ("%s/*", g_get_home_dir ());
 
441
        gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog),
 
442
                                                                   start_path);
 
443
        g_free (start_path);
 
444
 
 
445
        /* check the reply */
 
446
        if (gtk_dialog_run (GTK_DIALOG (file_chooser_dialog)) == GTK_RESPONSE_ACCEPT) {
 
447
                /* get the new path, and make the label from it */
 
448
                gchar *dir = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser_dialog));
 
449
                gchar *label = g_path_get_basename (dir);
 
450
                /* get the view's model, add a row and set the values */
 
451
                model = gtk_tree_view_get_model (GTK_TREE_VIEW(tree_view));
 
452
                gtk_list_store_append (GTK_LIST_STORE(model), &iter);
 
453
                gtk_list_store_set (GTK_LIST_STORE(model), &iter,
 
454
                                                        LABEL_COLUMN, label,
 
455
                                                        PATH_COLUMN, dir,
 
456
                                                        -1);
 
457
 
 
458
                /* create the data structure with the event info to pass to panel_menu_bar */
 
459
                PrefsChangedSignalData *signal_data = g_new0 (PrefsChangedSignalData, 1);
 
460
                signal_data->signal_id = PREFS_SIGNAL_DIR_ADD;
 
461
                signal_data->instance  = -1;
 
462
                signal_data->label         = label;
 
463
                signal_data->path          = dir;
 
464
 
 
465
                /* add this item from the list holding the path/label prefs */
 
466
                self->menu_bar_prefs->dirs   = g_slist_append (self->menu_bar_prefs->dirs,   g_strdup (dir));
 
467
                self->menu_bar_prefs->labels = g_slist_append (self->menu_bar_prefs->labels, g_strdup(label));
 
468
 
 
469
                /* emit the signal so the panel menu bar updates itself */
 
470
                g_signal_emit (G_OBJECT (data),
 
471
                                           applet_preferences_signals [PREFS_CHANGED],
 
472
                                           0,
 
473
                                           signal_data);
 
474
 
 
475
                /* update the revert button*/
 
476
                /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
477
        }
 
478
        gtk_widget_destroy (file_chooser_dialog);
 
479
        return;
 
480
}
 
481
/******************************************************************************/
 
482
static void
 
483
applet_preferences_on_rem_dir_clicked (GtkWidget *widget, gpointer data) {
 
484
        GtkTreeSelection        *selection;
 
485
        GtkTreeModel            *model;
 
486
        GtkTreeIter                     iter;
 
487
        AppletPreferences       *self = (AppletPreferences *)data;
 
488
        GtkWidget                       *tree_view = self->priv->tree_view;
 
489
 
 
490
        /* get the current selection */
 
491
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree_view));
 
492
 
 
493
        /* get the iterator for the current selection and remove the corresponding
 
494
         * row form the model */
 
495
        if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
 
496
 
 
497
                /* get the instance from the iterator */
 
498
                gchar *instance = gtk_tree_model_get_string_from_iter (model, &iter);
 
499
 
 
500
                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 
501
 
 
502
                /* create the data structure with the event info to pass to panel_menu_bar */
 
503
                PrefsChangedSignalData *signal_data = g_new0 (PrefsChangedSignalData, 1);
 
504
                signal_data->signal_id = PREFS_SIGNAL_DIR_DEL;
 
505
                signal_data->instance  = atoi (instance);
 
506
                signal_data->label         = NULL;
 
507
                signal_data->path          = NULL;
 
508
                g_free (instance);
 
509
 
 
510
                /* remove this item from the list holding the path/label prefs */
 
511
                GSList *tmp = NULL;
 
512
                tmp = g_slist_nth (self->menu_bar_prefs->dirs, signal_data->instance);
 
513
                g_free (tmp->data);
 
514
                self->menu_bar_prefs->dirs = g_slist_delete_link (self->menu_bar_prefs->dirs, tmp);
 
515
                tmp = g_slist_nth (self->menu_bar_prefs->labels, signal_data->instance);
 
516
                g_free (tmp->data);
 
517
                self->menu_bar_prefs->labels = g_slist_delete_link (self->menu_bar_prefs->labels, tmp);
 
518
 
 
519
                /* emit the signal so the panel menu bar updates itself */
 
520
                g_signal_emit (G_OBJECT (data),
 
521
                                applet_preferences_signals [PREFS_CHANGED],
 
522
                                0,
 
523
                                signal_data);
 
524
 
 
525
                /* update the revert button*/
 
526
                /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
527
        }
 
528
 
 
529
        return;
 
530
}
 
531
/******************************************************************************/
 
532
static void
 
533
applet_preferences_on_down_dir_clicked (GtkWidget *widget, gpointer data) {
 
534
        GtkTreeSelection        *selection = NULL;
 
535
        GtkTreeModel            *model = NULL;
 
536
        GtkTreeIter                     iter, iter_next;
 
537
        AppletPreferences       *self = (AppletPreferences *)data;
 
538
        GtkWidget                       *tree_view = self->priv->tree_view;
 
539
 
 
540
        /* get the current selection */
 
541
        selection =  gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
 
542
 
 
543
        /* get the iterator for the current selection */
 
544
        if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
 
545
                /* is this dangerous? Time will tell... */
 
546
                iter_next = iter;
 
547
                /* get the next iterator and it it's valid, swap them */
 
548
                if (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter_next)){
 
549
 
 
550
                        /* get the instance from the iterator */
 
551
                        gchar *instance = gtk_tree_model_get_string_from_iter (model, &iter);
 
552
 
 
553
                        gtk_list_store_swap (GTK_LIST_STORE (model),
 
554
                                                                 &iter,
 
555
                                                                 &iter_next);
 
556
 
 
557
                        /* create the data structure with the event info to pass to panel_menu_bar */
 
558
                        PrefsChangedSignalData *signal_data = g_new0 (PrefsChangedSignalData, 1);
 
559
                        signal_data->signal_id = PREFS_SIGNAL_DIR_MOVE_DOWN;
 
560
                        signal_data->instance  = atoi (instance);
 
561
                        signal_data->label         = NULL;
 
562
                        signal_data->path          = NULL;
 
563
                        g_free (instance);
 
564
 
 
565
                        /* swap the entries in the list holding the path/label prefs */
 
566
                        g_slist_swap_data (self->menu_bar_prefs->dirs, signal_data->instance);
 
567
                        g_slist_swap_data (self->menu_bar_prefs->labels, signal_data->instance);
 
568
 
 
569
                        /* emit the signal so the panel menu bar updates itself */
 
570
                        g_signal_emit (G_OBJECT (data),
 
571
                                        applet_preferences_signals [PREFS_CHANGED],
 
572
                                        0,
 
573
                                        signal_data);
 
574
 
 
575
                        /* update the revert button*/
 
576
                        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
577
                }
 
578
        }
 
579
        return;
 
580
}
 
581
/******************************************************************************/
 
582
static void
 
583
applet_preferences_on_up_dir_clicked (GtkWidget *widget, gpointer data) {
 
584
        GtkTreeSelection        *selection      = NULL;
 
585
        GtkTreeModel            *model          = NULL;
 
586
        GtkTreeIter                     iter, iter_prev;
 
587
        GtkTreePath                     *path;
 
588
        AppletPreferences       *self           = (AppletPreferences *)data;
 
589
        GtkWidget                       *tree_view      = self->priv->tree_view;
 
590
 
 
591
        /* get the current selection */
 
592
        selection =  gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
 
593
 
 
594
        /* get the iterator for the current selection */
 
595
        if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
 
596
                /* Sigh! gtk_tree_model_iter_prev does not exist, so have to get the
 
597
                 * path for that iter and do a prev on it, then get the iter for the
 
598
                 * new path. Shite!*/
 
599
                path = gtk_tree_model_get_path (model, &iter);
 
600
                /* if the previous path is valid */
 
601
                if (gtk_tree_path_prev (path)) {
 
602
                        /* get the corresponding iter, and swap the store elements*/
 
603
                        gtk_tree_model_get_iter (model, &iter_prev, path);
 
604
 
 
605
                        /* get the instance from the iterator */
 
606
                        gchar *instance = gtk_tree_model_get_string_from_iter (model, &iter);
 
607
 
 
608
                        gtk_list_store_swap (GTK_LIST_STORE (model),
 
609
                                                                 &iter,
 
610
                                                                 &iter_prev);
 
611
 
 
612
                        /* create the data structure with the event info to pass to panel_menu_bar */
 
613
                        PrefsChangedSignalData *signal_data = g_new0 (PrefsChangedSignalData, 1);
 
614
                        signal_data->signal_id = PREFS_SIGNAL_DIR_MOVE_UP;
 
615
                        signal_data->instance  = atoi (instance);
 
616
                        signal_data->label         = NULL;
 
617
                        signal_data->path          = NULL;
 
618
                        g_free (instance);
 
619
 
 
620
                        /* swap the entries in the list holding the path/label prefs */
 
621
                        g_slist_swap_data (self->menu_bar_prefs->dirs, signal_data->instance - 1);
 
622
                        g_slist_swap_data (self->menu_bar_prefs->labels, signal_data->instance - 1);
 
623
 
 
624
                        /* emit the signal so the panel menu bar updates itself */
 
625
                        g_signal_emit (G_OBJECT (data),
 
626
                                                   applet_preferences_signals [PREFS_CHANGED],
 
627
                                                   0,
 
628
                                                   signal_data);
 
629
 
 
630
                        /* update the revert button*/
 
631
                        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
 
632
                }
 
633
                gtk_tree_path_free (path);
 
634
        }
 
635
        return;
 
636
}
 
637
/******************************************************************************/
 
638
static void
 
639
applet_preferences_create_list_view (AppletPreferences *self) {
 
640
        GtkTreeIter                     iter;
 
641
        GtkListStore            *store;
 
642
        GtkTreeViewColumn       *column;
 
643
        GtkCellRenderer         *renderer;
 
644
        GtkTreeSelection        *selection;
 
645
 
 
646
        /* Create a model.  We are using the store model for now, though we
 
647
        * could use any other GtkTreeModel */
 
648
        store = gtk_list_store_new (N_COLUMNS,
 
649
                                                            G_TYPE_STRING,
 
650
                                                            G_TYPE_STRING);
 
651
 
 
652
        /* fill the model with data */
 
653
        GSList *tmp_dir   = self->menu_bar_prefs->dirs;
 
654
        GSList *tmp_label = self->menu_bar_prefs->labels;
 
655
        while (tmp_label && tmp_dir) {
 
656
                gtk_list_store_append (store, &iter);
 
657
                gtk_list_store_set (store, &iter,
 
658
                                                        LABEL_COLUMN, (gchar *)tmp_label->data,
 
659
                                                        PATH_COLUMN, (gchar *)tmp_dir->data,
 
660
                                                        -1);
 
661
                tmp_dir   = tmp_dir->next;
 
662
                tmp_label = tmp_label->next;
 
663
        }
 
664
 
 
665
        /* Create a view */
 
666
        gtk_tree_view_set_model (GTK_TREE_VIEW (self->priv->tree_view), GTK_TREE_MODEL (store));
 
667
        gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (self->priv->tree_view), TRUE);
 
668
 
 
669
        /* The view now holds a reference.  We can get rid of our own
 
670
        * reference */
 
671
        g_object_unref (G_OBJECT (store));
 
672
 
 
673
        /* Create a cell render for the label, make it editable as set the callback  */
 
674
        renderer = gtk_cell_renderer_text_new ();
 
675
        g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL);
 
676
        g_signal_connect (G_OBJECT (renderer),
 
677
                                          "edited",
 
678
                                          G_CALLBACK (applet_preferences_label_cell_edited),
 
679
                                          (gpointer) self);
 
680
 
 
681
        /* Create a column, associating the "text" attribute of the
 
682
        * cell_renderer to the first column of the model */
 
683
        column = gtk_tree_view_column_new_with_attributes ("Label", renderer,
 
684
                                                                                                           "text", LABEL_COLUMN,
 
685
                                                                                                           NULL);
 
686
        /* Add the column to the view. */
 
687
        gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->tree_view), column);
 
688
 
 
689
        /* Create a cell render for the path */
 
690
        renderer = gtk_cell_renderer_text_new ();
 
691
        g_signal_connect (G_OBJECT (self->priv->tree_view),
 
692
                                          "row-activated",
 
693
                                          G_CALLBACK (applet_preferences_path_cell_activated),
 
694
                                          (gpointer) self);
 
695
        column = gtk_tree_view_column_new_with_attributes ("Path", renderer,
 
696
                                                                                                           "text", PATH_COLUMN,
 
697
                                                                                                           NULL);
 
698
        gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->tree_view), column);
 
699
 
 
700
        /*put the selection in SINGLE mode */
 
701
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(self->priv->tree_view));
 
702
        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
 
703
        
 
704
        return;
 
705
}
 
706
/******************************************************************************/
 
707
void
 
708
applet_preferences_make_dialog (AppletPreferences *self) {
 
709
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
710
 
 
711
        GtkWidget *window;
 
712
    GtkWidget *show_icon;
 
713
    GtkWidget *icon_button;
 
714
    GtkWidget *show_hidden;
 
715
    GtkWidget *terminal;
 
716
    GtkWidget *editor;
 
717
        MenuBarPrefs *mb_prefs = self->menu_bar_prefs;
 
718
 
 
719
        if (self->priv->window == NULL) {
 
720
                GladeXML *xml = glade_xml_new (GLADEUI_PATH, NULL, NULL);
 
721
                g_return_if_fail (xml != NULL);
 
722
                window = glade_xml_get_widget (xml, "preferences_dialog");
 
723
 
 
724
                g_signal_connect (G_OBJECT (GTK_DIALOG (window)),
 
725
                                                  "response",
 
726
                                                  G_CALLBACK (applet_preferences_dialog_response),
 
727
                                                  (gpointer) self);
 
728
 
 
729
                g_signal_connect (G_OBJECT (window),
 
730
                                                  "delete_event",
 
731
                                                  G_CALLBACK (gtk_widget_hide),
 
732
                                                  (gpointer) self);
 
733
 
 
734
                /***** terminal *****/
 
735
                terminal = glade_xml_get_widget (xml, "terminal_entry");
 
736
                gtk_entry_set_width_chars (GTK_ENTRY (terminal), 10);
 
737
                gtk_entry_set_text (GTK_ENTRY (terminal),
 
738
                                                        mb_prefs->browser_prefs->terminal);
 
739
                g_signal_connect (G_OBJECT (terminal),                  
 
740
                                                  "changed",
 
741
                                                  G_CALLBACK (applet_preferences_on_terminal_changed),
 
742
                                                  (gpointer)self);
 
743
 
 
744
                /***** editor *****/
 
745
                editor = glade_xml_get_widget (xml, "editor_entry");
 
746
                gtk_entry_set_width_chars (GTK_ENTRY (editor), 10);
 
747
                gtk_entry_set_text (GTK_ENTRY (editor),
 
748
                                                        mb_prefs->browser_prefs->editor);
 
749
                g_signal_connect (G_OBJECT (editor),                    
 
750
                                                  "changed",
 
751
                                                  G_CALLBACK (applet_preferences_on_editor_changed),
 
752
                                                  (gpointer)self);
 
753
 
 
754
                /***** show hidden *****/
 
755
                show_hidden = glade_xml_get_widget (xml, "show_hidden_check");
 
756
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_hidden),
 
757
                                                                          mb_prefs->browser_prefs->show_hidden);
 
758
                g_signal_connect (G_OBJECT (show_hidden),
 
759
                                                  "toggled",
 
760
                                                  G_CALLBACK (applet_preferences_on_show_hidden_pressed),
 
761
                                                  (gpointer)self);
 
762
 
 
763
                /***** icon *****/
 
764
                show_icon = glade_xml_get_widget (xml, "show_icon_check");
 
765
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_icon),
 
766
                                                                          mb_prefs->show_icon);
 
767
                g_signal_connect (G_OBJECT (show_icon),
 
768
                                                  "toggled",
 
769
                                                  G_CALLBACK (applet_preferences_on_show_icon_pressed),
 
770
                                                  (gpointer)self);
 
771
 
 
772
                icon_button = glade_xml_get_widget (xml, "icon_button");
 
773
                GtkWidget *icon = utils_get_scaled_image_from_file (mb_prefs->icon, ICON_BUTTON_SIZE);
 
774
                if (icon == NULL) {
 
775
                        icon = gtk_image_new_from_icon_name ("user-home", GTK_ICON_SIZE_BUTTON);
 
776
                }
 
777
                gtk_button_set_image (GTK_BUTTON (icon_button), icon);
 
778
                g_signal_connect (G_OBJECT (icon_button),
 
779
                                                  "released",
 
780
                                                  G_CALLBACK (applet_preferences_on_icon_select),
 
781
                                                  (gpointer)self);
 
782
 
 
783
                /***** dirs/labels **/
 
784
                self->priv->tree_view = glade_xml_get_widget (xml, "directories_tree");
 
785
                applet_preferences_create_list_view (self);
 
786
 
 
787
                /***** more buttons ******/
 
788
                GtkWidget *add_button  = glade_xml_get_widget (xml, "directory_add_button");
 
789
                GtkWidget *rem_button  = glade_xml_get_widget (xml, "directory_remove_button");
 
790
                GtkWidget *up_button   = glade_xml_get_widget (xml, "move_up_button");
 
791
                GtkWidget *down_button = glade_xml_get_widget (xml, "move_down_button");
 
792
 
 
793
 
 
794
                g_signal_connect (G_OBJECT (add_button),
 
795
                                                  "released",
 
796
                                                  G_CALLBACK (applet_preferences_on_add_dir_clicked),
 
797
                                                  (gpointer) self);
 
798
                g_signal_connect (G_OBJECT (rem_button),
 
799
                                                  "released",
 
800
                                                  G_CALLBACK (applet_preferences_on_rem_dir_clicked),
 
801
                                                  (gpointer) self);
 
802
                g_signal_connect (G_OBJECT (up_button),
 
803
                                                  "released",
 
804
                                                  G_CALLBACK (applet_preferences_on_up_dir_clicked),
 
805
                                                  (gpointer) self);
 
806
                g_signal_connect (G_OBJECT (down_button),
 
807
                                                  "released",
 
808
                                                  G_CALLBACK (applet_preferences_on_down_dir_clicked),
 
809
                                                  (gpointer) self);
 
810
 
 
811
                /***** the end ******/
 
812
                self->priv->window = window;
 
813
        }
 
814
 
 
815
        gtk_widget_show_all (self->priv->window);
 
816
        gtk_window_present (GTK_WINDOW (self->priv->window));
 
817
 
 
818
        return;
 
819
}
 
820
/******************************************************************************/
 
821
static MenuBarPrefs *
 
822
applet_preferences_load_from_gconf (PanelApplet *applet) {
 
823
        GError *error = NULL;
 
824
 
 
825
        MenuBarPrefs *mb_prefs  = g_new0 (MenuBarPrefs, 1);
 
826
        mb_prefs->browser_prefs = g_new0 (BrowserPrefs, 1);
 
827
 
 
828
        /* this loads the default key's/values into the gconf entry for this applet
 
829
         * instance. It also check to make sure the values were retrieved properly
 
830
         * AND that they are valid */
 
831
        panel_applet_add_preferences (applet, "/schemas/apps/file-browser-applet/prefs", &error);
 
832
        if (utils_check_gerror (&error)) return NULL;   
 
833
 
 
834
        /* show hidden files? */
 
835
        mb_prefs->browser_prefs->show_hidden = panel_applet_gconf_get_bool (applet,
 
836
                                                                                                                                         KEY_HIDDEN_SHOW,
 
837
                                                                                                                                         &error);
 
838
        if (utils_check_gerror (&error)) {
 
839
                mb_prefs->browser_prefs->show_hidden = DEFAULT_SHOW_HIDDEN;
 
840
                panel_applet_gconf_set_bool (applet,
 
841
                                                                         KEY_HIDDEN_SHOW,
 
842
                                                                         mb_prefs->browser_prefs->show_hidden,
 
843
                                                                         &error);
 
844
        }
 
845
        /* terminal */
 
846
        mb_prefs->browser_prefs->terminal = panel_applet_gconf_get_string (applet,
 
847
                                                                                                                                        KEY_TERMINAL,
 
848
                                                                                                                                        &error);
 
849
        if (utils_check_gerror (&error) || mb_prefs->browser_prefs->terminal == NULL) {
 
850
                mb_prefs->browser_prefs->terminal = g_strdup (DEFAULT_TERMINAL);
 
851
                panel_applet_gconf_set_string (applet,
 
852
                                                                           KEY_TERMINAL,
 
853
                                                                           mb_prefs->browser_prefs->terminal,
 
854
                                                                           &error);
 
855
        }
 
856
        /* editor */
 
857
        mb_prefs->browser_prefs->editor = panel_applet_gconf_get_string (applet,
 
858
                                                                                                                                         KEY_EDITOR,
 
859
                                                                                                                                         &error);
 
860
        if (utils_check_gerror (&error) || mb_prefs->browser_prefs->editor == NULL) {
 
861
                mb_prefs->browser_prefs->editor = g_strdup (DEFAULT_EDITOR);
 
862
                panel_applet_gconf_set_string (applet,
 
863
                                                                           KEY_TERMINAL,
 
864
                                                                           mb_prefs->browser_prefs->editor,
 
865
                                                                           &error);
 
866
        }
 
867
 
 
868
        /* the icon */
 
869
        mb_prefs->icon = panel_applet_gconf_get_string (applet,
 
870
                                                                                                 KEY_ICON_NAME,
 
871
                                                                                                 &error);
 
872
        if (utils_check_gerror (&error) || mb_prefs->icon == NULL) {
 
873
                mb_prefs->icon = g_strdup (DEFAULT_ICON);
 
874
                panel_applet_gconf_set_string (applet,
 
875
                                                                           KEY_ICON_NAME,
 
876
                                                                           mb_prefs->icon,
 
877
                                                                           &error);
 
878
        }
 
879
 
 
880
        /* show the icon? */
 
881
        mb_prefs->show_icon = panel_applet_gconf_get_bool (applet,
 
882
                                                                                                        KEY_ICON_SHOW,
 
883
                                                                                                        &error);
 
884
        if (utils_check_gerror (&error)) {
 
885
                mb_prefs->show_icon = DEFAULT_SHOW_ICON;
 
886
                panel_applet_gconf_set_bool (applet,
 
887
                                                                         KEY_ICON_SHOW,
 
888
                                                                         mb_prefs->show_icon,
 
889
                                                                         &error);
 
890
        }
 
891
        /* directory list */
 
892
        GSList *dirs = panel_applet_gconf_get_list (applet,
 
893
                                                                                           KEY_DIR,
 
894
                                                                                           GCONF_VALUE_STRING,
 
895
                                                                                           &error);
 
896
        if (utils_check_gerror (&error) || dirs == NULL) {
 
897
                dirs = g_slist_alloc ();
 
898
                dirs->data = g_strdup (DEFAULT_PATH);
 
899
                dirs->next = NULL;
 
900
                panel_applet_gconf_set_list (applet,
 
901
                                                                         KEY_DIR,
 
902
                                                                         GCONF_VALUE_STRING,
 
903
                                                                         dirs,
 
904
                                                                         &error);
 
905
        }
 
906
        /* labels list */
 
907
        GSList *labels = panel_applet_gconf_get_list (applet,
 
908
                                                                                             KEY_LABELS,
 
909
                                                                                             GCONF_VALUE_STRING,
 
910
                                                                                             &error);
 
911
        if (utils_check_gerror (&error) || labels == NULL) {
 
912
                labels = g_slist_alloc ();
 
913
                labels->data = g_strdup (DEFAULT_LABEL);
 
914
                labels->next = NULL;
 
915
                panel_applet_gconf_set_list (applet,
 
916
                                                                         KEY_LABELS,
 
917
                                                                         GCONF_VALUE_STRING,
 
918
                                                                         labels,
 
919
                                                                         &error);
 
920
        }
 
921
        mb_prefs->dirs   = dirs;
 
922
        mb_prefs->labels = labels;
 
923
 
 
924
        return mb_prefs;
 
925
}
 
926
/******************************************************************************/
 
927
AppletPreferences*
 
928
applet_preferences_new (PanelApplet* applet) {
 
929
        AppletPreferences *self;
 
930
        g_return_val_if_fail (applet == NULL || PANEL_IS_APPLET (applet), NULL);
 
931
        self = g_object_newv (TYPE_APPLET_PREFERENCES, 0, NULL);
 
932
 
 
933
        self->menu_bar_prefs = applet_preferences_load_from_gconf (applet);
 
934
        self->priv->window = NULL;
 
935
        self->priv->applet = applet;
 
936
 
 
937
 
 
938
        return self;
 
939
}
 
940
/******************************************************************************/
 
941
static void
 
942
applet_preferences_class_init (AppletPreferencesClass * klass) {
 
943
        applet_preferences_parent_class = g_type_class_peek_parent (klass);
 
944
        g_type_class_add_private (klass, sizeof (AppletPreferencesPrivate));
 
945
        G_OBJECT_CLASS (klass)->dispose = applet_preferences_dispose;
 
946
 
 
947
        applet_preferences_signals [PREFS_CHANGED] =
 
948
                g_signal_new ("prefs_changed",
 
949
                      G_TYPE_FROM_CLASS (klass),
 
950
                                          G_SIGNAL_NO_HOOKS,
 
951
                      /*G_STRUCT_OFFSET (AppletPreferencesClass, prefs_changed),*/
 
952
                                          0,
 
953
                                          NULL,
 
954
                                          NULL,
 
955
                                      g_cclosure_marshal_VOID__INT,
 
956
                                          G_TYPE_NONE,
 
957
                                          1,
 
958
                                          G_TYPE_POINTER);
 
959
        /* NOTE!!! a dynamically allocated PrefsChangedSignalData structure is passed
 
960
         * to the callback function including 2 gchar pointers. The callback function
 
961
         * is responsible for freeing this memory. HOWEVER!!! make sure that the gchar*
 
962
         * can be freed!!! Be careful!!!*/
 
963
}
 
964
/******************************************************************************/
 
965
static void
 
966
applet_preferences_init (AppletPreferences * self) {
 
967
        self->priv = APPLET_PREFERENCES_GET_PRIVATE (self);
 
968
}
 
969
/******************************************************************************/
 
970
static void
 
971
applet_preferences_dispose (GObject * obj) {
 
972
        AppletPreferences * self;
 
973
        self = APPLET_PREFERENCES (obj);
 
974
        (self->priv->window == NULL ? NULL : (self->priv->window = (g_object_unref (self->priv->window), NULL)));
 
975
        G_OBJECT_CLASS (applet_preferences_parent_class)->dispose (obj);
 
976
}
 
977
/******************************************************************************/
 
978
GType
 
979
applet_preferences_get_type (void) {
 
980
        static GType applet_preferences_type_id = 0;
 
981
        if (G_UNLIKELY (applet_preferences_type_id == 0)) {
 
982
                static const GTypeInfo g_define_type_info = { sizeof (AppletPreferencesClass),
 
983
                                                                                                          (GBaseInitFunc) NULL,
 
984
                                                                                                          (GBaseFinalizeFunc) NULL,
 
985
                                                                                                          (GClassInitFunc) applet_preferences_class_init,
 
986
                                                                                                          (GClassFinalizeFunc) NULL,
 
987
                                                                                                          NULL,
 
988
                                                                                                          sizeof (AppletPreferences),
 
989
                                                                                                          0,
 
990
                                                                                                          (GInstanceInitFunc) applet_preferences_init };
 
991
 
 
992
                applet_preferences_type_id = g_type_register_static (G_TYPE_OBJECT,
 
993
                                                                                                                         "AppletPreferences",
 
994
                                                                                                                         &g_define_type_info, 0);
 
995
        }
 
996
        return applet_preferences_type_id;
 
997
}
 
998
/******************************************************************************/