*
* Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
*
- * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
+ * Contact: Rodrigo Novo <rodrigo.novo@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.
+ * the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
/**
* SECTION:hildon-color-button
- * @short_description: A widget to open HildonColorChooserDialog
+ * @short_description: A widget to open HildonColorChooserDialog.
* @see_also: #HildonColorChooserDialog, #HildonColorPopup
*
* HildonColorButton is a widget to open a HildonColorChooserDialog.
*
*/
+#undef HILDON_DISABLE_DEPRECATED
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include "hildon-color-button.h"
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkalignment.h>
-#include <gtk/gtkdrawingarea.h>
-#include <gtk/gtksignal.h>
#include <gdk/gdkkeysyms.h>
+
+#include "hildon-color-button.h"
#include "hildon-defines.h"
#include "hildon-color-chooser-dialog.h"
#include "hildon-color-button-private.h"
#define INNER_BORDER_THICKNESS 2
-enum
+enum
+{
+ SETUP_DIALOG,
+ LAST_SIGNAL
+};
+
+enum
{
PROP_0,
- PROP_COLOR
+ PROP_COLOR,
+ PROP_POPUP_SHOWN
};
static void
gint h);
static gpointer parent_class = NULL;
+static guint signals [LAST_SIGNAL] = { 0, };
+/**
+ * hildon_color_button_get_type:
+ *
+ * Initializes and returns the type of a hildon color button.
+ *
+ * Returns: GType of #HildonColorButton.
+ */
GType G_GNUC_CONST
hildon_color_button_get_type (void)
{
button_class->clicked = hildon_color_button_clicked;
widget_class->mnemonic_activate = hildon_color_button_mnemonic_activate;
+ signals[SETUP_DIALOG] =
+ g_signal_new ("setup-dialog",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ HILDON_TYPE_COLOR_CHOOSER_DIALOG);
+
/**
* HildonColorButton:color:
*
GDK_TYPE_COLOR,
G_PARAM_READWRITE));
+ /**
+ * HildonColorButton:popup-shown:
+ *
+ * If the color selection dialog is currently popped-up (visible)
+ */
+ g_object_class_install_property (gobject_class, PROP_POPUP_SHOWN,
+ g_param_spec_boolean ("popup-shown",
+ "IsPopped",
+ "If the color selection dialog is popped up",
+ 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;
}
cs_dialog = HILDON_COLOR_CHOOSER_DIALOG (priv->dialog);
if (parent)
gtk_window_set_transient_for (GTK_WINDOW (cs_dialog), GTK_WINDOW (parent));
+
+ g_signal_emit (button, signals[SETUP_DIALOG], 0, priv->dialog);
}
/* Set the initial color for the color selector dialog */
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_POPUP_SHOWN:
+ g_value_set_boolean (value, priv->popped);
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
/**
+ * hildon_color_button_get_popup_shown
+ * @button: a #HildonColorButton
+ *
+ * This function checks if the color button has the color
+ * selection dialog currently popped-up.
+ *
+ * Returns: TRUE if the dialog is popped-up (visible to user).
+ *
+ */
+gboolean
+hildon_color_button_get_popup_shown (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_popdown
+ * @button: a #HildonColorButton
+ *
+ * If the color selection dialog is currently popped-up (visible)
+ * it will be popped-down (hidden).
+ *
+ */
+void
+hildon_color_button_popdown (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