[Goodies-commits] r3752 - in xfce4-timer-plugin/trunk: . src

Kemal Eroglu ilgar at xfce.org
Tue Dec 25 22:36:48 CET 2007


Author: ilgar
Date: 2007-12-25 21:36:47 +0000 (Tue, 25 Dec 2007)
New Revision: 3752

Modified:
   xfce4-timer-plugin/trunk/ChangeLog
   xfce4-timer-plugin/trunk/INSTALL
   xfce4-timer-plugin/trunk/configure.in.in
   xfce4-timer-plugin/trunk/src/xfcetimer.c
   xfce4-timer-plugin/trunk/src/xfcetimer.h
Log:
Version 0.6, fix compiler warnings, save errors. New: Save settings permanently.

Modified: xfce4-timer-plugin/trunk/ChangeLog
===================================================================
--- xfce4-timer-plugin/trunk/ChangeLog	2007-12-24 22:31:07 UTC (rev 3751)
+++ xfce4-timer-plugin/trunk/ChangeLog	2007-12-25 21:36:47 UTC (rev 3752)
@@ -1,3 +1,9 @@
+25/12/2007 Kemal Ilgar Eroglu <ilgar_eroglu at yahoo.com>
+	* Version 0.6.
+	* Fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=456316 .
+	* Use XfceTimer.rc file to permanently remember settings.
+	* Add a workaround for settings not saving correctly, see XFCE bug #2647. 
+
 19/01/2007 Nick Schermer <nick at xfce.org>
 	* Add LINGUAS support for translators.
 	* Fix the plugin name in the configure file.

Modified: xfce4-timer-plugin/trunk/INSTALL
===================================================================
--- xfce4-timer-plugin/trunk/INSTALL	2007-12-24 22:31:07 UTC (rev 3751)
+++ xfce4-timer-plugin/trunk/INSTALL	2007-12-25 21:36:47 UTC (rev 3752)
@@ -102,16 +102,16 @@
 Installation Names
 ==================
 
-By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc.  You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PREFIX'.
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
 
    You can specify separate installation prefixes for
 architecture-specific files and architecture-independent files.  If you
-give `configure' the option `--exec-prefix=PREFIX', the package will
-use PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
 
    In addition, if you use an unusual directory layout you can give
 options like `--bindir=DIR' to specify different values for particular
@@ -159,7 +159,7 @@
 need to know the machine type.
 
    If you are _building_ compiler tools for cross-compiling, you should
-use the `--target=TYPE' option to select the type of system they will
+use the option `--target=TYPE' to select the type of system they will
 produce code for.
 
    If you want to _use_ a cross compiler, that generates code for a

Modified: xfce4-timer-plugin/trunk/configure.in.in
===================================================================
--- xfce4-timer-plugin/trunk/configure.in.in	2007-12-24 22:31:07 UTC (rev 3751)
+++ xfce4-timer-plugin/trunk/configure.in.in	2007-12-25 21:36:47 UTC (rev 3752)
@@ -4,10 +4,10 @@
 dnl 	Please disable it in the Anjuta project configuration
 
 dnl version info
-m4_define([xfce4_timer_version], [0.5.1])
+m4_define([xfce4_timer_version], [0.6])
 
 dnl init autoconf
-AC_INIT([xfce4-timer-plugin], [xfce4_timer_version], [kieroglu at math.washington.edu])
+AC_INIT([xfce4-timer-plugin], [xfce4_timer_version], [ilgar_eroglu at yahoo.com])
 AC_PREREQ([2.50])
 
 dnl init automake

Modified: xfce4-timer-plugin/trunk/src/xfcetimer.c
===================================================================
--- xfce4-timer-plugin/trunk/src/xfcetimer.c	2007-12-24 22:31:07 UTC (rev 3751)
+++ xfce4-timer-plugin/trunk/src/xfcetimer.c	2007-12-25 21:36:47 UTC (rev 3752)
@@ -35,10 +35,8 @@
 #include <libxfce4util/libxfce4util.h>
 #include <libxfcegui4/xfce_iconbutton.h>
 #include <libxfce4panel/xfce-panel-plugin.h>
+#include <libxfcegui4/dialogs.h>
 
-//#include <panel/xfce.h>
-//#include <panel/plugins.h>
-
 #include "xfcetimer.h"
 
 static gboolean create_plugin_control (XfcePanelPlugin *plugin);
@@ -862,81 +860,85 @@
   gboolean is_cd;
   GtkTreeIter iter;
   XfceRc *rc;
-  char *file;
-  
-  if ((file = xfce_panel_plugin_lookup_rc_file (pd->base)) != NULL)
-  {
-      rc = xfce_rc_simple_open (file, TRUE);
-      g_free (file);
 
-      if (rc != NULL)
-      {
+  //if ((file=xfce_panel_plugin_lookup_rc_file (pd->base)) != NULL) {
 
 
-	  groupnum=0;
-	  g_sprintf(groupname,"G0");
+	  if (g_file_test(pd->configfile,G_FILE_TEST_EXISTS)) {  
+	  	
+		  rc = xfce_rc_simple_open (pd->configfile, TRUE);
 
+		  
+		  if (rc != NULL)
+		  {
 
-	  while(xfce_rc_has_group(rc,groupname)){
 
-             xfce_rc_set_group(rc,groupname);
+		  groupnum=0;
+		  g_sprintf(groupname,"G0");
 
-	     /*g_fprintf(stderr,"\nLoading item %d\n",groupnum);*/
-	     gtk_list_store_append(pd->list,&iter);
 
-	     timerstring=(gchar *)xfce_rc_read_entry(rc,"timername","No name");
-	     gtk_list_store_set(pd->list,&iter,0,groupnum,1,timerstring,-1);
-	     /* g_free(timerstring); */ /* Entries read are not freed ! */
+		  while(xfce_rc_has_group(rc,groupname)){
 
-	     timerstring=(gchar *)xfce_rc_read_entry(rc,"timercommand","");
-	     gtk_list_store_set(pd->list,&iter,3,timerstring,-1);
-	     /*g_fprintf(stderr,"\nLoaded timer command ==> %s... with length %d", 
-						timerstring,strlen(timerstring));*/
-	     /*g_free(timerstring);*/
+				 xfce_rc_set_group(rc,groupname);
 
-	     timerstring=(gchar *)xfce_rc_read_entry(rc,"timerinfo","");
-	     gtk_list_store_set(pd->list,&iter,2,timerstring,-1);
+			 /*g_fprintf(stderr,"\nLoading item %d\n",groupnum);*/
+			 gtk_list_store_append(pd->list,&iter);
 
-	     /*g_free(timerstring);*/
+			 timerstring=(gchar *)xfce_rc_read_entry(rc,"timername","No name");
+			 gtk_list_store_set(pd->list,&iter,0,groupnum,1,timerstring,-1);
+			 /* g_free(timerstring); */ /* Entries read are not freed ! */
 
-	     is_cd=xfce_rc_read_bool_entry(rc,"is_countdown",TRUE);
-	     time=xfce_rc_read_int_entry(rc,"time",0);
+			 timerstring=(gchar *)xfce_rc_read_entry(rc,"timercommand","");
+			 gtk_list_store_set(pd->list,&iter,3,timerstring,-1);
+			 /*g_fprintf(stderr,"\nLoaded timer command ==> %s... with length %d", 
+							timerstring,strlen(timerstring));*/
+			 /*g_free(timerstring);*/
 
-	     gtk_list_store_set(pd->list,&iter,4,is_cd,5,time,-1);
+			 timerstring=(gchar *)xfce_rc_read_entry(rc,"timerinfo","");
+			 gtk_list_store_set(pd->list,&iter,2,timerstring,-1);
 
-	     groupnum++;
-	     g_snprintf(groupname,5,"G%d",groupnum);
-   
-	  } /* end of while loop */
+			 /*g_free(timerstring);*/
 
-	  pd->count=groupnum;
-  
+			 is_cd=xfce_rc_read_bool_entry(rc,"is_countdown",TRUE);
+			 time=xfce_rc_read_int_entry(rc,"time",0);
 
-	  /* Read other options */
-	  if(xfce_rc_has_group(rc,"others")){
-	    xfce_rc_set_group(rc,"others");
-	    pd->nowin_if_alarm= xfce_rc_read_bool_entry
-		    (rc,"nowin_if_alarm",FALSE);
-	    pd->repeat_alarm= xfce_rc_read_bool_entry
-		    (rc,"repeat_alarm",FALSE);
-	    pd->repetitions= xfce_rc_read_int_entry
-		    (rc,"repetitions",1);
-	    pd->repeat_interval= xfce_rc_read_int_entry
-		    (rc,"repeat_interval",10);
-	    	    
-	  }	        
+			 gtk_list_store_set(pd->list,&iter,4,is_cd,5,time,-1);
 
-	  add_pbar(pd->base,pd);  
+			 groupnum++;
+			 g_snprintf(groupname,5,"G%d",groupnum);
+	   
+		  } /* end of while loop */
 
-         xfce_rc_close(rc);
-      }
+		  pd->count=groupnum;
+	  
+
+		  /* Read other options */
+		  if(xfce_rc_has_group(rc,"others")){
+			xfce_rc_set_group(rc,"others");
+			pd->nowin_if_alarm= xfce_rc_read_bool_entry
+				(rc,"nowin_if_alarm",FALSE);
+			pd->repeat_alarm= xfce_rc_read_bool_entry
+				(rc,"repeat_alarm",FALSE);
+			pd->repetitions= xfce_rc_read_int_entry
+				(rc,"repetitions",1);
+			pd->repeat_interval= xfce_rc_read_int_entry
+				(rc,"repeat_interval",10);
+					
+		  }	        
+
+		  add_pbar(pd->base,pd);  
+
+			 xfce_rc_close(rc);
+		  }
+		  
+//	 }
   }   
   
 }
 
 
 /**
- * Saves the list to a keyfile
+ * Saves the list to a keyfile, backup a permanent copy
 **/ 
 static void save_settings(XfcePanelPlugin *plugin, plugin_data *pd){
 
@@ -952,17 +954,24 @@
   gint row_count;
   gsize size;
 
-  GIOChannel *io;
+  FILE *conffile;
   
   XfceRc *rc;
-  char *file;
+  gchar *file, *contents=NULL;
   
   if (!(file = xfce_panel_plugin_save_location (plugin, TRUE)))
     return;
 
+  // We do this to start a fresh config file, otherwise if the old config file is longer,
+  // the tail will not get truncated. See
+  // http://bugzilla.xfce.org/show_bug.cgi?id=2647
+  // for a related bug report.
+  conffile = fopen(file,"w");
+  if (conffile)
+    fclose(conffile);
+    
   rc = xfce_rc_simple_open (file, FALSE);
-  g_free (file);
-
+  
   if (!rc)
     return;
 
@@ -1015,7 +1024,16 @@
 
   xfce_rc_close(rc);
 
+  conffile = fopen (pd->configfile,"w");
+  /* We backup a permanent copy, which we'll use to load settings */
+  if (conffile && g_file_get_contents(file,&contents,NULL,NULL)){
+  	fputs(contents,conffile);
+  	fclose(conffile);
+  }
 
+  g_free(file);
+  if(contents)
+    g_free(contents);
 
 }
 
@@ -1059,6 +1077,9 @@
 
   if(pd->timeout_command)
     g_free(pd->timeout_command);
+    
+  if(pd->configfile)
+  	g_free(pd->configfile);
 
   gtk_object_destroy(GTK_OBJECT(pd->tip));
 
@@ -1307,6 +1328,7 @@
   GtkWidget *base,*menu,*socket,*menuitem,*box,*pbar2;
   GtkTooltips *tooltip;
   char command[1024]; 
+  gchar *filename,*pathname;
 
 
 
@@ -1347,12 +1369,19 @@
   pd->repeat_interval=10;
   pd->alarm_repeating=FALSE;
   pd->repeat_timeout=0;
- 
+
   gtk_tooltips_set_tip(pd->tip, GTK_WIDGET(plugin), "", NULL);
   gtk_tooltips_disable(pd->tip);
+ 
   
   g_object_ref(pd->list);
 
+  filename = xfce_panel_plugin_save_location (pd->base,TRUE);
+  pathname = g_path_get_dirname (filename);
+  pd->configfile = g_strconcat (pathname,"/XfceTimer.rc",NULL);
+  g_free(filename);
+  g_free(pathname);
+
   load_settings(pd);
 
   make_menu(pd);

Modified: xfce4-timer-plugin/trunk/src/xfcetimer.h
===================================================================
--- xfce4-timer-plugin/trunk/src/xfcetimer.h	2007-12-24 22:31:07 UTC (rev 3751)
+++ xfce4-timer-plugin/trunk/src/xfcetimer.h	2007-12-25 21:36:47 UTC (rev 3752)
@@ -54,7 +54,10 @@
 							   menuitems (alarms). These 
 							   are used to find the index
 							   of the selected menuitem. */
-  gchar 	*timeout_command;			/* Command when countdown ends */
+  gchar 	*timeout_command,			/* Command when countdown ends */
+  			*configfile;			/* Full address of the permanent
+  									config file -- this is not the
+  									plugin rc file. */
   GTimer 	*timer;					/* Keeps time elapsed */
 
 } plugin_data;




More information about the Goodies-commits mailing list