[gtk+] widget-factory: Improve context menu example
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget-factory: Improve context menu example
- Date: Sun, 7 Jun 2015 05:24:50 +0000 (UTC)
commit 359d1951bc2b7fcf7524bf4d1e78abcd41c7b26b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jun 7 01:24:13 2015 -0400
widget-factory: Improve context menu example
Show the text formatting in the menu / popover.
demos/widget-factory/widget-factory.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 10815ea..be03612 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -1143,25 +1143,30 @@ activate_item (GtkWidget *item, GtkTextView *tv)
static void
add_item (GtkTextView *tv,
GtkWidget *popup,
- const gchar *label,
+ const gchar *text,
const gchar *tag,
gboolean set)
{
- GtkWidget *item;
+ GtkWidget *item, *label;
if (GTK_IS_MENU (popup))
{
- item = gtk_check_menu_item_new_with_label (label);
+ item = gtk_check_menu_item_new ();
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), set);
g_signal_connect (item, "toggled", G_CALLBACK (activate_item), tv);
}
else
{
- item = gtk_check_button_new_with_label (label);
+ item = gtk_check_button_new ();
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), set);
g_signal_connect (item, "clicked", G_CALLBACK (activate_item), tv);
}
+ label = gtk_label_new ("");
+ gtk_label_set_xalign (GTK_LABEL (label), 0);
+ gtk_label_set_markup (GTK_LABEL (label), text);
+ gtk_widget_show (label);
+ gtk_container_add (GTK_CONTAINER (item), label);
g_object_set_data (G_OBJECT (item), "tag", (gpointer)tag);
gtk_widget_show (item);
gtk_container_add (GTK_CONTAINER (popup), item);
@@ -1206,9 +1211,9 @@ populate_popup (GtkTextView *tv,
gtk_container_add (GTK_CONTAINER (popup), item);
}
- add_item (tv, popup, "Bold", "bold", all_bold);
- add_item (tv, popup, "Italics", "italic", all_italic);
- add_item (tv, popup, "Underline", "underline", all_underline);
+ add_item (tv, popup, "<b>Bold</b>", "bold", all_bold);
+ add_item (tv, popup, "<i>Italics</i>", "italic", all_italic);
+ add_item (tv, popup, "<u>Underline</u>", "underline", all_underline);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]