formatting and minor improvements.

- popup menu/settings now brings "controls" dialog

 - -Wextra cleanups

 - formatting... bad Lucas ;-)



SVN revision: 47148
This commit is contained in:
Gustavo Sverzut Barbieri 2010-03-12 00:16:21 +00:00
parent 2e246ac1be
commit 4118dd6edc
2 changed files with 431 additions and 401 deletions

View File

@ -88,8 +88,9 @@ _connman_service_move_cb(void *data, DBusMessage *msg __UNUSED__, DBusError *err
struct connman_service_move_data *d = data;
if (error && dbus_error_is_set(error))
{
ERR("%s method failed with message \'%s\'", error->name, error->message);
dbus_error_free(error);
ERR("%s method failed with message \'%s\'",
error->name, error->message);
dbus_error_free(error);
}
else
DBG("Changed service order");
@ -113,19 +114,24 @@ _connman_service_move(E_Connman_Service *service, const E_Connman_Service *servi
d->service_path = eina_stringshare_ref(service->path);
d->ctxt = service->ctxt;
DBG("Try to move %s %s %s\n", d->service_path, direction==SERVICE_MOVE_UP?"before":"after", d->service_ref_path);
DBG("Try to move %s %s %s\n", d->service_path,
(direction == SERVICE_MOVE_UP) ? "before" : "after",
d->service_ref_path);
if (direction == SERVICE_MOVE_UP)
ret = e_connman_service_move_before(service->element, d->service_ref_path, _connman_service_move_cb, d);
ret = e_connman_service_move_before
(service->element, d->service_ref_path, _connman_service_move_cb, d);
else
ret = e_connman_service_move_after(service->element, d->service_ref_path, _connman_service_move_cb, d);
ret = e_connman_service_move_after
(service->element, d->service_ref_path, _connman_service_move_cb, d);
if (!ret)
{
eina_stringshare_del(d->service_ref_path);
eina_stringshare_del(d->service_path);
E_FREE(d);
_connman_operation_error_show(_("Re-order preferred services"));
}
{
eina_stringshare_del(d->service_ref_path);
eina_stringshare_del(d->service_path);
E_FREE(d);
_connman_operation_error_show(_("Re-order preferred services"));
}
}
struct _connman_technology_onoff_data
@ -141,11 +147,12 @@ _connman_technology_onoff_cb(void *data, DBusMessage *msg __UNUSED__, DBusError
struct _connman_technology_onoff_data *d = data;
if (error && dbus_error_is_set(error))
{
ERR("%s method failed with message \'%s\'.", error->name, error->message);
dbus_error_free(error);
ERR("%s method failed with message \'%s\'.",
error->name, error->message);
dbus_error_free(error);
}
else
DBG("Technology %s has been %s.", d->type, d->on?"enabled":"disabled");
DBG("Technology %s has been %s.", d->type, d->on ? "enabled" : "disabled");
eina_stringshare_del(d->type);
E_FREE(d);
@ -160,8 +167,8 @@ _connman_technology_onoff(E_Connman_Module_Context *ctxt, const char *type, bool
d = E_NEW(struct _connman_technology_onoff_data, 1);
if (!d)
{
_connman_operation_error_show("No memory available");
return;
_connman_operation_error_show("No memory available");
return;
}
d->type = eina_stringshare_add(type);
@ -169,14 +176,16 @@ _connman_technology_onoff(E_Connman_Module_Context *ctxt, const char *type, bool
d->on = on;
if(on)
ret = e_connman_manager_technology_enable(type, _connman_technology_onoff_cb, d);
ret = e_connman_manager_technology_enable
(type, _connman_technology_onoff_cb, d);
else
ret = e_connman_manager_technology_disable(type, _connman_technology_onoff_cb, d);
ret = e_connman_manager_technology_disable
(type, _connman_technology_onoff_cb, d);
if(!ret)
{
eina_stringshare_del(type);
E_FREE(d);
eina_stringshare_del(type);
E_FREE(d);
}
return;
@ -192,16 +201,17 @@ e_connman_config_dialog_new(E_Container *con, E_Connman_Module_Context *ctxt)
view = E_NEW(E_Config_Dialog_View, 1);
if (!view)
return NULL;
return NULL;
view->create_cfdata = _create_data;
view->free_cfdata = _free_data;
view->basic.create_widgets = _basic_create;
view->basic.apply_cfdata = _basic_apply;
dialog = e_config_dialog_new(con, _("Connection Manager"),
_e_connman_Name, "e_connman_config_dialog_new",
e_connman_theme_path(), 0, view, ctxt);
dialog = e_config_dialog_new
(con, _("Connection Manager"),
_e_connman_Name, "e_connman_config_dialog_new",
e_connman_theme_path(), 0, view, ctxt);
e_dialog_resizable_set(dialog->dia, 1);
return dialog;
@ -214,7 +224,7 @@ _create_data(E_Config_Dialog *dialog)
cfdata = E_NEW(E_Config_Dialog_Data, 1);
if (!cfdata)
return NULL;
return NULL;
_fill_data(cfdata, dialog->data);
return cfdata;
}
@ -227,9 +237,12 @@ _free_data(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata)
while(ui->technologies)
{
struct connman_config_technologies *t = (struct connman_config_technologies *) ui->technologies;
ui->technologies = eina_inlist_remove(ui->technologies, EINA_INLIST_GET(t));
E_FREE(t);
struct connman_config_technologies *t;
t = (struct connman_config_technologies *) ui->technologies;
ui->technologies = eina_inlist_remove
(ui->technologies, EINA_INLIST_GET(t));
E_FREE(t);
}
ctxt->conf_dialog = NULL;
@ -261,18 +274,18 @@ static void _network_settings_general_page_create(Evas *evas, E_Config_Dialog_Da
ui = &cfdata->networks.settings_otb;
ui->list_general = e_widget_list_add(evas, 0, 0);
#define _APPEND_ITEM(item, label) \
do \
{ \
ui->lb_##item = e_widget_label_add(evas, _(label)); \
ui->lb_##item ## _val = e_widget_entry_add \
(evas, NULL, NULL, NULL, NULL); \
e_widget_entry_readonly_set(ui->lb_##item ## _val, 1); \
e_widget_list_object_append \
(ui->list_general, ui->lb_##item, 1, 0, 0.0); \
e_widget_list_object_append \
(ui->list_general, ui->lb_##item ## _val, 1, 0, 0.0); \
} while(0)
#define _APPEND_ITEM(item, label) \
do \
{ \
ui->lb_##item = e_widget_label_add(evas, _(label)); \
ui->lb_##item ## _val = e_widget_entry_add \
(evas, NULL, NULL, NULL, NULL); \
e_widget_entry_readonly_set(ui->lb_##item ## _val, 1); \
e_widget_list_object_append \
(ui->list_general, ui->lb_##item, 1, 0, 0.0); \
e_widget_list_object_append \
(ui->list_general, ui->lb_##item ## _val, 1, 0, 0.0); \
} while(0)
_APPEND_ITEM(autoconn, _("Auto-connect:"));
_APPEND_ITEM(favorite, _("Favorite:"));
@ -322,12 +335,14 @@ _network_settings_create(Evas *evas, E_Config_Dialog_Data *cfdata)
ui->settings_otb.settings_otb = e_widget_toolbook_add(evas, 24 * e_scale, 24 * e_scale);
_network_settings_general_page_create(evas, cfdata);
e_widget_toolbook_page_append(ui->settings_otb.settings_otb, NULL, _("General"),
ui->settings_otb.scr_general, 1, 1, 1, 1, 0.5, 0.0);
e_widget_toolbook_page_append
(ui->settings_otb.settings_otb, NULL, _("General"),
ui->settings_otb.scr_general, 1, 1, 1, 1, 0.5, 0.0);
_network_settings_proxy_page_create(evas, cfdata);
e_widget_toolbook_page_append(ui->settings_otb.settings_otb, NULL, _("Proxy"),
ui->settings_otb.list_proxy, 1, 0, 1, 0, 0.5, 0.0);
e_widget_toolbook_page_append
(ui->settings_otb.settings_otb, NULL, _("Proxy"),
ui->settings_otb.list_proxy, 1, 0, 1, 0, 0.5, 0.0);
e_widget_size_min_set(ui->settings_otb.settings_otb, 100, 100);
e_widget_toolbook_page_show(ui->settings_otb.settings_otb, 0);
@ -345,16 +360,17 @@ _networks_fill_details(E_Config_Dialog_Data *cfdata, Evas_Object *list __UNUSED_
E_Connman_Module_Context *ctxt = cfdata->ctxt;
struct connman_config_network_settings_ui *ui = &cfdata->networks.settings_otb;
service = _connman_ctxt_find_service_stringshare(ctxt, cfdata->selected_network);
service = _connman_ctxt_find_service_stringshare
(ctxt, cfdata->selected_network);
if (!service)
{
ERR("service not found: %s.", cfdata->selected_network);
return;
ERR("service not found: %s.", cfdata->selected_network);
return;
}
e_widget_entry_text_set(ui->lb_autoconn_val,
service->auto_connect ? _("True"): _("False"));
service->auto_connect ? _("True"): _("False"));
e_widget_entry_text_set(ui->lb_favorite_val,
service->favorite ? _("True") : _("False"));
service->favorite ? _("True") : _("False"));
e_widget_entry_text_set(ui->lb_type_val, service->type);
e_widget_entry_text_set(ui->lb_ipv4_method_val, service->ipv4_method);
e_widget_entry_text_set(ui->lb_ipv4_address_val, service->ipv4_address);
@ -372,16 +388,16 @@ _networks_disable_buttons(E_Config_Dialog_Data *cfdata, Evas_Object *list, int s
if (sel >= 0)
{
int index = e_widget_ilist_selected_get(list);
int count = e_widget_ilist_count(list);
e_widget_disabled_set(o_up, !index);
int index = e_widget_ilist_selected_get(list);
int count = e_widget_ilist_count(list);
e_widget_disabled_set(o_up, !index);
e_widget_disabled_set(o_down, (count > index + 1)?0:1);
e_widget_disabled_set(o_down, (count > index + 1)?0:1);
}
else
{
e_widget_disabled_set(o_up, 1);
e_widget_disabled_set(o_down, 1);
e_widget_disabled_set(o_up, 1);
e_widget_disabled_set(o_down, 1);
}
}
@ -390,9 +406,7 @@ _cb_service_selected(void *data)
{
E_Config_Dialog_Data *cfdata = data;
Evas_Object *list = cfdata->networks.netlist;
int sel;
sel = e_widget_ilist_selected_get(list);
int sel = e_widget_ilist_selected_get(list);
_networks_disable_buttons(cfdata, list, sel);
_networks_fill_details(cfdata, list, sel);
}
@ -406,12 +420,11 @@ _networks_list_fill(Evas *evas, E_Config_Dialog_Data *cfdata)
EINA_INLIST_FOREACH(ctxt->services, service)
{
Evas_Object *icon;
icon = _connman_service_new_list_item(evas, service);
Evas_Object *icon = _connman_service_new_list_item(evas, service);
e_widget_ilist_append
(list, icon, service->name, _cb_service_selected,
cfdata, service->path);
e_widget_ilist_append
(list, icon, service->name, _cb_service_selected,
cfdata, service->path);
}
return eina_inlist_count(ctxt->services);
@ -430,10 +443,12 @@ _networks_button_up_cb(void *data, void *data2 __UNUSED__)
if (sel <= 0)
return;
service = _connman_ctxt_find_service_stringshare(ctxt, cfdata->selected_network);
service = _connman_ctxt_find_service_stringshare
(ctxt, cfdata->selected_network);
e_widget_ilist_selected_set(netlist, sel-1);
service_ref = _connman_ctxt_find_service_stringshare(ctxt, cfdata->selected_network);
service_ref = _connman_ctxt_find_service_stringshare
(ctxt, cfdata->selected_network);
e_widget_ilist_selected_set(netlist, sel);
@ -455,9 +470,11 @@ _networks_button_down_cb(void *data, void *data2 __UNUSED__)
if (sel < 0 || (count == sel+1))
return;
service = _connman_ctxt_find_service_stringshare(ctxt, cfdata->selected_network);
service = _connman_ctxt_find_service_stringshare
(ctxt, cfdata->selected_network);
e_widget_ilist_selected_set(netlist, sel+1);
service_ref = _connman_ctxt_find_service_stringshare(ctxt, cfdata->selected_network);
service_ref = _connman_ctxt_find_service_stringshare
(ctxt, cfdata->selected_network);
e_widget_ilist_selected_set(netlist, sel);
_connman_service_move(service, service_ref, SERVICE_MOVE_DOWN);
@ -482,24 +499,27 @@ _networks_list_create(Evas *evas, E_Config_Dialog_Data *cfdata)
/* Buttons */
ot = e_widget_table_add(evas, 0);
ui->o_up = e_widget_button_add(evas, _("Up"), "go-up", _networks_button_up_cb, cfdata, NULL);
ui->o_up = e_widget_button_add
(evas, _("Up"), "go-up", _networks_button_up_cb, cfdata, NULL);
e_widget_disabled_set(ui->o_up, 1);
e_widget_table_object_append(ot, ui->o_up, 0, 0, 1, 1, 1, 0, 1, 0);
ui->o_down = e_widget_button_add(evas, _("Down"), "go-down", _networks_button_down_cb, cfdata, NULL);
ui->o_down = e_widget_button_add
(evas, _("Down"), "go-down", _networks_button_down_cb, cfdata, NULL);
e_widget_disabled_set(ui->o_down, 1);
e_widget_table_object_append(ot, ui->o_down, 1, 0, 1, 1, 1, 0, 1, 0);
ui->o_add = e_widget_button_add(evas, _("Add"), "list-add", NULL, cfdata, NULL);
ui->o_add = e_widget_button_add
(evas, _("Add"), "list-add", NULL, cfdata, NULL);
e_widget_disabled_set(ui->o_add, 1);
e_widget_table_object_append(ot, ui->o_add, 0, 1, 2, 1, 1, 0, 1, 0);
e_widget_size_min_get(ot, &mw, &mh);
e_widget_framelist_object_append_full(ui->netframe, ot,
1, 1, /* fill */
1, 0, /* expand */
0.5, 0.5, /* align */
mw, mh, /* min */
99999, 99999 /* max */
);
1, 1, /* fill */
1, 0, /* expand */
0.5, 0.5, /* align */
mw, mh, /* min */
99999, 99999 /* max */
);
}
static void
@ -534,13 +554,17 @@ _switches_page_create_technologies(Evas *evas, E_Connman_Module_Context *ctxt, s
struct E_Connman_Technology *t;
EINA_INLIST_FOREACH(ctxt->technologies, t)
{
struct connman_config_technologies *t_list = E_NEW(struct connman_config_technologies, 1);
t_list->technology = t;
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);
struct connman_config_technologies *t_list;
ui->technologies = eina_inlist_append(ui->technologies, EINA_INLIST_GET(t_list));
e_widget_framelist_object_append(ui->type_frame, t_list->obj);
t_list = E_NEW(struct connman_config_technologies, 1);
t_list->technology = t;
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);
}
}
@ -571,11 +595,13 @@ _basic_create(E_Config_Dialog *dialog __UNUSED__, Evas *evas, E_Config_Dialog_Da
otb = e_widget_toolbook_add(evas, 48 * e_scale, 48 * e_scale);
_networks_page_create(evas, cfdata);
e_widget_toolbook_page_append(otb, NULL, _("Networks Settings"),
cfdata->networks.hlayout, 1, 1, 1, 1, 0.5, 0.0);
e_widget_toolbook_page_append
(otb, NULL, _("Networks Settings"),
cfdata->networks.hlayout, 1, 1, 1, 1, 0.5, 0.0);
_switches_page_create(evas, cfdata);
e_widget_toolbook_page_append(otb, NULL, _("Network Switches"),
cfdata->switches.vlayout, 1, 1, 0, 0, 0.5, 0.5);
e_widget_toolbook_page_append
(otb, NULL, _("Network Switches"),
cfdata->switches.vlayout, 1, 1, 0, 0, 0.5, 0.5);
_networks_list_fill(evas, cfdata);
e_widget_toolbook_page_show(otb, 0);
@ -593,9 +619,10 @@ _basic_apply(E_Config_Dialog *dialog __UNUSED__, E_Config_Dialog_Data *cfdata)
EINA_INLIST_FOREACH(sw->technologies, t)
{
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);
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);

File diff suppressed because it is too large Load Diff