[glide] New theme chooser has selections
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] New theme chooser has selections
- Date: Sat, 5 Jun 2010 22:30:46 +0000 (UTC)
commit fde68fe73e09c95e13a194c911a6f1275ed7d5e6
Author: Robert Carr <racarr Valentine localdomain>
Date: Sat Jun 5 18:21:39 2010 -0400
New theme chooser has selections
libglide/glide-theme-chooser-priv.h | 2 +
libglide/glide-theme-chooser.c | 27 ++++++++++++
libglide/glide-theme-preview-actor-priv.h | 3 +
libglide/glide-theme-preview-actor.c | 64 ++++++++++++++++++++++++++++-
libglide/glide-theme-preview-actor.h | 3 +
5 files changed, 97 insertions(+), 2 deletions(-)
---
diff --git a/libglide/glide-theme-chooser-priv.h b/libglide/glide-theme-chooser-priv.h
index 3b2623e..b847386 100644
--- a/libglide/glide-theme-chooser-priv.h
+++ b/libglide/glide-theme-chooser-priv.h
@@ -35,6 +35,8 @@ struct _GlideThemeChooserPrivate
ClutterLayoutManager *layout;
GlideTheme *theme;
+
+ ClutterActor *selection;
};
G_END_DECLS
diff --git a/libglide/glide-theme-chooser.c b/libglide/glide-theme-chooser.c
index 8ea833e..6191780 100644
--- a/libglide/glide-theme-chooser.c
+++ b/libglide/glide-theme-chooser.c
@@ -92,6 +92,29 @@ glide_theme_chooser_set_property (GObject *object,
}
}
+static gboolean
+glide_theme_chooser_stage_button_press (ClutterActor *actor,
+ ClutterButtonEvent *bev,
+ gpointer user_data)
+{
+ GlideThemeChooser *chooser = (GlideThemeChooser *)user_data;
+ ClutterActor *clicked;
+
+ if (chooser->priv->selection)
+ glide_theme_preview_actor_set_selected (GLIDE_THEME_PREVIEW_ACTOR (chooser->priv->selection),
+ FALSE);
+
+ clicked = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (actor), CLUTTER_PICK_REACTIVE,
+ bev->x, bev->y);
+ if (!clicked)
+ return;
+
+ chooser->priv->selection = clicked;
+
+ glide_theme_preview_actor_set_selected (GLIDE_THEME_PREVIEW_ACTOR (chooser->priv->selection),
+ TRUE);
+}
+
static ClutterLayoutManager *
glide_theme_chooser_make_layout (GlideThemeChooser *chooser)
{
@@ -191,6 +214,10 @@ glide_theme_chooser_setup_stage (GlideThemeChooser *chooser)
clutter_actor_show_all (stage);
+ g_signal_connect (stage, "button-press-event",
+ G_CALLBACK (glide_theme_chooser_stage_button_press),
+ chooser);
+
chooser->priv->stage = stage;
glide_theme_chooser_populate_stage (chooser);
diff --git a/libglide/glide-theme-preview-actor-priv.h b/libglide/glide-theme-preview-actor-priv.h
index 56f7177..f44d6f3 100644
--- a/libglide/glide-theme-preview-actor-priv.h
+++ b/libglide/glide-theme-preview-actor-priv.h
@@ -29,6 +29,9 @@ struct _GlideThemePreviewActorPrivate
GlideTheme *theme;
ClutterActor *preview_texture;
+ ClutterActor *border;
+
+ gboolean selected;
};
G_END_DECLS
diff --git a/libglide/glide-theme-preview-actor.c b/libglide/glide-theme-preview-actor.c
index 9a22080..516d4d6 100644
--- a/libglide/glide-theme-preview-actor.c
+++ b/libglide/glide-theme-preview-actor.c
@@ -35,7 +35,8 @@ G_DEFINE_TYPE(GlideThemePreviewActor, glide_theme_preview_actor, CLUTTER_TYPE_GR
enum {
PROP_0,
- PROP_THEME
+ PROP_THEME,
+ PROP_SELECTED
};
static void
@@ -67,6 +68,9 @@ glide_theme_preview_actor_get_property (GObject *object,
case PROP_THEME:
g_value_set_object (value, preview->priv->theme);
break;
+ case PROP_SELECTED:
+ g_value_set_boolean (value, preview->priv->selected);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -85,6 +89,9 @@ glide_theme_preview_actor_set_property (GObject *object,
case PROP_THEME:
glide_theme_preview_actor_set_theme (preview, (GlideTheme *)g_value_get_object (value));
break;
+ case PROP_SELECTED:
+ glide_theme_preview_actor_set_selected (preview, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -92,6 +99,24 @@ glide_theme_preview_actor_set_property (GObject *object,
}
static void
+glide_theme_preview_actor_add_border (GlideThemePreviewActor *preview)
+{
+ ClutterActor *border = clutter_rectangle_new();
+ ClutterColor trans = {0x00,0x00,0x00,0x00};
+ ClutterColor grey = {0xdf,0xdf,0xdf,0xcc};
+
+ clutter_rectangle_set_color (CLUTTER_RECTANGLE (border), &trans);
+ clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (border), &grey);
+
+ clutter_rectangle_set_border_width (CLUTTER_RECTANGLE (border), 2);
+
+ clutter_actor_set_size (border, 100, 75);
+ clutter_actor_set_position (border, 0, 0);
+
+ preview->priv->border = border;
+}
+
+static void
glide_theme_preview_actor_init (GlideThemePreviewActor *preview)
{
preview->priv = GLIDE_THEME_PREVIEW_ACTOR_GET_PRIVATE (preview);
@@ -100,6 +125,10 @@ glide_theme_preview_actor_init (GlideThemePreviewActor *preview)
clutter_container_add_actor (CLUTTER_CONTAINER (preview), preview->priv->preview_texture);
clutter_actor_set_position (preview->priv->preview_texture, 0, 0);
+
+ glide_theme_preview_actor_add_border (preview);
+
+ clutter_actor_set_reactive (CLUTTER_ACTOR (preview), TRUE);
}
static void
@@ -119,8 +148,14 @@ glide_theme_preview_actor_class_init (GlideThemePreviewActorClass *klass)
"The theme we are previewing",
GLIDE_TYPE_THEME,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_SELECTED,
+ g_param_spec_boolean("selected",
+ "Selected",
+ "Whether the theme preview is selected",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
g_type_class_add_private (object_class, sizeof(GlideThemePreviewActorPrivate));
}
@@ -145,3 +180,28 @@ glide_theme_preview_actor_get_theme (GlideThemePreviewActor *preview)
{
return preview->priv->theme;
}
+
+
+gboolean
+glide_theme_preview_actor_get_selected (GlideThemePreviewActor *preview)
+{
+ return preview->priv->selected;
+}
+
+void
+glide_theme_preview_actor_set_selected (GlideThemePreviewActor *preview,
+ gboolean selected)
+{
+ preview->priv->selected = selected;
+ g_object_notify (G_OBJECT (preview), "selected");
+
+ if (selected)
+ {
+ clutter_container_add_actor (CLUTTER_CONTAINER (preview), preview->priv->border);
+ clutter_actor_show (preview->priv->border);
+ }
+ else
+ {
+ clutter_container_remove_actor (CLUTTER_CONTAINER (preview), preview->priv->border);
+ }
+}
diff --git a/libglide/glide-theme-preview-actor.h b/libglide/glide-theme-preview-actor.h
index 251b73d..ea65749 100644
--- a/libglide/glide-theme-preview-actor.h
+++ b/libglide/glide-theme-preview-actor.h
@@ -56,6 +56,9 @@ ClutterActor *glide_theme_preview_actor_new (void);
void glide_theme_preview_actor_set_theme (GlideThemePreviewActor *preview, GlideTheme *theme);
GlideTheme *glide_theme_preview_actor_get_theme (GlideThemePreviewActor *preview);
+void glide_theme_preview_actor_set_selected (GlideThemePreviewActor *preview, gboolean selected);
+gboolean glide_theme_preview_actor_get_selected (GlideThemePreviewActor *preview);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]