[glide] Start implementing the slide inspector
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] Start implementing the slide inspector
- Date: Sun, 2 May 2010 08:11:05 +0000 (UTC)
commit 8c09fa0204b1c6d8c351ec6dd0527f1c53968dc9
Author: Robert Carr <racarr Valentine localdomain>
Date: Sun May 2 01:53:15 2010 -0400
Start implementing the slide inspector
src/glide-inspector-image-priv.h | 3 +
src/glide-inspector-image.c | 37 +++++++++
src/glide-inspector-slide-priv.h | 7 ++
src/glide-inspector-slide.c | 160 ++++++++++++++++++++++++++++++++++++++
4 files changed, 207 insertions(+), 0 deletions(-)
---
diff --git a/src/glide-inspector-image-priv.h b/src/glide-inspector-image-priv.h
index efce123..093cd10 100644
--- a/src/glide-inspector-image-priv.h
+++ b/src/glide-inspector-image-priv.h
@@ -27,6 +27,9 @@ G_BEGIN_DECLS
struct _GlideInspectorImagePrivate
{
GlideActor *actor;
+ GtkWidget *chooser_button;
+
+ gboolean ignore_set;
};
G_END_DECLS
diff --git a/src/glide-inspector-image.c b/src/glide-inspector-image.c
index c43fd4c..43c73ad 100644
--- a/src/glide-inspector-image.c
+++ b/src/glide-inspector-image.c
@@ -38,6 +38,38 @@ enum {
};
static void
+glide_inspector_image_update_filename (GlideInspectorImage *ins)
+{
+ gchar *path = glide_actor_get_resource_path (ins->priv->actor,
+ glide_image_get_filename (GLIDE_IMAGE (ins->priv->actor)));
+ ins->priv->ignore_set = TRUE;
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (ins->priv->chooser_button), path);
+ ins->priv->ignore_set = FALSE;
+ g_free (path);
+}
+
+static void
+glide_inspector_image_file_set (GtkFileChooserButton *file_button,
+ gpointer user_data)
+{
+ GlideInspectorImage *ins = (GlideInspectorImage *)user_data;
+ gchar *filename;
+
+ if (ins->priv->ignore_set)
+ return;
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_button));
+
+ // TODO: Error
+ // TODO: Doesn't work?
+ glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (ins->priv->actor),
+ ins->priv->actor, "Modify image filename");
+ glide_image_set_from_file (GLIDE_IMAGE (ins->priv->actor), filename, NULL);
+ glide_undo_manager_end_actor_action (glide_actor_get_undo_manager (ins->priv->actor),
+ ins->priv->actor);
+}
+
+static void
glide_inspector_image_finalize (GObject *object)
{
@@ -95,6 +127,10 @@ glide_inspector_image_make_file_box (GlideInspectorImage *ins)
gtk_box_pack_start (GTK_BOX(ret), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(ret), align, TRUE, TRUE, 0);
+
+ ins->priv->chooser_button = button;
+
+ g_signal_connect (button, "file-set", G_CALLBACK (glide_inspector_image_file_set), ins);
return ret;
}
@@ -169,6 +205,7 @@ glide_inspector_image_set_actor (GlideInspectorImage *inspector,
else
{
gtk_widget_set_sensitive (GTK_WIDGET (inspector), TRUE);
+ glide_inspector_image_update_filename (inspector);
}
g_object_notify (G_OBJECT (inspector), "actor");
diff --git a/src/glide-inspector-slide-priv.h b/src/glide-inspector-slide-priv.h
index 21d3900..c5be523 100644
--- a/src/glide-inspector-slide-priv.h
+++ b/src/glide-inspector-slide-priv.h
@@ -27,6 +27,13 @@ G_BEGIN_DECLS
struct _GlideInspectorSlidePrivate
{
GlideActor *actor;
+ GtkWidget *chooser_button;
+ GtkWidget *color_button;
+
+ gboolean ignore_set;
+
+ gulong background_notify_id;
+ gulong color_notify_id;
};
G_END_DECLS
diff --git a/src/glide-inspector-slide.c b/src/glide-inspector-slide.c
index 1ac44b6..1df76db 100644
--- a/src/glide-inspector-slide.c
+++ b/src/glide-inspector-slide.c
@@ -38,6 +38,90 @@ enum {
};
static void
+glide_inspector_slide_update_color (GlideInspectorSlide *ins)
+{
+ ClutterColor cc;
+ GdkColor c;
+
+ glide_slide_get_color (GLIDE_SLIDE (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_slide_update_filename (GlideInspectorSlide *ins)
+{
+ gchar *path = glide_actor_get_resource_path (ins->priv->actor,
+ glide_slide_get_background (GLIDE_SLIDE (ins->priv->actor)));
+ ins->priv->ignore_set = TRUE;
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (ins->priv->chooser_button), path);
+ ins->priv->ignore_set = FALSE;
+ g_free (path);
+}
+
+static void
+glide_inspector_slide_color_changed (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GlideInspectorSlide *ins = (GlideInspectorSlide *)user_data;
+ glide_inspector_slide_update_color (ins);
+}
+
+
+static void
+glide_inspector_slide_background_changed (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GlideInspectorSlide *ins = (GlideInspectorSlide *)user_data;
+ glide_inspector_slide_update_filename (ins);
+}
+
+static void
+glide_inspector_slide_color_set (GtkColorButton *widg,
+ gpointer user_data)
+{
+ GlideInspectorSlide *ins = (GlideInspectorSlide *)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_undo_manager_start_slide_action (glide_actor_get_undo_manager (ins->priv->actor), GLIDE_SLIDE (ins->priv->actor),
+ "Set slide color.");
+ glide_slide_set_color (GLIDE_SLIDE (ins->priv->actor), &cc);
+ glide_undo_manager_end_slide_action (glide_actor_get_undo_manager (ins->priv->actor), GLIDE_SLIDE (ins->priv->actor));
+}
+
+static void
+glide_inspector_slide_file_set (GtkFileChooserButton *file_button,
+ gpointer user_data)
+{
+ GlideInspectorSlide *ins = (GlideInspectorSlide *)user_data;
+ gchar *filename;
+
+ if (ins->priv->ignore_set)
+ return;
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_button));
+
+ glide_undo_manager_start_slide_action (glide_actor_get_undo_manager (ins->priv->actor), GLIDE_SLIDE (ins->priv->actor),
+ "Set slide background.");
+ glide_slide_set_background (GLIDE_SLIDE (ins->priv->actor), filename);
+ glide_undo_manager_end_slide_action (glide_actor_get_undo_manager (ins->priv->actor), GLIDE_SLIDE (ins->priv->actor));
+
+ g_free (filename);
+}
+
+static void
glide_inspector_slide_finalize (GObject *object)
{
@@ -81,11 +165,70 @@ glide_inspector_slide_set_property (GObject *object,
}
}
+static GtkWidget*
+glide_inspector_slide_make_color_box (GlideInspectorSlide *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>Background 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_slide_color_set), ins);
+
+ return ret;
+}
+
+static GtkWidget*
+glide_inspector_slide_make_file_box (GlideInspectorSlide *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_file_chooser_button_new ("Select image", GTK_FILE_CHOOSER_ACTION_OPEN);
+
+ gtk_label_set_markup (GTK_LABEL (label), "<b>Background Image:</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->chooser_button = button;
+
+ g_signal_connect (button, "file-set", G_CALLBACK (glide_inspector_slide_file_set), ins);
+
+ return ret;
+}
+
+static void
+glide_inspector_slide_setup_ui (GlideInspectorSlide *ins)
+{
+ GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
+ GtkWidget *file_box = glide_inspector_slide_make_file_box (ins);
+ GtkWidget *color_box = glide_inspector_slide_make_color_box (ins);
+
+ gtk_box_pack_start (GTK_BOX (vbox), file_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), color_box, FALSE, FALSE, 0);
+
+ gtk_container_add (GTK_CONTAINER (ins), vbox);
+
+}
+
static void
glide_inspector_slide_init (GlideInspectorSlide *inspector)
{
inspector->priv = GLIDE_INSPECTOR_SLIDE_GET_PRIVATE (inspector);
+ glide_inspector_slide_setup_ui (inspector);
+
gtk_widget_set_sensitive (GTK_WIDGET (inspector), FALSE);
gtk_alignment_set (GTK_ALIGNMENT (inspector), .5, 0, 0.8, 1.0);
@@ -129,6 +272,16 @@ void
glide_inspector_slide_set_actor (GlideInspectorSlide *inspector,
GlideActor *actor)
{
+ if (inspector->priv->background_notify_id)
+ {
+ g_signal_handler_disconnect (inspector->priv->actor,
+ inspector->priv->background_notify_id);
+ inspector->priv->background_notify_id = 0;
+
+ g_signal_handler_disconnect (inspector->priv->actor,
+ inspector->priv->color_notify_id);
+ inspector->priv->color_notify_id = 0;
+ }
inspector->priv->actor = actor;
if (!GLIDE_IS_SLIDE (actor))
@@ -138,6 +291,13 @@ glide_inspector_slide_set_actor (GlideInspectorSlide *inspector,
else
{
gtk_widget_set_sensitive (GTK_WIDGET (inspector), TRUE);
+ glide_inspector_slide_update_filename (inspector);
+ glide_inspector_slide_update_color (inspector);
+
+ inspector->priv->background_notify_id = g_signal_connect (actor, "notify::background", G_CALLBACK (glide_inspector_slide_background_changed),
+ inspector);
+ inspector->priv->color_notify_id = g_signal_connect (actor, "notify::color", G_CALLBACK (glide_inspector_slide_color_changed),
+ inspector);
}
g_object_notify (G_OBJECT (inspector), "actor");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]