[Goodies-commits] r5893 - in xfce4-notes-plugin/trunk: . panel-plugin

Mike Massonnet mmassonnet at xfce.org
Sat Nov 1 21:23:01 CET 2008


Author: mmassonnet
Date: 2008-11-01 20:23:00 +0000 (Sat, 01 Nov 2008)
New Revision: 5893

Modified:
   xfce4-notes-plugin/trunk/ChangeLog
   xfce4-notes-plugin/trunk/panel-plugin/defines.h
   xfce4-notes-plugin/trunk/panel-plugin/notes.c
   xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
   xfce4-notes-plugin/trunk/panel-plugin/settings-dialog.c
Log:
Update settings dialog

Modified: xfce4-notes-plugin/trunk/ChangeLog
===================================================================
--- xfce4-notes-plugin/trunk/ChangeLog	2008-11-01 17:17:49 UTC (rev 5892)
+++ xfce4-notes-plugin/trunk/ChangeLog	2008-11-01 20:23:00 UTC (rev 5893)
@@ -1,5 +1,19 @@
 2008-11-01  Mike Massonnet <mmassonnet at xfce.org>
 
+Update settings dialog
+	* panel-plugin/defines.h:
+	  - Define default settings.
+	* panel-plugin/{notes.c,panel-plugin.c}:
+	  - Use defines instead hard coded default values.
+	* panel-plugin/settings-dialog.c:
+	  - Set default values (if not yet set in xfconf) before binding the
+	  widgets to xfconf.
+	* panel-plugin/notes.c:
+	  - Fix a bug for previous commit, the tabs were shown back on note
+	  creation/deletion.
+
+2008-11-01  Mike Massonnet <mmassonnet at xfce.org>
+
 Hide tabs option
 	* panel-plugin/notes.[ch]:
 	  - New window option "Hide tabs".

Modified: xfce4-notes-plugin/trunk/panel-plugin/defines.h
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/defines.h	2008-11-01 17:17:49 UTC (rev 5892)
+++ xfce4-notes-plugin/trunk/panel-plugin/defines.h	2008-11-01 20:23:00 UTC (rev 5893)
@@ -23,5 +23,18 @@
 #define PLUGIN_WEBSITE                  "http://goodies.xfce.org/projects/panel-plugins/xfce4-notes-plugin"
 #define PLUGIN_XFCONF_CHANNEL           "xfce4-notes-plugin"
 
+/* Default settings */
+#define GENERAL_HIDE_FROM_TASKBAR       TRUE
+#define GENERAL_HIDE_ARROW_BUTTON       FALSE
+#define NEW_WINDOW_WIDTH                375
+#define NEW_WINDOW_HEIGHT               430
+#define NEW_WINDOW_ABOVE                FALSE
+#define NEW_WINDOW_STICKY               TRUE
+#define NEW_WINDOW_RESIZE_GRIP          FALSE
+#define NEW_WINDOW_TABS                 TRUE
+#define NEW_WINDOW_TRANSPARENCY         10
+#define NEW_WINDOW_USE_FONT             FALSE
+#define NEW_WINDOW_FONT_DESCR           "Sans 10"
+
 #endif
 

Modified: xfce4-notes-plugin/trunk/panel-plugin/notes.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/notes.c	2008-11-01 17:17:49 UTC (rev 5892)
+++ xfce4-notes-plugin/trunk/panel-plugin/notes.c	2008-11-01 20:23:00 UTC (rev 5893)
@@ -33,6 +33,7 @@
 #include <xfconf/xfconf.h>
 #endif
 
+#include "defines.h"
 #include "notes.h"
 
 #define PLUGIN_NAME "xfce4-notes-plugin"
@@ -186,15 +187,16 @@
 #ifdef HAVE_XFCONF
   gtk_window_set_skip_taskbar_hint (GTK_WINDOW (notes_window->window),
                                     xfconf_channel_get_bool (notes_plugin->xfconf_channel,
-                                                             "/general/hide_windows_from_taskbar", TRUE));
+                                                             "/general/hide_windows_from_taskbar",
+                                                             GENERAL_HIDE_FROM_TASKBAR));
   gtk_window_set_default_size (GTK_WINDOW (notes_window->window),
                                xfconf_channel_get_int (notes_plugin->xfconf_channel,
-                                                       "/new_window/width", 375),
+                                                       "/new_window/width", NEW_WINDOW_WIDTH),
                                xfconf_channel_get_int (notes_plugin->xfconf_channel,
-                                                       "/new_window/height", 430));
+                                                       "/new_window/height", NEW_WINDOW_HEIGHT));
 #else
   gtk_window_set_skip_taskbar_hint (GTK_WINDOW (notes_window->window), TRUE);
-  gtk_window_set_default_size (GTK_WINDOW (notes_window->window), 375, 430);
+  gtk_window_set_default_size (GTK_WINDOW (notes_window->window), NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);
 #endif
   gtk_window_set_decorated (GTK_WINDOW (notes_window->window), FALSE);
   gtk_window_set_icon_name (GTK_WINDOW (notes_window->window), "xfce4-notes-plugin");
@@ -497,15 +499,15 @@
   NotesNote            *notes_note;
   NotesPlugin          *notes_plugin = notes_window->notes_plugin;
   const gchar          *note_name;
-  gint                  w = 375;
-  gint                  h = 430;
-  gboolean              above = FALSE;
+  gint                  w = NEW_WINDOW_WIDTH;
+  gint                  h = NEW_WINDOW_HEIGHT;
+  gboolean              above = NEW_WINDOW_ABOVE;
   ShowOnStartup         show_on_startup = LAST_STATE;
-  gboolean              show_statusbar = FALSE;
-  gboolean              show_tabs = TRUE;
-  gboolean              sticky = TRUE;
+  gboolean              show_statusbar = NEW_WINDOW_RESIZE_GRIP;
+  gboolean              show_tabs = NEW_WINDOW_TABS;
+  gboolean              sticky = NEW_WINDOW_STICKY;
+  gint                  transparency = NEW_WINDOW_TRANSPARENCY;
   gboolean              visible = TRUE;
-  gint                  transparency = 10;
   gchar                *font_descr = NULL;
 
   if (G_LIKELY (NULL == notes_window->name))
@@ -547,8 +549,8 @@
   sticky =          xfconf_channel_get_bool (notes_plugin->xfconf_channel, "/new_window/sticky", sticky);
   visible =         xfconf_channel_get_bool (notes_plugin->xfconf_channel, "/new_window/visible", visible);
   transparency =    xfconf_channel_get_int  (notes_plugin->xfconf_channel, "/new_window/transparency", transparency);
-  if (xfconf_channel_get_bool (notes_plugin->xfconf_channel, "/new_window/use_font", FALSE))
-    font_descr =    xfconf_channel_get_string (notes_plugin->xfconf_channel, "/new_window/font_description", "Sans 10");
+  if (xfconf_channel_get_bool (notes_plugin->xfconf_channel, "/new_window/use_font", NEW_WINDOW_USE_FONT))
+    font_descr =    xfconf_channel_get_string (notes_plugin->xfconf_channel, "/new_window/font_description", NEW_WINDOW_FONT_DESCR);
 #endif
 
   rc = xfce_rc_simple_open (notes_window->notes_plugin->config_file, FALSE);
@@ -1647,7 +1649,7 @@
   gtk_notebook_set_current_page (GTK_NOTEBOOK (notes_window->notebook), id);
   TRACE ("Put to front note `%s'", notes_note->name);
   gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notes_window->notebook),
-                              (g_slist_length (notes_window->notes) > 1));
+                              (notes_window->show_tabs && g_slist_length (notes_window->notes) > 1));
 
   return notes_note;
 }
@@ -1675,7 +1677,7 @@
   id = g_slist_index (notes_window->notes, notes_note);
   gtk_notebook_remove_page (GTK_NOTEBOOK (notes_window->notebook), id);
   gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notes_window->notebook),
-                              ((g_slist_length (notes_window->notes) - 1) > 1));
+                              (notes_window->show_tabs && (g_slist_length (notes_window->notes) - 1) > 1));
 
   /* Remove file */
   note_path = g_build_path (G_DIR_SEPARATOR_S,

Modified: xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c	2008-11-01 17:17:49 UTC (rev 5892)
+++ xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c	2008-11-01 20:23:00 UTC (rev 5893)
@@ -121,7 +121,9 @@
 
   gtk_widget_show_all (GTK_WIDGET (panel_plugin));
 #ifdef HAVE_XFCONF
-  if (xfconf_channel_get_bool (notes_plugin->xfconf_channel, "/general/hide_arrow_button", FALSE))
+  if (xfconf_channel_get_bool (notes_plugin->xfconf_channel,
+                               "/general/hide_arrow_button",
+                               GENERAL_HIDE_ARROW_BUTTON))
     gtk_widget_hide (notes_plugin->btn_arrow);
 #endif
 

Modified: xfce4-notes-plugin/trunk/panel-plugin/settings-dialog.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/settings-dialog.c	2008-11-01 17:17:49 UTC (rev 5892)
+++ xfce4-notes-plugin/trunk/panel-plugin/settings-dialog.c	2008-11-01 20:23:00 UTC (rev 5893)
@@ -32,44 +32,62 @@
 
 static XfconfChannel *xfconf_channel = NULL;
 
-static void
-cb_channel_panel_plugin_toggled (GtkToggleButton *button,
-                                 const gchar *property)
-{
-  xfconf_channel_set_bool (xfconf_channel, property, gtk_toggle_button_get_active (button));
-}
-
-static void
-cb_channel_new_window_toggled (GtkToggleButton *button,
-                               const gchar *property)
-{
-  xfconf_channel_set_bool (xfconf_channel, property, gtk_toggle_button_get_active (button));
-}
-
-static void
-cb_channel_new_window_fontset (GtkFontButton *fontbutton,
-                               const gchar *property)
-{
-  xfconf_channel_set_string (xfconf_channel, property, gtk_font_button_get_font_name (fontbutton));
-}
-
-static void
-cb_channel_new_window_scale (GtkRange *range,
-                             const gchar *property)
-{
-  xfconf_channel_set_int (xfconf_channel, property, (gint32)gtk_range_get_value (range));
-}
-
 GtkWidget *
 prop_dialog_new (NotesPlugin *notes_plugin)
 {
-  GtkWidget *dialog, *frame, *box, *hbox, *button, *scale, *label;
-  GtkWidget *fontbutton, *size_box;
+  GtkWidget *dialog, *frame, *box, *hbox, *button, *spin, *label;
+  GtkWidget *size_box;
 
   /* Configuration channel */
   if (NULL == xfconf_channel)
     xfconf_channel = notes_plugin->xfconf_channel;
 
+  /* Set unset xfconf values */
+  if (!xfconf_channel_has_property (xfconf_channel, "/general/hide_windows_from_taskbar"))
+    xfconf_channel_set_bool (xfconf_channel,
+                             "/general/hide_windows_from_taskbar",
+                             GENERAL_HIDE_FROM_TASKBAR);
+  if (!xfconf_channel_has_property (xfconf_channel, "/general/hide_arrow_button"))
+    xfconf_channel_set_bool (xfconf_channel,
+                             "/general/hide_arrow_button",
+                             GENERAL_HIDE_ARROW_BUTTON);
+  if (!xfconf_channel_has_property (xfconf_channel, "/new_window/width"))
+    xfconf_channel_set_int (xfconf_channel,
+                            "/new_window/width",
+                            NEW_WINDOW_WIDTH);
+  if (!xfconf_channel_has_property (xfconf_channel, "/new_window/height"))
+    xfconf_channel_set_int (xfconf_channel,
+                            "/new_window/height",
+                            NEW_WINDOW_HEIGHT);
+  if (!xfconf_channel_has_property (xfconf_channel, "/new_window/always_on_top"))
+    xfconf_channel_set_bool (xfconf_channel,
+                             "/new_window/always_on_top",
+                             NEW_WINDOW_ABOVE);
+  if (!xfconf_channel_has_property (xfconf_channel, "/new_window/sticky"))
+    xfconf_channel_set_bool (xfconf_channel,
+                             "/new_window/sticky",
+                             NEW_WINDOW_STICKY);
+  if (!xfconf_channel_has_property (xfconf_channel, "/new_window/show_resize_grip"))
+    xfconf_channel_set_bool (xfconf_channel,
+                             "/new_window/show_resize_grip",
+                             NEW_WINDOW_RESIZE_GRIP);
+  if (!xfconf_channel_has_property (xfconf_channel, "/new_window/show_tabs"))
+    xfconf_channel_set_bool (xfconf_channel,
+                             "/new_window/show_tabs",
+                             NEW_WINDOW_TABS);
+  if (!xfconf_channel_has_property (xfconf_channel, "/new_window/transparency"))
+    xfconf_channel_set_int (xfconf_channel,
+                            "/new_window/transparency",
+                            NEW_WINDOW_TRANSPARENCY);
+  if (!xfconf_channel_has_property (xfconf_channel, "/new_window/use_font"))
+    xfconf_channel_set_bool (xfconf_channel,
+                             "/new_window/use_font",
+                             NEW_WINDOW_USE_FONT);
+  if (!xfconf_channel_has_property (xfconf_channel, "/new_window/font_description"))
+    xfconf_channel_set_string (xfconf_channel,
+                               "/new_window/font_description",
+                               NEW_WINDOW_FONT_DESCR);
+
   /* Dialog */
   dialog =
     xfce_titled_dialog_new_with_buttons (_("Xfce 4 Notes Plugin"),
@@ -92,17 +110,15 @@
 
   /* Hide from taskbar */
   button = gtk_check_button_new_with_label (_("Hide windows from taskbar"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-                                xfconf_channel_get_bool (xfconf_channel, "/general/hide_windows_from_taskbar", FALSE));
+  xfconf_g_property_bind (xfconf_channel, "/general/hide_windows_from_taskbar",
+                          G_TYPE_BOOLEAN, G_OBJECT (button), "active");
   gtk_container_add (GTK_CONTAINER (box), button);
-  g_signal_connect (button, "toggled", G_CALLBACK (cb_channel_panel_plugin_toggled), "/general/hide_windows_from_taskbar");
 
   /* Hide arrow button */
   button = gtk_check_button_new_with_label (_("Hide arrow button"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-                                xfconf_channel_get_bool (xfconf_channel, "/general/hide_arrow_button", FALSE));
+  xfconf_g_property_bind (xfconf_channel, "/general/hide_arrow_button",
+                          G_TYPE_BOOLEAN, G_OBJECT (button), "active");
   gtk_container_add (GTK_CONTAINER (box), button);
-  g_signal_connect (button, "toggled", G_CALLBACK (cb_channel_panel_plugin_toggled), "/general/hide_arrow_button");
 
   /* === New window settings === */
   box = gtk_vbox_new (TRUE, BORDER);
@@ -112,40 +128,35 @@
 
   /* Always on top */
   button = gtk_check_button_new_with_label (_("Always on top"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-                                xfconf_channel_get_bool (xfconf_channel, "/new_window/always_on_top", FALSE));
+  xfconf_g_property_bind (xfconf_channel, "/new_window/always_on_top",
+                          G_TYPE_BOOLEAN, G_OBJECT (button), "active");
   gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
-  g_signal_connect (button, "toggled", G_CALLBACK (cb_channel_new_window_toggled), "/new_window/always_on_top");
 
   /* Sticky window */
   button = gtk_check_button_new_with_label (_("Sticky window"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-                                xfconf_channel_get_bool (xfconf_channel, "/new_window/sticky", TRUE));
+  xfconf_g_property_bind (xfconf_channel, "/new_window/sticky",
+                          G_TYPE_BOOLEAN, G_OBJECT (button), "active");
   gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
-  g_signal_connect (button, "toggled", G_CALLBACK (cb_channel_new_window_toggled), "/new_window/sticky");
 
   /* Resize grip */
   button = gtk_check_button_new_with_label (_("Resize grip"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-                                xfconf_channel_get_bool (xfconf_channel, "/new_window/resize_grip", FALSE));
+  xfconf_g_property_bind (xfconf_channel, "/new_window/show_resize_grip",
+                          G_TYPE_BOOLEAN, G_OBJECT (button), "active");
   gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
-  g_signal_connect (button, "toggled", G_CALLBACK (cb_channel_new_window_toggled), "/new_window/resize_grip");
 
   /* Font */
   hbox = gtk_hbox_new (FALSE, BORDER);
   gtk_box_pack_start (GTK_BOX (box), hbox, TRUE, FALSE, 0);
 
   button = gtk_check_button_new_with_label (_("Font"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-                                xfconf_channel_get_bool (xfconf_channel, "/new_window/use_font", FALSE));
+  xfconf_g_property_bind (xfconf_channel, "/new_window/use_font",
+                          G_TYPE_BOOLEAN, G_OBJECT (button), "active");
   gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-  g_signal_connect (button, "toggled", G_CALLBACK (cb_channel_new_window_toggled), "/new_window/use_font");
 
-  gchar *description = xfconf_channel_get_string (xfconf_channel, "/new_window/font_description", "Sans 10");
-  fontbutton = gtk_font_button_new_with_font (description);
-  g_free (description);
-  gtk_box_pack_start (GTK_BOX (hbox), fontbutton, TRUE, TRUE, 0);
-  g_signal_connect (fontbutton, "font-set", G_CALLBACK (cb_channel_new_window_fontset), "/new_window/font_description");
+  button = gtk_font_button_new ();
+  xfconf_g_property_bind (xfconf_channel, "/new_window/font_description",
+                          G_TYPE_STRING, G_OBJECT (button), "font-name");
+  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
   /* Size */
   hbox = gtk_hbox_new (FALSE, BORDER);
@@ -157,22 +168,18 @@
   size_box = gtk_hbox_new (FALSE, 0);
   gtk_box_pack_start (GTK_BOX (hbox), size_box, TRUE, TRUE, 0);
 
-  scale = gtk_hscale_new_with_range (20, 600, 10);
-  gtk_range_set_value (GTK_RANGE (scale),
-                       (gdouble)xfconf_channel_get_int (xfconf_channel, "/new_window/width", 375));
-  gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT);
-  gtk_box_pack_start (GTK_BOX (size_box), scale, TRUE, TRUE, 0);
-  g_signal_connect (scale, "value-changed", G_CALLBACK (cb_channel_new_window_scale), "/new_window/width");
+  spin = gtk_spin_button_new_with_range (20.0, 600.0, 10.0);
+  xfconf_g_property_bind (xfconf_channel, "/new_window/width",
+                          G_TYPE_INT, G_OBJECT (spin), "value");
+  gtk_box_pack_start (GTK_BOX (size_box), spin, TRUE, TRUE, 0);
 
   label = gtk_label_new ("×");
-  gtk_box_pack_start (GTK_BOX (size_box), label, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (size_box), label, FALSE, FALSE, BORDER);
 
-  scale = gtk_hscale_new_with_range (20, 600, 10);
-  gtk_range_set_value (GTK_RANGE (scale),
-                       (gdouble)xfconf_channel_get_int (xfconf_channel, "/new_window/height", 430));
-  gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_LEFT);
-  gtk_box_pack_start (GTK_BOX (size_box), scale, TRUE, TRUE, 0);
-  g_signal_connect (scale, "value-changed", G_CALLBACK (cb_channel_new_window_scale), "/new_window/height");
+  spin = gtk_spin_button_new_with_range (20.0, 600.0, 10.0);
+  xfconf_g_property_bind (xfconf_channel, "/new_window/height",
+                          G_TYPE_INT, G_OBJECT (spin), "value");
+  gtk_box_pack_start (GTK_BOX (size_box), spin, TRUE, TRUE, 0);
 
   /* === Ending === */
   gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);




More information about the Goodies-commits mailing list