[glide] Add align buttons to text thing
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] Add align buttons to text thing
- Date: Sun, 2 May 2010 08:11:41 +0000 (UTC)
commit a3e692bcdd2ca2d3585a3a3a15a0004d94bee07f
Author: Robert Carr <racarr Valentine localdomain>
Date: Sun May 2 02:56:18 2010 -0400
Add align buttons to text thing
src/glide-inspector-text.c | 82 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/src/glide-inspector-text.c b/src/glide-inspector-text.c
index b701714..9274ec5 100644
--- a/src/glide-inspector-text.c
+++ b/src/glide-inspector-text.c
@@ -38,6 +38,38 @@ enum {
};
static void
+glide_inspector_text_align_text (GlideInspectorText *ins, PangoAlignment alignment)
+{
+ glide_actor_start_undo (ins->priv->actor, "Set text alignment");
+ glide_text_set_line_alignment (GLIDE_TEXT (ins->priv->actor), alignment);
+ glide_actor_end_undo (ins->priv->actor);
+}
+
+static void
+glide_inspector_text_align_left_clicked (GtkWidget *widg,
+ gpointer user_data)
+{
+ GlideInspectorText *ins = (GlideInspectorText *)user_data;
+ glide_inspector_text_align_text (ins, PANGO_ALIGN_LEFT);
+}
+
+static void
+glide_inspector_text_align_center_clicked (GtkWidget *widg,
+ gpointer user_data)
+{
+ GlideInspectorText *ins = (GlideInspectorText *)user_data;
+ glide_inspector_text_align_text (ins, PANGO_ALIGN_CENTER);
+}
+
+static void
+glide_inspector_text_align_right_clicked (GtkWidget *widg,
+ gpointer user_data)
+{
+ GlideInspectorText *ins = (GlideInspectorText *)user_data;
+ glide_inspector_text_align_text (ins, PANGO_ALIGN_RIGHT);
+}
+
+static void
glide_inspector_text_update_color (GlideInspectorText *ins)
{
ClutterColor cc;
@@ -158,6 +190,54 @@ glide_inspector_text_set_property (GObject *object,
}
}
+static GtkWidget *
+glide_inspector_text_make_alignment_button (const gchar *stock)
+{
+ GtkWidget *image = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_MENU);
+ GtkWidget *button = gtk_button_new ();
+
+ gtk_container_add (GTK_CONTAINER (button), image);
+
+ return button;
+}
+
+static GtkWidget *
+glide_inspector_text_make_alignment_button_box (GlideInspectorText *ins)
+{
+ GtkWidget *bbox = gtk_hbox_new (FALSE, 0);
+ GtkWidget *lbutton, *cbutton, *rbutton;
+
+ lbutton = glide_inspector_text_make_alignment_button (GTK_STOCK_JUSTIFY_LEFT);
+ cbutton = glide_inspector_text_make_alignment_button (GTK_STOCK_JUSTIFY_CENTER);
+ rbutton = glide_inspector_text_make_alignment_button (GTK_STOCK_JUSTIFY_RIGHT);
+
+ g_signal_connect (lbutton, "clicked", G_CALLBACK (glide_inspector_text_align_left_clicked), ins);
+ g_signal_connect (cbutton, "clicked", G_CALLBACK (glide_inspector_text_align_center_clicked), ins);
+ g_signal_connect (rbutton, "clicked", G_CALLBACK (glide_inspector_text_align_right_clicked), ins);
+
+ gtk_box_pack_start (GTK_BOX (bbox), lbutton, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (bbox), cbutton, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (bbox), rbutton, FALSE, FALSE, 0);
+ return bbox;
+}
+
+static GtkWidget *
+glide_inspector_text_make_alignment_box (GlideInspectorText *ins)
+{
+ GtkWidget *ret = gtk_hbox_new (FALSE, 0);
+ GtkWidget *label = gtk_label_new (NULL);
+ GtkWidget *align = gtk_alignment_new (1, 0, 0.0, 1);
+ GtkWidget *bbox = glide_inspector_text_make_alignment_button_box (ins);
+
+ gtk_label_set_markup (GTK_LABEL (label), "<b>Alignment:</b>");
+
+ gtk_container_add (GTK_CONTAINER (align), bbox);
+ gtk_box_pack_start (GTK_BOX (ret), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(ret), align, TRUE, TRUE, 0);
+
+ return ret;
+}
+
static GtkWidget*
glide_inspector_text_make_color_box (GlideInspectorText *ins)
{
@@ -205,9 +285,11 @@ glide_inspector_text_setup_ui (GlideInspectorText *ins)
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
GtkWidget *font_box = glide_inspector_text_make_font_box (ins);
GtkWidget *color_box = glide_inspector_text_make_color_box (ins);
+ GtkWidget *alignment_box = glide_inspector_text_make_alignment_box (ins);
gtk_box_pack_start (GTK_BOX (vbox), font_box, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), color_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), alignment_box, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (ins), vbox);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]