Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_iconbox.c ewl_iconbox.h ewl_menu_base.c 


Log Message:
* Icon menu for iconbox
* Fix 'if' statement in ewl_menu_base, to fix a null caught by dj2's new type 
checking code

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -3 -r1.41 -r1.42
--- ewl_iconbox.c       22 Oct 2005 03:58:11 -0000      1.41
+++ ewl_iconbox.c       23 Oct 2005 07:13:41 -0000      1.42
@@ -145,6 +145,9 @@
 
        /*Start with an empty background*/
        ib->background = NULL;
+
+       /*Set the defaults to 0 for layout*/
+       ib->lx = ib->ly = ib->iw = ib->ih = 0;
        
        ib->ewl_iconbox_pane_inner = ewl_overlay_new();
        ewl_container_child_append(EWL_CONTAINER(ib->ewl_iconbox_scrollpane), 
ib->ewl_iconbox_pane_inner);
@@ -155,13 +158,7 @@
        ewl_floater_follow_set(EWL_FLOATER(ib->ewl_iconbox_menu_floater),
                               ib->ewl_iconbox_pane_inner);
 
-       ewl_object_fill_policy_set(EWL_OBJECT(ib->ewl_iconbox_menu_floater), 
EWL_FLAG_FILL_FILL);
-
-
-       /*Set the defaults to 0*/
-       ib->lx = ib->ly = ib->iw = ib->ih = 0;
-       
-       
+       /*-------------------------------------------*/
        /* Get the context menu ready */
        ib->ewl_iconbox_context_menu = ewl_menu_new();
        ewl_menu_item_text_set(EWL_MENU_ITEM(ib->ewl_iconbox_context_menu), "");
@@ -190,8 +187,6 @@
        ib->ewl_iconbox_context_menu_item = ewl_menu_separator_new();
        ewl_container_child_append(EWL_CONTAINER(ib->ewl_iconbox_context_menu), 
ib->ewl_iconbox_context_menu_item);
        ewl_widget_show(ib->ewl_iconbox_context_menu_item);
-
-
        ewl_widget_show(ib->ewl_iconbox_view_menu);
                
        /* Add the menu floater to the pane inner */
@@ -199,10 +194,33 @@
 
        /* ------------------------------ Menu */
 
+       /*Icon menu*/
+       ib->icon_menu = ewl_menu_new();
+       ewl_menu_item_text_set(EWL_MENU_ITEM(ib->icon_menu), "");
+       ib->icon_menu_floater = ewl_floater_new();
+       ewl_floater_follow_set(EWL_FLOATER(ib->icon_menu_floater),
+                              ib->ewl_iconbox_pane_inner);
+       ewl_container_child_append(EWL_CONTAINER(ib->icon_menu_floater), 
ib->icon_menu);        
+       ewl_container_child_append(EWL_CONTAINER(ib->ewl_iconbox_pane_inner), 
ib->icon_menu_floater);
+
+
+       ib->icon_menu_item = ewl_menu_separator_new();
+       ewl_container_child_append(EWL_CONTAINER(ib->icon_menu), 
ib->icon_menu_item);
+       ewl_widget_show(ib->icon_menu_item);
+
+               
+       
+       
+       ewl_widget_show(ib->icon_menu_floater);
+       ewl_widget_show(ib->icon_menu);
+       
+       /*-----------------------------------*/
 
-       /* Fix these to be more generic */
-       
/*ewl_object_preferred_inner_size_set(EWL_OBJECT(ib->ewl_iconbox_pane_inner), 
680,300);
-       ewl_object_maximum_size_set(EWL_OBJECT(ib->ewl_iconbox_scrollpane), 
400,400);*/
+
+
+       ewl_object_fill_policy_set(EWL_OBJECT(ib->ewl_iconbox_menu_floater), 
EWL_FLAG_FILL_FILL);
+       ewl_object_fill_policy_set(EWL_OBJECT(ib->icon_menu_floater), 
EWL_FLAG_FILL_FILL);
+       
 
        /* Add the iconbox scrollpane to the iconbox */
        ewl_container_child_append(EWL_CONTAINER(ib), 
ib->ewl_iconbox_scrollpane);
@@ -296,6 +314,12 @@
        ewl_container_child_append(EWL_CONTAINER(ib->ewl_iconbox_context_menu), 
item);
 }
 
+void ewl_iconbox_icon_menu_item_add(Ewl_IconBox* ib, Ewl_Widget* item) {
+       ewl_container_child_append(EWL_CONTAINER(ib->icon_menu), item);
+}
+
+
+
 Ecore_List* ewl_iconbox_get_selection(Ewl_IconBox* ib) {
        Ewl_IconBox_Icon* list_item;
        Ecore_List* selected = ecore_list_new();
@@ -435,7 +459,9 @@
        int pw,ph;
        
        ewl_object_current_size_get(EWL_OBJECT(ib->ewl_iconbox_scrollpane), 
&pw, &ph);  
-       ewl_object_custom_size_set(EWL_OBJECT(ib->ewl_iconbox_pane_inner), pw > 
ib->lx ? pw + ib->iw: ib->lx+ib->iw+20, ph > ib->ly+ib->ih ? ph+ib->ih : 
ib->ly+ib->ih+30);
+       ewl_object_custom_size_set(EWL_OBJECT(ib->ewl_iconbox_pane_inner), 
+                       pw > ib->lx ? pw + ib->iw: ib->lx+ib->iw+20, 
+                       ph > ib->ly+ib->ih ? ph+ib->ih : ib->ly+ib->ih+30);
 
        
 }
@@ -889,23 +915,20 @@
        if (ev->button == 3 /* Confirm that this is not an icon event */ && 
(ib->xdown != ev->x && ib->ydown != ev->y)) {
                /*printf ("Context menu: %d,%d\n", ev->x, ev->y);*/
 
-               //ewl_widget_show(ib->ewl_iconbox_menu_floater);
-               //ewl_widget_show(ib->ewl_iconbox_context_menu);
-               //ewl_widget_show(ib->ewl_iconbox_view_menu);
                
ewl_floater_follow_set(EWL_FLOATER(ib->ewl_iconbox_menu_floater), 
ib->ewl_iconbox_pane_inner);
-               
                
ewl_floater_position_set(EWL_FLOATER(ib->ewl_iconbox_menu_floater), ev->x-ibx + 
abs(px-ibx), ev->y-iby +abs(py-iby));
                ewl_callback_call(EWL_WIDGET(ib->ewl_iconbox_context_menu), 
EWL_CALLBACK_SELECT);
        } else if (ev->button == 1 /* Confirm that this is not an icon event */ 
&& (ib->xdown != ev->x && ib->ydown != ev->y)) {
                /*Make sure the context menu is invisible*/
                
-               //ewl_widget_hide(ib->ewl_iconbox_context_menu);
-               //ewl_widget_hide(ib->ewl_iconbox_menu_floater);
-               //ewl_widget_hide(ib->ewl_iconbox_view_menu);
-               //
+               //Hide the context menu
                
ewl_widget_hide(EWL_MENU_ITEM(ib->ewl_iconbox_context_menu_item)->inmenu);
-               
                
ewl_floater_follow_set(EWL_FLOATER(ib->ewl_iconbox_menu_floater), NULL);
+
+
+               //Hide the icon menu
+               ewl_widget_hide(EWL_MENU_ITEM(ib->icon_menu_item)->inmenu);
+               ewl_floater_follow_set(EWL_FLOATER(ib->icon_menu_floater), 
NULL);
                
                ewl_object_custom_size_set(EWL_OBJECT(ib->select), 1, 1);
                
@@ -926,6 +949,7 @@
 
        Ewl_IconBox_Icon* ib = user_data;
        Ewl_Event_Mouse_Down *ev = ev_data;
+       int ibx,iby,px,py;
        
        /*printf ("Button down on icon: %s\n", 
ewl_border_text_get(EWL_BORDER(ib)));*/
        ib->drag = 1;
@@ -933,9 +957,26 @@
        ib->icon_box_parent->xdown = ev->x;
        ib->icon_box_parent->ydown = ev->y;
 
+       px = 
ewl_object_current_x_get(EWL_OBJECT(ib->icon_box_parent->ewl_iconbox_pane_inner));
+       py = 
ewl_object_current_y_get(EWL_OBJECT(ib->icon_box_parent->ewl_iconbox_pane_inner));
 
+       ibx = ewl_object_current_x_get(EWL_OBJECT(ib->icon_box_parent));
+       iby = ewl_object_current_y_get(EWL_OBJECT(ib->icon_box_parent));
+
        /* Set this to selected */
        ewl_iconbox_icon_select(ib,0);
 
+       if (ev->button == 3) {
+               printf("Showing menu at: %d:%d\n", ev->x-ibx + abs(px-ibx), 
ev->y-iby +abs(py-iby));
+               
+               
ewl_floater_position_set(EWL_FLOATER(ib->icon_box_parent->icon_menu_floater), 
ev->x-ibx + abs(px-ibx), ev->y-iby +abs(py-iby));
+               ewl_widget_show(ib->icon_box_parent->icon_menu);
+               ewl_widget_show(ib->icon_box_parent->icon_menu_floater);
+               ewl_callback_call(EWL_WIDGET(ib->icon_box_parent->icon_menu), 
EWL_CALLBACK_SELECT);     
+       } else {
+               
ewl_widget_hide(EWL_MENU_ITEM(ib->icon_box_parent->icon_menu_item)->inmenu);
+               
ewl_floater_follow_set(EWL_FLOATER(ib->icon_box_parent->icon_menu_floater), 
NULL);
+       }
+
        /*ewl_callback_call_with_event_data(EWL_WIDGET(ib), 
EWL_CALLBACK_MOUSE_DOWN, ev_data);*/
 }
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- ewl_iconbox.h       22 Oct 2005 03:58:11 -0000      1.17
+++ ewl_iconbox.h       23 Oct 2005 07:13:41 -0000      1.18
@@ -71,6 +71,11 @@
        Ewl_Widget* ewl_iconbox_menu_box;
        Ewl_Widget* ewl_iconbox_view_menu;
 
+       Ewl_Widget* icon_menu_floater;
+       Ewl_Widget* icon_menu_item;
+       Ewl_Widget* icon_menu;
+
+
        Ecore_List *ewl_iconbox_icon_list;  /* The icon list */
        char* test;
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_menu_base.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_menu_base.c     10 Oct 2005 18:43:31 -0000      1.7
+++ ewl_menu_base.c     23 Oct 2005 07:13:41 -0000      1.8
@@ -210,8 +210,8 @@
        /*
         * Destroy the icon if it's the wrong type.
         */
-       if ((item->icon && (image && !ewl_widget_type_is(item->icon, "image")))
-                       || (!image && (!ewl_widget_type_is(item->icon, 
"spacer")))) {
+       if ((item->icon && ((image && !ewl_widget_type_is(item->icon, "image")))
+                       || (!image && (!ewl_widget_type_is(item->icon, 
"spacer"))))) {
                ewl_widget_destroy(item->icon);
                item->icon = NULL;
        }




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to