Hi, here are the corrected patches. I hope I did not forget anything.
2011/3/10 Tristan Lelong <tristan.lel...@blunderer.org>:
> Ok, I correct all these and I'll submit patches again.
> Thx for the feedback.
>
> Le jeudi 10 mars 2011, Carsten Haitzler <ras...@rasterman.com> a écrit :
>> On Wed, 9 Mar 2011 16:24:10 +0100 Tristan Lelong
>> <tristan.lel...@blunderer.org>
>> said:
>>
>> ok. going to have to "reject" here.
>>
>> patch 1:
>> 1. formatting - elm_menu_discard() in Elementary.h.in doesnt align with the
>> rest of the calls next to it (looks ugly)
>> 2. elm_menu_discard() in elm_menu.c is indented using tabs, not spaces. make
>> it
>> align/look like all the code above/below it :)
>>
>> patch 2:
>> 3. elm_menu_item_selected_get() also not aligned in Elementary.h.in
>> 4. elm_menu_selected_item_get() also add a space between * and the function
>> call.
>> 5. more tabs in elm_menu.c indenting as opposed to spaces.
>> 6. ELM_CHECK_WIDTYPE() is changed to remove the NULL return - this creates a
>> bug.
>> 7. ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN provides no return value as arg in
>> elm_menu_item_selected_get(), elm_menu_item_prev_get(),
>> elm_menu_item_next_get
>> ()
>> 8. Eina_List * l there and not Eina_List *l.
>> 9. space between eina_list_data_find_list and ()
>> 10. same with eina_list_next() and eina_list_prev()
>>
>> ... :) (don't worry - you'll learn that we are picky about these things) :)
>>
>>> Hello,
>>>
>>> I was using elementary on a target that only has a keyboard, and I add
>>> to do several modification on the elm_menu to handle keyboard
>>> navigation.
>>> - patch 1: discard a menu from C source code
>>> - patch 2: add accessors for menu items and add the ability to handle
>>> selected item from C source code
>>>
>>>
>>>
>>> --
>>> 618FE3EF
>>
>>
>> --
>> ------------- Codito, ergo sum - "I code, therefore I am" --------------
>> The Rasterman (Carsten Haitzler) ras...@rasterman.com
>>
>>
>
> --
> 618FE3EF
>
--
618FE3EF
diff -Naur elementary-0.7.0.55225/src/lib/elm_menu.c elementary-0.7.0.55225.patched//src/lib/elm_menu.c
--- elementary-0.7.0.55225/src/lib/elm_menu.c 2011-02-17 18:34:36.000000000 +0100
+++ elementary-0.7.0.55225.patched//src/lib/elm_menu.c 2011-02-17 18:33:50.000000000 +0100
@@ -536,6 +536,22 @@
}
/**
+ * Close a opened menu
+ *
+ * @param obj the menu object
+ * @return void
+ *
+ * @ingroup Menu
+ */
+EAPI void
+elm_menu_discard(Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ _menu_hide(obj, wd->hv, NULL);
+}
+
+/**
* Get the Evas_Object of an Elm_Menu_Item
*
* @param item The menu item object.
diff -Naur elementary-0.7.0.55225/src/lib/Elementary.h.in elementary-0.7.0.55225.patched//src/lib/Elementary.h.in
--- elementary-0.7.0.55225/src/lib/Elementary.h.in 2010-12-03 22:38:49.000000000 +0100
+++ elementary-0.7.0.55225.patched//src/lib/Elementary.h.in 2011-02-15 13:22:59.000000000 +0100
@@ -1490,6 +1490,7 @@
EAPI void elm_menu_parent_set(Evas_Object *obj, Evas_Object *parent) EINA_ARG_NONNULL(1);
EAPI Evas_Object *elm_menu_parent_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
EAPI void elm_menu_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) EINA_ARG_NONNULL(1);
+ EAPI void elm_menu_discard(Evas_Object *obj) EINA_ARG_NONNULL(1);
EAPI Evas_Object *elm_menu_object_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1);
EAPI Elm_Menu_Item *elm_menu_item_add(Evas_Object *obj, Elm_Menu_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1);
EAPI void elm_menu_item_label_set(Elm_Menu_Item *item, const char *label) EINA_ARG_NONNULL(1);
diff -Naur elementary-0.7.0.55225/data/themes/default.edc elementary-0.7.0.55225.patched/data/themes/default.edc
--- elementary-0.7.0.55225/data/themes/default.edc 2011-02-22 09:56:06.000000000 +0100
+++ elementary-0.7.0.55225.patched/data/themes/default.edc 2011-02-21 17:19:08.000000000 +0100
@@ -4192,6 +4192,7 @@
name: "item_mouse_out";
signal: "mouse,out";
source: "over2";
+ action: SIGNAL_EMIT "elm,action,inactivate" "";
after: "item_mouse_out_2";
after: "item_mouse_out_3";
}
@@ -4289,6 +4290,18 @@
set_int(menu_disable, 1);
}
}
+ program { name: "item_select";
+ signal: "elm,state,selected";
+ source: "elm";
+ after: "item_mouse_in_2";
+ after: "item_mouse_in_3";
+ }
+ program { name: "item_unselect";
+ signal: "elm,state,unselected";
+ source: "elm";
+ after: "item_mouse_out_2";
+ after: "item_mouse_out_3";
+ }
program { name: "enable";
signal: "elm,state,enabled";
source: "elm";
diff -Naur elementary-0.7.0.55225/src/lib/Elementary.h.in elementary-0.7.0.55225.patched/src/lib/Elementary.h.in
--- elementary-0.7.0.55225/src/lib/Elementary.h.in 2011-02-22 09:55:26.000000000 +0100
+++ elementary-0.7.0.55225.patched/src/lib/Elementary.h.in 2011-02-21 18:06:11.000000000 +0100
@@ -1492,12 +1492,15 @@
EAPI void elm_menu_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) EINA_ARG_NONNULL(1);
EAPI void elm_menu_discard(Evas_Object *obj) EINA_ARG_NONNULL(1);
EAPI Evas_Object *elm_menu_object_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1);
+ EAPI const Eina_List *elm_menu_items_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
EAPI Elm_Menu_Item *elm_menu_item_add(Evas_Object *obj, Elm_Menu_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1);
EAPI void elm_menu_item_label_set(Elm_Menu_Item *item, const char *label) EINA_ARG_NONNULL(1);
EAPI const char *elm_menu_item_label_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
EAPI void elm_menu_item_icon_set(Elm_Menu_Item *item, const char *icon) EINA_ARG_NONNULL(1, 2);
EAPI const char *elm_menu_item_icon_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
EAPI const Evas_Object *elm_menu_item_object_icon_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
+ EAPI void elm_menu_item_selected_set(Elm_Menu_Item *item, Eina_Bool selected) EINA_ARG_NONNULL(1);
+ EAPI Eina_Bool elm_menu_item_selected_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
EAPI void elm_menu_item_disabled_set(Elm_Menu_Item *item, Eina_Bool disabled) EINA_ARG_NONNULL(1);
EAPI Eina_Bool elm_menu_item_disabled_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
EAPI Elm_Menu_Item *elm_menu_item_separator_add(Evas_Object *obj, Elm_Menu_Item *parent) EINA_ARG_NONNULL(1);
@@ -1507,6 +1510,12 @@
EAPI void *elm_menu_item_data_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1);
EAPI void elm_menu_item_data_set(Elm_Menu_Item *item, const void *data) EINA_ARG_NONNULL(1);
EAPI const Eina_List *elm_menu_item_subitems_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
+ EAPI const Elm_Menu_Item *elm_menu_selected_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1);
+ EAPI const Elm_Menu_Item *elm_menu_last_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1);
+ EAPI const Elm_Menu_Item *elm_menu_first_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1);
+ EAPI const Elm_Menu_Item *elm_menu_item_next_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1);
+ EAPI const Elm_Menu_Item *elm_menu_item_prev_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1);
+
/* smart callbacks called:
* "clicked" - the user clicked the empty space in the menu to dismiss. event_info is NULL.
*/
diff -Naur elementary-0.7.0.55225/src/lib/elm_menu.c elementary-0.7.0.55225.patched/src/lib/elm_menu.c
--- elementary-0.7.0.55225/src/lib/elm_menu.c 2011-02-22 09:55:26.000000000 +0100
+++ elementary-0.7.0.55225.patched/src/lib/elm_menu.c 2011-02-21 18:05:57.000000000 +0100
@@ -29,6 +29,7 @@
Eina_Bool separator : 1;
Eina_Bool disabled : 1;
+ Eina_Bool selected: 1;
};
struct _Widget_Data
@@ -305,11 +306,12 @@
Eina_List *l;
Elm_Menu_Item *item2;
Elm_Menu_Item *item = data;
+ item->selected = 1;
if (item->parent)
{
EINA_LIST_FOREACH(item->parent->submenu.items, l, item2)
{
- if ((item2->submenu.open) && (item2 != item)) _submenu_hide(item2);
+ if (item2 != item) elm_menu_item_selected_set(item2, 0);
}
}
else
@@ -317,12 +319,21 @@
Widget_Data *wd = elm_widget_data_get(item->base.widget);
EINA_LIST_FOREACH(wd->items, l, item2)
{
- if ((item2->submenu.open) && (item2 != item)) _submenu_hide(item2);
+ if (item2 != item) elm_menu_item_selected_set(item2, 0);
}
}
}
static void
+_menu_item_inactivate(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+ Eina_List *l;
+ Elm_Menu_Item *item = data;
+ item->selected = 0;
+ if (item->submenu.open) _submenu_hide(item);
+}
+
+static void
_submenu_open(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
{
Elm_Menu_Item *item = data;
@@ -352,6 +363,8 @@
_menu_item_select, item);
edje_object_signal_callback_add(item->base.view, "elm,action,activate", "",
_menu_item_activate, item);
+ edje_object_signal_callback_add(item->base.view, "elm,action,inactivate", "",
+ _menu_item_inactivate, item);
evas_object_show(item->base.view);
}
@@ -941,3 +954,185 @@
ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
return item->submenu.items;
}
+
+/**
+ * Returns a list of @p item's items.
+ *
+ * @param obj The menu object
+ * @return An Eina_List* of @p item's items
+ *
+ * @ingroup Menu
+ */
+EAPI const Eina_List *
+elm_menu_items_get(const Evas_Object * obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ return wd->items;
+}
+
+/**
+ * Set the selected state of @p item.
+ *
+ * @param item The menu item object.
+ * @param selected The selected/unselected state of the item
+ *
+ * @ingroup Menu
+ */
+EAPI void
+elm_menu_item_selected_set(Elm_Menu_Item *item, Eina_Bool selected)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
+ if (selected == item->selected) return;
+ item->selected = selected;
+ if (selected)
+ {
+ edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
+ _menu_item_activate(item, NULL, NULL, NULL);
+ }
+ else
+ {
+ edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
+ _menu_item_inactivate(item, NULL, NULL, NULL);
+ }
+ edje_object_message_signal_process(item->base.view);
+}
+
+/**
+ * Get the selected state of @p item.
+ *
+ * @param item The menu item object.
+ * @return The selected/unselected state of the item
+ *
+ * @ingroup Menu
+ */
+EAPI Eina_Bool
+elm_menu_item_selected_get(const Elm_Menu_Item *item)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
+ if (item->selected) return EINA_TRUE;
+ return EINA_FALSE;
+}
+
+/**
+ * Get the previous item in the menu.
+ *
+ * @param item The menu item object.
+ * @return The item before it, or NULL if none
+ *
+ * @ingroup Menu
+ */
+EAPI const Elm_Menu_Item *
+elm_menu_item_prev_get(const Elm_Menu_Item *it)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
+ if (it->parent)
+ {
+ Eina_List *l = eina_list_data_find_list(it->parent->submenu.items, it);
+ l = eina_list_prev(l);
+ if (!l) return NULL;
+ return l->data;
+ }
+ else
+ {
+ Widget_Data *wd = elm_widget_data_get(it->base.widget);
+ if (!wd | !wd->items) return NULL;
+ Eina_List *l = eina_list_data_find_list(wd->items, it);
+ l = eina_list_prev(l);
+ if (!l) return NULL;
+ return l->data;
+ }
+ return NULL;
+}
+
+/**
+ * Get the next item in the menu.
+ *
+ * @param item The menu item object.
+ * @return The item after it, or NULL if none
+ *
+ * @ingroup Menu
+ */
+EAPI const Elm_Menu_Item *
+elm_menu_item_next_get(const Elm_Menu_Item *it)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
+ if (it->parent)
+ {
+ Eina_List *l = eina_list_data_find_list(it->parent->submenu.items, it);
+ l = eina_list_next(l);
+ if (!l) return NULL;
+ return l->data;
+ }
+ else
+ {
+ Widget_Data *wd = elm_widget_data_get(it->base.widget);
+ if (!wd | !wd->items) return NULL;
+ Eina_List *l = eina_list_data_find_list(wd->items, it);
+ l = eina_list_next(l);
+ if (!l) return NULL;
+ return l->data;
+ }
+ return NULL;
+}
+
+/**
+ * Get the first item in the menu
+ *
+ * @param obj The menu object
+ * @return The first item, or NULL if none
+ *
+ * @ingroup Menu
+ */
+EAPI const Elm_Menu_Item *
+elm_menu_first_item_get(const Evas_Object * obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ if (wd->items) return wd->items->data;
+ return NULL;
+}
+
+/**
+ * Get the last item in the menu
+ *
+ * @param obj The menu object
+ * @return The last item, or NULL if none
+ *
+ * @ingroup Menu
+ */
+EAPI const Elm_Menu_Item *
+elm_menu_last_item_get(const Evas_Object * obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ Eina_List *l = eina_list_last(wd->items);
+ if (l) return l->data;
+ return NULL;
+}
+
+/**
+ * Get the selected item in the menu
+ *
+ * @param obj The menu object
+ * @return The selected item, or NULL if none
+ *
+ * @ingroup Menu
+ */
+EAPI const Elm_Menu_Item *
+elm_menu_selected_item_get(const Evas_Object * obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ Eina_List *l;
+ Elm_Menu_Item *item;
+ EINA_LIST_FOREACH(wd->items, l, item)
+ {
+ if (item->selected) return item;
+ }
+ return NULL;
+}
+
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel