X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon-color-button.c;h=3fa180db2a54c867ef8f037e5fa2919a8996821f;hb=7d3f0468795e7298a98578fbb054b5cb9908d523;hp=be908242ef9caeefc20ecaac37c9a7d9bd9993ca;hpb=bcd8bd04e4a43ea8d1e32b93638ebd6e6ce38887;p=hildon diff --git a/src/hildon-color-button.c b/src/hildon-color-button.c index be90824..3fa180d 100644 --- a/src/hildon-color-button.c +++ b/src/hildon-color-button.c @@ -3,12 +3,12 @@ * * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved. * - * Contact: Michael Dominic Kostrzewa + * Contact: Rodrigo Novo * * 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 @@ -24,7 +24,7 @@ /** * 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. @@ -45,16 +45,15 @@ * */ +#undef HILDON_DISABLE_DEPRECATED + #ifdef HAVE_CONFIG_H #include #endif -#include "hildon-color-button.h" -#include -#include -#include -#include #include + +#include "hildon-color-button.h" #include "hildon-defines.h" #include "hildon-color-chooser-dialog.h" #include "hildon-color-button-private.h" @@ -83,10 +82,17 @@ #define INNER_BORDER_THICKNESS 2 -enum +enum +{ + SETUP_DIALOG, + LAST_SIGNAL +}; + +enum { PROP_0, - PROP_COLOR + PROP_COLOR, + PROP_POPUP_SHOWN }; static void @@ -142,7 +148,15 @@ draw_grid (GdkDrawable *drawable, 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) { @@ -191,6 +205,16 @@ hildon_color_button_class_init (HildonColorButtonClass *klass) 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: * @@ -203,6 +227,18 @@ hildon_color_button_class_init (HildonColorButtonClass *klass) 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)); } @@ -302,6 +338,7 @@ hildon_color_button_init (HildonColorButton *cb) priv->dialog = NULL; priv->gc = NULL; + priv->popped = FALSE; gtk_widget_push_composite_child (); @@ -343,7 +380,7 @@ hildon_color_button_finalize (GObject *object) if (priv->dialog) { - gtk_widget_destroy(priv->dialog); + gtk_widget_destroy (priv->dialog); priv->dialog = NULL; } @@ -406,12 +443,15 @@ hildon_color_button_clicked (GtkButton *button) 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); @@ -420,6 +460,7 @@ hildon_color_button_clicked (GtkButton *button) } gtk_widget_hide (GTK_WIDGET(cs_dialog)); + priv->popped = FALSE; } /* Popup a color selector dialog on hardkey Select press. @@ -481,6 +522,9 @@ hildon_color_button_get_property (GObject *object, 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; @@ -535,6 +579,50 @@ hildon_color_button_set_color (HildonColorButton *button, } /** + * 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