[glide] Implement text color setting
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] Implement text color setting
- Date: Sun, 2 May 2010 08:11:30 +0000 (UTC)
commit 1cebce98ec2a911f677f3db39f74340f24dac7ed
Author: Robert Carr <racarr Valentine localdomain>
Date: Sun May 2 02:19:19 2010 -0400
Implement text color setting
src/glide-inspector-text-priv.h | 2 +
src/glide-inspector-text.c | 69 +++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 0 deletions(-)
---
diff --git a/src/glide-inspector-text-priv.h b/src/glide-inspector-text-priv.h
index e0819bd..6c932ab 100644
--- a/src/glide-inspector-text-priv.h
+++ b/src/glide-inspector-text-priv.h
@@ -29,10 +29,12 @@ struct _GlideInspectorTextPrivate
GlideActor *actor;
GtkWidget *font_button;
+ GtkWidget *color_button;
gboolean ignore_set;
gulong font_notify_id;
+ gulong color_notify_id;
};
G_END_DECLS
diff --git a/src/glide-inspector-text.c b/src/glide-inspector-text.c
index 35e9284..b701714 100644
--- a/src/glide-inspector-text.c
+++ b/src/glide-inspector-text.c
@@ -38,6 +38,48 @@ enum {
};
static void
+glide_inspector_text_update_color (GlideInspectorText *ins)
+{
+ ClutterColor cc;
+ GdkColor c;
+
+ glide_text_get_color (GLIDE_TEXT (ins->priv->actor), &cc);
+ glide_gdk_color_from_clutter_color (&cc, &c);
+
+ ins->priv->ignore_set = TRUE;
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (ins->priv->color_button), &c);
+ ins->priv->ignore_set = FALSE;
+}
+
+static void
+glide_inspector_text_color_changed (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GlideInspectorText *ins = (GlideInspectorText *)user_data;
+ glide_inspector_text_update_color (ins);
+}
+
+static void
+glide_inspector_text_color_set (GtkColorButton *widg,
+ gpointer user_data)
+{
+ GlideInspectorText *ins = (GlideInspectorText *)user_data;
+ GdkColor c;
+ ClutterColor cc;
+
+ if (ins->priv->ignore_set)
+ return;
+
+ gtk_color_button_get_color (widg, &c);
+ glide_clutter_color_from_gdk_color (&c, &cc);
+
+ glide_actor_start_undo (ins->priv->actor, "Modify text color");
+ glide_text_set_color (GLIDE_TEXT (ins->priv->actor), &cc);
+ glide_actor_end_undo (ins->priv->actor);
+}
+
+static void
glide_inspector_text_update_fontname (GlideInspectorText *ins)
{
const gchar *fontname = glide_text_get_font_name (GLIDE_TEXT (ins->priv->actor));
@@ -116,6 +158,27 @@ glide_inspector_text_set_property (GObject *object,
}
}
+static GtkWidget*
+glide_inspector_text_make_color_box (GlideInspectorText *ins)
+{
+ GtkWidget *ret = gtk_hbox_new (FALSE, 0);
+ GtkWidget *label = gtk_label_new (NULL);
+ GtkWidget *align = gtk_alignment_new (1, 0, 0.6, 1);
+ GtkWidget *button = gtk_color_button_new ();
+
+ gtk_label_set_markup (GTK_LABEL (label), "<b>Color:</b>");
+
+ gtk_container_add (GTK_CONTAINER (align), button);
+
+ gtk_box_pack_start (GTK_BOX(ret), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(ret), align, TRUE, TRUE, 0);
+
+ ins->priv->color_button = button;
+ g_signal_connect (button, "color-set", G_CALLBACK (glide_inspector_text_color_set), ins);
+
+ return ret;
+}
+
static GtkWidget *
glide_inspector_text_make_font_box (GlideInspectorText *ins)
{
@@ -141,8 +204,10 @@ 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);
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_container_add (GTK_CONTAINER (ins), vbox);
}
@@ -215,10 +280,14 @@ glide_inspector_text_set_actor (GlideInspectorText *inspector,
{
gtk_widget_set_sensitive (GTK_WIDGET (inspector), TRUE);
glide_inspector_text_update_fontname (inspector);
+ glide_inspector_text_update_color (inspector);
inspector->priv->font_notify_id = g_signal_connect (actor, "notify::font-name",
G_CALLBACK (glide_inspector_text_fontname_changed),
inspector);
+ inspector->priv->color_notify_id = g_signal_connect (actor, "notify::color",
+ G_CALLBACK (glide_inspector_text_color_changed),
+ inspector);
}
g_object_notify (G_OBJECT (inspector), "actor");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]