static void
listbox_active_changed (GObject    *object,
                        GParamSpec *pspec,
                        gpointer    button)
{
	NmtConnectConnectionList *list = NMT_CONNECT_CONNECTION_LIST (object);
	static const char *activate, *deactivate;
	static int deactivate_padding, activate_padding;
	NMActiveConnection *ac;
	gboolean has_selection;

	if (G_UNLIKELY (activate == NULL)) {
		int activate_width, deactivate_width;

		activate = _("Activate");
		activate_width = nmt_newt_text_width (activate);
		deactivate = _("Deactivate");
		deactivate_width = nmt_newt_text_width (deactivate);

		activate_padding = MAX (0, deactivate_width - activate_width);
		deactivate_padding = MAX (0, activate_width - deactivate_width);
	}

	has_selection = nmt_connect_connection_list_get_selection (list, NULL, NULL, NULL, &ac);

	nmt_newt_component_set_sensitive (button, has_selection);
	if (has_selection && ac) {
		nmt_newt_button_set_label (button, deactivate);
		nmt_newt_widget_set_padding (button, 0, 0, deactivate_padding, 0);
	} else {
		nmt_newt_button_set_label (button, activate);
		nmt_newt_widget_set_padding (button, 0, 0, activate_padding, 0);
	}
}
static newtComponent
nmt_newt_popup_build_component (NmtNewtComponent *component,
                                gboolean          sensitive)
{
	NmtNewtPopupPrivate *priv = NMT_NEWT_POPUP_GET_PRIVATE (component);
	NmtNewtPopupEntry *entries = (NmtNewtPopupEntry *)priv->entries->data;

	nmt_newt_button_set_label (NMT_NEWT_BUTTON (component),
	                           entries[priv->active].label);
	return NMT_NEWT_COMPONENT_CLASS (nmt_newt_popup_parent_class)->
		build_component (component, sensitive);
}
Beispiel #3
0
static void
nmt_newt_button_set_property (GObject      *object,
                              guint         prop_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
	switch (prop_id) {
	case PROP_LABEL:
		nmt_newt_button_set_label (NMT_NEWT_BUTTON (object),
		                           g_value_get_string (value));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}