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

« back to all changes in this revision

Viewing changes to src/preferences.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2009-04-11 17:15:39 UTC
  • mfrom: (1.1.4 upstream) (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090411171539-jk4kgkvm4i39nv3c
Tags: 0.6.2-1
* New upstream release. (Closes: #504525)
 - Added context menu with a few actions (open-with, new folder here, 
   delete file/folder, create/extract archive, create CD/DVD from 
   file/folder, compile a tex file).
 - Added configuration option to make text vertical/horizontal when 
   the panel is vertical.
 - Added tooltips to configuration dialog.
 - Fixes upstream bugs #21, #30, #34, #37, #39, #43, #44, #45, #49, 
   #51, #56, #59, #60, and #62.
 - Added mnemonic keyboard shortcut to menus for 
   faster keyboard navigation.
 - Added recent documents' support.
 - Improved menu browser focus after context menu close.
 - Added preliminary DnD dragging out of applet. MOVE is the default 
   behaviour.
 - Some code cleanups and plugged memory leaks.
 - Slightly improved "New Folder" dialog.
 - Migrated to gtk+ builder from libglade.
* debian/control:
 - Add suggests on file-roller, brasero, and rubber 
   for new features.
 - Add Vcs-Bzr field.
 - Drop depricated libglade2-dev Build-Depend
 - Drop unneeded libpanel-applet2-0 Depend. Already picked up by 
   shlibs:Depends.
 - Add versionized Build-Depend on libgtk2.0-dev (>= 2.14)
 - Bump Standards-Version to 3.8.1
* debian/copyright:
 - Use /usr/share/common-licenses/GPL-2 rather than just GLP.

Show diffs side-by-side

added added

removed removed

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