Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/bin


Modified Files:
        ewl_dialog_test.c ewl_filedialog_test.c ewl_image_test.c 


Log Message:
Convert stock buttons and filedialog to new API conventions.
Improve the image test to make its use more obvious.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/ewl_dialog_test.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_dialog_test.c   3 Oct 2005 06:43:07 -0000       1.3
+++ ewl_dialog_test.c   5 Oct 2005 05:41:01 -0000       1.4
@@ -120,13 +120,18 @@
   ewl_container_child_append (EWL_CONTAINER (hbox), label);
   ewl_widget_show (label);
 
-  button = ewl_button_stock_with_id_new (EWL_STOCK_OK, EWL_RESPONSE_OK);
+  button = ewl_button_stock_new();
+  ewl_button_stock_id_set(EWL_BUTTON_STOCK(button), EWL_STOCK_OK);
+  ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(button), EWL_RESPONSE_OK);
   ewl_container_child_append (EWL_CONTAINER (dialog_win), button);
   ewl_callback_append (button, EWL_CALLBACK_VALUE_CHANGED,
                       EWL_CALLBACK_FUNCTION (__create_window_response), NULL);
   ewl_widget_show (button);
 
-  button = ewl_button_stock_with_id_new (EWL_STOCK_CANCEL, 
EWL_RESPONSE_CANCEL);
+  button = ewl_button_stock_new();
+  ewl_button_stock_id_set(EWL_BUTTON_STOCK(button), EWL_STOCK_CANCEL);
+  ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(button),
+                                  EWL_RESPONSE_CANCEL);
   ewl_container_child_append (EWL_CONTAINER (dialog_win), button);
   ewl_callback_append (button, EWL_CALLBACK_VALUE_CHANGED,
                       EWL_CALLBACK_FUNCTION (__create_window_response), NULL);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/ewl_filedialog_test.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_filedialog_test.c       28 May 2005 20:32:49 -0000      1.3
+++ ewl_filedialog_test.c       5 Oct 2005 05:41:01 -0000       1.4
@@ -28,7 +28,8 @@
                                                __close_main_window, NULL);
        ewl_widget_show(win);
 
-       fd = ewl_filedialog_new(EWL_FILEDIALOG_TYPE_OPEN);
+       fd = ewl_filedialog_new();
+       ewl_filedialog_type_set(EWL_FILEDIALOG(fd), EWL_FILEDIALOG_TYPE_OPEN);
        ewl_callback_append (fd, EWL_CALLBACK_VALUE_CHANGED, 
                            __create_fd_window_response, NULL);
        ewl_container_child_append(EWL_CONTAINER(win), fd);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/ewl_image_test.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_image_test.c    3 Oct 2005 06:43:07 -0000       1.4
+++ ewl_image_test.c    5 Oct 2005 05:41:01 -0000       1.5
@@ -8,6 +8,12 @@
 static Ewl_Widget     *entry_path;
 static Ewl_Widget     *note_box;
 static Ewl_Widget     *note;
+static Ewl_Widget     *fdwin;
+
+void __create_image_fd_cb(Ewl_Widget *w, void *ev_data, void *user_data);
+
+static void __destroy_image_fd_cb(Ewl_Widget * w, void *ev_data, void 
*user_data);
+static void __create_image_fd_window_response (Ewl_Widget *w, void *ev, void 
*data);
 
 static void
 __destroy_image_test_window(Ewl_Widget * w, void *ev_data __UNUSED__,
@@ -151,15 +157,36 @@
        if (image_file)
                ecore_dlist_append(images, image_file);
 
+       button_hbox = ewl_hbox_new();
+       ewl_box_spacing_set(EWL_BOX(button_hbox), 5);
+       ewl_object_fill_policy_set(EWL_OBJECT(button_hbox),
+                                  EWL_FLAG_FILL_HFILL | EWL_FLAG_FILL_HSHRINK);
+       ewl_container_child_append(EWL_CONTAINER(image_box), button_hbox);
+       ewl_widget_show(button_hbox);
+
        entry_path = ewl_entry_new();
        ewl_text_text_set(EWL_TEXT(entry_path), image_file);
-       ewl_container_child_append(EWL_CONTAINER(image_box), entry_path);
+       ewl_object_fill_policy_set(EWL_OBJECT(entry_path), EWL_FLAG_FILL_HFILL);
+       ewl_object_alignment_set(EWL_OBJECT(entry_path), EWL_FLAG_ALIGN_CENTER);
+       ewl_container_child_append(EWL_CONTAINER(button_hbox), entry_path);
        ewl_widget_show(entry_path);
 
+       button_load = ewl_button_new();
+       ewl_button_label_set(EWL_BUTTON(button_load), "Browse...");
+       ewl_callback_append(button_load, EWL_CALLBACK_CLICKED,
+                           __create_image_fd_cb, entry_path);
+       ewl_object_fill_policy_set(EWL_OBJECT(button_load), EWL_FLAG_FILL_NONE);
+       ewl_object_alignment_set(EWL_OBJECT(button_load),
+                                EWL_FLAG_ALIGN_CENTER);
+       ewl_container_child_append(EWL_CONTAINER(button_hbox), button_load);
+       ewl_widget_show(button_load);
+
        button_hbox = ewl_hbox_new();
        ewl_box_spacing_set(EWL_BOX(button_hbox), 5);
-       ewl_object_alignment_set(EWL_OBJECT(button_hbox), 
EWL_FLAG_ALIGN_CENTER);
-       ewl_object_custom_size_set(EWL_OBJECT(button_hbox), 300, 26);
+       ewl_object_fill_policy_set(EWL_OBJECT(button_hbox),
+                                  EWL_FLAG_FILL_HFILL);
+       ewl_object_alignment_set(EWL_OBJECT(button_hbox),
+                                EWL_FLAG_ALIGN_CENTER);
        ewl_container_child_append(EWL_CONTAINER(image_box), button_hbox);
        ewl_widget_show(button_hbox);
 
@@ -174,50 +201,6 @@
        ewl_container_child_append(EWL_CONTAINER(button_hbox), button_load);
        ewl_container_child_append(EWL_CONTAINER(button_hbox), button_next);
 
-       image_file = NULL;
-
-       if ((__image_exists
-            (PACKAGE_DATA_DIR "/images/button_prev.bits.db")) != -1)
-               image_file =
-                       strdup(PACKAGE_DATA_DIR "/images/button_prev.bits.db");
-       else if ((__image_exists("./data/images/button_prev.bits.db")) != -1)
-               image_file = strdup("./data/images/button_prev.bits.db");
-       else if ((__image_exists("../data/images/button_prev.bits.db")) != -1)
-               image_file = strdup("../data/images/button_prev.bits.db");
-
-       ewl_theme_data_str_set(button_prev, "/appearance/button/default/base",
-                              image_file);
-
-       IF_FREE(image_file);
-
-       if ((__image_exists
-            (PACKAGE_DATA_DIR "/images/button_load.bits.db")) != -1)
-               image_file =
-                       strdup(PACKAGE_DATA_DIR "/images/button_load.bits.db");
-       else if ((__image_exists("./data/images/button_load.bits.db")) != -1)
-               image_file = strdup("./data/images/button_load.bits.db");
-       else if ((__image_exists("../data/images/button_load.bits.db")) != -1)
-               image_file = strdup("../data/images/button_load.bits.db");
-
-       ewl_theme_data_str_set(button_load, "/appearance/button/default/base",
-                              image_file);
-
-       IF_FREE(image_file);
-
-       if ((__image_exists
-            (PACKAGE_DATA_DIR "/images/button_next.bits.db")) != -1)
-               image_file =
-                       strdup(PACKAGE_DATA_DIR "/images/button_next.bits.db");
-       else if ((__image_exists("./data/images/button_next.bits.db")) != -1)
-               image_file = strdup("./data/images/button_next.bits.db");
-       else if ((__image_exists("../data/images/button_next.bits.db")) != -1)
-               image_file = strdup("../data/images/button_next.bits.db");
-
-       ewl_theme_data_str_set(button_next, "/appearance/button/default/base",
-                              image_file);
-
-       IF_FREE(image_file);
-
        ewl_callback_append(button_prev, EWL_CALLBACK_CLICKED,
                            __image_goto_prev_cb, NULL);
        ewl_callback_append(button_load, EWL_CALLBACK_CLICKED,
@@ -237,27 +220,67 @@
        ewl_widget_show(note_box);
 
        note = ewl_text_new();
-       ewl_text_text_set(EWL_TEXT(note), "These buttons don't do shit.");
-       ewl_text_color_set(EWL_TEXT(note), 255, 0, 0, 255);
+       ewl_text_text_set(EWL_TEXT(note), "Simple image viewer, load up images 
and page through them.");
        ewl_container_child_append(EWL_CONTAINER(note_box), note);
        ewl_widget_show(note);
 
+        ewl_widget_show(image);
+}
 
+void
+__create_image_fd_cb(Ewl_Widget *w __UNUSED__, void *ev_data __UNUSED__,
+                                   void *user_data)
+{
+       Ewl_Widget *fd = NULL;
 
-       image_file = NULL;
-
-       if ((__image_exists(PACKAGE_DATA_DIR "/images/e17-border.bits.db"))
-           != -1)
-               image_file =
-                       strdup(PACKAGE_DATA_DIR "/images/e17-border.bits.db");
-       else if ((__image_exists("./data/images/e17-border.bits.db")) != -1)
-               image_file = strdup("./data/images/e17-border.bits.db");
-       else if ((__image_exists("../data/images/e17-border.bits.db")) != -1)
-               image_file = strdup("../data/images/e17-border.bits.db");
+       if (fdwin)
+               return;
 
-       if (image_file)
-               ecore_dlist_append(images, image_file);
+       fdwin = ewl_window_new();
+       ewl_window_title_set (EWL_WINDOW (fdwin), "Select an Image...");
+       ewl_window_name_set (EWL_WINDOW (fdwin), "EWL Image Test");
+       ewl_window_class_set (EWL_WINDOW (fdwin), "EWL Filedialog");
+
+       ewl_callback_append (fdwin, EWL_CALLBACK_DELETE_WINDOW,
+                            __destroy_image_fd_cb, NULL);
+       ewl_widget_show(fdwin);
+
+       fd = ewl_filedialog_new();
+       ewl_filedialog_type_set(EWL_FILEDIALOG(fd), EWL_FILEDIALOG_TYPE_OPEN);
+       ewl_callback_append (fd, EWL_CALLBACK_VALUE_CHANGED, 
+                           __create_image_fd_window_response, user_data);
+       ewl_container_child_append(EWL_CONTAINER(fdwin), fd);
+       ewl_widget_show(fd);
+}
 
-        ewl_widget_show(image);
+static void
+__create_image_fd_window_response (Ewl_Widget *w, void *ev, void *data)
+{
+       int *response;
+       Ewl_Widget *entry = data;
+  
+       response = (int *)ev;
+
+       if (*response == EWL_RESPONSE_OPEN) {
+               char *path;
+
+               printf("File open from image test: %s\n", 
+               path = ewl_filedialog_file_get (EWL_FILEDIALOG (w)));
+               if (path) {
+                       ewl_text_text_set(EWL_TEXT(entry), path);
+                       // FREE(path); FIXME: Is text widget allocated 
correctly?
+               }
+               ewl_widget_destroy(fdwin);
+               fdwin = NULL;
+       }
+       else {
+               printf("Test program says bugger off.\n");
+       }
 }
 
+static void
+__destroy_image_fd_cb(Ewl_Widget * w, void *ev_data __UNUSED__,
+                                   void *user_data __UNUSED__)
+{
+       ewl_widget_destroy(w);
+}




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to