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

[E-devel] tclock timeformat patch



Hi,

i have a little patch for the tclock module.
With this patch you can change the timeformat with the configuration
dialog of the module.

Regards 

_FireFly_ (Stephan Wezel)
? tclock.diff
? 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	4 Apr 2006 07:29:26 -0000
@@ -5,6 +5,7 @@
 struct _E_Config_Dialog_Data
 {
    int resolution;
+   char *format;
 };
 
 /* Protos */
@@ -35,6 +36,8 @@
 _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);
 }
 
 static void *
@@ -53,13 +56,14 @@
 _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
 {
    free(cfdata);
+   E_FREE(cfdata->format);
 }
 
 static Evas_Object *
 _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;
    E_Radio_Group *rg;
 
    o = e_widget_list_add(evas, 0, 0);
@@ -70,6 +74,16 @@
    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"), 0);
+   ob = e_widget_label_add(evas, D_("TimeFormat"));
+   e_widget_frametable_object_append(of, ob,0,0,1,1,1,0,1,0);
+   entry = e_widget_entry_add(evas,(&(cfdata->format)));
+   e_widget_min_size_set(entry,150,1);
+   e_widget_frametable_object_append(of, entry,1,0,1,1,1,0,1,0);
+   e_widget_list_object_append(o, of, 1, 1, 0.5);
+   
+   
    return o;
 }
 
@@ -81,6 +95,10 @@
    f = cfd->data;
    e_border_button_bindings_ungrab_all();
    f->conf->resolution = cfdata->resolution;
+   if(f->conf->format && strlen(cfdata->format)>0)
+    evas_stringshare_del(f->conf->format);
+   if(strlen(cfdata->format)>0)
+      f->conf->format = evas_stringshare_add(cfdata->format);
    e_config_save_queue();
    e_border_button_bindings_grab_all();
    return 1;
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	4 Apr 2006 07:29:26 -0000
@@ -188,6 +188,7 @@
                        /* set instance config values */
                        face->conf->enabled = 1;
                        face->conf->resolution = RESOLUTION_MINUTE;
+		       face->conf->format = evas_stringshare_add("%c");
                        tclock->conf->faces =
                            evas_list_append(tclock->conf->faces, face->conf);
                     }
@@ -341,6 +342,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--;
@@ -367,11 +370,12 @@
         face = l->data;
 
         const char         *format;
-
-        format =
-            edje_object_part_state_get(face->tclock_object, "tclock_format",
-                                       NULL);
-        face->conf->format = format;
+	
+	//if(face->conf->format)
+        //format =
+        //    edje_object_part_state_get(face->tclock_object, "tclock_format",
+        //                               NULL);
+//        face->conf->format = face->tclock->conf->format;
 
         strftime(buf, TIME_BUF, face->conf->format, local_time);
 
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	4 Apr 2006 07:29:27 -0000
@@ -21,7 +21,7 @@
 typedef struct _Config_Face {
    unsigned char       enabled;
    unsigned int        resolution;
-   const char         *format;
+   char		       *format;
 } Config_Face;
 
 typedef struct _TClock {