Rewrite screenshot icon creation by using Erigo
This commit is contained in:
parent
f1963435ba
commit
6abb5cab36
|
@ -5,7 +5,7 @@ LIST(APPEND SOURCES clouseau_client.c gui.c)
|
|||
STRING(REGEX REPLACE "\n" "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR})
|
||||
STRING(REGEX REPLACE " " "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR})
|
||||
add_definitions(${CLI_COMMON_DEFINITIONS} -DEFL_EO_API_SUPPORT
|
||||
-DEOLIAN_EO_DIR="${EOLIAN_EO_DIR}" -DPACKAGE_DATA_DIR="${CMAKE_HOME_DIRECTORY}/data")
|
||||
-DEOLIAN_EO_DIR="${EOLIAN_EO_DIR}" -DGUI_IMAGES_PATH="${CMAKE_HOME_DIRECTORY}/data/images")
|
||||
|
||||
link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS})
|
||||
|
||||
|
|
|
@ -454,43 +454,27 @@ _objs_item_label_get(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
return strdup(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
_set_button(Evas_Object *w, Evas_Object *bt,
|
||||
char *ic_name, char *tip, Eina_Bool en)
|
||||
{ /* Update button icon and tooltip */
|
||||
char buf[1024];
|
||||
Evas_Object *ic = elm_icon_add(w);
|
||||
snprintf(buf, sizeof(buf), "%s%s", PACKAGE_DATA_DIR, ic_name);
|
||||
elm_image_file_set(ic, buf, NULL);
|
||||
elm_object_part_content_set(bt, "icon", ic);
|
||||
elm_object_tooltip_text_set(bt, tip);
|
||||
elm_object_disabled_set(bt, en);
|
||||
}
|
||||
|
||||
static void
|
||||
_show_app_window(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
Eina_Bool
|
||||
screenshot_req_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
_Obj_list_node *info_node = data;
|
||||
_Obj_list_node *info_node = NULL;
|
||||
eo_do(obj, info_node = eo_key_data_get("__info_node"));
|
||||
|
||||
printf("show screenshot of obj %s %p\n", info_node->info->kl_name, info_node->info->ptr);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_objs_item_content_get(void *data, Evas_Object *obj, const char *part)
|
||||
{
|
||||
Evas_Object *bt = NULL;
|
||||
|
||||
if(!strcmp(part, "elm.swallow.end"))
|
||||
{
|
||||
bt = elm_button_add(obj);
|
||||
_set_button(obj, bt,
|
||||
SHOW_SCREENSHOT,
|
||||
"Show App Screenshot", EINA_FALSE);
|
||||
|
||||
evas_object_smart_callback_add(bt, "clicked",
|
||||
_show_app_window, data);
|
||||
Gui_Screenshot_Button_Widgets *wdgs = gui_screenshot_button_create(obj);
|
||||
elm_object_tooltip_text_set(wdgs->screenshot_button, "Show App Screenshot");
|
||||
eo_do(wdgs->screenshot_button, eo_key_data_set("__info_node", data));
|
||||
return wdgs->screenshot_button;
|
||||
}
|
||||
return bt;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
47
src/bin/gui
47
src/bin/gui
|
@ -7,12 +7,17 @@
|
|||
},
|
||||
"Resources":
|
||||
{
|
||||
"Images":
|
||||
{
|
||||
"SCREENSHOT_ICON":"../../data/images/show-screenshot.png"
|
||||
},
|
||||
"Eo_Callbacks":
|
||||
{
|
||||
"profile_close":"_profile_win_close_cb",
|
||||
"new_profile_save":"_new_profile_save_cb",
|
||||
"new_profile_cancel":"_new_profile_cancel_cb",
|
||||
"profile_del":"_profile_del_cb"
|
||||
"profile_del":"_profile_del_cb",
|
||||
"screenshot_request":"screenshot_req_cb"
|
||||
}
|
||||
},
|
||||
"Widgets":
|
||||
|
@ -547,6 +552,44 @@
|
|||
"Evas.Object.size_hint_weight":[1, 8],
|
||||
"Elm.Widget.disabled":[true]
|
||||
}
|
||||
},
|
||||
"screenshot_button":
|
||||
{
|
||||
"Desc":
|
||||
{
|
||||
"parent":null,
|
||||
"class":"Elm.Button",
|
||||
"public":true
|
||||
},
|
||||
"Properties":
|
||||
{
|
||||
"Evas.Object.size_hint_weight":[1, 1],
|
||||
"Efl.Gfx.Base.visible":[true],
|
||||
"Efl.Gfx.Base.size":[73, 30]
|
||||
},
|
||||
"Callbacks":
|
||||
{
|
||||
"clicked":["Invoke", "screenshot_request", null]
|
||||
},
|
||||
"Contains":
|
||||
{
|
||||
"elm_icon1":["icon"]
|
||||
}
|
||||
},
|
||||
"elm_icon1":
|
||||
{
|
||||
"Desc":
|
||||
{
|
||||
"parent":"screenshot_button",
|
||||
"class":"Elm.Icon"
|
||||
},
|
||||
"Properties":
|
||||
{
|
||||
"Evas.Object.size_hint_weight":[1, 1],
|
||||
"Efl.Gfx.Base.visible":[true],
|
||||
"Efl.Gfx.Base.size":[40, 40],
|
||||
"Efl.File.file":["SCREENSHOT_ICON", null]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,12 @@ static Gui_Widgets g_pub_widgets;
|
|||
|
||||
extern void gui_new_profile_win_create_done(Gui_New_Profile_Win_Widgets *wdgs);
|
||||
|
||||
#ifdef GUI_IMAGES_PATH
|
||||
const char *SCREENSHOT_ICON = GUI_IMAGES_PATH"/show-screenshot.png";
|
||||
#else
|
||||
#error "Please define GUI_IMAGES_PATH"
|
||||
#endif
|
||||
|
||||
extern Eina_Bool
|
||||
_profile_win_close_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
|
||||
extern Eina_Bool
|
||||
|
@ -25,6 +31,8 @@ extern Eina_Bool
|
|||
_new_profile_cancel_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
|
||||
extern Eina_Bool
|
||||
_profile_del_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
|
||||
extern Eina_Bool
|
||||
screenshot_req_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
|
||||
|
||||
static Eina_Bool
|
||||
_pubs_free_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
|
@ -357,6 +365,39 @@ gui_new_profile_win_create(Eo *__main_parent)
|
|||
return pub_widgets;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
screenshot_button_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
screenshot_req_cb(data, obj, desc, event_info);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
Gui_Screenshot_Button_Widgets *
|
||||
gui_screenshot_button_create(Eo *__main_parent)
|
||||
{
|
||||
Gui_Screenshot_Button_Widgets *pub_widgets = calloc(1, sizeof(*pub_widgets));
|
||||
|
||||
Eo *screenshot_button;
|
||||
Eo *elm_icon1;
|
||||
|
||||
|
||||
screenshot_button = eo_add(ELM_BUTTON_CLASS, __main_parent);
|
||||
pub_widgets->screenshot_button = screenshot_button;
|
||||
eo_do(screenshot_button, evas_obj_size_hint_weight_set(1.000000, 1.000000));
|
||||
eo_do(screenshot_button, efl_gfx_visible_set(EINA_TRUE));
|
||||
eo_do(screenshot_button, efl_gfx_size_set(73, 30));
|
||||
eo_do(screenshot_button, eo_event_callback_add(EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, screenshot_button_clicked, NULL));
|
||||
elm_icon1 = eo_add(ELM_ICON_CLASS, screenshot_button);
|
||||
eo_do(elm_icon1, evas_obj_size_hint_weight_set(1.000000, 1.000000));
|
||||
eo_do(elm_icon1, efl_gfx_visible_set(EINA_TRUE));
|
||||
eo_do(elm_icon1, efl_gfx_size_set(40, 40));
|
||||
eo_do(elm_icon1, efl_file_set(SCREENSHOT_ICON, NULL));
|
||||
eo_do(screenshot_button, elm_obj_container_content_set("icon", elm_icon1));
|
||||
eo_do(screenshot_button, eo_event_callback_add(EO_BASE_EVENT_DEL, _pubs_free_cb, pub_widgets));
|
||||
|
||||
return pub_widgets;
|
||||
}
|
||||
|
||||
Gui_Widgets *gui_gui_get()
|
||||
{
|
||||
static Eina_Bool initialized = EINA_FALSE;
|
||||
|
|
|
@ -34,6 +34,12 @@ typedef struct
|
|||
} Gui_New_Profile_Win_Widgets;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Eo *screenshot_button;
|
||||
} Gui_Screenshot_Button_Widgets;
|
||||
|
||||
|
||||
typedef struct {
|
||||
Gui_Main_Win_Widgets *main_win;
|
||||
} Gui_Widgets;
|
||||
|
@ -44,5 +50,7 @@ Gui_Profiles_Win_Widgets *gui_profiles_win_create(Eo *parent);
|
|||
|
||||
Gui_New_Profile_Win_Widgets *gui_new_profile_win_create(Eo *parent);
|
||||
|
||||
Gui_Screenshot_Button_Widgets *gui_screenshot_button_create(Eo *parent);
|
||||
|
||||
Gui_Widgets *gui_gui_get();
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue