static gboolean tt_parse_func (MarkupData *md, OpenTag *tag, const gchar **names, const gchar **values, GMarkupParseContext *context, GError **error) { CHECK_NO_ATTRS("tt"); add_attribute (tag, pango_attr_family_new ("Monospace")); return TRUE; }
/* This function is used by gtk_text_cell_accessible_get_offset_at_point() * and gtk_text_cell_accessible_get_character_extents(). There is no * cached PangoLayout so we must create a temporary one using this function. */ static PangoLayout * create_pango_layout (GtkTextCellAccessible *text) { GdkRGBA *foreground_rgba; PangoAttrList *attr_list, *attributes; PangoLayout *layout; PangoUnderline uline, underline; PangoFontMask mask; PangoFontDescription *font_desc; gboolean foreground_set, strikethrough_set, strikethrough; gboolean scale_set, underline_set, rise_set; gchar *renderer_text; gdouble scale; gint rise; GtkRendererCellAccessible *gail_renderer; GtkCellRendererText *gtk_renderer; gail_renderer = GTK_RENDERER_CELL_ACCESSIBLE (text); gtk_renderer = GTK_CELL_RENDERER_TEXT (gail_renderer->renderer); g_object_get (gtk_renderer, "text", &renderer_text, "attributes", &attributes, "foreground-set", &foreground_set, "foreground-rgba", &foreground_rgba, "strikethrough-set", &strikethrough_set, "strikethrough", &strikethrough, "font-desc", &font_desc, "scale-set", &scale_set, "scale", &scale, "underline-set", &underline_set, "underline", &underline, "rise-set", &rise_set, "rise", &rise, NULL); layout = gtk_widget_create_pango_layout (get_widget (text), renderer_text); if (attributes) attr_list = pango_attr_list_copy (attributes); else attr_list = pango_attr_list_new (); if (foreground_set) { add_attr (attr_list, pango_attr_foreground_new (foreground_rgba->red * 65535, foreground_rgba->green * 65535, foreground_rgba->blue * 65535)); } if (strikethrough_set) add_attr (attr_list, pango_attr_strikethrough_new (strikethrough)); mask = pango_font_description_get_set_fields (font_desc); if (mask & PANGO_FONT_MASK_FAMILY) add_attr (attr_list, pango_attr_family_new (pango_font_description_get_family (font_desc))); if (mask & PANGO_FONT_MASK_STYLE) add_attr (attr_list, pango_attr_style_new (pango_font_description_get_style (font_desc))); if (mask & PANGO_FONT_MASK_VARIANT) add_attr (attr_list, pango_attr_variant_new (pango_font_description_get_variant (font_desc))); if (mask & PANGO_FONT_MASK_WEIGHT) add_attr (attr_list, pango_attr_weight_new (pango_font_description_get_weight (font_desc))); if (mask & PANGO_FONT_MASK_STRETCH) add_attr (attr_list, pango_attr_stretch_new (pango_font_description_get_stretch (font_desc))); if (mask & PANGO_FONT_MASK_SIZE) add_attr (attr_list, pango_attr_size_new (pango_font_description_get_size (font_desc))); if (scale_set && scale != 1.0) add_attr (attr_list, pango_attr_scale_new (scale)); if (underline_set) uline = underline; else uline = PANGO_UNDERLINE_NONE; if (uline != PANGO_UNDERLINE_NONE) add_attr (attr_list, pango_attr_underline_new (underline)); if (rise_set) add_attr (attr_list, pango_attr_rise_new (rise)); pango_layout_set_attributes (layout, attr_list); pango_layout_set_width (layout, -1); pango_attr_list_unref (attr_list); pango_font_description_free (font_desc); pango_attr_list_unref (attributes); g_free (renderer_text); gdk_rgba_free (foreground_rgba); return layout; }
/* * This function is used by gail_text_cell_get_offset_at_point() * and gail_text_cell_get_character_extents(). There is no * cached PangoLayout for gailtextcell so we must create a temporary * one using this function. */ static PangoLayout* create_pango_layout(GtkCellRendererText *gtk_renderer, GtkWidget *widget) { PangoAttrList *attr_list; PangoLayout *layout; PangoUnderline uline; PangoFontMask mask; layout = gtk_widget_create_pango_layout (widget, gtk_renderer->text); if (gtk_renderer->extra_attrs) attr_list = pango_attr_list_copy (gtk_renderer->extra_attrs); else attr_list = pango_attr_list_new (); if (gtk_renderer->foreground_set) { PangoColor color; color = gtk_renderer->foreground; add_attr (attr_list, pango_attr_foreground_new (color.red, color.green, color.blue)); } if (gtk_renderer->strikethrough_set) add_attr (attr_list, pango_attr_strikethrough_new (gtk_renderer->strikethrough)); mask = pango_font_description_get_set_fields (gtk_renderer->font); if (mask & PANGO_FONT_MASK_FAMILY) add_attr (attr_list, pango_attr_family_new (pango_font_description_get_family (gtk_renderer->font))); if (mask & PANGO_FONT_MASK_STYLE) add_attr (attr_list, pango_attr_style_new (pango_font_description_get_style (gtk_renderer->font))); if (mask & PANGO_FONT_MASK_VARIANT) add_attr (attr_list, pango_attr_variant_new (pango_font_description_get_variant (gtk_renderer->font))); if (mask & PANGO_FONT_MASK_WEIGHT) add_attr (attr_list, pango_attr_weight_new (pango_font_description_get_weight (gtk_renderer->font))); if (mask & PANGO_FONT_MASK_STRETCH) add_attr (attr_list, pango_attr_stretch_new (pango_font_description_get_stretch (gtk_renderer->font))); if (mask & PANGO_FONT_MASK_SIZE) add_attr (attr_list, pango_attr_size_new (pango_font_description_get_size (gtk_renderer->font))); if (gtk_renderer->scale_set && gtk_renderer->font_scale != 1.0) add_attr (attr_list, pango_attr_scale_new (gtk_renderer->font_scale)); if (gtk_renderer->underline_set) uline = gtk_renderer->underline_style; else uline = PANGO_UNDERLINE_NONE; if (uline != PANGO_UNDERLINE_NONE) add_attr (attr_list, pango_attr_underline_new (gtk_renderer->underline_style)); if (gtk_renderer->rise_set) add_attr (attr_list, pango_attr_rise_new (gtk_renderer->rise)); pango_layout_set_attributes (layout, attr_list); pango_layout_set_width (layout, -1); pango_attr_list_unref (attr_list); return layout; }
static PangoAttrList* hildon_font_selection_dialog_create_attrlist (HildonFontSelectionDialog *fontsel, guint start_index, guint len) { PangoAttrList *list; PangoAttribute *attr; gint size, position; gboolean family_set, size_set, color_set, bold, bold_set, italic, italic_set, underline, underline_set, strikethrough, strikethrough_set, position_set; GdkColor *color = NULL; gchar *family = NULL; gdouble font_scaling = 1.0; list = pango_attr_list_new (); g_object_get (G_OBJECT (fontsel), "family", &family, "family-set", &family_set, "size", &size, "size-set", &size_set, "color", &color, "color-set", &color_set, "bold", &bold, "bold-set", &bold_set, "italic", &italic, "italic-set", &italic_set, "underline", &underline, "underline-set", &underline_set, "strikethrough", &strikethrough, "strikethrough-set", &strikethrough_set, "position", &position, "position-set", &position_set, "font-scaling", &font_scaling, NULL); /* family */ if (family_set) { attr = pango_attr_family_new (family); add_preview_text_attr (list, attr, start_index, len); } g_free (family); /* size */ if (size_set) { attr = pango_attr_size_new (size * PANGO_SCALE); add_preview_text_attr (list, attr, start_index, len); } /*color*/ if (color_set) { attr = pango_attr_foreground_new (color->red, color->green, color->blue); add_preview_text_attr (list, attr, start_index, len); } if (color != NULL) gdk_color_free (color); /*weight*/ if (bold_set) { if (bold) attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); else attr = pango_attr_weight_new (PANGO_WEIGHT_NORMAL); add_preview_text_attr(list, attr, start_index, len); } /* style */ if (italic_set) { if (italic) attr = pango_attr_style_new (PANGO_STYLE_ITALIC); else attr = pango_attr_style_new (PANGO_STYLE_NORMAL); add_preview_text_attr(list, attr, start_index, len); } /* underline */ if (underline_set) { if (underline) attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE); else attr = pango_attr_underline_new (PANGO_UNDERLINE_NONE); add_preview_text_attr(list, attr, start_index, len); } /* strikethrough */ if (strikethrough_set) { if (strikethrough) attr = pango_attr_strikethrough_new (TRUE); else attr = pango_attr_strikethrough_new (FALSE); add_preview_text_attr(list, attr, start_index, len); } /* position */ if (position_set) { switch (position) { case 1: /*super*/ attr = pango_attr_rise_new (SUPERSCRIPT_RISE); break; case -1: /*sub*/ attr = pango_attr_rise_new (SUBSCRIPT_LOW); break; default: /*normal*/ attr = pango_attr_rise_new (0); break; } add_preview_text_attr (list, attr, start_index, len); } /* font scaling for preview */ if (font_scaling) { attr = pango_attr_scale_new(font_scaling); add_preview_text_attr(list, attr, 0, len + start_index); } return list; }
static void hildon_font_selection_dialog_show_preview (HildonFontSelectionDialog *fontsel) { HildonFontSelectionDialogPrivate *priv = HILDON_FONT_SELECTION_DIALOG_GET_PRIVATE (fontsel); gint size; gboolean family_set, size_set; PangoAttribute *attr; PangoAttrList *list; GtkWidget *preview_dialog; GtkWidget *preview_label; gchar *str = NULL; gboolean position_set = FALSE; gint position = 0; gboolean show_ref = FALSE; g_assert (priv); g_object_get (G_OBJECT (fontsel), "position-set", &position_set, NULL); if (position_set) { g_object_get (G_OBJECT (fontsel), "position", &position, NULL); if (position == 1 || position == -1) show_ref = TRUE; } /* preview dialog init */ preview_dialog = gtk_dialog_new_with_buttons (_("ecdg_ti_preview_font"), NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, _("wdgt_bd_done"), GTK_RESPONSE_ACCEPT, NULL); str = (show_ref) ? g_strconcat (_("ecdg_fi_preview_font_preview_reference"), priv->preview_text, 0) : g_strdup (priv->preview_text); preview_label = gtk_label_new (str); gtk_label_set_line_wrap (GTK_LABEL(preview_label), TRUE); if (str) g_free (str); str = NULL; /* set keypress handler (ESC hardkey) */ g_signal_connect (G_OBJECT (preview_dialog), "key-press-event", G_CALLBACK(hildon_font_selection_dialog_preview_key_press), NULL); /* Set the font */ list = (show_ref) ? hildon_font_selection_dialog_create_attrlist (fontsel, strlen (_("ecdg_fi_preview_font_preview_reference")), strlen (priv->preview_text)) : hildon_font_selection_dialog_create_attrlist (fontsel, 0, strlen(priv->preview_text)); g_object_get (G_OBJECT (fontsel), "family", &str, "family-set", &family_set, "size", &size, "size-set", &size_set, NULL); /* A smallish hack to add scrollbar when font size is really big */ if (size_set && size > 24) { GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL)); gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport (scrolled, GTK_WIDGET (preview_label)); gtk_container_add (GTK_CONTAINER (GTK_DIALOG(preview_dialog)->vbox), GTK_WIDGET (scrolled)); gtk_widget_set_size_request (GTK_WIDGET (scrolled), -1, 400); } else gtk_container_add (GTK_CONTAINER (GTK_DIALOG(preview_dialog)->vbox), GTK_WIDGET (preview_label)); /* make reference text to have the same fontface and size */ if (family_set) { attr = pango_attr_family_new (str); add_preview_text_attr (list, attr, 0, strlen (_("ecdg_fi_preview_font_preview_reference"))); } if (str != NULL) g_free (str); str = NULL; /* size */ if (size_set) { attr = pango_attr_size_new (size * PANGO_SCALE); add_preview_text_attr (list, attr, 0, strlen (_("ecdg_fi_preview_font_preview_reference"))); } gtk_label_set_attributes (GTK_LABEL (preview_label), list); pango_attr_list_unref (list); /*And show the dialog*/ gtk_window_set_transient_for (GTK_WINDOW (preview_dialog), GTK_WINDOW (fontsel)); gtk_widget_show_all (preview_dialog); gtk_dialog_set_default_response (GTK_DIALOG (preview_dialog), GTK_RESPONSE_OK); GtkBox *action_area = (GtkBox *) GTK_DIALOG (preview_dialog)->action_area; GtkWidget *button = ((GtkBoxChild *) ((GSList *) action_area->children)->data)->widget; gtk_widget_grab_focus (button); gtk_dialog_run (GTK_DIALOG (preview_dialog)); gtk_widget_destroy (preview_dialog); }
static gboolean span_parse_func (MarkupData *md, OpenTag *tag, const gchar **names, const gchar **values, GMarkupParseContext *context, GError **error) { int line_number, char_number; int i; const char *family = NULL; const char *size = NULL; const char *style = NULL; const char *weight = NULL; const char *variant = NULL; const char *stretch = NULL; const char *desc = NULL; const char *foreground = NULL; const char *background = NULL; const char *underline = NULL; const char *underline_color = NULL; const char *strikethrough = NULL; const char *strikethrough_color = NULL; const char *rise = NULL; const char *letter_spacing = NULL; const char *lang = NULL; const char *fallback = NULL; const char *gravity = NULL; const char *gravity_hint = NULL; g_markup_parse_context_get_position (context, &line_number, &char_number); #define CHECK_DUPLICATE(var) G_STMT_START{ \ if ((var) != NULL) { \ g_set_error (error, G_MARKUP_ERROR, \ G_MARKUP_ERROR_INVALID_CONTENT, \ _("Attribute '%s' occurs twice on <span> tag " \ "on line %d char %d, may only occur once"), \ names[i], line_number, char_number); \ return FALSE; \ }}G_STMT_END #define CHECK_ATTRIBUTE2(var, name) \ if (attr_strcmp (names[i], (name)) == 0) { \ CHECK_DUPLICATE (var); \ (var) = values[i]; \ found = TRUE; \ break; \ } #define CHECK_ATTRIBUTE(var) CHECK_ATTRIBUTE2 (var, G_STRINGIFY (var)) i = 0; while (names[i]) { gboolean found = FALSE; switch (names[i][0]) { case 'f': CHECK_ATTRIBUTE (fallback); CHECK_ATTRIBUTE2(desc, "font"); CHECK_ATTRIBUTE2(desc, "font_desc"); CHECK_ATTRIBUTE2(family, "face"); CHECK_ATTRIBUTE2(family, "font_family"); CHECK_ATTRIBUTE2(size, "font_size"); CHECK_ATTRIBUTE2(stretch, "font_stretch"); CHECK_ATTRIBUTE2(style, "font_style"); CHECK_ATTRIBUTE2(variant, "font_variant"); CHECK_ATTRIBUTE2(weight, "font_weight"); CHECK_ATTRIBUTE (foreground); CHECK_ATTRIBUTE2 (foreground, "fgcolor"); break; case 's': CHECK_ATTRIBUTE (size); CHECK_ATTRIBUTE (stretch); CHECK_ATTRIBUTE (strikethrough); CHECK_ATTRIBUTE (strikethrough_color); CHECK_ATTRIBUTE (style); break; case 'g': CHECK_ATTRIBUTE (gravity); CHECK_ATTRIBUTE (gravity_hint); break; case 'l': CHECK_ATTRIBUTE (lang); CHECK_ATTRIBUTE (letter_spacing); break; case 'u': CHECK_ATTRIBUTE (underline); CHECK_ATTRIBUTE (underline_color); break; default: CHECK_ATTRIBUTE (background); CHECK_ATTRIBUTE2 (background, "bgcolor"); CHECK_ATTRIBUTE2(foreground, "color"); CHECK_ATTRIBUTE (rise); CHECK_ATTRIBUTE (variant); CHECK_ATTRIBUTE (weight); break; } if (!found) { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, _("Attribute '%s' is not allowed on the <span> tag " "on line %d char %d"), names[i], line_number, char_number); return FALSE; } ++i; } /* Parse desc first, then modify it with other font-related attributes. */ if (G_UNLIKELY (desc)) { PangoFontDescription *parsed; parsed = pango_font_description_from_string (desc); if (parsed) { add_attribute (tag, pango_attr_font_desc_new (parsed)); if (tag) open_tag_set_absolute_font_size (tag, pango_font_description_get_size (parsed)); pango_font_description_free (parsed); } } if (G_UNLIKELY (family)) { add_attribute (tag, pango_attr_family_new (family)); } if (G_UNLIKELY (size)) { if (g_ascii_isdigit (*size)) { const char *end; gint n; /* cap size from the top at an arbitrary 2048 */ #define MAX_SIZE (2048 * PANGO_SCALE) if ((end = size, !pango_scan_int (&end, &n)) || *end != '\0' || n < 0 || n > MAX_SIZE) { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, _("Value of 'size' attribute on <span> tag on line %d " "could not be parsed; should be an integer less than %d, or a " "string such as 'small', not '%s'"), line_number, MAX_SIZE+1, size); goto error; } add_attribute (tag, pango_attr_size_new (n)); if (tag) open_tag_set_absolute_font_size (tag, n); } else if (strcmp (size, "smaller") == 0) { if (tag) { tag->scale_level_delta -= 1; tag->scale_level -= 1; } } else if (strcmp (size, "larger") == 0) { if (tag) { tag->scale_level_delta += 1; tag->scale_level += 1; } } else if (parse_absolute_size (tag, size)) ; /* nothing */ else { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, _("Value of 'size' attribute on <span> tag on line %d " "could not be parsed; should be an integer, or a " "string such as 'small', not '%s'"), line_number, size); goto error; } } if (G_UNLIKELY (style)) { PangoStyle pango_style; if (pango_parse_style (style, &pango_style, FALSE)) add_attribute (tag, pango_attr_style_new (pango_style)); else { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, _("'%s' is not a valid value for the 'style' attribute " "on <span> tag, line %d; valid values are " "'normal', 'oblique', 'italic'"), style, line_number); goto error; } } if (G_UNLIKELY (weight)) { PangoWeight pango_weight; if (pango_parse_weight (weight, &pango_weight, FALSE)) add_attribute (tag, pango_attr_weight_new (pango_weight)); else { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, _("'%s' is not a valid value for the 'weight' " "attribute on <span> tag, line %d; valid " "values are for example 'light', 'ultrabold' or a number"), weight, line_number); goto error; } } if (G_UNLIKELY (variant)) { PangoVariant pango_variant; if (pango_parse_variant (variant, &pango_variant, FALSE)) add_attribute (tag, pango_attr_variant_new (pango_variant)); else { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, _("'%s' is not a valid value for the 'variant' " "attribute on <span> tag, line %d; valid values are " "'normal', 'smallcaps'"), variant, line_number); goto error; } } if (G_UNLIKELY (stretch)) { PangoStretch pango_stretch; if (pango_parse_stretch (stretch, &pango_stretch, FALSE)) add_attribute (tag, pango_attr_stretch_new (pango_stretch)); else { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, _("'%s' is not a valid value for the 'stretch' " "attribute on <span> tag, line %d; valid " "values are for example 'condensed', " "'ultraexpanded', 'normal'"), stretch, line_number); goto error; } } if (G_UNLIKELY (foreground)) { PangoColor color; if (!span_parse_color ("foreground", foreground, &color, line_number, error)) goto error; add_attribute (tag, pango_attr_foreground_new (color.red, color.green, color.blue)); } if (G_UNLIKELY (background)) { PangoColor color; if (!span_parse_color ("background", background, &color, line_number, error)) goto error; add_attribute (tag, pango_attr_background_new (color.red, color.green, color.blue)); } if (G_UNLIKELY (underline)) { PangoUnderline ul = PANGO_UNDERLINE_NONE; if (!span_parse_enum ("underline", underline, PANGO_TYPE_UNDERLINE, &ul, line_number, error)) goto error; add_attribute (tag, pango_attr_underline_new (ul)); } if (G_UNLIKELY (underline_color)) { PangoColor color; if (!span_parse_color ("underline_color", underline_color, &color, line_number, error)) goto error; add_attribute (tag, pango_attr_underline_color_new (color.red, color.green, color.blue)); } if (G_UNLIKELY (gravity)) { PangoGravity gr = PANGO_GRAVITY_SOUTH; if (!span_parse_enum ("gravity", gravity, PANGO_TYPE_GRAVITY, &gr, line_number, error)) goto error; add_attribute (tag, pango_attr_gravity_new (gr)); } if (G_UNLIKELY (gravity_hint)) { PangoGravityHint hint = PANGO_GRAVITY_HINT_NATURAL; if (!span_parse_enum ("gravity_hint", gravity_hint, PANGO_TYPE_GRAVITY_HINT, &hint, line_number, error)) goto error; add_attribute (tag, pango_attr_gravity_hint_new (hint)); } if (G_UNLIKELY (strikethrough)) { gboolean b = FALSE; if (!span_parse_boolean ("strikethrough", strikethrough, &b, line_number, error)) goto error; add_attribute (tag, pango_attr_strikethrough_new (b)); } if (G_UNLIKELY (strikethrough_color)) { PangoColor color; if (!span_parse_color ("strikethrough_color", strikethrough_color, &color, line_number, error)) goto error; add_attribute (tag, pango_attr_strikethrough_color_new (color.red, color.green, color.blue)); } if (G_UNLIKELY (fallback)) { gboolean b = FALSE; if (!span_parse_boolean ("fallback", fallback, &b, line_number, error)) goto error; add_attribute (tag, pango_attr_fallback_new (b)); } if (G_UNLIKELY (rise)) { gint n = 0; if (!span_parse_int ("rise", rise, &n, line_number, error)) goto error; add_attribute (tag, pango_attr_rise_new (n)); } if (G_UNLIKELY (letter_spacing)) { gint n = 0; if (!span_parse_int ("letter_spacing", letter_spacing, &n, line_number, error)) goto error; add_attribute (tag, pango_attr_letter_spacing_new (n)); } if (G_UNLIKELY (lang)) { add_attribute (tag, pango_attr_language_new (pango_language_from_string (lang))); } return TRUE; error: return FALSE; }
struct info_popup_t *info_popup_create(char *text) { struct info_popup_t *popup; /* Allocate */ popup = calloc(1, sizeof(struct info_popup_t)); if (!popup) fatal("%s: out of memory", __FUNCTION__); /* Create window */ GtkWidget *window; window = gtk_window_new(GTK_WINDOW_POPUP); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE); gtk_window_set_modal(GTK_WINDOW(window), TRUE); gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK); g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(info_popup_button_press_event), popup); g_signal_connect(G_OBJECT(window), "motion-notify-event", G_CALLBACK(info_popup_motion_event), popup); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(info_popup_destroy_event), popup); popup->window = window; /* Create label with text */ GtkWidget *label; label = gtk_label_new(text); gtk_widget_set_size_request(window, -1, 250); //gtk_label_set_selectable(GTK_LABEL(label), TRUE); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_label_set_line_wrap_mode(GTK_LABEL(label), TRUE); //gtk_label_select_region(GTK_LABEL(label), 0, 0); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); /* Label font */ PangoAttrList *attrs; attrs = pango_attr_list_new(); PangoAttribute *attr_family = pango_attr_family_new("Courier"); PangoAttribute *attr_size = pango_attr_size_new(10 << 10); pango_attr_list_insert(attrs, attr_family); pango_attr_list_insert(attrs, attr_size); gtk_label_set_attributes(GTK_LABEL(label), attrs); /* Scrolled window */ GtkWidget *scrolled_window; GtkWidget *viewport; scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); viewport = gtk_viewport_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(viewport), label); gtk_container_add(GTK_CONTAINER(scrolled_window), viewport); gtk_container_add(GTK_CONTAINER(window), scrolled_window); /* Background color */ GdkColor color; gdk_color_parse("#ffffa0", &color); gtk_widget_modify_bg(viewport, GTK_STATE_NORMAL, &color); /* Return */ return popup; }