Fix for recent gadget api changes
Also use "new style" dialog done with ctxpopup
This commit is contained in:
parent
eda7aef670
commit
381121b45d
|
@ -477,6 +477,83 @@ edgar_theme_object_set(Edgar_Py_Gadget *gadget, Evas_Object *obj, const char *gr
|
|||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
edgar_show_gadget_info(Edgar_Py_Gadget *gadget)
|
||||
{
|
||||
Evas_Object *popup, *table, *icon, *entry;
|
||||
Eina_Strbuf *strbuf;
|
||||
PyObject *attr;
|
||||
|
||||
// build the text
|
||||
strbuf = eina_strbuf_new();
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_name__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, "<title>%s</title>",
|
||||
PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_vers__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, " v%s", PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_auth__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, "<br>Author: %s", PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_mail__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, "<br>Contact: %s", PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_desc__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, "<br><br>%s", PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
|
||||
// popup
|
||||
popup = elm_popup_add(e_comp->elm);
|
||||
E_EXPAND(popup);
|
||||
evas_object_layer_set(popup, E_LAYER_POPUP);
|
||||
elm_popup_allow_events_set(popup, EINA_TRUE);
|
||||
elm_popup_scrollable_set(popup, EINA_FALSE);
|
||||
|
||||
table = elm_table_add(popup);
|
||||
elm_table_padding_set(table, 10 * e_scale, 0);
|
||||
E_EXPAND(table);
|
||||
evas_object_show(table);
|
||||
elm_object_content_set(popup, table);
|
||||
|
||||
// icon
|
||||
icon = edje_object_add(evas_object_evas_get(table));
|
||||
edgar_theme_object_set(gadget, icon, "icon");
|
||||
evas_object_size_hint_min_set(icon, 64 * e_scale, 64 * e_scale);
|
||||
elm_table_pack(table, icon, 0, 0, 1, 1);
|
||||
evas_object_show(icon);
|
||||
|
||||
// text
|
||||
entry = elm_entry_add(table);
|
||||
elm_entry_editable_set(entry, EINA_FALSE);
|
||||
elm_object_text_set(entry, eina_strbuf_string_get(strbuf));
|
||||
E_EXPAND(entry); E_FILL(entry);
|
||||
elm_table_pack(table, entry, 1, 0, 1, 1);
|
||||
evas_object_show(entry);
|
||||
|
||||
// show the popup
|
||||
E_Zone *zone = e_zone_current_get();
|
||||
popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE);
|
||||
evas_object_layer_set(popup, E_LAYER_POPUP);
|
||||
evas_object_move(popup, zone->x, zone->y);
|
||||
evas_object_resize(popup, zone->w / 3, zone->h / 3);
|
||||
e_comp_object_util_center(popup);
|
||||
evas_object_show(popup);
|
||||
e_comp_object_util_autoclose(popup, NULL, e_comp_object_util_autoclose_on_escape, NULL);
|
||||
|
||||
eina_strbuf_free(strbuf);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/***** Gadcon (old) Popup *************************************************/
|
||||
|
@ -546,83 +623,7 @@ edgar_popup_new(Edgar_Py_Gadget *gadget, E_Gadcon_Client *gcc)
|
|||
static void
|
||||
edgar_menu_info_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
{
|
||||
Edgar_Py_Gadget *gadget = data;
|
||||
Evas_Object *hbox, *tb, *icon, *img;
|
||||
Eina_Strbuf *strbuf;
|
||||
Evas_Coord w, h;
|
||||
PyObject *attr;
|
||||
E_Dialog *dia;
|
||||
|
||||
// build the text
|
||||
strbuf = eina_strbuf_new();
|
||||
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_name__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, "<title>%s</title>",
|
||||
PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_vers__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, " v%s", PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_auth__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, "<br>Author: %s", PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_mail__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, "<br>Contact: %s", PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_desc__")))
|
||||
{
|
||||
eina_strbuf_append_printf(strbuf, "<br><br>%s", PyString_AsString(attr));
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
|
||||
// dialog
|
||||
#if E_VERSION_MAJOR >= 19
|
||||
dia = e_dialog_new(NULL, "gadget_info", "class");
|
||||
#else
|
||||
E_Container *con = e_container_current_get(e_manager_current_get());
|
||||
dia = e_dialog_new(con, "gadget_info", "class");
|
||||
#endif
|
||||
|
||||
e_dialog_resizable_set(dia, 1);
|
||||
e_dialog_title_set(dia, "Gadget info");
|
||||
e_dialog_button_add(dia, "Close", NULL, NULL, NULL);
|
||||
|
||||
#if E_VERSION_MAJOR >= 20
|
||||
Evas *evas = evas_object_evas_get(dia->win);
|
||||
#else
|
||||
Evas *evas = dia->win->evas;
|
||||
#endif
|
||||
|
||||
// hbox
|
||||
hbox = e_widget_list_add(evas, 0, 1);
|
||||
|
||||
// icon
|
||||
icon = edje_object_add(evas);
|
||||
edgar_theme_object_set(gadget, icon, "icon");
|
||||
img = e_widget_image_add_from_object(evas, icon,
|
||||
70 * e_scale, 70 * e_scale);
|
||||
e_widget_list_object_append(hbox, img, 1, 0, 0.0);
|
||||
|
||||
// text
|
||||
tb = e_widget_textblock_add(evas);
|
||||
e_widget_textblock_markup_set(tb, eina_strbuf_string_get(strbuf));
|
||||
e_widget_size_min_set(tb, 250 * e_scale, 100 * e_scale);
|
||||
e_widget_list_object_append(hbox, tb, 1, 1, 0.0);
|
||||
|
||||
// resize & show the dialog
|
||||
e_widget_size_min_get(hbox, &w, &h);
|
||||
e_dialog_content_set(dia, hbox, w, h);
|
||||
e_dialog_show(dia);
|
||||
|
||||
eina_strbuf_free(strbuf);
|
||||
edgar_show_gadget_info(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -750,19 +751,24 @@ edgar_bryce_popup_del(Edgar_Py_Gadget *gadget, Evas_Object *ctxpopup)
|
|||
/***** Gadget/Bryce Menu *************************************************/
|
||||
/*****************************************************************************/
|
||||
static void
|
||||
edgar_bryce_menu_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
edgar_bryce_menu_info_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
{
|
||||
Edgar_Py_Gadget *gadget = data;
|
||||
E_Menu *m = event_info;
|
||||
edgar_show_gadget_info(data);
|
||||
}
|
||||
|
||||
static void
|
||||
edgar_bryce_menu_cb(Evas_Object *gadget_obj, E_Menu *m)
|
||||
{
|
||||
Edgar_Py_Gadget *gadget = evas_object_data_get(gadget_obj, "edgar-gadget");
|
||||
E_Menu_Item *mi;
|
||||
|
||||
DBG("EDGAR: Bryce menu for gadget:%s", gadget->name);
|
||||
e_menu_title_set(m, gadget->label);
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_separator_set(mi, 1);
|
||||
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_label_set(mi, "Gadget info");
|
||||
e_util_menu_item_theme_icon_set(mi, "help-about");
|
||||
e_menu_item_callback_set(mi, edgar_menu_info_cb, gadget);
|
||||
e_menu_item_callback_set(mi, edgar_bryce_menu_info_cb, gadget);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -783,13 +789,15 @@ edgar_bryce_mouse_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj,
|
|||
else if ((ctxpopup = edgar_bryce_popup_new(gadget, obj)))
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
}
|
||||
else if (ev->button == 3) // right button (TODO)
|
||||
{
|
||||
// e_gadget_configure(inst->o_clock);
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
}
|
||||
}
|
||||
|
||||
//static Evas_Object *
|
||||
//edgar_bryce_configure_cb(Evas_Object *gadget_obj)
|
||||
//{
|
||||
//Edgar_Py_Gadget *gadget = evas_object_data_get(gadget_obj, "edgar-gadget");
|
||||
//DBG("EDGAR: Bryce configure for gadget: %s", gadget->name);
|
||||
//return NULL;
|
||||
//}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***** Gadget/Bryce IFace *************************************************/
|
||||
|
@ -828,6 +836,21 @@ edgar_bryce_delete_cb(void *data, const Efl_Event *event)
|
|||
Py_XDECREF(pyobj);
|
||||
}
|
||||
|
||||
static void
|
||||
_edgar_bryce_created_cb(void *data, Evas_Object *obj, void *event_data)
|
||||
{
|
||||
Edgar_Py_Gadget *gadget = data;
|
||||
Evas_Object *gadget_obj = event_data;
|
||||
|
||||
evas_object_smart_callback_del_full(obj, "gadget_created",
|
||||
_edgar_bryce_created_cb, data);
|
||||
|
||||
//e_gadget_configure_cb_set(gadget_obj, edgar_bryce_configure_cb);
|
||||
e_gadget_menu_populate_cb_set(gadget_obj, edgar_bryce_menu_cb);
|
||||
evas_object_event_callback_add(gadget_obj, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
edgar_bryce_mouse_down_cb, gadget);
|
||||
}
|
||||
|
||||
EINTERN Evas_Object *
|
||||
edgar_bryce_create_cb(Evas_Object *parent, const char *type, int *id, E_Gadget_Site_Orient orient)
|
||||
{
|
||||
|
@ -881,14 +904,12 @@ edgar_bryce_create_cb(Evas_Object *parent, const char *type, int *id, E_Gadget_S
|
|||
obj = edgar_request_popup_content(gadget, parent);
|
||||
if (!obj) return NULL;
|
||||
}
|
||||
|
||||
|
||||
evas_object_data_set(obj, "edgar-gadget", gadget);
|
||||
evas_object_data_set(obj, "edgar-pop-on-desk", (void*)(uintptr_t)pop_on_desk);
|
||||
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
edgar_bryce_mouse_down_cb, gadget);
|
||||
evas_object_smart_callback_add(obj, "gadget_menu",
|
||||
edgar_bryce_menu_cb, gadget);
|
||||
evas_object_smart_callback_add(parent, "gadget_created",
|
||||
_edgar_bryce_created_cb, gadget);
|
||||
|
||||
|
||||
// keep track of this instance lifetime (I would have really preferred an explicit callback here!!)
|
||||
// NOTE: del cb with priority to be called before the python-efl one.
|
||||
// Otherwise python-efl delete the python obj too soon.
|
||||
|
|
Loading…
Reference in New Issue