[Goodies-commits] r3305 - in xfce4-fsguard-plugin/trunk: . panel-plugin

Mike Massonnet mmassonnet at xfce.org
Fri Oct 5 04:29:54 CEST 2007


Author: mmassonnet
Date: 2007-10-05 02:29:54 +0000 (Fri, 05 Oct 2007)
New Revision: 3305

Modified:
   xfce4-fsguard-plugin/trunk/TODO
   xfce4-fsguard-plugin/trunk/panel-plugin/fsguard.c
Log:
	* panel-plugin/fsguard.c(fsguard_refresh_button): New function.
	  Shows the panel button if no other option is left...
	* panel-plugin/fsguard.c(fsguard_check3_changed): New function.
	  Sets the visibility of the panel button and refresh its state
	  on hide to not end in a void.
	* panel-plugin/fsguard.c(fsguard_refresh_name),
	  panel-plugin/fsguard.c(fsguard_check1_changed),
	  panel-plugin/fsguard.c(fsguard_check2_changed): Refresh the
	  panel button visibility.
	* panel-plugin/fsguard.c(fsguard_dialog_response): Add an option
	  to hide the panel button.
	* panel-plugin/fsguard.c(fsguard_read_config),
	  panel-plugin/fsguard.c(fsguard_save_config): Save the state of
	  the panel button visibility.
	* panel-plugin/fsguard.c(fsguard_new): Set the initial
	  panel button visibility.


Modified: xfce4-fsguard-plugin/trunk/TODO
===================================================================
--- xfce4-fsguard-plugin/trunk/TODO	2007-10-05 00:49:10 UTC (rev 3304)
+++ xfce4-fsguard-plugin/trunk/TODO	2007-10-05 02:29:54 UTC (rev 3305)
@@ -1,2 +1 @@
-? Possibility to hide the icon so it fits the same gui as netload,
-  systemload, ...
+- Color the progres bar depending on the limit state

Modified: xfce4-fsguard-plugin/trunk/panel-plugin/fsguard.c
===================================================================
--- xfce4-fsguard-plugin/trunk/panel-plugin/fsguard.c	2007-10-05 00:49:10 UTC (rev 3304)
+++ xfce4-fsguard-plugin/trunk/panel-plugin/fsguard.c	2007-10-05 02:29:54 UTC (rev 3305)
@@ -72,6 +72,7 @@
     guint               limit_urgent;
     gboolean            show_size;
     gboolean            show_progress_bar;
+    gboolean            hide_button;
     gchar              *name;
     gchar              *path;
     gchar              *filemanager;
@@ -85,6 +86,7 @@
     GtkWidget          *lab_size;
     GtkWidget          *pb_box;
     GtkWidget          *progress_bar;
+    GtkWidget          *cb_hide_button;
 } FsGuard;
 
 static GtkTooltips *tooltips = NULL;
@@ -93,14 +95,24 @@
 
 // all functions {{{
 
+static inline void
+fsguard_refresh_button (FsGuard *fsguard)
+{
+    if (GTK_IS_WIDGET (fsguard->cb_hide_button)
+        && fsguard->hide_button == TRUE && *(fsguard->name) == '\0'
+        && !fsguard->show_size && !fsguard->show_progress_bar)
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fsguard->cb_hide_button), FALSE);
+}
+
 static void
 fsguard_refresh_name (FsGuard *fsguard)
 {
-    if (fsguard->name != NULL && (strlen (fsguard->name) > 0)) {
+    if (*(fsguard->name) != '\0') {
         gtk_label_set_text (GTK_LABEL(fsguard->lab_name), fsguard->name);
         gtk_widget_show (fsguard->lab_name);
     } else {
         gtk_widget_hide (fsguard->lab_name);
+        fsguard_refresh_button (fsguard);
     }
 }
 
@@ -238,6 +250,7 @@
     DBG ("Lookup rc file `%s'", file);
     rc = xfce_rc_simple_open (file, FALSE);
     g_free (file);
+    g_return_if_fail (rc);
 
     fsguard->seen               = FALSE;
     fsguard->name               = g_strdup (xfce_rc_read_entry (rc, "label", ""));
@@ -245,6 +258,7 @@
     fsguard->filemanager        = g_strdup (xfce_rc_read_entry (rc, "filemanager", "Thunar"));
     fsguard->show_size          = xfce_rc_read_bool_entry (rc, "lab_size_visible", TRUE);
     fsguard->show_progress_bar  = xfce_rc_read_bool_entry (rc, "progress_bar_visible", TRUE);
+    fsguard->hide_button        = xfce_rc_read_bool_entry (rc, "hide_button", FALSE);
     fsguard->limit_warning      = xfce_rc_read_int_entry (rc, "yellow", 1500);
     fsguard->limit_urgent       = xfce_rc_read_int_entry (rc, "red", 300);
 
@@ -257,19 +271,16 @@
     char               *file;
     XfceRc             *rc;
 
-    if (!(file = xfce_panel_plugin_save_location (plugin, TRUE)))
-        return;
-    
+    file = xfce_panel_plugin_save_location (plugin, TRUE);
     rc = xfce_rc_simple_open (file, FALSE);
     g_free (file);
+    g_return_if_fail (rc);
 
-    if (!rc)
-        return;
-    
     xfce_rc_write_int_entry (rc, "yellow", fsguard->limit_warning);
     xfce_rc_write_int_entry (rc, "red", fsguard->limit_urgent);
     xfce_rc_write_bool_entry (rc, "lab_size_visible", fsguard->show_size);
     xfce_rc_write_bool_entry (rc, "progress_bar_visible", fsguard->show_progress_bar);
+    xfce_rc_write_bool_entry (rc, "hide_button", fsguard->hide_button);
     xfce_rc_write_entry (rc, "label", fsguard->name);
     xfce_rc_write_entry (rc, "mnt", fsguard->path);
     xfce_rc_write_entry (rc, "filemanager", fsguard->filemanager);
@@ -295,7 +306,7 @@
                       GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
                       FALSE, 2);
 
-    fsguard->lab_name = gtk_label_new (fsguard->name);
+    fsguard->lab_name = gtk_label_new (NULL);
     fsguard->lab_size = gtk_label_new (NULL);
     fsguard->lab_box = gtk_vbox_new (FALSE, 0);
 
@@ -337,6 +348,8 @@
         gtk_widget_hide (fsguard->lab_size);
     if (fsguard->show_progress_bar != TRUE)
         gtk_widget_hide (fsguard->pb_box);
+    if (fsguard->hide_button != FALSE)
+        gtk_widget_hide (fsguard->btn_panel);
 
     return fsguard;
 }
@@ -431,8 +444,10 @@
     fsguard->show_size = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget));
     if (fsguard->show_size)
         gtk_widget_show (fsguard->lab_size);
-    else
+    else {
         gtk_widget_hide (fsguard->lab_size);
+        fsguard_refresh_button (fsguard);
+    }
 }
 
 static void
@@ -441,11 +456,26 @@
     fsguard->show_progress_bar = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget));
     if (fsguard->show_progress_bar)
         gtk_widget_show (fsguard->pb_box);
-    else
+    else {
         gtk_widget_hide (fsguard->pb_box);
+        fsguard_refresh_button (fsguard);
+    }
 }
 
 static void
+fsguard_check3_changed (GtkWidget *widget, FsGuard *fsguard)
+{
+    fsguard->hide_button = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget));
+
+    if (fsguard->hide_button == FALSE)
+        gtk_widget_show (fsguard->btn_panel);
+    else {
+        gtk_widget_hide (fsguard->btn_panel);
+        fsguard_refresh_button (fsguard);
+    }
+}
+
+static void
 fsguard_dialog_response (GtkWidget *dlg, int response, FsGuard *fsguard)
 {
     gtk_widget_destroy (dlg);
@@ -458,7 +488,7 @@
 {
     GtkWidget *dlg;
     GtkWidget *hbox, *vbox1, *vbox2, *spin1, *spin2;
-    GtkWidget *lab1, *lab2, *lab3, *lab4, *lab5, *lab6, *lab7;
+    GtkWidget *lab1, *lab2, *lab3, *lab4, *lab5, *lab6, *lab7, *lab8;
     GtkWidget *ent1, *ent2, *ent3;
     GtkWidget *check1, *check2;
     gchar *text[] = {
@@ -469,6 +499,7 @@
 	     N_("File manager"),
 	     N_("Display size"),
 	     N_("Display progress bar"),
+	     N_("Hide button"),
     };
     xfce_panel_plugin_block_menu (plugin);
     
@@ -502,6 +533,7 @@
     lab5 = gtk_label_new (_(text[4]));
     lab6 = gtk_label_new (NULL);
     lab7 = gtk_label_new (NULL);
+    lab8 = gtk_label_new (NULL);
 
     ent1 = gtk_entry_new ();
     gtk_entry_set_max_length (GTK_ENTRY(ent1), 16);
@@ -515,16 +547,20 @@
     gtk_entry_set_max_length (GTK_ENTRY(ent3), 16);
     gtk_entry_set_text (GTK_ENTRY(ent3), fsguard->filemanager);
 
+    spin1 = gtk_spin_button_new_with_range (0, G_MAXUINT, 100);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin1), fsguard->limit_warning);
+
+    spin2 = gtk_spin_button_new_with_range (0, G_MAXUINT, 100);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin2), fsguard->limit_urgent);
+
     check1 = gtk_check_button_new_with_label (_(text[5]));
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check1), fsguard->show_size);
  
     check2 = gtk_check_button_new_with_label (_(text[6]));
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check2), fsguard->show_progress_bar);
 
-    spin1 = gtk_spin_button_new_with_range (0, G_MAXUINT, 100);
-    gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin1), fsguard->limit_warning);
-    spin2 = gtk_spin_button_new_with_range (0, G_MAXUINT, 100);
-    gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin2), fsguard->limit_urgent);
+    fsguard->cb_hide_button = gtk_check_button_new_with_label (_(text[7]));
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(fsguard->cb_hide_button), fsguard->hide_button);
 
     g_signal_connect (ent1, "changed", G_CALLBACK(fsguard_ent1_changed), fsguard);
     g_signal_connect (ent2, "changed", G_CALLBACK(fsguard_ent2_changed), fsguard);
@@ -533,6 +569,7 @@
     g_signal_connect (spin2, "value-changed", G_CALLBACK(fsguard_spin2_changed), fsguard);
     g_signal_connect (check1, "toggled", G_CALLBACK(fsguard_check1_changed), fsguard);
     g_signal_connect (check2, "toggled", G_CALLBACK(fsguard_check2_changed), fsguard);
+    g_signal_connect (fsguard->cb_hide_button, "toggled", G_CALLBACK(fsguard_check3_changed), fsguard);
 
     gtk_box_pack_start (GTK_BOX(vbox1), lab1, TRUE, FALSE, 1);
     gtk_box_pack_start (GTK_BOX(vbox1), lab2, TRUE, FALSE, 1);
@@ -541,6 +578,7 @@
     gtk_box_pack_start (GTK_BOX(vbox1), lab4, TRUE, FALSE, 1);
     gtk_box_pack_start (GTK_BOX(vbox1), lab6, TRUE, FALSE, 1);
     gtk_box_pack_start (GTK_BOX(vbox1), lab7, TRUE, FALSE, 1);
+    gtk_box_pack_start (GTK_BOX(vbox1), lab8, TRUE, FALSE, 1);
 
     gtk_box_pack_start (GTK_BOX(vbox2), ent1, TRUE, FALSE, 1);
     gtk_box_pack_start (GTK_BOX(vbox2), ent2, TRUE, FALSE, 1);
@@ -549,6 +587,7 @@
     gtk_box_pack_start (GTK_BOX(vbox2), spin2, TRUE, FALSE, 1);
     gtk_box_pack_start (GTK_BOX(vbox2), check1, TRUE, FALSE, 1);
     gtk_box_pack_start (GTK_BOX(vbox2), check2, TRUE, FALSE, 1);
+    gtk_box_pack_start (GTK_BOX(vbox2), fsguard->cb_hide_button, TRUE, FALSE, 1);
 
     gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox,
                         TRUE, TRUE, 0);




More information about the Goodies-commits mailing list