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

« back to all changes in this revision

Viewing changes to src/preferences.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2009-07-01 17:43:20 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090701174320-47ghs6125y9in9e3
Tags: 0.6.4-0ubuntu1
* New upstream release.
 - Added option to display thumbnails (if available) instead of icons.
 - Usability improvements.
 - Code cleanups.
* debian/control:
 - Bump standards version to 3.8.2, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
/******************************************************************************/
70
70
static void
71
71
applet_preferences_on_show_icon_pressed (GtkWidget* widget, AppletPreferences* self) {
72
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
73
 
 
74
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
72
    g_assert (IS_APPLET_PREFERENCES (self));
75
73
 
76
74
    /* get the new state from the widget and update the prefs structure */
77
75
    self->menu_bar_prefs->show_icon = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
94
92
}
95
93
/******************************************************************************/
96
94
static void
 
95
applet_preferences_on_show_thumbnail_toggled (GtkWidget* widget, AppletPreferences* self) {
 
96
    g_assert (IS_APPLET_PREFERENCES (self));
 
97
 
 
98
    self->menu_bar_prefs->browser_prefs->show_thumbnail =
 
99
        gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 
100
}
 
101
/******************************************************************************/
 
102
static void
97
103
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));
 
104
    g_assert (IS_APPLET_PREFERENCES (self));
101
105
 
102
106
    /* get the new state from the widget and update the prefs structure. No
103
107
     * need to let the menu bar or browser object know */
118
122
/******************************************************************************/
119
123
static void
120
124
applet_preferences_on_show_hidden_pressed (GtkWidget* widget, AppletPreferences* self) {
121
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
122
 
 
123
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
125
    g_assert (IS_APPLET_PREFERENCES (self));
124
126
 
125
127
    /* get the new state from the widget and update the prefs structure. No
126
128
     * need to let the menu bar or browser object know */
133
135
/******************************************************************************/
134
136
static void
135
137
applet_preferences_on_terminal_changed (GtkWidget* widget, AppletPreferences* self) {
136
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
137
 
 
138
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
138
    g_assert (IS_APPLET_PREFERENCES (self));
139
139
 
140
140
    gchar *tmp = NULL;
141
141
 
152
152
/******************************************************************************/
153
153
static void
154
154
applet_preferences_on_editor_changed (GtkWidget* widget, AppletPreferences* self) {
155
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
156
 
 
157
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
155
    g_assert (IS_APPLET_PREFERENCES (self));
158
156
 
159
157
    gchar *tmp = NULL;
160
158
 
171
169
/******************************************************************************/
172
170
static void
173
171
applet_preferences_on_icon_select (GtkWidget* button, AppletPreferences* self) {
174
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
175
 
 
176
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
172
    g_assert (IS_APPLET_PREFERENCES (self));
177
173
 
178
174
    GtkWidget *file_chooser_dialog;
179
175
    gchar *icon_path = DEFAULT_ICON_PATH;
241
237
/******************************************************************************/
242
238
static void
243
239
applet_preferences_save_to_gconf (AppletPreferences *self) {
244
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
245
 
 
246
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
240
    g_assert (IS_APPLET_PREFERENCES (self));
247
241
 
248
242
    PanelApplet *applet = self->priv->applet;
249
243
    GError* error = NULL;
255
249
                                 &error);
256
250
    utils_gerror_ok (&error, TRUE);
257
251
 
 
252
    /* show thumbnails? */
 
253
    panel_applet_gconf_set_bool (applet,
 
254
                                 KEY_SHOW_THUMBNAILS,
 
255
                                 self->menu_bar_prefs->browser_prefs->show_thumbnail,
 
256
                                 &error);
 
257
    utils_gerror_ok (&error, TRUE);
 
258
 
258
259
    /* terminal */
259
260
    panel_applet_gconf_set_string (applet,
260
261
                                   KEY_TERMINAL,
309
310
/******************************************************************************/
310
311
static void
311
312
applet_preferences_dialog_response (GtkWidget* window, gint response, AppletPreferences* self) {
312
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
313
 
 
314
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
313
    g_assert (IS_APPLET_PREFERENCES (self));
315
314
 
316
315
    /* figure out what button closed the dialog and take the appropriate action */
317
316
    switch (response) {
339
338
                                      gchar             *path_string,
340
339
                                      gchar             *new_string,
341
340
                                      AppletPreferences* self){
342
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
343
 
 
344
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
341
    g_assert (IS_APPLET_PREFERENCES (self));
345
342
 
346
343
    GtkWidget           *tree_view  = self->priv->tree_view;
347
344
    GtkTreeModel        *model;
387
384
                                        GtkTreePath       *path,
388
385
                                        GtkTreeViewColumn *col,
389
386
                                        AppletPreferences* self) {
390
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
391
 
 
392
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
387
    g_assert (IS_APPLET_PREFERENCES (self));
393
388
 
394
389
    GtkTreeModel* model;
395
390
    GtkTreeIter   iter;
459
454
/******************************************************************************/
460
455
static void
461
456
applet_preferences_on_add_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
462
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
463
 
 
464
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
457
    g_assert (IS_APPLET_PREFERENCES (self));
465
458
 
466
459
    GtkTreeModel* model;
467
460
    GtkTreeIter   iter;
522
515
/******************************************************************************/
523
516
static void
524
517
applet_preferences_on_rem_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
525
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
526
 
 
527
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
518
    g_assert (IS_APPLET_PREFERENCES (self));
528
519
 
529
520
    GtkTreeSelection    *selection;
530
521
    GtkTreeModel        *model;
573
564
/******************************************************************************/
574
565
static void
575
566
applet_preferences_on_down_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
576
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
577
 
 
578
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
567
    g_assert (IS_APPLET_PREFERENCES (self));
579
568
 
580
569
    GtkTreeSelection    *selection = NULL;
581
570
    GtkTreeModel        *model = NULL;
623
612
/******************************************************************************/
624
613
static void
625
614
applet_preferences_on_up_dir_clicked (GtkWidget* widget, AppletPreferences* self) {
626
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
627
 
 
628
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
615
    g_assert (IS_APPLET_PREFERENCES (self));
629
616
 
630
617
    GtkTreeSelection    *selection  = NULL;
631
618
    GtkTreeModel        *model      = NULL;
679
666
/******************************************************************************/
680
667
static void
681
668
applet_preferences_create_list_view (AppletPreferences* self) {
682
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
683
 
 
684
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
669
    g_assert (IS_APPLET_PREFERENCES (self));
685
670
 
686
671
    GtkTreeIter         iter;
687
672
    GtkListStore        *store;
755
740
/******************************************************************************/
756
741
void
757
742
applet_preferences_make_dialog (AppletPreferences* self) {
758
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
759
 
 
760
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
743
    g_assert (IS_APPLET_PREFERENCES (self));
761
744
 
762
745
    GError *error = NULL;
763
746
    GtkWidget* window;
764
747
    GtkWidget* show_icon;
765
748
    GtkWidget* icon_button;
766
749
    GtkWidget* show_hidden;
 
750
    GtkWidget* show_thumbnail;
767
751
    GtkWidget* terminal;
768
752
    GtkWidget* editor;
769
753
    GtkWidget* horizontal_text;
815
799
                          "toggled",
816
800
                          G_CALLBACK (applet_preferences_on_show_hidden_pressed),
817
801
                          self);
 
802
        
 
803
        /***** show thumbnail *****/
 
804
        show_thumbnail = GTK_WIDGET (gtk_builder_get_object (builder, "show_thumbnail"));
 
805
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_thumbnail),
 
806
                                      mb_prefs->browser_prefs->show_thumbnail);
 
807
        g_signal_connect (G_OBJECT (show_thumbnail),
 
808
                          "toggled",
 
809
                          G_CALLBACK (applet_preferences_on_show_thumbnail_toggled),
 
810
                          self);
818
811
 
819
812
        /***** horizontal text *****/
820
813
        horizontal_text = GTK_WIDGET (gtk_builder_get_object (builder, "horizontal_text_check"));
882
875
/******************************************************************************/
883
876
static MenuBarPrefs*
884
877
applet_preferences_load_from_gconf (PanelApplet* applet) {
885
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
886
 
 
887
 
    g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
 
878
    g_assert (PANEL_IS_APPLET (applet));
888
879
 
889
880
    GError* error = NULL;
890
881
 
895
886
     * instance. It also check to make sure the values were retrieved properly
896
887
     * AND that they are valid */
897
888
    panel_applet_add_preferences (applet, "/schemas/apps/file-browser-applet/prefs", &error);
898
 
    g_return_val_if_fail (utils_gerror_ok (&error, TRUE), NULL);
 
889
    g_assert (utils_gerror_ok (&error, TRUE));
899
890
 
900
891
    /* show hidden files? */
901
892
    mb_prefs->browser_prefs->show_hidden = panel_applet_gconf_get_bool (applet, KEY_HIDDEN_SHOW, &error);
904
895
        panel_applet_gconf_set_bool (applet, KEY_HIDDEN_SHOW, mb_prefs->browser_prefs->show_hidden, &error);
905
896
        utils_gerror_ok (&error, TRUE);
906
897
    }
907
 
 
 
898
    /* show hidden files? */
 
899
    mb_prefs->browser_prefs->show_thumbnail = panel_applet_gconf_get_bool (applet, KEY_SHOW_THUMBNAILS, &error);
 
900
    if (!utils_gerror_ok (&error, TRUE)) {
 
901
        mb_prefs->browser_prefs->show_thumbnail = DEFAULT_SHOW_THUMBNAILS;
 
902
        panel_applet_gconf_set_bool (applet, KEY_SHOW_THUMBNAILS, mb_prefs->browser_prefs->show_thumbnail, &error);
 
903
        utils_gerror_ok (&error, TRUE);
 
904
    }
908
905
    /* terminal */
909
906
    mb_prefs->browser_prefs->terminal = panel_applet_gconf_get_string (applet, KEY_TERMINAL, &error);
910
907
    if (!utils_gerror_ok (&error, TRUE) || mb_prefs->browser_prefs->terminal == NULL) {
912
909
        panel_applet_gconf_set_string (applet, KEY_TERMINAL, mb_prefs->browser_prefs->terminal, &error);
913
910
        utils_gerror_ok (&error, TRUE);
914
911
    }
915
 
 
916
912
    /* editor */
917
913
    mb_prefs->browser_prefs->editor = panel_applet_gconf_get_string (applet, KEY_EDITOR, &error);
918
914
    if (!utils_gerror_ok (&error, TRUE) || mb_prefs->browser_prefs->editor == NULL) {
972
968
/******************************************************************************/
973
969
AppletPreferences*
974
970
applet_preferences_new (PanelApplet* applet) {
975
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
976
 
 
977
 
    g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
 
971
    g_assert (PANEL_IS_APPLET (applet));
978
972
 
979
973
    AppletPreferences* self = g_object_newv (TYPE_APPLET_PREFERENCES, 0, NULL);
980
974
 
987
981
/******************************************************************************/
988
982
static void
989
983
applet_preferences_class_init (AppletPreferencesClass* klass) {
990
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
991
 
 
992
984
    applet_preferences_parent_class = g_type_class_peek_parent (klass);
993
985
    GObjectClass      *gobject_class   = (GObjectClass      *) klass;
994
986
    g_type_class_add_private (klass, sizeof (AppletPreferencesPrivate));
1013
1005
/******************************************************************************/
1014
1006
static void
1015
1007
applet_preferences_init (AppletPreferences* self) {
1016
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
1017
 
 
1018
 
    g_return_if_fail (IS_APPLET_PREFERENCES (self));
 
1008
    g_assert (IS_APPLET_PREFERENCES (self));
1019
1009
 
1020
1010
    self->priv = APPLET_PREFERENCES_GET_PRIVATE (self);
1021
1011
}
1029
1019
/******************************************************************************/
1030
1020
GType
1031
1021
applet_preferences_get_type (void) {
1032
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
1033
 
 
1034
1022
    static GType applet_preferences_type_id = 0;
1035
1023
    if (G_UNLIKELY (applet_preferences_type_id == 0)) {
1036
1024
        static const GTypeInfo g_define_type_info = { sizeof (AppletPreferencesClass),