Evas_Object *ilist, *button;
Evas_Object *renable, *rdisable;
Evas_Object *c1, *c2, *c3;
+ Eina_List *disable_list;
} gui;
};
*
* These can/should be changed to "official" key/names
*/
-const CFColor_Hash _wm_hash[] =
+static const CFColor_Hash _wm_hash[] =
{
{NULL, N_("Window Manager")},
{"about_title", N_("About Dialog Title")},
{NULL, NULL}
};
-const CFColor_Hash _wid_hash[] =
+static const CFColor_Hash _wid_hash[] =
{
{NULL, N_("Widgets")},
{"button_text", N_("Button Text")},
{NULL, NULL}
};
-const CFColor_Hash _mod_hash[] =
+xxx todo fix this crap design xxxx
+
+static const CFColor_Hash _mod_hash[] =
{
{NULL, N_("Modules")},
{"module_label", N_("Module Label")},
{NULL, NULL}
};
-Eina_List *color_classes;
+static Eina_List *color_classes;
static void *_create_data (E_Config_Dialog *cfd);
static void _free_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static void _fill_data_basic (E_Config_Dialog_Data *cfdata);
static void _load_color_classes (Evas_Object *obj, E_Config_Dialog_Data *cfdata);
-static void _radio_cb_change (void *data, Evas_Object *obj, void *event_info);
static void _list_cb_change (void *data, Evas_Object *obj);
static void _update_colors (E_Config_Dialog_Data *cfdata, CFColor_Class *cc);
static void _color1_cb_change (void *data, Evas_Object *obj);
cfdata->classes = eina_list_remove_list(cfdata->classes, cfdata->classes);
}
+ eina_list_free(cfdata->gui.disable_list);
E_FREE(cfdata->color1);
E_FREE(cfdata->color2);
E_FREE(cfdata->color3);
static Evas_Object *
_adv_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
- Evas_Object *o, *of, *ob, *ot;
- E_Radio_Group *rg;
-
- o = e_widget_list_add(evas, 0, 1);
+ Evas_Object *o, *ob, *ot;
+ Evas_Coord mw, mh;
+ char buf[1024];
+
+ o = e_widget_list_add(evas, 0, 0);
- of = e_widget_framelist_add(evas, _("Color Classes"), 0);
- e_widget_framelist_content_align_set(of, 0.0, 0.0);
ob = e_widget_ilist_add(evas, 16, 16, NULL);
e_widget_ilist_selector_set(ob, 1);
cfdata->gui.ilist = ob;
e_widget_on_change_hook_set(ob, _list_cb_change, cfdata);
_load_color_classes(ob, cfdata);
- e_widget_framelist_object_append(of, ob);
- e_widget_list_object_append(o, of, 1, 1, 0.5);
+ e_widget_list_object_append(o, ob, 1, 1, 0.5);
- /* Pack the right side frames into a table for resizing*/
- ot = e_widget_table_add(evas, 0);
-
- of = e_widget_framelist_add(evas, _("State"), 0);
- e_widget_framelist_content_align_set(of, 0.0, 0.0);
- rg = e_widget_radio_group_new(&(cfdata->state));
- ob = e_widget_radio_add(evas, _("Enabled"), 1, rg);
+ snprintf(buf, sizeof(buf), _("Color settings: %s"), "");
+ ot = e_widget_frametable_add(evas, buf, 0);
+
+ cfdata->state = 0;
+ ob = e_widget_check_add(evas, _("Custom colors"), &(cfdata->state));
cfdata->gui.renable = ob;
- e_widget_disabled_set(ob, 1);
- evas_object_smart_callback_add(ob, "changed", _radio_cb_change, cfdata);
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_radio_add(evas, _("Disabled"), 0, rg);
- cfdata->gui.rdisable = ob;
- e_widget_disabled_set(ob, 1);
- evas_object_smart_callback_add(ob, "changed", _radio_cb_change, cfdata);
- e_widget_framelist_object_append(of, ob);
- e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 0, 1, 0);
+ e_widget_on_change_hook_set(ob, _custom_color_cb_change, cfdata);
+ e_widget_size_min_get(ob, &mw, &mh);
+ e_widget_frametable_object_append_full
+ (ot, ob, 0, 0, 2, 1, 1, 0, 1, 0, 0.0, 0.0, mw, mh, 9999, 9999);
+
+ ob = e_widget_label_add(evas, _("Object:"));
+ cfdata->gui.disable_list = eina_list_append(cfdata->disable_list, ob);
+ e_widget_size_min_get(ob, &mw, &mh);
+ e_widget_frametable_object_append_full
+ (ot, ob, 0, 1, 1, 1, 0, 0, 0, 0, 1.0, 0.0, mw, mh, 9999, 9999);
- of = e_widget_framelist_add(evas, _("Object Color"), 0);
- e_widget_framelist_content_align_set(of, 0.0, 0.0);
ob = e_widget_color_well_add(evas, cfdata->color1, 1);
+ cfdata->gui.disable_list = eina_list_append(cfdata->disable_list, ob);
cfdata->gui.c1 = ob;
e_widget_on_change_hook_set(ob, _color1_cb_change, cfdata);
- e_widget_disabled_set(ob, 1);
- e_widget_framelist_object_append(of, ob);
- e_widget_table_object_append(ot, of, 0, 1, 1, 1, 1, 1, 1, 1);
+ e_widget_size_min_get(ob, &mw, &mh);
+ if (mw < 16 * e_scale) mw = 16 * e_scale;
+ if (mh < 16 * e_scale) mh = 16 * e_scale;
+ e_widget_frametable_object_append_full
+ (ot, ob, 0, 1, 1, 1, 0, 0, 0, 0, 1.0, 0.0, mw, mh, 9999, 9999);
+
+ ob = e_widget_label_add(evas, _("Outline:"));
+ cfdata->gui.disable_list = eina_list_append(cfdata->disable_list, ob);
+ e_widget_size_min_get(ob, &mw, &mh);
+ e_widget_frametable_object_append_full
+ (ot, ob, 0, 2, 1, 1, 0, 0, 0, 0, 1.0, 0.0, mw, mh, 9999, 9999);
- of = e_widget_framelist_add(evas, _("Outline Color"), 0);
- e_widget_framelist_content_align_set(of, 0.0, 0.0);
ob = e_widget_color_well_add(evas, cfdata->color2, 1);
+ cfdata->gui.disable_list = eina_list_append(cfdata->disable_list, ob);
cfdata->gui.c2 = ob;
e_widget_on_change_hook_set(ob, _color2_cb_change, cfdata);
- e_widget_disabled_set(ob, 1);
- e_widget_framelist_object_append(of, ob);
- e_widget_table_object_append(ot, of, 0, 2, 1, 1, 1, 1, 1, 1);
+ e_widget_size_min_get(ob, &mw, &mh);
+ if (mw < 16 * e_scale) mw = 16 * e_scale;
+ if (mh < 16 * e_scale) mh = 16 * e_scale;
+ e_widget_frametable_object_append_full
+ (ot, ob, 0, 2, 1, 1, 0, 0, 0, 0, 1.0, 0.0, mw, mh, 9999, 9999);
+
+ ob = e_widget_label_add(evas, _("Shadow:"));
+ cfdata->gui.disable_list = eina_list_append(cfdata->disable_list, ob);
+ e_widget_size_min_get(ob, &mw, &mh);
+ e_widget_frametable_object_append_full
+ (ot, ob, 0, 3, 1, 1, 0, 0, 0, 0, 1.0, 0.0, mw, mh, 9999, 9999);
- of = e_widget_framelist_add(evas, _("Shadow Color"), 0);
- e_widget_framelist_content_align_set(of, 0.0, 0.0);
ob = e_widget_color_well_add(evas, cfdata->color3, 1);
+ cfdata->gui.disable_list = eina_list_append(cfdata->disable_list, ob);
cfdata->gui.c3 = ob;
e_widget_on_change_hook_set(ob, _color3_cb_change, cfdata);
- e_widget_disabled_set(ob, 1);
- e_widget_framelist_object_append(of, ob);
- e_widget_table_object_append(ot, of, 0, 3, 1, 1, 1, 1, 1, 1);
-
- ob = e_widget_button_add(evas, _("Defaults"), NULL,
- _button_cb, cfdata, NULL);
+ e_widget_size_min_get(ob, &mw, &mh);
+ if (mw < 16 * e_scale) mw = 16 * e_scale;
+ if (mh < 16 * e_scale) mh = 16 * e_scale;
+ e_widget_frametable_object_append_full
+ (ot, ob, 0, 3, 1, 1, 0, 0, 0, 0, 1.0, 0.0, mw, mh, 9999, 9999);
+
+ ob = e_widget_button_add
+ (evas, _("Defaults"), NULL, _button_cb, cfdata, NULL);
+ cfdata->gui.disable_list = eina_list_append(cfdata->disable_list, ob);
cfdata->gui.button = ob;
- e_widget_disabled_set(ob, 1);
- e_widget_table_object_append(ot, ob, 0, 4, 1, 1, 0, 0, 0, 0);
-
- e_widget_list_object_append(o, ot, 1, 1, 0.5);
+ e_widget_frametable_object_append_full
+ (ot, ob, 0, 4, 2, 1, 0, 0, 0, 0, 1.0, 0.0, mw, mh, 9999, 9999);
+
+ _custom_color_cb_change(cfdata, NULL);
+
e_dialog_resizable_set(cfd->dia, 1);
return o;
}
extern const char _e_connman_Name[];
+extern const char *e_str_enabled;
+extern const char *e_str_available;
+extern const char *e_str_connected;
+extern const char *e_str_offline;
+
struct connman_config_technologies
{
EINA_INLIST;
Evas_Object *obj;
E_Connman_Technology *technology;
- int val;
+ int enabled;
};
struct _E_Config_Dialog_Data
struct _connman_technology_onoff_data
{
- const char *name;
+ const char *type;
E_Connman_Module_Context *ctxt;
bool on;
};
dbus_error_free(error);
}
else
- {
- /* TODO: update config dialog */
- E_Connman_Technology *t;
- t = _connman_technology_find(d->ctxt, d->name);
- if (t)
- {
- t->enabled = d->on;
- DBG("Technology %s has been %s.", d->name, d->on?"enabled":"disabled");
- }
- else
- WRN("Technology does not exist anymore: %s.", d->name);
- }
+ DBG("Technology %s has been %s.", d->type, d->on?"enabled":"disabled");
- eina_stringshare_del(d->name);
+ eina_stringshare_del(d->type);
E_FREE(d);
}
static void
-_connman_technology_onoff(E_Connman_Module_Context *ctxt, const char *technology, bool on)
+_connman_technology_onoff(E_Connman_Module_Context *ctxt, const char *type, bool on)
{
int ret;
struct _connman_technology_onoff_data *d;
return;
}
- d->name = eina_stringshare_add(technology);
+ d->type = eina_stringshare_add(type);
d->ctxt = ctxt;
d->on = on;
if(on)
- ret = e_connman_manager_technology_enable(technology, _connman_technology_onoff_cb, d);
+ ret = e_connman_manager_technology_enable(type, _connman_technology_onoff_cb, d);
else
- ret = e_connman_manager_technology_disable(technology, _connman_technology_onoff_cb, d);
+ ret = e_connman_manager_technology_disable(type, _connman_technology_onoff_cb, d);
if(!ret)
{
- eina_stringshare_del(d->name);
+ eina_stringshare_del(type);
E_FREE(d);
}
return;
- }
+}
E_Config_Dialog *
e_connman_config_dialog_new(E_Container *con, E_Connman_Module_Context *ctxt)
{
struct connman_config_technologies *t_list = E_NEW(struct connman_config_technologies, 1);
t_list->technology = t;
- t_list->val = t->enabled;
- t_list->obj = e_widget_check_add(evas, _(t->name), &t_list->val);
+ t_list->enabled = ((t->state == e_str_enabled) || (t->state == e_str_connected));
+ t_list->obj = e_widget_check_add(evas, _(t->name), &t_list->enabled);
ui->technologies = eina_inlist_append(ui->technologies, EINA_INLIST_GET(t_list));
e_widget_framelist_object_append(ui->type_frame, t_list->obj);
EINA_INLIST_FOREACH(sw->technologies, t)
{
- if (t->val != t->technology->enabled)
- _connman_technology_onoff(ctxt, t->technology->name, t->val);
+ int was_enabled = ((t->technology->state == e_str_enabled) || (t->technology->state == e_str_connected));
+ if (t->enabled != was_enabled)
+ _connman_technology_onoff(ctxt, t->technology->type, t->enabled);
}
if (ctxt->offline_mode != sw->offline_mode)
_connman_toggle_offline_mode(ctxt);
static const char *e_str_disconnect = NULL;
static const char *e_str_failure = NULL;
-static struct _Connman_Technologies_Names
-{
- const char **names;
- unsigned int count;
-} _connman_enabled_technologies = {
- NULL,
- 0
-};
+const char *e_str_enabled = NULL;
+const char *e_str_available = NULL;
+const char *e_str_connected = NULL;
+const char *e_str_offline = NULL;
static void _connman_service_ask_pass_and_connect(E_Connman_Service *service);
static void _connman_default_service_changed_delayed(E_Connman_Module_Context *ctxt);
return service;
}
+
+#define GSTR(name_, getter) \
+ str = NULL; \
+ if (!getter(element, &str)) \
+ str = NULL; \
+ eina_stringshare_replace(&t->name_, str)
+
+static void
+_connman_technology_free(E_Connman_Technology *t)
+{
+ eina_stringshare_del(t->path);
+ eina_stringshare_del(t->name);
+ eina_stringshare_del(t->type);
+ eina_stringshare_del(t->state);
+
+ E_FREE(t);
+}
+
+static void
+_connman_technology_changed(void *data, const E_Connman_Element *element)
+{
+ E_Connman_Technology *t = data;
+ const char *str;
+
+ GSTR(name, e_connman_technology_name_get);
+ GSTR(type, e_connman_technology_type_get);
+ GSTR(state, e_connman_technology_state_get);
+}
+
+static void
+_connman_technology_freed(void *data)
+{
+ E_Connman_Technology *t = data;
+ E_Connman_Module_Context *ctxt = t->ctxt;
+
+ ctxt->technologies = eina_inlist_remove
+ (ctxt->technologies, EINA_INLIST_GET(t));
+
+ _connman_technology_free(t);
+}
+
+static E_Connman_Technology *
+_connman_technology_new(E_Connman_Module_Context *ctxt, E_Connman_Element *element)
+{
+ E_Connman_Technology *t;
+ const char *str;
+
+ if (!element)
+ return NULL;
+
+ t = E_NEW(E_Connman_Technology, 1);
+ if (!t)
+ return NULL;
+
+ t->ctxt = ctxt;
+ t->element = element;
+ t->path = eina_stringshare_add(element->path);
+
+ GSTR(name, e_connman_technology_name_get);
+ GSTR(type, e_connman_technology_type_get);
+ GSTR(state, e_connman_technology_state_get);
+
+ e_connman_element_listener_add
+ (element, _connman_technology_changed, t,
+ _connman_technology_freed);
+
+ return t;
+}
+#undef GSTR
+
static void
_connman_service_disconnect_cb(void *data, DBusMessage *msg __UNUSED__, DBusError *error)
{
}
}
-E_Connman_Technology *
-_connman_technology_find(E_Connman_Module_Context *ctxt, const char* name)
-{
- E_Connman_Technology *t;
-
- EINA_INLIST_FOREACH(ctxt->technologies, t)
- {
- if (!strcmp(t->name, name))
- return t;
- }
-
- return NULL;
-}
-
static inline Eina_Bool
_connman_services_element_exists(const E_Connman_Module_Context *ctxt, const E_Connman_Element *element)
{
}
static inline Eina_Bool
-_connman_technology_exists(const E_Connman_Module_Context *ctxt, const char* name)
+_connman_technologies_element_exists(const E_Connman_Module_Context *ctxt, const E_Connman_Element *element)
{
const E_Connman_Technology *t;
EINA_INLIST_FOREACH(ctxt->technologies, t)
{
- if (t->name == name)
+ if (t->path == element->path)
return EINA_TRUE;
}
return EINA_FALSE;
}
-static inline int
-_connman_technologies_enabled_update()
-{
- int ret;
- if (_connman_enabled_technologies.names)
- free(_connman_enabled_technologies.names);
-
- ret = e_connman_manager_technologies_enabled_get
- (&_connman_enabled_technologies.count, &_connman_enabled_technologies.names);
- if (!ret)
- {
- WRN("Failed to query enabled technologies.");
- return 0;
- }
- return 1;
-}
-
-static inline int
-_connman_technology_enabled(const char *type)
-{
- unsigned int i;
- if (!_connman_enabled_technologies.names && !_connman_technologies_enabled_update())
- return 0;
- DBG("%d technologies enabled.", _connman_enabled_technologies.count);
-
- for (i = 0; i < _connman_enabled_technologies.count; i++)
- {
- if(!strcmp(type, _connman_enabled_technologies.names[i]))
- {
- DBG("Technology %s is enabled.", type);
- return 1;
- }
-
- }
- DBG("Technology %s is disabled.", type);
- return 0;
-}
-
-static void
-_connman_technologies_free(E_Connman_Module_Context *ctxt)
-{
- while (ctxt->technologies)
- {
- E_Connman_Technology *t = (E_Connman_Technology *) ctxt->technologies;
- eina_stringshare_del(t->name);
- ctxt->technologies = eina_inlist_remove(ctxt->technologies, EINA_INLIST_GET(t));
- E_FREE(t);
- }
- if (_connman_enabled_technologies.names)
- free(_connman_enabled_technologies.names);
-}
void
_connman_request_scan_cb(void *data __UNUSED__, DBusMessage *msg __UNUSED__, DBusError *error)
{
static void
_connman_technologies_load(E_Connman_Module_Context *ctxt)
{
- const char **names;
unsigned int count, i;
+ E_Connman_Element **elements;
- if (!e_connman_manager_technologies_available_get(&count, &names))
+ if (!e_connman_manager_technologies_get(&count, &elements))
return;
- DBG("Available Technologies = %d.", count);
+ DBG("Technologies = %d.", count);
for (i = 0; i < count; i++)
{
- const char *name = eina_stringshare_add(names[i]);
+ E_Connman_Element *e = elements[i];
E_Connman_Technology *t;
- if ((name == NULL) || _connman_technology_exists(ctxt, name))
- {
- eina_stringshare_del(name);
- continue;
- }
- t = E_NEW(E_Connman_Technology, 1);
- t->name = name;
- t->enabled = _connman_technology_enabled(name);
- ctxt->technologies = eina_inlist_append(ctxt->technologies, EINA_INLIST_GET(t));
+ if ((!e) || _connman_technologies_element_exists(ctxt, e))
+ continue;
+
+ t = _connman_technology_new(ctxt, e);
+ if (!t)
+ continue;
DBG("Added technology: %s.", t->name);
+ ctxt->technologies = eina_inlist_append
+ (ctxt->technologies, EINA_INLIST_GET(t));
}
if (!e_connman_manager_request_scan("", _connman_request_scan_cb, NULL))
ERR("Request scan on all technologies failed.");
- free(names);
+
+ free(elements);
}
static void
e_str_online = eina_stringshare_add(N_("online"));
e_str_disconnect = eina_stringshare_add(N_("disconnect"));
e_str_failure = eina_stringshare_add(N_("failure"));
+ e_str_enabled = eina_stringshare_add(N_("enabled"));
+ e_str_available = eina_stringshare_add(N_("available"));
+ e_str_connected = eina_stringshare_add(N_("connected"));
+ e_str_offline = eina_stringshare_add(N_("offline"));
}
static inline void
eina_stringshare_replace(&e_str_online, NULL);
eina_stringshare_replace(&e_str_disconnect, NULL);
eina_stringshare_replace(&e_str_failure, NULL);
+ eina_stringshare_replace(&e_str_enabled, NULL);
+ eina_stringshare_replace(&e_str_available, NULL);
+ eina_stringshare_replace(&e_str_connected, NULL);
+ eina_stringshare_replace(&e_str_offline, NULL);
}
EAPI void *