network: Remove two common functions that are more simply done inside the few cases that use them
The existing code relied on using GtkBuilder, which will no longer work when we switch to GtkTemplate.
This commit is contained in:
parent
4ba3a2c3d1
commit
3c32ee72ea
5 changed files with 19 additions and 43 deletions
|
@ -23,7 +23,8 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#define HANDY_USE_UNSTABLE_API
|
||||
#include <handy.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "panel-common.h"
|
||||
|
@ -204,6 +205,7 @@ device_ethernet_refresh_ui (NetDeviceEthernet *device)
|
|||
NMDeviceState state;
|
||||
GtkWidget *widget;
|
||||
g_autofree gchar *speed = NULL;
|
||||
g_autofree gchar *status = NULL;
|
||||
|
||||
nm_device = net_device_get_nm_device (NET_DEVICE (device));
|
||||
|
||||
|
@ -221,7 +223,9 @@ device_ethernet_refresh_ui (NetDeviceEthernet *device)
|
|||
|
||||
if (state != NM_DEVICE_STATE_UNAVAILABLE)
|
||||
speed = net_device_simple_get_speed (NET_DEVICE_SIMPLE (device));
|
||||
panel_set_device_row_status (device->builder, "details_row", nm_device, speed);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "details_row"));
|
||||
status = panel_device_status_to_localized_string (nm_device, speed);
|
||||
hdy_action_row_set_title (HDY_ACTION_ROW (widget), status);
|
||||
|
||||
populate_ui (device);
|
||||
}
|
||||
|
|
|
@ -374,6 +374,7 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *device_mobile)
|
|||
NMClient *client;
|
||||
NMDeviceModemCapabilities caps;
|
||||
NMDevice *nm_device;
|
||||
g_autofree gchar *status = NULL;
|
||||
|
||||
nm_device = net_device_get_nm_device (NET_DEVICE (device_mobile));
|
||||
|
||||
|
@ -388,7 +389,9 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *device_mobile)
|
|||
mobilebb_enabled_toggled (client, NULL, device_mobile);
|
||||
|
||||
/* set device state, with status */
|
||||
panel_set_device_status (device_mobile->builder, "label_status", nm_device, NULL);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->builder, "label_status"));
|
||||
status = panel_device_status_to_localized_string (nm_device, NULL);
|
||||
gtk_label_set_label (GTK_LABEL (widget), status);
|
||||
|
||||
/* sensitive for other connection types if the device is currently connected */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->builder,
|
||||
|
|
|
@ -491,6 +491,8 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
|
|||
NMAccessPoint *ap;
|
||||
NMConnection *connection;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *widget;
|
||||
g_autofree gchar *status = NULL;
|
||||
|
||||
if (device_is_hotspot (device_wifi)) {
|
||||
nm_device_wifi_refresh_hotspot (device_wifi);
|
||||
|
@ -585,7 +587,9 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
|
|||
else
|
||||
panel_set_device_widget_details (device_wifi->builder, "last_used", NULL);
|
||||
|
||||
panel_set_device_status (device_wifi->builder, "heading_status", nm_device, NULL);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "heading_status"));
|
||||
status = panel_device_status_to_localized_string (nm_device, NULL);
|
||||
gtk_label_set_label (GTK_LABEL (widget), status);
|
||||
|
||||
/* update list of APs */
|
||||
show_wifi_list (device_wifi);
|
||||
|
|
|
@ -269,9 +269,9 @@ device_state_reason_to_localized_string (NMDevice *device)
|
|||
return value;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
device_status_to_localized_string (NMDevice *nm_device,
|
||||
const gchar *speed)
|
||||
gchar *
|
||||
panel_device_status_to_localized_string (NMDevice *nm_device,
|
||||
const gchar *speed)
|
||||
{
|
||||
NMDeviceState state;
|
||||
GString *string;
|
||||
|
@ -314,34 +314,6 @@ device_status_to_localized_string (NMDevice *nm_device,
|
|||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
panel_set_device_status (GtkBuilder *builder,
|
||||
const gchar *label_name,
|
||||
NMDevice *nm_device,
|
||||
const gchar *speed)
|
||||
{
|
||||
GtkLabel *label;
|
||||
g_autofree gchar *status = NULL;
|
||||
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, label_name));
|
||||
status = device_status_to_localized_string (nm_device, speed);
|
||||
gtk_label_set_label (label, status);
|
||||
}
|
||||
|
||||
void
|
||||
panel_set_device_row_status (GtkBuilder *builder,
|
||||
const gchar *row_name,
|
||||
NMDevice *nm_device,
|
||||
const gchar *speed)
|
||||
{
|
||||
HdyActionRow *row;
|
||||
g_autofree gchar *status = NULL;
|
||||
|
||||
row = HDY_ACTION_ROW (gtk_builder_get_object (builder, row_name));
|
||||
status = device_status_to_localized_string (nm_device, speed);
|
||||
hdy_action_row_set_title (row, status);
|
||||
}
|
||||
|
||||
gboolean
|
||||
panel_set_device_widget_details (GtkBuilder *builder,
|
||||
const gchar *widget_suffix,
|
||||
|
|
|
@ -21,19 +21,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <NetworkManager.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void panel_set_device_status (GtkBuilder *builder,
|
||||
const gchar *label_name,
|
||||
NMDevice *nm_device,
|
||||
const gchar *speed);
|
||||
void panel_set_device_row_status (GtkBuilder *builder,
|
||||
const gchar *row_name,
|
||||
NMDevice *nm_device,
|
||||
gchar *panel_device_status_to_localized_string (NMDevice *nm_device,
|
||||
const gchar *speed);
|
||||
gboolean panel_set_device_widget_details (GtkBuilder *builder,
|
||||
const gchar *widget_suffix,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue