Change some macros according to service based solutions. Remove some unused functions in properties.
Signed-off-by: Dongxiao Xu <dongxiao...@intel.com> --- common/connman-client.c | 50 +++++++++++++++++++++++++-- common/connman-client.h | 2 + properties/main.c | 89 +---------------------------------------------- 3 files changed, 50 insertions(+), 91 deletions(-) diff --git a/common/connman-client.c b/common/connman-client.c index 29f68c1..59f6318 100644 --- a/common/connman-client.c +++ b/common/connman-client.c @@ -118,7 +118,8 @@ static void connman_client_init(ConnmanClient *client) G_TYPE_BOOLEAN, /* favorite */ G_TYPE_UINT, /* strength */ G_TYPE_UINT, /* security */ - G_TYPE_STRING); /* passphrase */ + G_TYPE_STRING, /* passphrase */ + G_TYPE_STRING); /* address */ gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(priv->store), compare_index, NULL, NULL); @@ -215,6 +216,43 @@ GtkTreeModel *connman_client_get_connection_model(ConnmanClient *client) return connman_client_get_model(client); } +static gboolean device_filter(GtkTreeModel *model, + GtkTreeIter *iter, gpointer user_data) +{ + DBusGProxy *proxy; + gboolean active; + guint type; + + gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, + CONNMAN_COLUMN_TYPE, &type, + -1); + + if (proxy == NULL) + return FALSE; + + active = g_str_equal(CONNMAN_SERVICE_INTERFACE, + dbus_g_proxy_get_interface(proxy)); + + g_object_unref(proxy); + + return active; +} + +GtkTreeModel *connman_client_get_device_model(ConnmanClient *client) +{ + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); + GtkTreeModel *model; + + DBG("client %p", client); + + model = gtk_tree_model_filter_new(GTK_TREE_MODEL(priv->store), NULL); + + gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(model), + device_filter, NULL, NULL); + + return model; +} + void connman_client_set_policy(ConnmanClient *client, const gchar *device, const gchar *policy) { @@ -310,8 +348,13 @@ static gboolean network_disconnect(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) { DBusGProxy *proxy; + char *name; + guint type; - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, -1); + gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, + CONNMAN_COLUMN_NAME, &name, + CONNMAN_COLUMN_TYPE, &type, + -1); if (proxy == NULL) return FALSE; @@ -320,7 +363,8 @@ static gboolean network_disconnect(GtkTreeModel *model, GtkTreePath *path, CONNMAN_SERVICE_INTERFACE) == FALSE) return FALSE; - connman_disconnect(proxy, NULL); + if (type == CONNMAN_TYPE_WIFI) + connman_disconnect(proxy, NULL); g_object_unref(proxy); diff --git a/common/connman-client.h b/common/connman-client.h index 1d9b91b..7251265 100644 --- a/common/connman-client.h +++ b/common/connman-client.h @@ -54,6 +54,7 @@ GType connman_client_get_type(void); ConnmanClient *connman_client_new(void); GtkTreeModel *connman_client_get_model(ConnmanClient *client); +GtkTreeModel *connman_client_get_device_model(ConnmanClient *client); GtkTreeModel *connman_client_get_connection_model(ConnmanClient *client); void connman_client_set_policy(ConnmanClient *client, const gchar *device, @@ -88,6 +89,7 @@ enum { CONNMAN_COLUMN_STRENGTH, /* G_TYPE_UINT */ CONNMAN_COLUMN_SECURITY, /* G_TYPE_UINT */ CONNMAN_COLUMN_PASSPHRASE, /* G_TYPE_STRING */ + CONNMAN_COLUMN_ADDRESS, /* G_TYPE_STRING */ _CONNMAN_NUM_COLUMNS }; diff --git a/properties/main.c b/properties/main.c index a77a43c..03e7fa4 100644 --- a/properties/main.c +++ b/properties/main.c @@ -30,7 +30,6 @@ #include "advanced.h" -#if 0 static ConnmanClient *client; static GtkWidget *interface_notebook; @@ -140,10 +139,8 @@ static struct config_data *create_config(GtkTreeModel *model, gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, CONNMAN_COLUMN_TYPE, &type, - CONNMAN_COLUMN_INRANGE, &inrange, - CONNMAN_COLUMN_NETWORK, &network, CONNMAN_COLUMN_ADDRESS, &address, - CONNMAN_COLUMN_POLICY, &policy, -1); + -1); data->device = g_strdup(dbus_g_proxy_get_path(proxy)); g_object_unref(proxy); @@ -250,73 +247,6 @@ static void select_callback(GtkTreeSelection *selection, gpointer user_data) gtk_widget_show(notebook); } -static void row_changed(GtkTreeModel *model, GtkTreePath *path, - GtkTreeIter *iter, gpointer user_data) -{ - guint type; - gboolean powered, inrange; - - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type, - CONNMAN_COLUMN_ENABLED, &powered, - CONNMAN_COLUMN_INRANGE, &inrange, -1); -} - -static void state_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) -{ - gboolean inrange; - - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_INRANGE, &inrange, -1); - - if (inrange == TRUE) - g_object_set(cell, "icon-name", GTK_STOCK_YES, NULL); - else - g_object_set(cell, "icon-name", NULL, NULL); -} - -static void type_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) -{ - guint type; - gboolean powered, inrange; - gchar *markup; - const char *title, *info; - - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type, - CONNMAN_COLUMN_ENABLED, &powered, - CONNMAN_COLUMN_INRANGE, &inrange, -1); - - switch (type) { - case CONNMAN_TYPE_ETHERNET: - title = N_("Ethernet"); - break; - case CONNMAN_TYPE_WIFI: - title = N_("Wireless"); - break; - case CONNMAN_TYPE_WIMAX: - title = N_("WiMAX"); - break; - case CONNMAN_TYPE_BLUETOOTH: - title = N_("Bluetooth"); - break; - default: - title = N_("Unknown"); - break; - } - - if (powered == TRUE) { - if (inrange == TRUE) - info = N_("Connected"); - else - info = N_("Not Connected"); - } else - info = N_("Disabled"); - - markup = g_strdup_printf("<b>%s</b>\n<small>%s</small>", title, info); - g_object_set(cell, "markup", markup, NULL); - g_free(markup); -} - static void type_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { @@ -382,17 +312,6 @@ static GtkWidget *create_interfaces(GtkWidget *window) gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); renderer = gtk_cell_renderer_pixbuf_new(); - gtk_cell_renderer_set_fixed_size(renderer, 20, 45); - gtk_tree_view_column_pack_start(column, renderer, FALSE); - gtk_tree_view_column_set_cell_data_func(column, renderer, - state_to_icon, NULL, NULL); - - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(column, renderer, TRUE); - gtk_tree_view_column_set_cell_data_func(column, renderer, - type_to_text, NULL, NULL); - - renderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_end(column, renderer, FALSE); gtk_tree_view_column_set_cell_data_func(column, renderer, type_to_icon, NULL, NULL); @@ -413,9 +332,6 @@ static GtkWidget *create_interfaces(GtkWidget *window) g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(select_callback), window); - g_signal_connect(G_OBJECT(model), "row-changed", - G_CALLBACK(row_changed), selection); - return mainbox; } @@ -479,11 +395,9 @@ static GtkWidget *create_window(void) return window; } -#endif int main(int argc, char *argv[]) { -#if 0 GtkWidget *window; bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); @@ -501,7 +415,6 @@ int main(int argc, char *argv[]) gtk_main(); g_object_unref(client); -#endif return 0; } -- 1.7.1 _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman