Commit 0abb2e56 authored by Guido Gunther's avatar Guido Gunther

wwaninfo: Allow to hide access tec

Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 00001cda
......@@ -26,6 +26,7 @@
<property name="can_focus">False</property>
<property name="margin-left">0</property>
<property name="size">16</property>
<property name="show_detail">True</property>
</object>
<packing>
<property name="expand">False</property>
......
......@@ -21,6 +21,7 @@
enum {
PROP_0,
PROP_SIZE,
PROP_SHOW_DETAIL,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
......@@ -34,6 +35,7 @@ struct _PhoshWWanInfo
GtkImage *icon;
GtkLabel *access_tec;
gboolean show_detail;
gint size;
};
......@@ -52,6 +54,9 @@ phosh_wwan_info_set_property (GObject *object,
case PROP_SIZE:
phosh_wwan_info_set_size (self, g_value_get_int(value));
break;
case PROP_SHOW_DETAIL:
phosh_wwan_info_set_show_detail (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -71,6 +76,9 @@ phosh_wwan_info_get_property (GObject *object,
case PROP_SIZE:
g_value_set_int (value, self->size);
break;
case PROP_SHOW_DETAIL:
g_value_set_boolean (value, self->show_detail);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -130,6 +138,11 @@ update_icon_data(PhoshWWanInfo *self, GParamSpec *psepc, PhoshWWanMM *wwan)
gtk_image_set_from_icon_name (GTK_IMAGE (self->icon), icon_name, -1);
gtk_widget_show (GTK_WIDGET (self->icon));
if (!self->show_detail) {
gtk_widget_hide (GTK_WIDGET(self->access_tec));
return;
}
/* Access technology */
access_tec = phosh_wwan_get_access_tec (PHOSH_WWAN (self->wwan));
if (access_tec == NULL) {
......@@ -214,6 +227,14 @@ phosh_wwan_info_class_init (PhoshWWanInfoClass *klass)
-1,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
props[PROP_SHOW_DETAIL] =
g_param_spec_boolean (
"show-detail",
"Show detail",
"Show wwan details",
FALSE,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
gtk_widget_class_set_template_from_resource (widget_class,
......@@ -261,3 +282,26 @@ phosh_wwan_info_get_size (PhoshWWanInfo *self)
return self->size;
}
void
phosh_wwan_info_set_show_detail (PhoshWWanInfo *self, gboolean show)
{
g_return_if_fail (PHOSH_IS_WWAN_INFO (self));
if (self->show_detail == show)
return;
self->show_detail = !!show;
gtk_widget_set_visible (GTK_WIDGET (self->access_tec), show);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SHOW_DETAIL]);
}
gboolean
phosh_wwan_info_get_show_detail (PhoshWWanInfo *self)
{
g_return_val_if_fail (PHOSH_IS_WWAN_INFO (self), 0);
return self->show_detail;
}
......@@ -15,7 +15,9 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (PhoshWWanInfo, phosh_wwan_info, PHOSH, WWAN_INFO, GtkBox)
GtkWidget * phosh_wwan_info_new (void);
void phosh_wwan_info_set_size (PhoshWWanInfo *self, gint size);
gint phosh_wwan_info_get_size (PhoshWWanInfo *self);
void phosh_wwan_info_set_size (PhoshWWanInfo *self, gint size);
gint phosh_wwan_info_get_size (PhoshWWanInfo *self);
void phosh_wwan_info_set_show_detail (PhoshWWanInfo *self, gboolean show);
gboolean phosh_wwan_info_get_show_detail (PhoshWWanInfo *self);
G_END_DECLS
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment