70
69
/******************************************************************************/
72
71
applet_preferences_on_show_icon_pressed (GtkWidget* widget, AppletPreferences* self) {
73
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
75
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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));
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;
86
/* emit the signal so the panel menu bar updates itself */
87
g_signal_emit (G_OBJECT (self),
88
applet_preferences_signals [PREFS_CHANGED],
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__);
74
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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));
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;
85
/* emit the signal so the panel menu bar updates itself */
86
g_signal_emit (G_OBJECT (self),
87
applet_preferences_signals [PREFS_CHANGED],
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);*/
96
95
/******************************************************************************/
98
97
applet_preferences_on_horizontal_text_pressed (GtkWidget* widget, AppletPreferences* self) {
99
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
101
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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));
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;
113
/* emit the signal so the panel menu bar updates itself */
114
g_signal_emit (G_OBJECT (self),
115
applet_preferences_signals [PREFS_CHANGED],
98
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
100
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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));
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;
112
/* emit the signal so the panel menu bar updates itself */
113
g_signal_emit (G_OBJECT (self),
114
applet_preferences_signals [PREFS_CHANGED],
119
118
/******************************************************************************/
121
120
applet_preferences_on_show_hidden_pressed (GtkWidget* widget, AppletPreferences* self) {
122
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
124
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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));
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__);
123
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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));
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);*/
134
133
/******************************************************************************/
136
135
applet_preferences_on_terminal_changed (GtkWidget* widget, AppletPreferences* self) {
137
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
139
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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;
147
self->menu_bar_prefs->browser_prefs->terminal = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
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__);
138
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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;
146
self->menu_bar_prefs->browser_prefs->terminal = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
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);*/
153
152
/******************************************************************************/
155
154
applet_preferences_on_editor_changed (GtkWidget* widget, AppletPreferences* self) {
156
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
158
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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;
166
self->menu_bar_prefs->browser_prefs->editor = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
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__);
157
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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;
165
self->menu_bar_prefs->browser_prefs->editor = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
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);*/
172
171
/******************************************************************************/
174
173
applet_preferences_on_icon_select (GtkWidget* button, AppletPreferences* self) {
175
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
177
g_return_if_fail (IS_APPLET_PREFERENCES (self));
179
GtkWidget *file_chooser_dialog;
180
gchar *icon_path = DEFAULT_ICON_PATH;
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"),
187
GTK_FILE_CHOOSER_ACTION_OPEN,
193
/* Set the starting path */
194
if (vfs_file_exists (self->menu_bar_prefs->icon)) {
195
icon_path = self->menu_bar_prefs->icon;
197
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog),
199
/* check the reply */
200
if (gtk_dialog_run (GTK_DIALOG (file_chooser_dialog)) == GTK_RESPONSE_ACCEPT) {
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;
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,
215
icon = gtk_image_new_from_icon_name ("user-home", GTK_ICON_SIZE_BUTTON);
217
gtk_button_set_image (GTK_BUTTON (button), icon);
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;
225
/* emit the signal so the panel menu bar updates itself */
226
g_signal_emit (G_OBJECT (self),
227
applet_preferences_signals [PREFS_CHANGED],
230
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
233
/* they chose the same icon again! */
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__);
176
g_return_if_fail (IS_APPLET_PREFERENCES (self));
178
GtkWidget *file_chooser_dialog;
179
gchar *icon_path = DEFAULT_ICON_PATH;
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"),
186
GTK_FILE_CHOOSER_ACTION_OPEN,
192
/* Set the starting path */
193
if (vfs_file_exists (self->menu_bar_prefs->icon)) {
194
icon_path = self->menu_bar_prefs->icon;
196
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog),
198
/* check the reply */
199
if (gtk_dialog_run (GTK_DIALOG (file_chooser_dialog)) == GTK_RESPONSE_ACCEPT) {
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;
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,
214
icon = gtk_image_new_from_icon_name ("user-home", GTK_ICON_SIZE_BUTTON);
216
gtk_button_set_image (GTK_BUTTON (button), icon);
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;
224
/* emit the signal so the panel menu bar updates itself */
225
g_signal_emit (G_OBJECT (self),
226
applet_preferences_signals [PREFS_CHANGED],
229
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
232
/* they chose the same icon again! */
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);
242
241
/******************************************************************************/
244
243
applet_preferences_save_to_gconf (AppletPreferences *self) {
245
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
247
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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,
255
self->menu_bar_prefs->browser_prefs->show_hidden,
257
utils_gerror_ok (&error, TRUE);
260
panel_applet_gconf_set_string (applet,
262
self->menu_bar_prefs->browser_prefs->terminal,
264
utils_gerror_ok (&error, TRUE);
267
panel_applet_gconf_set_string (applet,
269
self->menu_bar_prefs->browser_prefs->editor,
271
utils_gerror_ok (&error, TRUE);
274
panel_applet_gconf_set_string (applet,
276
self->menu_bar_prefs->icon,
278
utils_gerror_ok (&error, TRUE);
281
panel_applet_gconf_set_bool (applet,
283
self->menu_bar_prefs->show_icon,
285
utils_gerror_ok (&error, TRUE);
287
/* horizontal text? */
288
panel_applet_gconf_set_bool (applet,
290
self->menu_bar_prefs->horizontal_text,
292
utils_gerror_ok (&error, TRUE);
295
panel_applet_gconf_set_list (applet,
298
self->menu_bar_prefs->dirs,
300
utils_gerror_ok (&error, TRUE);
303
panel_applet_gconf_set_list (applet,
306
self->menu_bar_prefs->labels,
308
utils_gerror_ok (&error, TRUE);
244
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
246
g_return_if_fail (IS_APPLET_PREFERENCES (self));
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,
254
self->menu_bar_prefs->browser_prefs->show_hidden,
256
utils_gerror_ok (&error, TRUE);
259
panel_applet_gconf_set_string (applet,
261
self->menu_bar_prefs->browser_prefs->terminal,
263
utils_gerror_ok (&error, TRUE);
266
panel_applet_gconf_set_string (applet,
268
self->menu_bar_prefs->browser_prefs->editor,
270
utils_gerror_ok (&error, TRUE);
273
panel_applet_gconf_set_string (applet,
275
self->menu_bar_prefs->icon,
277
utils_gerror_ok (&error, TRUE);
280
panel_applet_gconf_set_bool (applet,
282
self->menu_bar_prefs->show_icon,
284
utils_gerror_ok (&error, TRUE);
286
/* horizontal text? */
287
panel_applet_gconf_set_bool (applet,
289
self->menu_bar_prefs->horizontal_text,
291
utils_gerror_ok (&error, TRUE);
294
panel_applet_gconf_set_list (applet,
297
self->menu_bar_prefs->dirs,
299
utils_gerror_ok (&error, TRUE);
302
panel_applet_gconf_set_list (applet,
305
self->menu_bar_prefs->labels,
307
utils_gerror_ok (&error, TRUE);
310
309
/******************************************************************************/
312
311
applet_preferences_dialog_response (GtkWidget* window, gint response, AppletPreferences* self) {
313
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
315
g_return_if_fail (IS_APPLET_PREFERENCES (self));
317
/* figure out what button closed the dialog and take the appropriate action */
319
case RESPONSE_REVERT:
320
/* revert to the saved config */
321
/*gtk_widget_set_sensitive (revert_button, FALSE);*/
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);
331
case GTK_RESPONSE_DELETE_EVENT:
332
/* neither save nor revert */
333
gtk_widget_hide (window);
337
/******************************************************************************/
339
applet_preferences_label_cell_edited (GtkCellRenderer *cell,
342
AppletPreferences* self){
343
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
345
g_return_if_fail (IS_APPLET_PREFERENCES (self));
347
GtkWidget *tree_view = self->priv->tree_view;
352
/* get the model where the actual data is stored */
353
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
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);
360
/* the path associated with the selection */
361
gtk_tree_model_get (model, &iter, PATH_COLUMN, &path, -1);
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;
370
/* update this item from the list holding the label prefs */
372
tmp = g_slist_nth (self->menu_bar_prefs->labels, signal_data->instance);
374
tmp->data = (gpointer)g_strdup (new_string);
376
/* emit the signal so the panel menu bar updates itself */
377
g_signal_emit (G_OBJECT (self),
378
applet_preferences_signals [PREFS_CHANGED],
382
/* update the revert button*/
383
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
385
/******************************************************************************/
387
applet_preferences_path_cell_activated (GtkTreeView *tree_view,
389
GtkTreeViewColumn *col,
390
AppletPreferences* self) {
391
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
393
g_return_if_fail (IS_APPLET_PREFERENCES (self));
397
GtkWidget* file_chooser_dialog;
398
gchar* old_path = NULL;
400
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
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);
407
/* make a file chooser object to select the new path */
408
file_chooser_dialog = gtk_file_chooser_dialog_new (_("Select Folder To Browse"),
410
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
416
/* Set the starting path as the old path */
417
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog), old_path);
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);
427
/* the label associated with the selection */
429
gtk_tree_model_get (model, &iter, LABEL_COLUMN, &label, -1);
431
/* get the instance from the iterator */
432
gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
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;
442
/* update this item from the list holding the path prefs */
444
tmp = g_slist_nth (self->menu_bar_prefs->dirs, signal_data->instance);
446
tmp->data = (gpointer)g_strdup (new_path);
448
/* emit the signal so the panel menu bar updates itself */
449
g_signal_emit (G_OBJECT (self),
450
applet_preferences_signals [PREFS_CHANGED],
454
/* update the revert button*/
455
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
458
gtk_widget_destroy (file_chooser_dialog);
312
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
314
g_return_if_fail (IS_APPLET_PREFERENCES (self));
316
/* figure out what button closed the dialog and take the appropriate action */
318
case RESPONSE_REVERT:
319
/* revert to the saved config */
320
/*gtk_widget_set_sensitive (revert_button, FALSE);*/
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);
330
case GTK_RESPONSE_DELETE_EVENT:
331
/* neither save nor revert */
332
gtk_widget_hide (window);
336
/******************************************************************************/
338
applet_preferences_label_cell_edited (GtkCellRenderer *cell,
341
AppletPreferences* self){
342
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
344
g_return_if_fail (IS_APPLET_PREFERENCES (self));
346
GtkWidget *tree_view = self->priv->tree_view;
351
/* get the model where the actual data is stored */
352
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
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);
359
/* the path associated with the selection */
360
gtk_tree_model_get (model, &iter, PATH_COLUMN, &path, -1);
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;
369
/* update this item from the list holding the label prefs */
371
tmp = g_slist_nth (self->menu_bar_prefs->labels, signal_data->instance);
373
tmp->data = (gpointer)g_strdup (new_string);
375
/* emit the signal so the panel menu bar updates itself */
376
g_signal_emit (G_OBJECT (self),
377
applet_preferences_signals [PREFS_CHANGED],
381
/* update the revert button*/
382
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
384
/******************************************************************************/
386
applet_preferences_path_cell_activated (GtkTreeView *tree_view,
388
GtkTreeViewColumn *col,
389
AppletPreferences* self) {
390
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
392
g_return_if_fail (IS_APPLET_PREFERENCES (self));
396
GtkWidget* file_chooser_dialog;
397
gchar* old_path = NULL;
399
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
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);
406
/* make a file chooser object to select the new path */
407
file_chooser_dialog = gtk_file_chooser_dialog_new (_("Select Folder To Browse"),
409
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
415
/* Set the starting path as the old path */
416
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog), old_path);
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);
426
/* the label associated with the selection */
428
gtk_tree_model_get (model, &iter, LABEL_COLUMN, &label, -1);
430
/* get the instance from the iterator */
431
gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
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;
441
/* update this item from the list holding the path prefs */
443
tmp = g_slist_nth (self->menu_bar_prefs->dirs, signal_data->instance);
445
tmp->data = (gpointer)g_strdup (new_path);
447
/* emit the signal so the panel menu bar updates itself */
448
g_signal_emit (G_OBJECT (self),
449
applet_preferences_signals [PREFS_CHANGED],
453
/* update the revert button*/
454
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
457
gtk_widget_destroy (file_chooser_dialog);
460
459
/******************************************************************************/
462
461
applet_preferences_on_add_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
463
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
465
g_return_if_fail (IS_APPLET_PREFERENCES (self));
469
GtkWidget* file_chooser_dialog;
470
GtkWidget* tree_view = self->priv->tree_view;
472
file_chooser_dialog = gtk_file_chooser_dialog_new (_("Select Folder To Add"),
474
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
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);
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),
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;
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));
512
/* emit the signal so the panel menu bar updates itself */
513
g_signal_emit (G_OBJECT (self),
514
applet_preferences_signals [PREFS_CHANGED],
518
/* update the revert button*/
519
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
521
gtk_widget_destroy (file_chooser_dialog);
462
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
464
g_return_if_fail (IS_APPLET_PREFERENCES (self));
468
GtkWidget* file_chooser_dialog;
469
GtkWidget* tree_view = self->priv->tree_view;
471
file_chooser_dialog = gtk_file_chooser_dialog_new (_("Select Folder To Add"),
473
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
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);
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),
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;
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));
511
/* emit the signal so the panel menu bar updates itself */
512
g_signal_emit (G_OBJECT (self),
513
applet_preferences_signals [PREFS_CHANGED],
517
/* update the revert button*/
518
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
520
gtk_widget_destroy (file_chooser_dialog);
523
522
/******************************************************************************/
525
524
applet_preferences_on_rem_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
526
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
528
g_return_if_fail (IS_APPLET_PREFERENCES (self));
530
GtkTreeSelection *selection;
533
GtkWidget *tree_view = self->priv->tree_view;
535
/* get the current selection */
536
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree_view));
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)) {
542
/* get the instance from the iterator */
543
gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
545
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
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;
555
/* remove this item from the list holding the path/label prefs */
557
tmp = g_slist_nth (self->menu_bar_prefs->dirs, signal_data->instance);
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);
562
self->menu_bar_prefs->labels = g_slist_delete_link (self->menu_bar_prefs->labels, tmp);
564
/* emit the signal so the panel menu bar updates itself */
565
g_signal_emit (G_OBJECT (self),
566
applet_preferences_signals [PREFS_CHANGED],
570
/* update the revert button*/
571
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
525
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
527
g_return_if_fail (IS_APPLET_PREFERENCES (self));
529
GtkTreeSelection *selection;
532
GtkWidget *tree_view = self->priv->tree_view;
534
/* get the current selection */
535
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree_view));
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)) {
541
/* get the instance from the iterator */
542
gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
544
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
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;
554
/* remove this item from the list holding the path/label prefs */
556
tmp = g_slist_nth (self->menu_bar_prefs->dirs, signal_data->instance);
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);
561
self->menu_bar_prefs->labels = g_slist_delete_link (self->menu_bar_prefs->labels, tmp);
563
/* emit the signal so the panel menu bar updates itself */
564
g_signal_emit (G_OBJECT (self),
565
applet_preferences_signals [PREFS_CHANGED],
569
/* update the revert button*/
570
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
574
573
/******************************************************************************/
576
575
applet_preferences_on_down_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
577
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
579
g_return_if_fail (IS_APPLET_PREFERENCES (self));
581
GtkTreeSelection *selection = NULL;
582
GtkTreeModel *model = NULL;
583
GtkTreeIter iter, iter_next;
584
GtkWidget *tree_view = self->priv->tree_view;
586
/* get the current selection */
587
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
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... */
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)){
596
/* get the instance from the iterator */
597
gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
599
gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter_next);
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;
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);
613
/* emit the signal so the panel menu bar updates itself */
614
g_signal_emit (G_OBJECT (self),
615
applet_preferences_signals [PREFS_CHANGED],
619
/* update the revert button*/
620
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
576
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
578
g_return_if_fail (IS_APPLET_PREFERENCES (self));
580
GtkTreeSelection *selection = NULL;
581
GtkTreeModel *model = NULL;
582
GtkTreeIter iter, iter_next;
583
GtkWidget *tree_view = self->priv->tree_view;
585
/* get the current selection */
586
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
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... */
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)){
595
/* get the instance from the iterator */
596
gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
598
gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter_next);
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;
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);
612
/* emit the signal so the panel menu bar updates itself */
613
g_signal_emit (G_OBJECT (self),
614
applet_preferences_signals [PREFS_CHANGED],
618
/* update the revert button*/
619
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
624
623
/******************************************************************************/
626
625
applet_preferences_on_up_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
627
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
629
g_return_if_fail (IS_APPLET_PREFERENCES (self));
631
GtkTreeSelection *selection = NULL;
632
GtkTreeModel *model = NULL;
633
GtkTreeIter iter, iter_prev;
635
GtkWidget *tree_view = self->priv->tree_view;
637
/* get the current selection */
638
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
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
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);
651
/* get the instance from the iterator */
652
gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
654
gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter_prev);
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;
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);
668
/* emit the signal so the panel menu bar updates itself */
669
g_signal_emit (G_OBJECT (self),
670
applet_preferences_signals [PREFS_CHANGED],
674
/* update the revert button*/
675
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
677
gtk_tree_path_free (path);
626
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
628
g_return_if_fail (IS_APPLET_PREFERENCES (self));
630
GtkTreeSelection *selection = NULL;
631
GtkTreeModel *model = NULL;
632
GtkTreeIter iter, iter_prev;
634
GtkWidget *tree_view = self->priv->tree_view;
636
/* get the current selection */
637
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
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
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);
650
/* get the instance from the iterator */
651
gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
653
gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter_prev);
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;
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);
667
/* emit the signal so the panel menu bar updates itself */
668
g_signal_emit (G_OBJECT (self),
669
applet_preferences_signals [PREFS_CHANGED],
673
/* update the revert button*/
674
/*gtk_widget_set_sensitive (revert_button, TRUE);*/
676
gtk_tree_path_free (path);
680
679
/******************************************************************************/
682
681
applet_preferences_create_list_view (AppletPreferences* self) {
683
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
685
g_return_if_fail (IS_APPLET_PREFERENCES (self));
689
GtkTreeViewColumn *column;
690
GtkCellRenderer *renderer;
691
GtkTreeSelection *selection;
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);
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,
705
(gchar *)tmp_label->data,
707
(gchar *)tmp_dir->data,
709
tmp_dir = tmp_dir->next;
710
tmp_label = tmp_label->next;
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);
717
/* The view now holds a reference. We can get rid of our own
719
g_object_unref (G_OBJECT (store));
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),
726
G_CALLBACK (applet_preferences_label_cell_edited),
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"),
736
/* Add the column to the view. */
737
gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->tree_view), column);
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),
743
G_CALLBACK (applet_preferences_path_cell_activated),
745
column = gtk_tree_view_column_new_with_attributes (_("Path"),
750
gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->tree_view), column);
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__);
684
g_return_if_fail (IS_APPLET_PREFERENCES (self));
688
GtkTreeViewColumn *column;
689
GtkCellRenderer *renderer;
690
GtkTreeSelection *selection;
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);
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,
704
(gchar *)tmp_label->data,
706
(gchar *)tmp_dir->data,
708
tmp_dir = tmp_dir->next;
709
tmp_label = tmp_label->next;
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);
716
/* The view now holds a reference. We can get rid of our own
718
g_object_unref (G_OBJECT (store));
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),
725
G_CALLBACK (applet_preferences_label_cell_edited),
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"),
735
/* Add the column to the view. */
736
gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->tree_view), column);
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),
742
G_CALLBACK (applet_preferences_path_cell_activated),
744
column = gtk_tree_view_column_new_with_attributes (_("Path"),
749
gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->tree_view), column);
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);
756
755
/******************************************************************************/
758
757
applet_preferences_make_dialog (AppletPreferences* self) {
759
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
761
g_return_if_fail (IS_APPLET_PREFERENCES (self));
758
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
760
g_return_if_fail (IS_APPLET_PREFERENCES (self));
762
GError *error = NULL;
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;
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");
777
g_signal_connect (G_OBJECT (GTK_DIALOG (window)),
779
G_CALLBACK (applet_preferences_dialog_response),
782
g_signal_connect (G_OBJECT (window),
784
G_CALLBACK (gtk_widget_hide),
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),
794
G_CALLBACK (applet_preferences_on_terminal_changed),
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),
804
G_CALLBACK (applet_preferences_on_editor_changed),
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),
813
G_CALLBACK (applet_preferences_on_show_hidden_pressed),
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),
822
G_CALLBACK (applet_preferences_on_horizontal_text_pressed),
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),
831
G_CALLBACK (applet_preferences_on_show_icon_pressed),
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);
837
icon = gtk_image_new_from_icon_name ("user-home", GTK_ICON_SIZE_BUTTON);
839
gtk_button_set_image (GTK_BUTTON (icon_button), icon);
840
g_signal_connect (G_OBJECT (icon_button),
842
G_CALLBACK (applet_preferences_on_icon_select),
845
/***** dirs/labels **/
846
self->priv->tree_view = glade_xml_get_widget (xml, "directories_tree");
847
applet_preferences_create_list_view (self);
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");
856
g_signal_connect (G_OBJECT (add_button),
858
G_CALLBACK (applet_preferences_on_add_dir_clicked),
860
g_signal_connect (G_OBJECT (rem_button),
862
G_CALLBACK (applet_preferences_on_rem_dir_clicked),
864
g_signal_connect (G_OBJECT (up_button),
866
G_CALLBACK (applet_preferences_on_up_dir_clicked),
868
g_signal_connect (G_OBJECT (down_button),
870
G_CALLBACK (applet_preferences_on_down_dir_clicked),
873
/***** the end ******/
874
self->priv->window = window;
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;
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)) {
778
window = GTK_WIDGET (gtk_builder_get_object (builder, "preferences_dialog"));
780
g_signal_connect (G_OBJECT (GTK_DIALOG (window)),
782
G_CALLBACK (applet_preferences_dialog_response),
785
g_signal_connect (G_OBJECT (window),
787
G_CALLBACK (gtk_widget_hide),
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),
797
G_CALLBACK (applet_preferences_on_terminal_changed),
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),
807
G_CALLBACK (applet_preferences_on_editor_changed),
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),
816
G_CALLBACK (applet_preferences_on_show_hidden_pressed),
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),
825
G_CALLBACK (applet_preferences_on_horizontal_text_pressed),
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),
834
G_CALLBACK (applet_preferences_on_show_icon_pressed),
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);
840
icon = gtk_image_new_from_icon_name ("user-home", GTK_ICON_SIZE_BUTTON);
842
gtk_button_set_image (GTK_BUTTON (icon_button), icon);
843
g_signal_connect (G_OBJECT (icon_button),
845
G_CALLBACK (applet_preferences_on_icon_select),
848
/***** dirs/labels **/
849
self->priv->tree_view = GTK_WIDGET (gtk_builder_get_object (builder, "directories_tree"));
850
applet_preferences_create_list_view (self);
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"));
858
g_signal_connect (G_OBJECT (add_button),
860
G_CALLBACK (applet_preferences_on_add_dir_clicked),
862
g_signal_connect (G_OBJECT (rem_button),
864
G_CALLBACK (applet_preferences_on_rem_dir_clicked),
866
g_signal_connect (G_OBJECT (up_button),
868
G_CALLBACK (applet_preferences_on_up_dir_clicked),
870
g_signal_connect (G_OBJECT (down_button),
872
G_CALLBACK (applet_preferences_on_down_dir_clicked),
875
/***** the end ******/
876
self->priv->window = window;
879
gtk_widget_show_all (self->priv->window);
880
gtk_window_present (GTK_WINDOW (self->priv->window));
880
882
/******************************************************************************/
881
883
static MenuBarPrefs*
882
884
applet_preferences_load_from_gconf (PanelApplet* applet) {
883
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
885
g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
887
GError* error = NULL;
889
MenuBarPrefs* mb_prefs = g_new0 (MenuBarPrefs, 1);
890
mb_prefs->browser_prefs = g_new0 (BrowserPrefs, 1);
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);
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);
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);
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);
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);
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);
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);
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);
952
panel_applet_gconf_set_list (applet, KEY_DIR, GCONF_VALUE_STRING, dirs, &error);
953
utils_gerror_ok (&error, TRUE);
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);
962
panel_applet_gconf_set_list (applet, KEY_LABELS, GCONF_VALUE_STRING, labels, &error);
963
utils_gerror_ok (&error, TRUE);
965
mb_prefs->dirs = dirs;
966
mb_prefs->labels = labels;
885
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
887
g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
889
GError* error = NULL;
891
MenuBarPrefs* mb_prefs = g_new0 (MenuBarPrefs, 1);
892
mb_prefs->browser_prefs = g_new0 (BrowserPrefs, 1);
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);
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);
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);
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);
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);
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);
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);
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);
954
panel_applet_gconf_set_list (applet, KEY_DIR, GCONF_VALUE_STRING, dirs, &error);
955
utils_gerror_ok (&error, TRUE);
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);
964
panel_applet_gconf_set_list (applet, KEY_LABELS, GCONF_VALUE_STRING, labels, &error);
965
utils_gerror_ok (&error, TRUE);
967
mb_prefs->dirs = dirs;
968
mb_prefs->labels = labels;
970
972
/******************************************************************************/
971
973
AppletPreferences*
972
974
applet_preferences_new (PanelApplet* applet) {
973
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
975
g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
977
AppletPreferences* self = g_object_newv (TYPE_APPLET_PREFERENCES, 0, NULL);
979
self->menu_bar_prefs = applet_preferences_load_from_gconf (applet);
980
self->priv->window = NULL;
981
self->priv->applet = applet;
975
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
977
g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
979
AppletPreferences* self = g_object_newv (TYPE_APPLET_PREFERENCES, 0, NULL);
981
self->menu_bar_prefs = applet_preferences_load_from_gconf (applet);
982
self->priv->window = NULL;
983
self->priv->applet = applet;
985
987
/******************************************************************************/
987
989
applet_preferences_class_init (AppletPreferencesClass* klass) {
988
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
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;
994
applet_preferences_signals [PREFS_CHANGED] =
995
g_signal_new ("prefs_changed",
996
G_TYPE_FROM_CLASS (klass),
998
G_STRUCT_OFFSET (AppletPreferencesClass, prefs_changed),
1001
g_cclosure_marshal_VOID__INT,
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__);
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;
997
applet_preferences_signals [PREFS_CHANGED] =
998
g_signal_new ("prefs_changed",
999
G_TYPE_FROM_CLASS (gobject_class),
1001
G_STRUCT_OFFSET (AppletPreferencesClass, prefs_changed),
1004
g_cclosure_marshal_VOID__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!!!*/
1010
1013
/******************************************************************************/
1012
1015
applet_preferences_init (AppletPreferences* self) {
1013
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
1015
g_return_if_fail (IS_APPLET_PREFERENCES (self));
1017
self->priv = APPLET_PREFERENCES_GET_PRIVATE (self);
1016
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
1018
g_return_if_fail (IS_APPLET_PREFERENCES (self));
1020
self->priv = APPLET_PREFERENCES_GET_PRIVATE (self);
1019
1022
/******************************************************************************/
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);
1026
1029
/******************************************************************************/
1028
1031
applet_preferences_get_type (void) {
1029
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
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,
1039
sizeof (AppletPreferences),
1041
(GInstanceInitFunc) applet_preferences_init };
1043
applet_preferences_type_id = g_type_register_static (G_TYPE_OBJECT,
1044
"AppletPreferences",
1045
&g_define_type_info, 0);
1047
return applet_preferences_type_id;
1032
if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
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,
1042
sizeof (AppletPreferences),
1044
(GInstanceInitFunc) applet_preferences_init };
1046
applet_preferences_type_id = g_type_register_static (G_TYPE_OBJECT,
1047
"AppletPreferences",
1048
&g_define_type_info, 0);
1050
return applet_preferences_type_id;
1049
1052
/******************************************************************************/