network: show the AP mode and signal strength in the wireless dropdown
This commit is contained in:
parent
a248ecc4d4
commit
ad8223c284
2 changed files with 51 additions and 3 deletions
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "cc-network-panel.h"
|
#include "cc-network-panel.h"
|
||||||
|
|
||||||
|
#include "panel-cell-renderer-mode.h"
|
||||||
|
#include "panel-cell-renderer-signal.h"
|
||||||
#include "panel-common.h"
|
#include "panel-common.h"
|
||||||
|
|
||||||
G_DEFINE_DYNAMIC_TYPE (CcNetworkPanel, cc_network_panel, CC_TYPE_PANEL)
|
G_DEFINE_DYNAMIC_TYPE (CcNetworkPanel, cc_network_panel, CC_TYPE_PANEL)
|
||||||
|
@ -49,6 +51,8 @@ enum {
|
||||||
enum {
|
enum {
|
||||||
PANEL_WIRELESS_COLUMN_ID,
|
PANEL_WIRELESS_COLUMN_ID,
|
||||||
PANEL_WIRELESS_COLUMN_TITLE,
|
PANEL_WIRELESS_COLUMN_TITLE,
|
||||||
|
PANEL_WIRELESS_COLUMN_STRENGTH,
|
||||||
|
PANEL_WIRELESS_COLUMN_MODE,
|
||||||
PANEL_WIRELESS_COLUMN_LAST
|
PANEL_WIRELESS_COLUMN_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -309,6 +313,8 @@ panel_add_device_to_listview (PanelDeviceItem *item)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *access_point;
|
gchar *access_point;
|
||||||
gchar *active_access_point;
|
gchar *active_access_point;
|
||||||
|
guint strength;
|
||||||
|
guint mode;
|
||||||
CcNetworkPanel *panel;
|
CcNetworkPanel *panel;
|
||||||
} PanelAccessPointItem;
|
} PanelAccessPointItem;
|
||||||
|
|
||||||
|
@ -328,7 +334,9 @@ panel_got_proxy_access_point_cb (GObject *source_object, GAsyncResult *res, gpoi
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
GVariantIter iter;
|
GVariantIter iter;
|
||||||
|
GVariant *variant_mode = NULL;
|
||||||
GVariant *variant_ssid = NULL;
|
GVariant *variant_ssid = NULL;
|
||||||
|
GVariant *variant_strength = NULL;
|
||||||
PanelAccessPointItem *ap_item = (PanelAccessPointItem *) user_data;
|
PanelAccessPointItem *ap_item = (PanelAccessPointItem *) user_data;
|
||||||
CcNetworkPanelPrivate *priv = ap_item->panel->priv;
|
CcNetworkPanelPrivate *priv = ap_item->panel->priv;
|
||||||
|
|
||||||
|
@ -339,6 +347,14 @@ panel_got_proxy_access_point_cb (GObject *source_object, GAsyncResult *res, gpoi
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get the strength */
|
||||||
|
variant_strength = g_dbus_proxy_get_cached_property (proxy, "Strength");
|
||||||
|
ap_item->strength = g_variant_get_byte (variant_strength);
|
||||||
|
|
||||||
|
/* get the mode */
|
||||||
|
variant_mode = g_dbus_proxy_get_cached_property (proxy, "Mode");
|
||||||
|
ap_item->mode = g_variant_get_uint32 (variant_mode);
|
||||||
|
|
||||||
/* get the (non NULL terminated, urgh) SSID */
|
/* get the (non NULL terminated, urgh) SSID */
|
||||||
variant_ssid = g_dbus_proxy_get_cached_property (proxy, "Ssid");
|
variant_ssid = g_dbus_proxy_get_cached_property (proxy, "Ssid");
|
||||||
len = g_variant_iter_init (&iter, variant_ssid);
|
len = g_variant_iter_init (&iter, variant_ssid);
|
||||||
|
@ -351,7 +367,7 @@ panel_got_proxy_access_point_cb (GObject *source_object, GAsyncResult *res, gpoi
|
||||||
ssid = g_new0 (gchar, len + 1);
|
ssid = g_new0 (gchar, len + 1);
|
||||||
while (g_variant_iter_loop (&iter, "y", &tmp))
|
while (g_variant_iter_loop (&iter, "y", &tmp))
|
||||||
ssid[i++] = tmp;
|
ssid[i++] = tmp;
|
||||||
g_debug ("adding access point %s", ssid);
|
g_debug ("adding access point %s (%i%%) [%i]", ssid, ap_item->strength, ap_item->mode);
|
||||||
|
|
||||||
/* add to the model */
|
/* add to the model */
|
||||||
liststore_wireless_network = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
|
liststore_wireless_network = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
|
||||||
|
@ -361,6 +377,8 @@ panel_got_proxy_access_point_cb (GObject *source_object, GAsyncResult *res, gpoi
|
||||||
&treeiter,
|
&treeiter,
|
||||||
PANEL_WIRELESS_COLUMN_ID, ap_item->access_point,
|
PANEL_WIRELESS_COLUMN_ID, ap_item->access_point,
|
||||||
PANEL_WIRELESS_COLUMN_TITLE, ssid,
|
PANEL_WIRELESS_COLUMN_TITLE, ssid,
|
||||||
|
PANEL_WIRELESS_COLUMN_STRENGTH, ap_item->strength,
|
||||||
|
PANEL_WIRELESS_COLUMN_MODE, ap_item->mode,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
/* is this what we're on already? */
|
/* is this what we're on already? */
|
||||||
|
@ -378,6 +396,10 @@ out:
|
||||||
g_free (ssid);
|
g_free (ssid);
|
||||||
if (variant_ssid != NULL)
|
if (variant_ssid != NULL)
|
||||||
g_variant_unref (variant_ssid);
|
g_variant_unref (variant_ssid);
|
||||||
|
if (variant_strength != NULL)
|
||||||
|
g_variant_unref (variant_strength);
|
||||||
|
if (variant_mode != NULL)
|
||||||
|
g_variant_unref (variant_mode);
|
||||||
if (proxy != NULL)
|
if (proxy != NULL)
|
||||||
g_object_unref (proxy);
|
g_object_unref (proxy);
|
||||||
return;
|
return;
|
||||||
|
@ -941,9 +963,11 @@ cc_network_panel_init (CcNetworkPanel *panel)
|
||||||
GError *error;
|
GError *error;
|
||||||
gint value;
|
gint value;
|
||||||
GSettings *settings_tmp;
|
GSettings *settings_tmp;
|
||||||
|
GtkAdjustment *adjustment;
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
GtkComboBox *combobox;
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
GtkAdjustment *adjustment;
|
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
panel->priv = NETWORK_PANEL_PRIVATE (panel);
|
panel->priv = NETWORK_PANEL_PRIVATE (panel);
|
||||||
|
@ -1066,6 +1090,26 @@ cc_network_panel_init (CcNetworkPanel *panel)
|
||||||
gtk_tree_selection_select_path (selection, path);
|
gtk_tree_selection_select_path (selection, path);
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
|
|
||||||
|
/* setup wireless combobox model */
|
||||||
|
combobox = GTK_COMBO_BOX (gtk_builder_get_object (panel->priv->builder,
|
||||||
|
"combobox_network_name"));
|
||||||
|
|
||||||
|
renderer = panel_cell_renderer_mode_new ();
|
||||||
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
|
||||||
|
renderer,
|
||||||
|
FALSE);
|
||||||
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
|
||||||
|
"mode", PANEL_WIRELESS_COLUMN_MODE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
renderer = panel_cell_renderer_signal_new ();
|
||||||
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
|
||||||
|
renderer,
|
||||||
|
FALSE);
|
||||||
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
|
||||||
|
"signal", PANEL_WIRELESS_COLUMN_STRENGTH,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* disable for now */
|
/* disable for now */
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
|
||||||
"button_add"));
|
"button_add"));
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
<column type="gchararray"/>
|
<column type="gchararray"/>
|
||||||
<!-- column-name title -->
|
<!-- column-name title -->
|
||||||
<column type="gchararray"/>
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name strength -->
|
||||||
|
<column type="guint"/>
|
||||||
|
<!-- column-name mode -->
|
||||||
|
<column type="guint"/>
|
||||||
</columns>
|
</columns>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkListStore" id="liststore_devices">
|
<object class="GtkListStore" id="liststore_devices">
|
||||||
|
@ -532,7 +536,7 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkComboBoxText" id="combobox_network_name">
|
<object class="GtkComboBox" id="combobox_network_name">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="has-entry">True</property>
|
<property name="has-entry">True</property>
|
||||||
<property name="model">liststore_wireless_network</property>
|
<property name="model">liststore_wireless_network</property>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue