[Xfce4-commits] <xfce4-session:master> Remember if the user wants to see tips or fortunes (Bug #2020).

Jérôme Guelfucci noreply at xfce.org
Mon Feb 8 23:24:03 CET 2010


Updating branch refs/heads/master
         to 5406303d90447aa3acc78b260d175ba482f33d2a (commit)
       from 41022b3180784b4169107ba3f45a54b5466b612b (commit)

commit 5406303d90447aa3acc78b260d175ba482f33d2a
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Mon Feb 8 23:15:55 2010 +0100

    Remember if the user wants to see tips or fortunes (Bug #2020).

 xfce4-tips/Makefile.am |    6 ++++--
 xfce4-tips/main.c      |   25 ++++++++++++++++++++++---
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/xfce4-tips/Makefile.am b/xfce4-tips/Makefile.am
index 074b930..bc22c19 100644
--- a/xfce4-tips/Makefile.am
+++ b/xfce4-tips/Makefile.am
@@ -16,10 +16,12 @@ xfce4_tips_SOURCES =							\
 	main.c
 
 xfce4_tips_CFLAGS =							\
-	@LIBXFCE4UI_CFLAGS@
+	@LIBXFCE4UI_CFLAGS@                                             \
+	@XFCONF_CFLAGS@
 
 xfce4_tips_LDADD =							\
-	@LIBXFCE4UI_LIBS@
+	@LIBXFCE4UI_LIBS@                                               \
+	@XFCONF_LIBS@
 
 desktopdir = $(sysconfdir)/xdg/autostart
 desktop_in_files = xfce4-tips-autostart.desktop.in
diff --git a/xfce4-tips/main.c b/xfce4-tips/main.c
index a2e6292..355d6bd 100644
--- a/xfce4-tips/main.c
+++ b/xfce4-tips/main.c
@@ -35,6 +35,7 @@
 #endif
 
 #include <libxfce4ui/libxfce4ui.h>
+#include <xfconf/xfconf.h>
 
 
 
@@ -149,12 +150,15 @@ autostart_toggled (GtkToggleButton *button)
 
 
 static void
-item_cb (GtkComboBox *combobox, gpointer data)
+item_cb (GtkComboBox *combobox, XfconfChannel *channel)
 {
   gint active_item = gtk_combo_box_get_active (combobox);
 
   if (active_item >=0)
-    option = active_item;
+    {
+      option = active_item;
+      xfconf_channel_set_bool (channel, "/fortunes", option == 1);
+    }
 
   gtk_window_set_title (GTK_WINDOW (dlg), _(titles[option]));
 }
@@ -247,6 +251,7 @@ next_cb(GtkWidget *widget, GtkTextBuffer *textbuf)
 int
 main (int argc, char **argv)
 {
+  GError    *error = NULL;
   GtkWidget *sw;
   GtkWidget *view;
   GtkWidget *vbox2;
@@ -255,11 +260,19 @@ main (int argc, char **argv)
   GtkWidget *next;
   GtkWidget *close_btn;
   GtkWidget *action_area;
+  XfconfChannel *channel;
 
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
 
   gtk_init (&argc, &argv);
 
+  if (G_UNLIKELY (!xfconf_init (&error))) {
+    xfce_dialog_show_error (NULL, error, _("Unable to contact settings server"));
+    g_error_free (error);
+  }
+
+  channel = xfconf_channel_get ("xfce4-tips");
+
   /* test for fortune */
   fortune_cmd = g_find_program_in_path ("fortune");
 
@@ -306,15 +319,19 @@ main (int argc, char **argv)
 
   if (fortune_cmd != NULL)
     {
+      gboolean fortunes = xfconf_channel_get_bool (channel, "/fortunes", FALSE);
+
       combobox = gtk_combo_box_new_text ();
       gtk_widget_show (combobox);
 
       gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), titles[OPTION_TIPS]);
       gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), titles[OPTION_FORTUNES]);
 
-      g_signal_connect (combobox, "changed", G_CALLBACK (item_cb), NULL);
+      g_signal_connect (combobox, "changed", G_CALLBACK (item_cb), channel);
       g_signal_connect (combobox, "changed", G_CALLBACK (next_cb), gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
 
+      gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), fortunes ? 1 : 0);
+
       gtk_box_pack_start (GTK_BOX (action_area), combobox, FALSE, FALSE, 0);
     }
 
@@ -345,5 +362,7 @@ main (int argc, char **argv)
       g_ptr_array_free (tips, TRUE);
     }
 
+  xfconf_shutdown ();
+
   return EXIT_SUCCESS;
 }



More information about the Xfce4-commits mailing list