[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [E-devel] tclock timeformat patch



Am Tue, 04 Apr 2006 20:53:58 +0200
schrieb Massimo Maiurana <maiurana@gmail.com>:

> Stephan Wezel, il 04/04/2006 17:14, scrisse:
> 
> > +   ob = e_widget_label_add(evas, D_(""));
> 
> I've not even tried it so I could be wrong, but I think an empty
> string can cause troubles in catalogue compilation with msgfmt.
> 
Could be and i have it removed in this patch.
? tclock-timeformat-config-dialog.diff
Index: e_mod_config.c
===================================================================
RCS file: /var/cvs/e/e_modules/tclock/e_mod_config.c,v
retrieving revision 1.12
diff -u -r1.12 e_mod_config.c
--- e_mod_config.c	1 Apr 2006 19:35:59 -0000	1.12
+++ e_mod_config.c	5 Apr 2006 06:09:14 -0000
@@ -4,7 +4,9 @@
 
 struct _E_Config_Dialog_Data
 {
-   int resolution;
+   unsigned int	 resolution;
+   char 	 *format;
+   int		 userformat;
 };
 
 /* Protos */
@@ -14,6 +16,7 @@
                                           E_Config_Dialog_Data *cfdata);
 static int _basic_apply_data(E_Config_Dialog *cfd,
                              E_Config_Dialog_Data *cfdata);
+static void onCheckChange(void *data, Evas_Object *obj);
 
 void
 _config_tclock_module(E_Container *con, TClock_Face * f)
@@ -35,6 +38,9 @@
 _fill_data(TClock_Face * f, E_Config_Dialog_Data *cfdata)
 {
    cfdata->resolution = f->conf->resolution;
+   if(f->conf->format)
+     cfdata->format = strdup(f->conf->format);
+   cfdata->userformat = f->conf->userformat;
 }
 
 static void *
@@ -59,7 +65,7 @@
 _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas,
                       E_Config_Dialog_Data *cfdata)
 {
-   Evas_Object *o, *of, *ob;
+   Evas_Object *o, *of, *ob, *entry, *checked;
    E_Radio_Group *rg;
 
    o = e_widget_list_add(evas, 0, 0);
@@ -70,6 +76,23 @@
    ob = e_widget_radio_add(evas, D_("1 Second"), RESOLUTION_SECOND, rg);
    e_widget_framelist_object_append(of, ob);
    e_widget_list_object_append(o, of, 1, 1, 0.5);
+   
+   of = e_widget_frametable_add(evas, D_("Timeformat"), 1);
+   checked = e_widget_check_add(evas,D_("User format String"),&(cfdata->userformat));
+   if(cfdata->userformat)
+    e_widget_check_checked_set(checked,1);
+   e_widget_frametable_object_append(of, checked,0,0,1,1,1,0,1,0);
+   ob = e_widget_label_add(evas, D_("For the format syntax please read the docu from strftime"));
+   e_widget_frametable_object_append(of, ob,0,2,1,1,1,0,1,0);
+   entry = e_widget_entry_add(evas,&(cfdata->format));
+   e_widget_disabled_set(entry,!cfdata->userformat);
+   e_widget_min_size_set(entry,150,1);
+   e_widget_frametable_object_append(of, entry,0,1,1,1,1,0,1,0);
+   e_widget_list_object_append(o, of, 1, 1, 0.5);
+   e_widget_on_change_hook_set(checked,onCheckChange,entry);
+   
+   
+   
    return o;
 }
 
@@ -80,8 +103,32 @@
 
    f = cfd->data;
    e_border_button_bindings_ungrab_all();
+   if(cfdata->resolution != f->conf->resolution) {
+     if (cfdata->resolution == RESOLUTION_MINUTE)
+        f->tclock->conf->poll_time = 60.0;
+     else
+        f->tclock->conf->poll_time = 1.0;
+     ecore_timer_interval_set(f->tclock->tclock_check_timer,
+                              f->tclock->conf->poll_time);
+   }
    f->conf->resolution = cfdata->resolution;
+   f->conf->userformat = cfdata->userformat;
+   
+   /* update the format string with the format string given by the user
+      when the userformat is true and the string(typed by the user) isn't empty */
+   if(strlen(cfdata->format)>0 && cfdata->userformat) {
+     if(f->conf->format)
+       evas_stringshare_del(f->conf->format);
+     f->conf->format = (char*)evas_stringshare_add(cfdata->format);
+   }
+   
    e_config_save_queue();
    e_border_button_bindings_grab_all();
    return 1;
 }
+
+static void onCheckChange(void *data, Evas_Object *obj)
+{
+    int checked = e_widget_check_checked_get(obj);
+    e_widget_disabled_set(data,!checked);
+}
Index: e_mod_main.c
===================================================================
RCS file: /var/cvs/e/e_modules/tclock/e_mod_main.c,v
retrieving revision 1.13
diff -u -r1.13 e_mod_main.c
--- e_mod_main.c	1 Apr 2006 19:35:59 -0000	1.13
+++ e_mod_main.c	5 Apr 2006 06:09:15 -0000
@@ -143,6 +143,7 @@
    E_CONFIG_VAL(D, T, enabled, UCHAR);
    E_CONFIG_VAL(D, T, resolution, UINT);
    E_CONFIG_VAL(D, T, format, STR);
+   E_CONFIG_VAL(D, T, userformat, UINT);
 
    conf_edd = E_CONFIG_DD_NEW("TClock_Config", Config);
 #undef T
@@ -188,6 +189,14 @@
                        /* set instance config values */
                        face->conf->enabled = 1;
                        face->conf->resolution = RESOLUTION_MINUTE;
+		       face->conf->userformat = 0;
+
+		       const char         *format;
+	               format =
+                           edje_object_part_state_get(face->tclock_object, "tclock_format",
+	                                              NULL);
+		       face->conf->format = (char*)evas_stringshare_add(format);
+		       
                        tclock->conf->faces =
                            evas_list_append(tclock->conf->faces, face->conf);
                     }
@@ -207,11 +216,13 @@
                     }
                   else
                     {
-                       E_CONFIG_LIMIT(tclock->conf->poll_time, 1.0, 60.0);
+                       E_CONFIG_LIMIT(tclock->conf->poll_time, 60.0, 60.0);
                        tclock->tclock_check_timer =
                            ecore_timer_add(tclock->conf->poll_time,
                                            _tclock_cb_check, tclock);
                        TCLOCK_DEBUG("RES_MIN");
+		       /* to avoid the long display of "Starting the clock..." */
+		       _tclock_cb_check(tclock);
                     }
 
                   /* Menu */
@@ -229,6 +240,7 @@
                }
           }
      }
+   
    return tclock;
 }
 
@@ -341,6 +353,8 @@
    evas_object_del(face->event_object);
    e_object_del(E_OBJECT(face->menu));
 
+   if(face->conf->format)
+    evas_stringshare_del(face->conf->format);
    free(face->conf);
    free(face);
    _tclock_count--;
@@ -365,15 +379,18 @@
         TClock_Face        *face;
 
         face = l->data;
+	
+	const char *format;
+	/* Load the default format string from the module.edj-file
+	   when the user defineable format string shouldn't be used 
+	   otherwise use the user defined format string*/
+	if(!face->conf->userformat) {
+      	  format = edje_object_part_state_get(face->tclock_object, "tclock_format",
+	                                      NULL);
+        } else 
+	  format = face->conf->format;
 
-        const char         *format;
-
-        format =
-            edje_object_part_state_get(face->tclock_object, "tclock_format",
-                                       NULL);
-        face->conf->format = format;
-
-        strftime(buf, TIME_BUF, face->conf->format, local_time);
+        strftime(buf, TIME_BUF, format, local_time);
 
         TCLOCK_DEBUG(face->conf->format);
         edje_object_part_text_set(face->tclock_object, "tclock_text", buf);
Index: e_mod_main.h
===================================================================
RCS file: /var/cvs/e/e_modules/tclock/e_mod_main.h,v
retrieving revision 1.6
diff -u -r1.6 e_mod_main.h
--- e_mod_main.h	1 Apr 2006 19:35:59 -0000	1.6
+++ e_mod_main.h	5 Apr 2006 06:09:15 -0000
@@ -21,7 +21,8 @@
 typedef struct _Config_Face {
    unsigned char       enabled;
    unsigned int        resolution;
-   const char         *format;
+   char		       *format;
+   unsigned int        userformat;
 } Config_Face;
 
 typedef struct _TClock {