Enlightenment CVS committal

Author  : moom
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/bin


Modified Files:
        etk_iconbox_test.c 


Log Message:
* [Iconbox] More work on selection, and add some signals signals to know 
when an icon is selected. Also add etk_iconbox_icon_get_at_xy() to know 
what icon has been pressed, clicked, released...


===================================================================
RCS file: /cvs/e/e17/proto/etk/src/bin/etk_iconbox_test.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- etk_iconbox_test.c  9 Apr 2006 12:36:03 -0000       1.3
+++ etk_iconbox_test.c  10 Apr 2006 09:23:47 -0000      1.4
@@ -5,9 +5,39 @@
 #include <Ecore_Data.h>
 #include <Ecore_File.h>
 
+typedef struct _Etk_Test_Iconbox_Types
+{
+   void *extension;
+   char *icon;
+} Etk_Test_Iconbox_Types;
+
+static void _etk_test_iconbox_mouse_up_cb(Etk_Object *object, void 
*event_info, void *data);
 static void _etk_test_iconbox_folder_set(Etk_Iconbox *iconbox, const char 
*folder);
 
-static char *_etk_test_iconbox_icon_filenames[] =
+static Etk_Test_Iconbox_Types _etk_test_iconbox_types[] =
+{
+   { "jpg", "mimetypes/image-x-generic_48" },
+   { "jpeg", "mimetypes/image-x-generic_48" },
+   { "png", "mimetypes/image-x-generic_48" },
+   { "bmp", "mimetypes/image-x-generic_48" },
+   { "gif", "mimetypes/image-x-generic_48" },
+   { "mp3", "mimetypes/audio-x-generic_48" },
+   { "ogg", "mimetypes/audio-x-generic_48" },
+   { "wav", "mimetypes/audio-x-generic_48" },
+   { "avi", "mimetypes/video-x-generic_48" },
+   { "mpg", "mimetypes/video-x-generic_48" },
+   { "mpeg", "mimetypes/video-x-generic_48" },
+   { "gz", "mimetypes/package-x-generic_48" },
+   { "tgz", "mimetypes/package-x-generic_48" },
+   { "bz2", "mimetypes/package-x-generic_48" },
+   { "tbz2", "mimetypes/package-x-generic_48" },
+   { "zip", "mimetypes/package-x-generic_48" },
+   { "rar", "mimetypes/package-x-generic_48" },
+};
+static int _etk_test_iconbox_num_types = sizeof(_etk_test_iconbox_types) / 
sizeof (_etk_test_iconbox_types[0]);
+static Etk_String *_etk_test_iconbox_current_folder = NULL;
+
+/*static char *_etk_test_iconbox_icon_filenames[] =
 {
    
"/home/simon/etk/data/icons/default/icons/48x48/mimetypes/audio-x-generic.png",
    
"/home/simon/etk/data/icons/default/icons/48x48/mimetypes/image-x-generic.png",
@@ -18,7 +48,7 @@
    "/home/simon/etk/data/themes/default/images/scrollbar_button_up1.png",
    "/home/simon/etk/data/themes/default/images/scrollbar_vdrag2.png"
 };
-static int _etk_test_iconbox_num_icon_filenames = 
sizeof(_etk_test_iconbox_icon_filenames) / sizeof(char *);
+static int _etk_test_iconbox_num_icon_filenames = 
sizeof(_etk_test_iconbox_icon_filenames) / sizeof(char *);*/
 
 /* Creates the window for the iconbox test */
 void etk_test_iconbox_window_create(void *data)
@@ -26,7 +56,7 @@
    static Etk_Widget *win = NULL;
    Etk_Widget *iconbox;
    Etk_Iconbox_Model *mini_model;
-   int i;
+   //int i;
    
    if (win)
    {
@@ -41,6 +71,7 @@
    
    iconbox = etk_iconbox_new();
    etk_container_add(ETK_CONTAINER(win), iconbox);
+   etk_signal_connect("mouse_up", ETK_OBJECT(iconbox), 
ETK_CALLBACK(_etk_test_iconbox_mouse_up_cb), NULL);
    
    /* Create a new iconbox model: mini view */
    mini_model = etk_iconbox_model_new(ETK_ICONBOX(iconbox));
@@ -56,6 +87,26 @@
    etk_widget_show_all(win);
 }
 
+/* Called when the iconbox is pressed by the mouse */
+static void _etk_test_iconbox_mouse_up_cb(Etk_Object *object, void 
*event_info, void *data)
+{
+   Etk_Iconbox *iconbox;
+   Etk_Iconbox_Icon *icon;
+   Etk_Event_Mouse_Up_Down *event;
+   Etk_String *new_folder;
+   
+   if (!(iconbox = ETK_ICONBOX(object)) || !(event = event_info))
+      return;
+   if (event->button != 1)
+      return;
+   if (!(icon = etk_iconbox_icon_get_at_xy(iconbox, event->canvas.x, 
event->canvas.y, ETK_FALSE, ETK_TRUE, ETK_TRUE)))
+      return;
+   
+   new_folder = etk_string_new_printf("%s/%s", 
etk_string_get(_etk_test_iconbox_current_folder), 
etk_iconbox_icon_label_get(icon));
+   _etk_test_iconbox_folder_set(iconbox, etk_string_get(new_folder));
+   etk_object_destroy(ETK_OBJECT(new_folder));
+}
+
 /* Sets the folder displayed in the iconbox */
 static void _etk_test_iconbox_folder_set(Etk_Iconbox *iconbox, const char 
*folder)
 {
@@ -71,7 +122,9 @@
       return;
    
    etk_iconbox_clear(iconbox);
+   etk_iconbox_append(iconbox, etk_theme_icon_theme_get(), "actions/go-up_48", 
"..");
    
+   /* First, add the folders */
    ecore_list_goto_first(files);
    while ((filename = ecore_list_next(files)))
    {      
@@ -85,6 +138,7 @@
       etk_iconbox_append(iconbox, etk_theme_icon_theme_get(), 
"places/folder_48", filename);
    }
    
+   /* Then the files */
    ecore_list_goto_first(files);
    while ((filename = ecore_list_next(files)))
    {
@@ -101,18 +155,22 @@
       
       if ((ext = strrchr(filename, '.')) && (ext = ext + 1))
       {
-         /*for (i = 0; i < _etk_filechooser_num_icons; i++)
+         for (i = 0; i < _etk_test_iconbox_num_types; i++)
          {
-            if (strcasecmp(ext, _etk_filechooser_icons[i].extension) == 0)
+            if (strcasecmp(ext, _etk_test_iconbox_types[i].extension) == 0)
             {
-               icon = _etk_filechooser_icons[i].icon;
+               icon = _etk_test_iconbox_types[i].icon;
                break;
             }
-         }*/
+         }
       }
       
-      etk_iconbox_append(iconbox, etk_theme_icon_theme_get(), 
"mimetypes/audio-x-generic_48", filename);
+      etk_iconbox_append(iconbox, etk_theme_icon_theme_get(), icon ? icon : 
"mimetypes/text-x-generic_48", filename);
    }
    
    ecore_list_destroy(files);
+   
+   if (!_etk_test_iconbox_current_folder)
+      _etk_test_iconbox_current_folder = etk_string_new(NULL);
+   etk_string_set(_etk_test_iconbox_current_folder, folder);
 }




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to