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

« back to all changes in this revision

Viewing changes to src/preferences.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2008-11-04 13:34:36 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081104133436-7kgxv6psv6mjnxh0
Tags: 0.6.0-0ubuntu1
* New upstream release.
 - 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.
 - Fixed bugs #21, #30, #34, #37, #39.
 - Plugged some memory leaks (thanks Silvio Ricardo Cordeiro).
 - Lots of code cleanup. 
* debian/control:
 - Add suggests on file-roller, brasero, and rubber 
   for new features.
 - Add Vcs-Bzr field.
 - Add versionized Build-Depend on libgtk2.0-dev (>= 2.14)

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
applet_preferences_on_show_icon_pressed (GtkWidget* widget, AppletPreferences* self) {
72
72
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
73
73
 
74
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
74
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
75
75
 
76
76
        /* get the new state from the widget and update the prefs structure */
77
77
        self->menu_bar_prefs->show_icon = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
91
91
        /* update the state of the revert button. A pref has changed so the button
92
92
         * should now be sensitive  */
93
93
        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
94
 
        return;
 
94
}
 
95
/******************************************************************************/
 
96
static void
 
97
applet_preferences_on_horizontal_text_pressed (GtkWidget* widget, AppletPreferences* self) {
 
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);
95
117
}
96
118
/******************************************************************************/
97
119
static void
98
120
applet_preferences_on_show_hidden_pressed (GtkWidget* widget, AppletPreferences* self) {
99
121
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
100
122
 
101
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
123
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
102
124
 
103
125
        /* get the new state from the widget and update the prefs structure. No
104
126
         * need to let the menu bar or browser object know */
107
129
        /* update the state of the revert button. A pref has changed so the button
108
130
         * should now be sensitive  */
109
131
        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
110
 
        return;
111
132
}
112
133
/******************************************************************************/
113
134
static void
114
135
applet_preferences_on_terminal_changed (GtkWidget* widget, AppletPreferences* self) {
115
136
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
116
137
 
117
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
138
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
118
139
 
119
140
        gchar *tmp = NULL;
120
141
 
133
154
applet_preferences_on_editor_changed (GtkWidget* widget, AppletPreferences* self) {
134
155
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
135
156
 
136
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
157
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
137
158
 
138
159
        gchar *tmp = NULL;
139
160
 
152
173
applet_preferences_on_icon_select (GtkWidget* button, AppletPreferences* self) {
153
174
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
154
175
 
155
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
176
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
156
177
 
157
178
        GtkWidget *file_chooser_dialog;
158
179
        gchar *icon_path = DEFAULT_ICON_PATH;
222
243
applet_preferences_save_to_gconf (AppletPreferences *self) {
223
244
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
224
245
 
225
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
246
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
226
247
 
227
248
        PanelApplet *applet = self->priv->applet;
228
249
        GError* error = NULL;
232
253
                                                                 KEY_HIDDEN_SHOW,
233
254
                                                                 self->menu_bar_prefs->browser_prefs->show_hidden,
234
255
                                                                 &error);
235
 
        utils_check_gerror (&error);
 
256
        utils_gerror_ok (&error, TRUE);
 
257
 
236
258
        /* terminal */
237
259
        panel_applet_gconf_set_string (applet,
238
260
                                                                   KEY_TERMINAL,
239
261
                                                                   self->menu_bar_prefs->browser_prefs->terminal,
240
262
                                                                   &error);
241
 
        utils_check_gerror (&error);
 
263
        utils_gerror_ok (&error, TRUE);
 
264
 
242
265
        /* editor */
243
266
        panel_applet_gconf_set_string (applet,
244
267
                                                                   KEY_EDITOR,
245
268
                                                                   self->menu_bar_prefs->browser_prefs->editor,
246
269
                                                                   &error);
247
 
        utils_check_gerror (&error);
 
270
        utils_gerror_ok (&error, TRUE);
 
271
 
248
272
        /* the icon */
249
273
        panel_applet_gconf_set_string (applet,
250
274
                                                                   KEY_ICON_NAME,
251
275
                                                                   self->menu_bar_prefs->icon,
252
276
                                                                   &error);
253
 
        utils_check_gerror (&error);
 
277
        utils_gerror_ok (&error, TRUE);
 
278
 
254
279
        /* show the icon? */
255
280
        panel_applet_gconf_set_bool (applet,
256
281
                                                                 KEY_ICON_SHOW,
257
282
                                                                 self->menu_bar_prefs->show_icon,
258
283
                                                                 &error);
259
 
        utils_check_gerror (&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
 
260
293
        /* directory list */
261
294
        panel_applet_gconf_set_list (applet,
262
295
                                                                 KEY_DIR,
263
296
                                                                 GCONF_VALUE_STRING,
264
297
                                                                 self->menu_bar_prefs->dirs,
265
298
                                                                 &error);
266
 
        utils_check_gerror (&error);
 
299
        utils_gerror_ok (&error, TRUE);
 
300
 
267
301
        /* labels list */
268
302
        panel_applet_gconf_set_list (applet,
269
303
                                                                 KEY_LABELS,
270
304
                                                                 GCONF_VALUE_STRING,
271
305
                                                                 self->menu_bar_prefs->labels,
272
306
                                                                 &error);
273
 
        utils_check_gerror (&error);
274
 
        return;
 
307
        utils_gerror_ok (&error, TRUE);
275
308
}
276
309
/******************************************************************************/
277
310
static void
278
311
applet_preferences_dialog_response (GtkWidget* window, gint response, AppletPreferences* self) {
279
312
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
280
313
 
281
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
314
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
282
315
 
283
316
        /* figure out what button closed the dialog and take the appropriate action */
284
317
        switch (response) {
299
332
                        gtk_widget_hide (window);
300
333
                        break;
301
334
        }
302
 
        return;
303
335
}
304
336
/******************************************************************************/
305
337
static void
309
341
                                                                          AppletPreferences* self){
310
342
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
311
343
 
312
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
344
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
313
345
 
314
346
        GtkWidget                       *tree_view      = self->priv->tree_view;
315
347
        GtkTreeModel            *model;
320
352
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
321
353
 
322
354
        /* get an iterator to the model for the currently selected cell */
323
 
        gtk_tree_model_get_iter_from_string (model,
324
 
                                                                                 &iter,
325
 
                                                                                 path_string);
 
355
        gtk_tree_model_get_iter_from_string (model, &iter, path_string);
326
356
        /* update the model */
327
 
        gtk_list_store_set (GTK_LIST_STORE (model), &iter,
328
 
                                                LABEL_COLUMN, new_string,
329
 
                                                -1);
 
357
        gtk_list_store_set (GTK_LIST_STORE (model), &iter, LABEL_COLUMN, new_string, -1);
330
358
 
331
359
        /* the path associated with the selection */
332
 
        gtk_tree_model_get (model,
333
 
                                                &iter,
334
 
                                                PATH_COLUMN, &path,
335
 
                                                -1);
 
360
        gtk_tree_model_get (model, &iter, PATH_COLUMN, &path, -1);
336
361
 
337
362
        /* create the data structure with the event info to pass to panel_menu_bar */
338
363
        PrefsChangedSignalData* signal_data = g_new0 (PrefsChangedSignalData, 1);
355
380
 
356
381
        /* update the revert button*/
357
382
        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
358
 
        return;
359
383
}
360
384
/******************************************************************************/
361
385
static void
365
389
                                                                                AppletPreferences* self) {
366
390
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
367
391
 
368
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
392
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
369
393
 
370
394
        GtkTreeModel* model;
371
395
        GtkTreeIter       iter;
375
399
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
376
400
 
377
401
        /* get an iterator to the model for the currently selected cell */
378
 
        gtk_tree_model_get_iter (model,
379
 
                                                         &iter,
380
 
                                                         path);
 
402
        gtk_tree_model_get_iter (model, &iter, path);
381
403
        /* the "Path" value for the active cell */
382
 
        gtk_tree_model_get (model,
383
 
                                                &iter,
384
 
                                                PATH_COLUMN, &old_path,
385
 
                                                -1);
 
404
        gtk_tree_model_get (model, &iter, PATH_COLUMN, &old_path, -1);
386
405
 
387
406
        /* make a file chooser object to select the new path */
388
407
        file_chooser_dialog = gtk_file_chooser_dialog_new ("Select New Folder To Browse",
394
413
                                                                                                           GTK_RESPONSE_ACCEPT,
395
414
                                                                                                           NULL);
396
415
        /* Set the starting path as the old path */
397
 
        gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog),
398
 
                                                                   old_path);
 
416
        gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog), old_path);
399
417
        g_free (old_path);
400
418
        /* run the dialog */
401
419
        if (gtk_dialog_run (GTK_DIALOG (file_chooser_dialog)) == GTK_RESPONSE_ACCEPT) {
403
421
                gchar* new_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser_dialog));
404
422
                /* only update data if it's not the same as the old one */
405
423
                if (g_ascii_strcasecmp (old_path, new_path)) {
406
 
                        gtk_list_store_set (GTK_LIST_STORE (model), &iter,
407
 
                                                                PATH_COLUMN, new_path,
408
 
                                                                -1);
409
 
 
 
424
                        gtk_list_store_set (GTK_LIST_STORE (model), &iter, PATH_COLUMN, new_path, -1);
410
425
 
411
426
                        /* the label associated with the selection */
412
427
                        gchar* label = NULL;
413
 
                        gtk_tree_model_get (model,
414
 
                                                                &iter,
415
 
                                                                LABEL_COLUMN, &label,
416
 
                                                                -1);
 
428
                        gtk_tree_model_get (model, &iter, LABEL_COLUMN, &label, -1);
417
429
 
418
430
                        /* get the instance from the iterator */
419
431
                        gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
443
455
                }
444
456
        }
445
457
        gtk_widget_destroy (file_chooser_dialog);
446
 
 
447
 
        return;
448
458
}
449
459
/******************************************************************************/
450
460
static void
451
461
applet_preferences_on_add_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
452
462
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
453
463
 
454
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
464
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
455
465
 
456
466
        GtkTreeModel* model;
457
467
        GtkTreeIter       iter;
468
478
                                                                                                           NULL);
469
479
        /* Set the starting path */
470
480
        gchar* start_path = g_strdup_printf ("%s/*", g_get_home_dir ());
471
 
        gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog),
472
 
                                                                   start_path);
 
481
        gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_chooser_dialog), start_path);
473
482
        g_free (start_path);
474
483
 
475
484
        /* check the reply */
480
489
                /* get the view's model, add a row and set the values */
481
490
                model = gtk_tree_view_get_model (GTK_TREE_VIEW(tree_view));
482
491
                gtk_list_store_append (GTK_LIST_STORE(model), &iter);
483
 
                gtk_list_store_set (GTK_LIST_STORE(model), &iter,
484
 
                                                        LABEL_COLUMN, label,
485
 
                                                        PATH_COLUMN, dir,
 
492
                gtk_list_store_set (GTK_LIST_STORE(model),
 
493
                                                        &iter,
 
494
                                                        LABEL_COLUMN,
 
495
                                                        label,
 
496
                                                        PATH_COLUMN,
 
497
                                                        dir,
486
498
                                                        -1);
487
499
 
488
500
                /* create the data structure with the event info to pass to panel_menu_bar */
506
518
                /*gtk_widget_set_sensitive (revert_button, TRUE);*/
507
519
        }
508
520
        gtk_widget_destroy (file_chooser_dialog);
509
 
        return;
510
521
}
511
522
/******************************************************************************/
512
523
static void
513
524
applet_preferences_on_rem_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
514
525
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
515
526
 
516
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
527
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
517
528
 
518
529
        GtkTreeSelection        *selection;
519
530
        GtkTreeModel            *model;
558
569
                /* update the revert button*/
559
570
                /*gtk_widget_set_sensitive (revert_button, TRUE);*/
560
571
        }
561
 
 
562
 
        return;
563
572
}
564
573
/******************************************************************************/
565
574
static void
566
575
applet_preferences_on_down_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
567
576
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
568
577
 
569
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
578
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
570
579
 
571
580
        GtkTreeSelection        *selection = NULL;
572
581
        GtkTreeModel            *model = NULL;
586
595
                        /* get the instance from the iterator */
587
596
                        gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
588
597
 
589
 
                        gtk_list_store_swap (GTK_LIST_STORE (model),
590
 
                                                                 &iter,
591
 
                                                                 &iter_next);
 
598
                        gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter_next);
592
599
 
593
600
                        /* create the data structure with the event info to pass to panel_menu_bar */
594
601
                        PrefsChangedSignalData* signal_data = g_new0 (PrefsChangedSignalData, 1);
604
611
 
605
612
                        /* emit the signal so the panel menu bar updates itself */
606
613
                        g_signal_emit (G_OBJECT (self),
607
 
                                        applet_preferences_signals [PREFS_CHANGED],
608
 
                                        0,
609
 
                                        signal_data);
 
614
                                                   applet_preferences_signals [PREFS_CHANGED],
 
615
                                                   0,
 
616
                                                   signal_data);
610
617
 
611
618
                        /* update the revert button*/
612
619
                        /*gtk_widget_set_sensitive (revert_button, TRUE);*/
613
620
                }
614
621
        }
615
 
        return;
616
622
}
617
623
/******************************************************************************/
618
624
static void
619
625
applet_preferences_on_up_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
620
626
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
621
627
 
622
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
628
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
623
629
 
624
630
        GtkTreeSelection        *selection      = NULL;
625
631
        GtkTreeModel            *model          = NULL;
644
650
                        /* get the instance from the iterator */
645
651
                        gchar* instance = gtk_tree_model_get_string_from_iter (model, &iter);
646
652
 
647
 
                        gtk_list_store_swap (GTK_LIST_STORE (model),
648
 
                                                                 &iter,
649
 
                                                                 &iter_prev);
 
653
                        gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter_prev);
650
654
 
651
655
                        /* create the data structure with the event info to pass to panel_menu_bar */
652
656
                        PrefsChangedSignalData* signal_data = g_new0 (PrefsChangedSignalData, 1);
671
675
                }
672
676
                gtk_tree_path_free (path);
673
677
        }
674
 
        return;
675
678
}
676
679
/******************************************************************************/
677
680
static void
678
681
applet_preferences_create_list_view (AppletPreferences* self) {
679
682
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
680
683
 
681
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
684
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
682
685
 
683
686
        GtkTreeIter                     iter;
684
687
        GtkListStore            *store;
688
691
 
689
692
        /* Create a model.  We are using the store model for now, though we
690
693
        * could use any other GtkTreeModel */
691
 
        store = gtk_list_store_new (N_COLUMNS,
692
 
                                                            G_TYPE_STRING,
693
 
                                                            G_TYPE_STRING);
 
694
        store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
694
695
 
695
696
        /* fill the model with data */
696
697
        GSList* tmp_dir   = self->menu_bar_prefs->dirs;
697
698
        GSList* tmp_label = self->menu_bar_prefs->labels;
698
699
        while (tmp_label && tmp_dir) {
699
700
                gtk_list_store_append (store, &iter);
700
 
                gtk_list_store_set (store, &iter,
701
 
                                                        LABEL_COLUMN, (gchar *)tmp_label->data,
702
 
                                                        PATH_COLUMN, (gchar *)tmp_dir->data,
 
701
                gtk_list_store_set (store,
 
702
                                                        &iter,
 
703
                                                        LABEL_COLUMN,
 
704
                                                        (gchar *)tmp_label->data,
 
705
                                                        PATH_COLUMN,
 
706
                                                        (gchar *)tmp_dir->data,
703
707
                                                        -1);
704
708
                tmp_dir   = tmp_dir->next;
705
709
                tmp_label = tmp_label->next;
723
727
 
724
728
        /* Create a column, associating the "text" attribute of the
725
729
        * cell_renderer to the first column of the model */
726
 
        column = gtk_tree_view_column_new_with_attributes ("Label", renderer,
727
 
                                                                                                           "text", LABEL_COLUMN,
 
730
        column = gtk_tree_view_column_new_with_attributes ("Label",
 
731
                                                                                                           renderer,
 
732
                                                                                                           "text",
 
733
                                                                                                           LABEL_COLUMN,
728
734
                                                                                                           NULL);
729
735
        /* Add the column to the view. */
730
736
        gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->tree_view), column);
735
741
                                          "row-activated",
736
742
                                          G_CALLBACK (applet_preferences_path_cell_activated),
737
743
                                          self);
738
 
        column = gtk_tree_view_column_new_with_attributes ("Path", renderer,
739
 
                                                                                                           "text", PATH_COLUMN,
 
744
        column = gtk_tree_view_column_new_with_attributes ("Path",
 
745
                                                                                                           renderer,
 
746
                                                                                                           "text",
 
747
                                                                                                           PATH_COLUMN,
740
748
                                                                                                           NULL);
741
749
        gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->tree_view), column);
742
750
 
743
751
        /*put the selection in SINGLE mode */
744
752
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(self->priv->tree_view));
745
753
        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
746
 
 
747
 
        return;
748
754
}
749
755
/******************************************************************************/
750
756
void
751
757
applet_preferences_make_dialog (AppletPreferences* self) {
752
758
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
753
759
 
754
 
        g_return_if_fail (self == NULL || IS_APPLET_PREFERENCES (self));
 
760
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
755
761
 
756
762
        GtkWidget* window;
757
763
    GtkWidget* show_icon;
759
765
    GtkWidget* show_hidden;
760
766
    GtkWidget* terminal;
761
767
    GtkWidget* editor;
 
768
    GtkWidget* horizontal_text;
762
769
        MenuBarPrefs* mb_prefs = self->menu_bar_prefs;
763
770
 
764
771
        if (self->priv->window == NULL) {
805
812
                                                  G_CALLBACK (applet_preferences_on_show_hidden_pressed),
806
813
                                                  self);
807
814
 
 
815
                /***** horizontal text *****/
 
816
                horizontal_text = glade_xml_get_widget (xml, "horizontal_text_check");
 
817
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (horizontal_text),
 
818
                                                                          mb_prefs->horizontal_text);
 
819
                g_signal_connect (G_OBJECT (horizontal_text),
 
820
                                                  "toggled",
 
821
                                                  G_CALLBACK (applet_preferences_on_horizontal_text_pressed),
 
822
                                                  self);
 
823
 
808
824
                /***** icon *****/
809
825
                show_icon = glade_xml_get_widget (xml, "show_icon_check");
810
826
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_icon),
859
875
 
860
876
        gtk_widget_show_all (self->priv->window);
861
877
        gtk_window_present (GTK_WINDOW (self->priv->window));
862
 
 
863
 
        return;
864
878
}
865
879
/******************************************************************************/
866
880
static MenuBarPrefs*
867
881
applet_preferences_load_from_gconf (PanelApplet* applet) {
868
882
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
869
883
 
870
 
        g_return_val_if_fail (applet == NULL || PANEL_IS_APPLET (applet), NULL);
 
884
        g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
871
885
 
872
886
        GError* error = NULL;
873
887
 
878
892
         * instance. It also check to make sure the values were retrieved properly
879
893
         * AND that they are valid */
880
894
        panel_applet_add_preferences (applet, "/schemas/apps/file-browser-applet/prefs", &error);
881
 
        if (utils_check_gerror (&error)) return NULL;
 
895
        g_return_val_if_fail (utils_gerror_ok (&error, TRUE), NULL);
882
896
 
883
897
        /* show hidden files? */
884
 
        mb_prefs->browser_prefs->show_hidden = panel_applet_gconf_get_bool (applet,
885
 
                                                                                                                                         KEY_HIDDEN_SHOW,
886
 
                                                                                                                                         &error);
887
 
        if (utils_check_gerror (&error)) {
 
898
        mb_prefs->browser_prefs->show_hidden = panel_applet_gconf_get_bool (applet, KEY_HIDDEN_SHOW, &error);
 
899
        if (!utils_gerror_ok (&error, TRUE)) {
888
900
                mb_prefs->browser_prefs->show_hidden = DEFAULT_SHOW_HIDDEN;
889
 
                panel_applet_gconf_set_bool (applet,
890
 
                                                                         KEY_HIDDEN_SHOW,
891
 
                                                                         mb_prefs->browser_prefs->show_hidden,
892
 
                                                                         &error);
 
901
                panel_applet_gconf_set_bool (applet, KEY_HIDDEN_SHOW, mb_prefs->browser_prefs->show_hidden, &error);
 
902
                utils_gerror_ok (&error, TRUE);
893
903
        }
 
904
 
894
905
        /* terminal */
895
 
        mb_prefs->browser_prefs->terminal = panel_applet_gconf_get_string (applet,
896
 
                                                                                                                                        KEY_TERMINAL,
897
 
                                                                                                                                        &error);
898
 
        if (utils_check_gerror (&error) || mb_prefs->browser_prefs->terminal == NULL) {
 
906
        mb_prefs->browser_prefs->terminal = panel_applet_gconf_get_string (applet, KEY_TERMINAL, &error);
 
907
        if (!utils_gerror_ok (&error, TRUE) || mb_prefs->browser_prefs->terminal == NULL) {
899
908
                mb_prefs->browser_prefs->terminal = g_strdup (DEFAULT_TERMINAL);
900
 
                panel_applet_gconf_set_string (applet,
901
 
                                                                           KEY_TERMINAL,
902
 
                                                                           mb_prefs->browser_prefs->terminal,
903
 
                                                                           &error);
 
909
                panel_applet_gconf_set_string (applet, KEY_TERMINAL, mb_prefs->browser_prefs->terminal, &error);
 
910
                utils_gerror_ok (&error, TRUE);
904
911
        }
 
912
 
905
913
        /* editor */
906
 
        mb_prefs->browser_prefs->editor = panel_applet_gconf_get_string (applet,
907
 
                                                                                                                                         KEY_EDITOR,
908
 
                                                                                                                                         &error);
909
 
        if (utils_check_gerror (&error) || mb_prefs->browser_prefs->editor == NULL) {
 
914
        mb_prefs->browser_prefs->editor = panel_applet_gconf_get_string (applet, KEY_EDITOR, &error);
 
915
        if (!utils_gerror_ok (&error, TRUE) || mb_prefs->browser_prefs->editor == NULL) {
910
916
                mb_prefs->browser_prefs->editor = g_strdup (DEFAULT_EDITOR);
911
 
                panel_applet_gconf_set_string (applet,
912
 
                                                                           KEY_TERMINAL,
913
 
                                                                           mb_prefs->browser_prefs->editor,
914
 
                                                                           &error);
 
917
                panel_applet_gconf_set_string (applet, KEY_TERMINAL, mb_prefs->browser_prefs->editor, &error);
 
918
                utils_gerror_ok (&error, TRUE);
915
919
        }
916
920
 
917
921
        /* the icon */
918
 
        mb_prefs->icon = panel_applet_gconf_get_string (applet,
919
 
                                                                                                 KEY_ICON_NAME,
920
 
                                                                                                 &error);
921
 
        if (utils_check_gerror (&error) || mb_prefs->icon == NULL) {
 
922
        mb_prefs->icon = panel_applet_gconf_get_string (applet, KEY_ICON_NAME, &error);
 
923
        if (!utils_gerror_ok (&error, TRUE) || mb_prefs->icon == NULL) {
922
924
                mb_prefs->icon = g_strdup (DEFAULT_ICON);
923
 
                panel_applet_gconf_set_string (applet,
924
 
                                                                           KEY_ICON_NAME,
925
 
                                                                           mb_prefs->icon,
926
 
                                                                           &error);
 
925
                panel_applet_gconf_set_string (applet, KEY_ICON_NAME, mb_prefs->icon, &error);
 
926
                utils_gerror_ok (&error, TRUE);
927
927
        }
928
928
 
929
929
        /* show the icon? */
930
 
        mb_prefs->show_icon = panel_applet_gconf_get_bool (applet,
931
 
                                                                                                        KEY_ICON_SHOW,
932
 
                                                                                                        &error);
933
 
        if (utils_check_gerror (&error)) {
 
930
        mb_prefs->show_icon = panel_applet_gconf_get_bool (applet, KEY_ICON_SHOW, &error);
 
931
        if (!utils_gerror_ok (&error, TRUE)) {
934
932
                mb_prefs->show_icon = DEFAULT_SHOW_ICON;
935
 
                panel_applet_gconf_set_bool (applet,
936
 
                                                                         KEY_ICON_SHOW,
937
 
                                                                         mb_prefs->show_icon,
938
 
                                                                         &error);
939
 
        }
 
933
                panel_applet_gconf_set_bool (applet, KEY_ICON_SHOW, mb_prefs->show_icon, &error);
 
934
                utils_gerror_ok (&error, TRUE);
 
935
        }
 
936
 
 
937
        /* horizontal text ? */
 
938
        mb_prefs->horizontal_text = panel_applet_gconf_get_bool (applet, KEY_HORIZONTAL_TEXT, &error);
 
939
        if (!utils_gerror_ok (&error, TRUE)) {
 
940
                mb_prefs->horizontal_text = DEFAULT_HORIZONTAL_TEXT;
 
941
                panel_applet_gconf_set_bool (applet, KEY_HORIZONTAL_TEXT, mb_prefs->horizontal_text, &error);
 
942
                utils_gerror_ok (&error, TRUE);
 
943
        }
 
944
 
940
945
        /* directory list */
941
 
        GSList* dirs = panel_applet_gconf_get_list (applet,
942
 
                                                                                           KEY_DIR,
943
 
                                                                                           GCONF_VALUE_STRING,
944
 
                                                                                           &error);
945
 
        if (utils_check_gerror (&error) || dirs == NULL) {
 
946
        GSList* dirs = panel_applet_gconf_get_list (applet, KEY_DIR, GCONF_VALUE_STRING, &error);
 
947
        if (!utils_gerror_ok (&error, TRUE) || dirs == NULL) {
946
948
                dirs = g_slist_alloc ();
947
949
                dirs->data = g_strdup (DEFAULT_PATH);
948
950
                dirs->next = NULL;
949
 
                panel_applet_gconf_set_list (applet,
950
 
                                                                         KEY_DIR,
951
 
                                                                         GCONF_VALUE_STRING,
952
 
                                                                         dirs,
953
 
                                                                         &error);
 
951
                panel_applet_gconf_set_list (applet, KEY_DIR, GCONF_VALUE_STRING, dirs, &error);
 
952
                utils_gerror_ok (&error, TRUE);
954
953
        }
 
954
 
955
955
        /* labels list */
956
 
        GSList* labels = panel_applet_gconf_get_list (applet,
957
 
                                                                                             KEY_LABELS,
958
 
                                                                                             GCONF_VALUE_STRING,
959
 
                                                                                             &error);
960
 
        if (utils_check_gerror (&error) || labels == NULL) {
 
956
        GSList* labels = panel_applet_gconf_get_list (applet, KEY_LABELS, GCONF_VALUE_STRING, &error);
 
957
        if (!utils_gerror_ok (&error, TRUE) || labels == NULL) {
961
958
                labels = g_slist_alloc ();
962
959
                labels->data = g_strdup (DEFAULT_LABEL);
963
960
                labels->next = NULL;
964
 
                panel_applet_gconf_set_list (applet,
965
 
                                                                         KEY_LABELS,
966
 
                                                                         GCONF_VALUE_STRING,
967
 
                                                                         labels,
968
 
                                                                         &error);
 
961
                panel_applet_gconf_set_list (applet, KEY_LABELS, GCONF_VALUE_STRING, labels, &error);
 
962
                utils_gerror_ok (&error, TRUE);
969
963
        }
970
964
        mb_prefs->dirs   = dirs;
971
965
        mb_prefs->labels = labels;
977
971
applet_preferences_new (PanelApplet* applet) {
978
972
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
979
973
 
980
 
        g_return_val_if_fail (applet == NULL || PANEL_IS_APPLET (applet), NULL);
 
974
        g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
981
975
 
982
 
        AppletPreferences* self;
983
 
        self = g_object_newv (TYPE_APPLET_PREFERENCES, 0, NULL);
 
976
        AppletPreferences* self = g_object_newv (TYPE_APPLET_PREFERENCES, 0, NULL);
984
977
 
985
978
        self->menu_bar_prefs = applet_preferences_load_from_gconf (applet);
986
979
        self->priv->window = NULL;
987
980
        self->priv->applet = applet;
988
981
 
989
 
 
990
982
        return self;
991
983
}
992
984
/******************************************************************************/
1001
993
        applet_preferences_signals [PREFS_CHANGED] =
1002
994
                g_signal_new ("prefs_changed",
1003
995
                      G_TYPE_FROM_CLASS (klass),
1004
 
                                          G_SIGNAL_NO_HOOKS,
1005
 
                      /*G_STRUCT_OFFSET (AppletPreferencesClass, prefs_changed),*/
1006
 
                                          0,
 
996
                                          G_SIGNAL_RUN_LAST,
 
997
                      G_STRUCT_OFFSET (AppletPreferencesClass, prefs_changed),
1007
998
                                          NULL,
1008
999
                                          NULL,
1009
1000
                                      g_cclosure_marshal_VOID__INT,
1020
1011
applet_preferences_init (AppletPreferences* self) {
1021
1012
        if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
1022
1013
 
 
1014
        g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
1015
 
1023
1016
        self->priv = APPLET_PREFERENCES_GET_PRIVATE (self);
1024
1017
}
1025
1018
/******************************************************************************/
1026
1019
static void
1027
1020
applet_preferences_dispose (GObject* obj) {
1028
 
        AppletPreferences* self;
1029
 
        self = APPLET_PREFERENCES (obj);
 
1021
        AppletPreferences* self = APPLET_PREFERENCES (obj);
1030
1022
        (self->priv->window == NULL ? NULL : (self->priv->window = (g_object_unref (self->priv->window), NULL)));
1031
1023
        G_OBJECT_CLASS (applet_preferences_parent_class)->dispose (obj);
1032
1024
}