+2007-03-08 Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
+
+ * src/hildon-color-button-private.h:
+ * src/hildon-color-button.c:
+ * src/hildon-color-button.h: Adding a property 'is-popped' and some
+ functions to pop-up the color selection dialog.
+
+ * configure.ac:
+ * examples/Makefile.am:
+ * examples/hildon-color-pop-example.c: An example that pops-up the
+ dialog from another thread.
+
2007-03-07 Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
* src/hildon-caption.c:
# includes all the low-level flags
# FIXME Add esd and gconf flags
HILDON_OBJ_CFLAGS="\$(CFLAGS) \$(GTK_CFLAGS) \$(CHECK_CFLAGS) \$(GCONF_CFLAGS) -I\$(top_builddir)/src/"
-HILDON_OBJ_LIBS="\$(top_builddir)/src/libhildon_\$(PACKAGE_VERSION_MAJOR).la \$(GTK_LIBS) \$(GCONF_LIBS) \$(CHECK_LIBS)"
+HILDON_OBJ_LIBS="\$(top_builddir)/src/libhildon_\$(PACKAGE_VERSION_MAJOR).la \$(GTK_LIBS) \$(GCONF_LIBS) \$(CHECK_LIBS) `pkg-config --libs gthread-2.0`"
AC_SUBST(HILDON_OBJ_CFLAGS)
AC_SUBST(HILDON_OBJ_LIBS)
hildon-hvolumebar-example \
hildon-lookup-example \
hildon-number-editor-example \
- hildon-scrolled-window-example
+ hildon-scrolled-window-example \
+ hildon-color-pop-example
# HIldon window
hildon_window_example_LDADD = $(HILDON_OBJ_LIBS)
hildon_color_button_example_CFLAGS = $(HILDON_OBJ_CFLAGS)
hildon_color_button_example_SOURCES = hildon-color-button-example.c
+# Hildon color pop example
+hildon_color_pop_example_LDADD = $(HILDON_OBJ_LIBS)
+hildon_color_pop_example_CFLAGS = $(HILDON_OBJ_CFLAGS)
+hildon_color_pop_example_SOURCES = hildon-color-pop-example.c
+
# Hildon color button example
hildon_login_dialog_example_LDADD = $(HILDON_OBJ_LIBS)
hildon_login_dialog_example_CFLAGS = $(HILDON_OBJ_CFLAGS)
--- /dev/null
+/*
+ * This file is a part of hildon examples
+ *
+ * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
+ *
+ * Author: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include "hildon.h"
+#include <unistd.h>
+
+gpointer
+new_thread_func (gpointer data);
+
+gpointer
+new_thread_func (gpointer data)
+{
+ HildonColorButton *button = (HildonColorButton *) data;
+
+ sleep (3);
+
+
+ if (hildon_color_button_get_is_popped (button)) {
+ g_debug ("Dialog popped, trying to close it!");
+ hildon_color_button_pop_up (button);
+ } else {
+ g_debug ("Dialog not popped, doing nothing");
+ }
+
+ return NULL;
+}
+
+int
+main (int argc,
+ char **args)
+{
+ g_thread_init (NULL);
+ gtk_init (&argc, &args);
+
+ HildonProgram *program = hildon_program_get_instance ();
+
+ GtkWidget *window = hildon_window_new ();
+ hildon_program_add_window (program, HILDON_WINDOW (window));
+
+ GtkWidget *button = hildon_color_button_new ();
+
+ gtk_container_set_border_width (GTK_CONTAINER (window), 6);
+
+ g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+ gtk_container_add (GTK_CONTAINER (window), button);
+ gtk_widget_show_all (GTK_WIDGET (window));
+
+ g_thread_create (new_thread_func, button, TRUE, NULL);
+
+ gtk_main ();
+ return 0;
+}
+
+
struct _HildonColorButtonPrivate
{
GtkWidget *dialog;
+ gboolean popped;
GdkColor color;
GdkGC *gc;
enum
{
PROP_0,
- PROP_COLOR
+ PROP_COLOR,
+ PROP_IS_POPPED
};
static void
GDK_TYPE_COLOR,
G_PARAM_READWRITE));
+ /**
+ * HildonColorButton:is-popped:
+ *
+ * If the color selection dialog is currently popped-down (visible)
+ */
+ g_object_class_install_property (gobject_class, PROP_IS_POPPED,
+ g_param_spec_boolean ("is-popped",
+ "IsPopped",
+ "If the color selection dialog is popped down",
+ FALSE,
+ G_PARAM_READABLE));
+
g_type_class_add_private (gobject_class, sizeof (HildonColorButtonPrivate));
}
priv->dialog = NULL;
priv->gc = NULL;
+ priv->popped = FALSE;
gtk_widget_push_composite_child ();
if (priv->dialog)
{
- gtk_widget_destroy(priv->dialog);
+ gtk_widget_destroy (priv->dialog);
priv->dialog = NULL;
}
hildon_color_chooser_dialog_set_color (cs_dialog, &priv->color);
/* Update the color for color button if selection was made */
+ priv->popped = TRUE;
if (gtk_dialog_run (GTK_DIALOG (cs_dialog)) == GTK_RESPONSE_OK)
{
hildon_color_chooser_dialog_get_color (cs_dialog, &priv->color);
}
gtk_widget_hide (GTK_WIDGET(cs_dialog));
+ priv->popped = FALSE;
}
/* Popup a color selector dialog on hardkey Select press.
g_value_set_boxed (value, &priv->color);
break;
+ case PROP_IS_POPPED:
+ g_value_set_boolean (value, priv->popped);
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
/**
+ * hildon_color_button_get_is_popped
+ * @button: a #HildonColorButton
+ *
+ * This function checks if the color button has the color
+ * selection dialog currently popped-down.
+ *
+ * Returns: TRUE if the dialog is popped-down (visible to user).
+ *
+ */
+gboolean
+hildon_color_button_get_is_popped (HildonColorButton *button)
+{
+ HildonColorButtonPrivate *priv = NULL;
+ g_return_val_if_fail (HILDON_IS_COLOR_BUTTON (button), FALSE);
+
+ priv = HILDON_COLOR_BUTTON_GET_PRIVATE (button);
+ g_assert (priv);
+
+ return priv->popped;
+}
+
+/**
+ * hildon_color_button_pop_up
+ * @button: a #HildonColorButton
+ *
+ * If the color selection dialog is currently popped-down (visible)
+ * it will be popped-up (hidden).
+ *
+ */
+void
+hildon_color_button_pop_up (HildonColorButton *button)
+{
+ HildonColorButtonPrivate *priv = NULL;
+ g_return_if_fail (HILDON_IS_COLOR_BUTTON (button));
+
+ priv = HILDON_COLOR_BUTTON_GET_PRIVATE (button);
+ g_assert (priv);
+
+ if (priv->popped && priv->dialog) {
+ gtk_dialog_response (GTK_DIALOG (priv->dialog), GTK_RESPONSE_CANCEL);
+ }
+}
+
+/**
* hildon_color_button_get_color:
* @button: a #HildonColorButton
* @color: a color #GdkColor to be fillled with the current color
hildon_color_button_set_color (HildonColorButton *button,
GdkColor *color);
+gboolean
+hildon_color_button_get_is_popped (HildonColorButton *button);
+
+void
+hildon_color_button_pop_up (HildonColorButton *button);
+
G_END_DECLS
#endif /* __HILDON_COLOR_BUTTON_H__ */