static newtComponent nmt_newt_button_build_component (NmtNewtComponent *component, gboolean sensitive) { NmtNewtButtonPrivate *priv = NMT_NEWT_BUTTON_GET_PRIVATE (component); newtComponent co; char *label = NULL, *label_lc; if (sensitive) { label_lc = nmt_newt_locale_from_utf8 (priv->label); co = newtCompactButton (-1, -1, label_lc); g_free (label_lc); } else { label = g_strdup_printf (" <%s>", priv->label); label_lc = nmt_newt_locale_from_utf8 (label); co = newtLabel (-1, -1, label_lc); g_free (label_lc); newtLabelSetColors (co, NMT_NEWT_COLORSET_DISABLED_BUTTON); } return co; }
static newtComponent nmt_newt_label_build_component (NmtNewtComponent *component, gboolean sensitive) { NmtNewtLabelPrivate *priv = NMT_NEWT_LABEL_GET_PRIVATE (component); newtComponent co; char *text_lc; text_lc = nmt_newt_locale_from_utf8 (priv->text); co = newtLabel (-1, -1, text_lc); g_free (text_lc); if (priv->highlight) newtLabelSetColors (co, NMT_NEWT_COLORSET_BAD_LABEL); else if (priv->style == NMT_NEWT_LABEL_PLAIN) newtLabelSetColors (co, NMT_NEWT_COLORSET_PLAIN_LABEL); return co; }
/** * nmt_newt_popup_new: * @entries: an array of #NmtNewtPopupEntry, terminated by an * entry with a %NULL label * * Creates a new #NmtNewtPopup with the given entries. * * Returns: a new #NmtNewtPopup */ NmtNewtWidget * nmt_newt_popup_new (NmtNewtPopupEntry *entries) { NmtNewtWidget *widget; NmtNewtPopupPrivate *priv; int i; widget = g_object_new (NMT_TYPE_NEWT_POPUP, NULL); priv = NMT_NEWT_POPUP_GET_PRIVATE (widget); for (i = 0; entries[i].label; i++) { NmtNewtPopupEntry entry; entry.label = nmt_newt_locale_from_utf8 (_(entries[i].label)); entry.id = g_strdup (entries[i].id); g_array_append_val (priv->entries, entry); } return widget; }
static newtComponent nmt_newt_entry_build_component (NmtNewtComponent *component, gboolean sensitive) { NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE (component); newtComponent co; char *text_lc; int flags; flags = convert_flags (priv->flags); if (!sensitive) flags |= NEWT_FLAG_DISABLED; text_lc = priv->text ? nmt_newt_locale_from_utf8 (priv->text) : NULL; co = newtEntry (-1, -1, text_lc, priv->width, NULL, flags); g_free (text_lc); if (priv->last_cursor_pos != -1) newtEntrySetCursorPosition (co, priv->last_cursor_pos); newtEntrySetFilter (co, entry_filter, component); return co; }
static void nmt_newt_form_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NmtNewtFormPrivate *priv = NMT_NEWT_FORM_GET_PRIVATE (object); int screen_width, screen_height; switch (prop_id) { case PROP_TITLE: if (g_value_get_string (value)) { priv->title_lc = nmt_newt_locale_from_utf8 (g_value_get_string (value)); } else priv->title_lc = NULL; break; case PROP_FULLSCREEN: if (g_value_get_boolean (value)) { newtGetScreenSize (&screen_width, &screen_height); priv->x = priv->y = 2; priv->fixed_x = priv->fixed_y = TRUE; priv->width = screen_width - 4; priv->height = screen_height - 4; priv->fixed_width = priv->fixed_height = TRUE; } break; case PROP_FULLSCREEN_VERTICAL: if (g_value_get_boolean (value)) { newtGetScreenSize (&screen_width, &screen_height); priv->y = 2; priv->fixed_y = TRUE; priv->height = screen_height - 4; priv->fixed_height = TRUE; } break; case PROP_FULLSCREEN_HORIZONTAL: if (g_value_get_boolean (value)) { newtGetScreenSize (&screen_width, &screen_height); priv->x = 2; priv->fixed_x = TRUE; priv->width = screen_width - 4; priv->fixed_width = TRUE; } break; case PROP_X: if (g_value_get_uint (value)) { priv->x = g_value_get_uint (value); priv->fixed_x = TRUE; } break; case PROP_Y: if (g_value_get_uint (value)) { priv->y = g_value_get_uint (value); priv->fixed_y = TRUE; } break; case PROP_WIDTH: if (g_value_get_uint (value)) { priv->width = g_value_get_uint (value); priv->fixed_width = TRUE; } break; case PROP_HEIGHT: if (g_value_get_uint (value)) { priv->height = g_value_get_uint (value); priv->fixed_height = TRUE; } break; case PROP_PADDING: priv->padding = g_value_get_uint (value); break; case PROP_ESCAPE_EXITS: priv->escape_exits = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void nmt_newt_section_class_init (NmtNewtSectionClass *section_class) { GObjectClass *object_class = G_OBJECT_CLASS (section_class); NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS (section_class); NmtNewtContainerClass *container_class = NMT_NEWT_CONTAINER_CLASS (section_class); g_type_class_add_private (section_class, sizeof (NmtNewtSectionPrivate)); /* virtual methods */ object_class->set_property = nmt_newt_section_set_property; object_class->get_property = nmt_newt_section_get_property; object_class->finalize = nmt_newt_section_finalize; widget_class->get_components = nmt_newt_section_get_components; widget_class->size_request = nmt_newt_section_size_request; widget_class->size_allocate = nmt_newt_section_size_allocate; container_class->remove = nmt_newt_section_remove; /* properties */ /** * NmtNewtSection:show-border: * * %TRUE if the section should show a border along the left side. */ g_object_class_install_property (object_class, PROP_SHOW_BORDER, g_param_spec_boolean ("show-border", "", "", TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * NmtNewtSection:open: * * %TRUE if the section is open (ie, its body is visible), %FALSE * if not. */ g_object_class_install_property (object_class, PROP_OPEN, g_param_spec_boolean ("open", "", "", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* globals */ closed_glyph = nmt_newt_locale_from_utf8 ("\342\225\220"); /* ═ */ open_glyph = nmt_newt_locale_from_utf8 ("\342\225\244"); /* ╤ */ line_glyph = nmt_newt_locale_from_utf8 ("\342\224\202"); /* │ */ end_glyph = nmt_newt_locale_from_utf8 ("\342\224\224"); /* └ */ if (!*closed_glyph || !*open_glyph || !*line_glyph || !*end_glyph) { g_free (closed_glyph); g_free (open_glyph); g_free (line_glyph); g_free (end_glyph); closed_glyph = g_strdup ("-"); open_glyph = g_strdup ("+"); line_glyph = g_strdup ("|"); end_glyph = g_strdup ("\\"); } }