rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=519fb9e5f26e66bae75c0ac36663c9aec36ce8c9

commit 519fb9e5f26e66bae75c0ac36663c9aec36ce8c9
Author: Vyacheslav Reutskiy <v.reuts...@samsung.com>
Date:   Wed Apr 6 10:35:53 2016 +0300

    menu: move 'scale' items to workspace ctx menu
    
    We are forced to move those items, because in case when used the dbus
    session for menu, like it did in Unity (Ubuntu), we have a problem, who
    am I kidding, this a big trouble, can't set the custom widget to menu
    item. So now this items in the ctx menu on workspace.
    
    Change-Id: Icb4aad8f3dc2775ecd0ce54da65f5b4a96af0944
---
 src/bin/ui/main_window.h         |  3 --
 src/bin/ui/menu.c                | 15 ----------
 src/bin/ui/workspace/workspace.c | 65 ++++++++++++++++++++++++++--------------
 3 files changed, 43 insertions(+), 40 deletions(-)

diff --git a/src/bin/ui/main_window.h b/src/bin/ui/main_window.h
index dce5fdb..1ff5e0f 100644
--- a/src/bin/ui/main_window.h
+++ b/src/bin/ui/main_window.h
@@ -79,9 +79,6 @@ enum Menu_Item
       MENU_VIEW_WORKSPACE_FILL,
       MENU_VIEW_WORKSPACE_OBJECT_AREA,
       MENU_VIEW_RULERS_SHOW,
-      MENU_VIEW_RULERS_ABS,
-      MENU_VIEW_RULERS_REL,
-      MENU_VIEW_RULERS_BOTH,
    MENU_HELP,
       MENU_HELP_ABOUT,
 
diff --git a/src/bin/ui/menu.c b/src/bin/ui/menu.c
index a93c6e6..77bfa07 100644
--- a/src/bin/ui/menu.c
+++ b/src/bin/ui/menu.c
@@ -51,9 +51,6 @@ int MENU_ITEMS_LIST_STYLE_ONLY[] = {
    MENU_VIEW_WORKSPACE_FILL,
    MENU_VIEW_WORKSPACE_OBJECT_AREA,
    MENU_VIEW_RULERS_SHOW,
-   MENU_VIEW_RULERS_ABS,
-   MENU_VIEW_RULERS_REL,
-   MENU_VIEW_RULERS_BOTH,
    MENU_FILE_EXPORT_EDC_GROUP,
    MENU_EDIT_PART_ADD,
    MENU_EDIT_STATE_ADD,
@@ -155,15 +152,6 @@ _menu_cb(void *data __UNUSED__,
       case MENU_VIEW_RULERS_SHOW:
          evas_object_smart_callback_call(ap.win, 
SIGNAL_SHORTCUT_RULERS_VISIBLED, NULL);
          break;
-      case MENU_VIEW_RULERS_ABS:
-         evas_object_smart_callback_call(tabs_current_workspace_get(), 
"ruler,toggle", strdup("abs"));
-         break;
-      case MENU_VIEW_RULERS_REL:
-         evas_object_smart_callback_call(tabs_current_workspace_get(), 
"ruler,toggle", strdup("rel"));
-         break;
-      case MENU_VIEW_RULERS_BOTH:
-         evas_object_smart_callback_call(tabs_current_workspace_get(), 
"ruler,toggle", strdup("abs&rel"));
-         break;
       case MENU_VIEW_WORKSPACE_OBJECT_AREA:
          evas_object_smart_callback_call(ap.win, SIGNAL_SHORTCUT_OBJECT_AREA, 
NULL);
          break;
@@ -315,9 +303,6 @@ ui_menu_add(void)
       ITEM_MENU_ADD(MENU_VIEW, MENU_VIEW_WORKSPACE_OBJECT_AREA, NULL, _("Show 
object area"), "o")
       ___(MENU_VIEW);
       ITEM_MENU_ADD(MENU_VIEW, MENU_VIEW_RULERS_SHOW, NULL, _("Show rulers"), 
NULL)
-      ITEM_MENU_ADD(MENU_VIEW, MENU_VIEW_RULERS_ABS, NULL, _("Absolute 
scale"), NULL)
-      ITEM_MENU_ADD(MENU_VIEW, MENU_VIEW_RULERS_REL, NULL, _("Relative 
scale"), NULL)
-      ITEM_MENU_ADD(MENU_VIEW, MENU_VIEW_RULERS_BOTH, NULL, _("Both scales"), 
NULL)
 
    ITEM_MENU_ADD(MENU_NULL, MENU_HELP, NULL, _("Help"), NULL)
       ITEM_MENU_ADD(MENU_HELP, MENU_HELP_ABOUT, NULL, _("About"), NULL)
diff --git a/src/bin/ui/workspace/workspace.c b/src/bin/ui/workspace/workspace.c
index cd124b9..9ac8c60 100644
--- a/src/bin/ui/workspace/workspace.c
+++ b/src/bin/ui/workspace/workspace.c
@@ -96,6 +96,12 @@ struct _Workspace_Data
    } toolbar;
    Evas_Object *panes_h; /* for set subobject like code, sequance etc */
 
+   struct {
+      Evas_Object *obj;
+      Evas_Object *scale_abs;
+      Evas_Object *scale_rel;
+      Evas_Object *scale_both;
+   } menu;
    Scroll_Area normal;
    Scroll_Area demo;
    struct {
@@ -572,23 +578,16 @@ _menu_rulers_visible(void *data __UNUSED__,
    evas_object_smart_callback_call(ap.win, SIGNAL_SHORTCUT_RULERS_VISIBLED, 
NULL);
 }
 
-static void
-_menu_dismiss(void *data __UNUSED__,
-              Evas_Object *obj,
-              void *event_info __UNUSED__)
-{
-   evas_object_del(obj);
-}
-
-#define MENU_ITEM_ADD(MENU, PARENT, ICON, LABEL, CALLBACK, SHORTCUT) \
+#define MENU_ITEM_ADD(MENU, PARENT, ICON, LABEL, CALLBACK, SHORTCUT, WIDGET) \
    do \
      { \
         Elm_Object_Item *item; \
         item = elm_menu_item_add(MENU, PARENT, ICON, LABEL, CALLBACK, NULL); \
-        if (SHORTCUT) \
+        if (SHORTCUT || WIDGET) \
           { \
              Evas_Object *item_obj = elm_menu_item_object_get(item);\
-             elm_object_part_text_set(item_obj, "elm.shortcut", SHORTCUT); \
+             if (SHORTCUT) elm_object_part_text_set(item_obj, "elm.shortcut", 
SHORTCUT); \
+             if (WIDGET) elm_object_part_content_set(item_obj, 
"elm.swallow.content", WIDGET); \
           } \
      } \
    while (0);
@@ -599,21 +598,41 @@ _menu_cb(void *data,
          Evas_Object *obj __UNUSED__,
          void *event_info)
 {
-   Scroll_Area *area = data;
+   Workspace_Data *wd = data;
+   Scroll_Area *area;
    Evas_Event_Mouse_Down *ev = event_info;
-   Evas_Object *menu;
+   Eina_Bool sa, sr;
 
    if (ev->button != 3) return;
+   area = _scroll_area_get(wd);
+
+   sa = ewe_ruler_scale_visible_get(area->ruler_h.obj, NULL);
+   sr = ewe_ruler_scale_visible_get(area->ruler_h.obj, 
area->ruler_h.scale_rel);
+
+   if (sa) elm_radio_value_set(wd->menu.scale_abs, 0);
+   if (sr) elm_radio_value_set(wd->menu.scale_abs, 1);
+   if (sa && sr) elm_radio_value_set(wd->menu.scale_abs, 2);
+
+   elm_menu_move(wd->menu.obj, ev->canvas.x, ev->canvas.y);
+   evas_object_show(wd->menu.obj);
+}
 
-   menu = elm_menu_add(area->scroller);
-   evas_object_smart_callback_add(menu, "dismissed", _menu_dismiss, NULL);
-   MENU_ITEM_ADD(menu, NULL, NULL, _("Undo"), _menu_undo, "Ctrl-Z");
-   MENU_ITEM_ADD(menu, NULL, NULL, _("Redo"), _menu_redo, "Ctrl-Y");
-   elm_menu_item_separator_add(menu, NULL);
-   MENU_ITEM_ADD(menu, NULL, NULL, _("Show rulers"), _menu_rulers_visible, 
NULL);
+static void
+_menu_add(Workspace_Data *wd)
+{
+   wd->menu.obj = elm_menu_add(ap.win);
+   MENU_ITEM_ADD(wd->menu.obj, NULL, NULL, _("Undo"), _menu_undo, "Ctrl-Z", 
NULL);
+   MENU_ITEM_ADD(wd->menu.obj, NULL, NULL, _("Redo"), _menu_redo, "Ctrl-Y", 
NULL);
+   elm_menu_item_separator_add(wd->menu.obj, NULL);
+   MENU_ITEM_ADD(wd->menu.obj, NULL, NULL, _("Show rulers"), 
_menu_rulers_visible, NULL, NULL);
 
-   elm_menu_move(menu, ev->canvas.x, ev->canvas.y);
-   evas_object_show(menu);
+   elm_menu_item_separator_add(wd->menu.obj, NULL);
+   wd->menu.scale_abs = _radio_switcher_add(wd, NULL, NULL, 0, NULL);
+   MENU_ITEM_ADD(wd->menu.obj, NULL, NULL, _("Absolute scale"), 
_menu_rulers_visible, NULL, wd->menu.scale_abs);
+   wd->menu.scale_rel = _radio_switcher_add(wd, NULL, NULL, 1, 
wd->menu.scale_abs);
+   MENU_ITEM_ADD(wd->menu.obj, NULL, NULL, _("Relative scale"), 
_menu_rulers_visible, NULL, wd->menu.scale_rel);
+   wd->menu.scale_both = _radio_switcher_add(wd, NULL, NULL, 2, 
wd->menu.scale_abs);
+   MENU_ITEM_ADD(wd->menu.obj, NULL, NULL, _("Both scales"), 
_menu_rulers_visible, NULL, wd->menu.scale_both);
 }
 
 static void
@@ -646,7 +665,7 @@ _scroll_area_add(Workspace_Data *wd, Scroll_Area *area, 
Eina_Bool scale_rel)
    container_container_size_set(area->container, 350, 350);
 
    if (scale_rel) /* this bool like marker, if scale_rel is true we have the 
area for normal mode */
-     evas_object_event_callback_add(area->scroller, EVAS_CALLBACK_MOUSE_DOWN, 
_menu_cb, area);
+     evas_object_event_callback_add(area->scroller, EVAS_CALLBACK_MOUSE_DOWN, 
_menu_cb, wd);
 }
 
 static void
@@ -1040,6 +1059,8 @@ workspace_add(Evas_Object *parent, Group *group)
    evas_object_size_hint_align_set(wd->demo_navi, EVAS_HINT_FILL, 
EVAS_HINT_FILL);
    evas_object_hide(wd->demo_navi);
 
+   _menu_add(wd);
+
    evas_object_data_set(wd->panes, WORKSPACE_DATA, wd);
    evas_object_event_callback_add(wd->panes, EVAS_CALLBACK_DEL, 
_workspace_del, wd);
 

-- 


Reply via email to