static Evas_Object * _e_util_icon_add(const char *path, Evas *evas, int size) { Evas_Object *o = NULL; const char *ext; if (!path) return NULL; if (!ecore_file_exists(path)) return NULL; o = e_icon_add(evas); e_icon_scale_size_set(o, size); e_icon_preload_set(o, 1); ext = strrchr(path, '.'); if (ext) { if (!strcmp(ext, ".edj")) e_icon_file_edje_set(o, path, "icon"); else e_icon_file_set(o, path); } else e_icon_file_set(o, path); e_icon_fill_inside_set(o, 1); return o; }
void news_config_dialog_item_content_refresh_selected_feeds(News_Item *ni) { E_Config_Dialog_Data *cfdata; Evas_Object *ilist; int pos, iw, ih; if (!ni->config_dialog_content) return; cfdata = ni->config_dialog_content->cfdata; ilist = cfdata->ilist_selected_feeds; e_widget_ilist_freeze(ilist); /* disable the callback until we finish to refresh the list */ e_widget_on_change_hook_set(ilist, NULL, NULL); e_widget_ilist_clear(ilist); if (cfdata->button_rem) { e_widget_disabled_set(cfdata->button_rem, 1); e_widget_disabled_set(cfdata->button_up, 1); e_widget_disabled_set(cfdata->button_down, 1); } cfdata->ilist_selected_feeds_inrefresh = 1; pos = -1; NEWS_ITEM_FEEDS_FOREACH_BEG(ni); { Evas_Object *ic = NULL; char buf[1024]; if (_feed->icon && _feed->icon[0]) { ic = e_icon_add(evas_object_evas_get(ilist)); e_icon_file_set(ic, _feed->icon); } snprintf(buf, sizeof(buf), "%s%s", (_feed->important) ? "[i] " : "", _feed->name); e_widget_ilist_append(ilist, ic, buf, NULL, _feed, NULL); pos++; if (eina_list_data_find(cfdata->ilist_selected_feeds_sel, _feed)) e_widget_ilist_multi_select(ilist, pos); } NEWS_ITEM_FEEDS_FOREACH_END(); cfdata->ilist_selected_feeds_inrefresh = 0; e_widget_size_min_get(ilist, &iw, &ih); if (iw < 200) iw = 200; e_widget_size_min_set(ilist, iw, 250); e_widget_ilist_go(ilist); e_widget_ilist_thaw(ilist); _cb_selected_feed_change(cfdata, NULL); /* restore the callback */ e_widget_on_change_hook_set(ilist, _cb_selected_feed_change, cfdata); }
/* externally accessible functions */ EAPI Evas_Object * e_widget_button_add(Evas *evas, const char *label, const char *icon, void (*func) (void *data, void *data2), void *data, void *data2) { Evas_Object *obj, *o; E_Widget_Data *wd; Evas_Coord mw, mh; obj = e_widget_add(evas); e_widget_del_hook_set(obj, _e_wid_del_hook); e_widget_focus_hook_set(obj, _e_wid_focus_hook); e_widget_activate_hook_set(obj, _e_wid_activate_hook); e_widget_disable_hook_set(obj, _e_wid_disable_hook); wd = calloc(1, sizeof(E_Widget_Data)); wd->func = func; wd->data = data; wd->data2 = data2; e_widget_data_set(obj, wd); o = edje_object_add(evas); wd->o_button = o; e_theme_edje_object_set(o, "base/theme/widgets", "e/widgets/button"); edje_object_signal_callback_add(o, "e,action,click", "", _e_wid_signal_cb1, obj); if ((label) && (label[0] != 0)) { edje_object_part_text_set(o, "e.text.label", label); wd->type |= E_WIDGET_BUTTON_TEXT; } e_widget_sub_object_add(obj, o); evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj); e_widget_resize_object_set(obj, o); evas_object_show(o); if (icon) { o = e_icon_add(evas); wd->o_icon = o; e_util_icon_theme_set(o, icon); edje_object_part_swallow(wd->o_button, "e.swallow.icon", o); e_widget_sub_object_add(obj, o); evas_object_show(o); wd->type |= E_WIDGET_BUTTON_ICON; } _e_wid_button_state_send(wd); edje_object_size_min_calc(wd->o_button, &mw, &mh); e_widget_size_min_set(obj, mw, mh); return obj; }
/* taken from e_int_menus */ static void _itask_menu_icon_cb(void *data, E_Menu *m, E_Menu_Item *mi) { E_Border *bd; Evas_Object *o; bd = data; E_OBJECT_CHECK(bd); o = e_icon_add(m->evas); e_icon_object_set(o, e_border_icon_add(bd, m->evas)); mi->icon_object = o; }
E_API int e_widget_preview_file_set(Evas_Object *obj, const char *file, const char *key) { E_Widget_Data *wd; wd = e_widget_data_get(obj); if (wd->o_thumb) evas_object_del(wd->o_thumb); wd->o_thumb = e_icon_add(e_livethumb_evas_get(wd->img)); e_icon_fill_inside_set(wd->o_thumb, 0); e_icon_file_key_set(wd->o_thumb, file, key); evas_object_show(wd->o_thumb); e_livethumb_thumb_set(wd->img, wd->o_thumb); e_widget_change(obj); return 1; }
int e_syscon_show(E_Zone *zone, const char *defact) { Evas_Object *o, *o2; Evas_Coord mw, mh; int x, y, w, h, zx, zy, zw, zh; int iw, ih; Eina_List *l; double t; t = ecore_loop_time_get(); if (popup) { if ((t - show_time) > 0.5) { for (l = e_config->syscon.actions; l; l = l->next) { E_Config_Syscon_Action *sca; E_Action *a; if (!(sca = l->data)) continue; if (!sca->action) continue; a = e_action_find(sca->action); if (!a) continue; if (sca->is_main == 2) { a->func.go(NULL, sca->params); e_syscon_hide(); break; } } } return 0; } input_window = ecore_x_window_input_new(zone->container->win, zone->x, zone->y, zone->w, zone->h); ecore_x_window_show(input_window); if (!e_grabinput_get(input_window, 1, input_window)) { ecore_x_window_free(input_window); input_window = 0; return 0; } popup = e_popup_new(zone, 0, 0, 1, 1); if (!popup) { e_grabinput_release(input_window, input_window); ecore_x_window_free(input_window); input_window = 0; return 0; } evas_event_freeze(popup->evas); e_popup_layer_set(popup, E_LAYER_POPUP); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _cb_key_down, NULL)); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_MOUSE_BUTTON_DOWN, _cb_mouse_down, NULL)); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_MOUSE_BUTTON_UP, _cb_mouse_up, NULL)); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_MOUSE_MOVE, _cb_mouse_move, NULL)); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_MOUSE_WHEEL, _cb_mouse_wheel, NULL)); o = edje_object_add(popup->evas); o_bg = o; e_theme_edje_object_set(o, "base/theme/syscon", "e/widgets/syscon/main"); edje_object_part_text_set(o, "e.text.label", _("Cancel")); edje_object_signal_callback_add(o, "e,action,close", "", _cb_signal_close, NULL); edje_object_signal_callback_add(o, "e,action,syscon", "*", _cb_signal_syscon, NULL); act_count = 0; show_time = t; // main (default): // halt | suspend | desk_lock // secondary (default): // reboot | hibernate | logout // extra (example for illume): // home | close | kill o = e_flowlayout_add(popup->evas); o_flow_main = o; e_flowlayout_orientation_set(o, 1); e_flowlayout_flowdirection_set(o, 1, 1); e_flowlayout_homogenous_set(o, 1); o = e_flowlayout_add(popup->evas); o_flow_secondary = o; e_flowlayout_orientation_set(o, 1); e_flowlayout_flowdirection_set(o, 1, 1); e_flowlayout_homogenous_set(o, 1); o = e_flowlayout_add(popup->evas); o_flow_extra = o; e_flowlayout_orientation_set(o, 1); e_flowlayout_flowdirection_set(o, 1, 1); e_flowlayout_homogenous_set(o, 1); for (l = e_config->syscon.actions; l; l = l->next) { E_Config_Syscon_Action *sca; char buf[1024]; E_Action *a; int disabled; if (!(sca = l->data)) continue; if (!sca->action) continue; a = e_action_find(sca->action); if (!a) continue; disabled = 0; if ((!strcmp(sca->action, "logout")) && (!e_sys_action_possible_get(E_SYS_LOGOUT))) disabled = 1; else if ((!strcmp(sca->action, "halt")) && (!e_sys_action_possible_get(E_SYS_HALT))) disabled = 1; else if ((!strcmp(sca->action, "halt_now")) && (!e_sys_action_possible_get(E_SYS_HALT_NOW))) disabled = 1; else if ((!strcmp(sca->action, "reboot")) && (!e_sys_action_possible_get(E_SYS_REBOOT))) disabled = 1; else if ((!strcmp(sca->action, "suspend")) && (!e_sys_action_possible_get(E_SYS_SUSPEND))) disabled = 1; else if ((!strcmp(sca->action, "hibernate")) && (!e_sys_action_possible_get(E_SYS_HIBERNATE))) disabled = 1; o = edje_object_add(popup->evas); edje_object_signal_callback_add(o, "e,action,click", "", _cb_signal_action, sca); if (sca->button) { snprintf(buf, sizeof(buf), "e/widgets/syscon/item/%s", sca->button); e_theme_edje_object_set(o, "base/theme/widgets", buf); } else e_theme_edje_object_set(o, "base/theme/widgets", "e/widgets/syscon/item/button"); edje_object_part_text_set(o, "e.text.label", _(e_action_predef_label_get(sca->action, sca->params))); if (sca->icon) { o2 = e_icon_add(popup->evas); e_util_icon_theme_set(o2, sca->icon); edje_object_part_swallow(o, "e.swallow.icon", o2); evas_object_show(o2); if (disabled) edje_object_signal_emit(o2, "e,state,disabled", "e"); } if (disabled) edje_object_signal_emit(o, "e,state,disabled", "e"); if (sca->is_main) { e_flowlayout_pack_end(o_flow_main, o); iw = ih = e_config->syscon.main.icon_size * e_scale; } else { e_flowlayout_pack_end(o_flow_secondary, o); iw = ih = e_config->syscon.secondary.icon_size * e_scale; } edje_object_message_signal_process(o); edje_object_size_min_calc(o, &mw, &mh); if (mw > iw) iw = mw; if (mh > ih) ih = mh; e_flowlayout_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5, iw, ih, iw, ih); evas_object_show(o); } for (l = (Eina_List *)e_sys_con_extra_action_list_get(); l; l = l->next) { E_Sys_Con_Action *sca; char buf[1024]; sca = l->data; o = edje_object_add(popup->evas); edje_object_signal_callback_add(o, "e,action,click", "", _cb_signal_action_extra, sca); if (sca->button_name) { snprintf(buf, sizeof(buf), "e/widgets/syscon/item/%s", sca->button_name); e_theme_edje_object_set(o, "base/theme/widgets", buf); } else e_theme_edje_object_set(o, "base/theme/widgets", "e/widgets/syscon/item/button"); edje_object_part_text_set(o, "e.text.label", sca->label); if (sca->icon_group) { o2 = edje_object_add(popup->evas); e_util_edje_icon_set(o2, sca->icon_group); edje_object_part_swallow(o, "e.swallow.icon", o2); evas_object_show(o2); if (sca->disabled) edje_object_signal_emit(o2, "e,state,disabled", "e"); } if (sca->disabled) edje_object_signal_emit(o, "e,state,disabled", "e"); e_flowlayout_pack_end(o_flow_extra, o); iw = ih = e_config->syscon.extra.icon_size * e_scale; e_flowlayout_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5, iw, ih, iw, ih); evas_object_show(o); } e_flowlayout_fill_set(o_flow_main, 1); edje_object_part_swallow(o_bg, "e.swallow.main", o_flow_main); e_flowlayout_fill_set(o_flow_secondary, 1); edje_object_part_swallow(o_bg, "e.swallow.secondary", o_flow_secondary); e_flowlayout_fill_set(o_flow_extra, 1); edje_object_part_swallow(o_bg, "e.swallow.extra", o_flow_extra); e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh); evas_object_resize(o_bg, zw, zh); edje_object_calc_force(o_bg); e_flowlayout_size_min_get(o_flow_main, &mw, &mh); edje_extern_object_min_size_set(o_flow_main, mw, mh); edje_object_part_swallow(o_bg, "e.swallow.main", o_flow_main); e_flowlayout_size_min_get(o_flow_secondary, &mw, &mh); edje_extern_object_min_size_set(o_flow_secondary, mw, mh); edje_object_part_swallow(o_bg, "e.swallow.secondary", o_flow_secondary); e_flowlayout_size_min_get(o_flow_extra, &mw, &mh); edje_extern_object_min_size_set(o_flow_extra, mw, mh); edje_object_part_swallow(o_bg, "e.swallow.extra", o_flow_extra); edje_object_size_min_calc(o_bg, &mw, &mh); w = mw; if (w > zw) w = zw; x = zx - zone->x + (zw - w) / 2; h = mh; if (h > zh) h = zh; y = zy - zone->y + (zh - h) / 2; e_popup_move_resize(popup, x, y, w, h); evas_object_move(o_bg, 0, 0); evas_object_resize(o_bg, w, h); evas_object_show(o_bg); e_popup_edje_bg_object_set(popup, o_bg); if (e_config->syscon.do_input) { deftimer = ecore_timer_add(e_config->syscon.timeout, _cb_timeout_defaction, NULL); if (defact) do_defact = eina_stringshare_add(defact); } evas_event_thaw(popup->evas); inevas = 0; e_popup_show(popup); return 1; }
/** * Creates a check box widget with icon * * @param evas pointer * @param label the text to asign to check widget * @param icon the path to the icon file * @param icon_w the minimum wdith of the icon * @param icon_h the minumum height of the icon * @param val pointer to int where changes are stored * @return the newly created evas object */ EAPI Evas_Object * e_widget_check_icon_add(Evas *evas, const char *label, const char *icon, int icon_w, int icon_h, int *val) { Evas_Object *obj, *o, *o2; E_Widget_Data *wd; Evas_Coord mw, mh; obj = e_widget_add(evas); e_widget_del_hook_set(obj, _e_wid_del_hook); e_widget_focus_hook_set(obj, _e_wid_focus_hook); e_widget_activate_hook_set(obj, _e_wid_activate_hook); e_widget_disable_hook_set(obj, _e_wid_disable_hook); wd = calloc(1, sizeof(E_Widget_Data)); wd->valptr = val; e_widget_data_set(obj, wd); o = edje_object_add(evas); wd->o_check = o; e_theme_edje_object_set(o, "base/theme/widgets", "e/widgets/check_icon"); edje_object_signal_callback_add(o, "e,action,toggle", "*", _e_wid_signal_cb1, obj); edje_object_part_text_set(o, "e.text.label", label); evas_object_show(o); if (label) { edje_object_signal_emit(o, "e,state,labeled", "e"); edje_object_message_signal_process(o); } if (icon) { if (icon[0] == '/') { o2 = e_icon_add(evas); e_icon_file_set(o2, icon); } else { o2 = edje_object_add(evas); e_util_edje_icon_set(o2, icon); } evas_object_size_hint_min_set(o2, icon_w, icon_h); edje_object_part_swallow(wd->o_check, "e.swallow.icon", o2); evas_object_show(o2); e_widget_sub_object_add(obj, o2); wd->o_icon = o2; } edje_object_size_min_calc(o, &mw, &mh); e_widget_size_min_set(obj, mw, mh); if (wd->valptr) { if (*(wd->valptr)) edje_object_signal_emit(o, "e,state,checked", "e"); } e_widget_sub_object_add(obj, o); evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj); e_widget_resize_object_set(obj, o); return obj; }
void news_config_dialog_item_content_refresh_feeds(News_Item *ni) { E_Config_Dialog_Data *cfdata; Eina_List *l, *l2; Evas_Object *ilist; int pos; int iw, ih; if (!ni->config_dialog_content) return; cfdata = ni->config_dialog_content->cfdata; ilist = cfdata->ilist_feeds; e_widget_ilist_freeze(ilist); /* disable the callback until we finish to refresh the list */ e_widget_on_change_hook_set(ilist, NULL, NULL); e_widget_ilist_clear(ilist); if (cfdata->button_add) e_widget_disabled_set(cfdata->button_add, 1); pos = -1; for(l=news->config->feed.categories; l; l=eina_list_next(l)) { News_Feed_Category *cat; Evas_Object *iccat = NULL; cat = eina_list_data_get(l); if (!cat->feeds_visible) continue; if (cat->icon) { iccat = e_icon_add(evas_object_evas_get(ilist)); e_icon_file_set(iccat, cat->icon); } e_widget_ilist_header_append(ilist, iccat, cat->name); pos++; for(l2=cat->feeds_visible; l2; l2=eina_list_next(l2)) { Evas_Object *ic = NULL; News_Feed *f; char buf[1024]; f = eina_list_data_get(l2); if (f->icon && f->icon[0]) { ic = e_icon_add(evas_object_evas_get(ilist)); e_icon_file_set(ic, f->icon); } snprintf(buf, sizeof(buf), "%s%s", (f->important) ? "[i] " : "", f->name); e_widget_ilist_append(ilist, ic, buf, NULL, f, NULL); pos++; if (eina_list_data_find(cfdata->ilist_feeds_sel, f)) e_widget_ilist_multi_select(ilist, pos); } } e_widget_ilist_thaw(ilist); e_widget_size_min_get(ilist, &iw, &ih); if (iw < 200) iw = 200; e_widget_size_min_set(ilist, iw, 250); e_widget_ilist_go(ilist); _cb_feed_change(cfdata, NULL); /* restore the callback */ e_widget_on_change_hook_set(ilist, _cb_feed_change, cfdata); }