/* Color has changed at settings */ static void _plugin_on_settings_color_change(GObject *inObject, GParamSpec *inSpec, gpointer inUserData) { XfdashboardClockViewSettings *settings; GtkColorButton *button; ClutterColor *settingsColor; GdkRGBA widgetColor; g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(inObject)); g_return_if_fail(GTK_IS_COLOR_BUTTON(inUserData)); settings=XFDASHBOARD_CLOCK_VIEW_SETTINGS(inObject); button=GTK_COLOR_BUTTON(inUserData); /* Get current color from settings */ g_object_get(G_OBJECT(settings), g_param_spec_get_name(inSpec), &settingsColor, NULL); /* Convert color for color button */ widgetColor.red=settingsColor->red/255.0f; widgetColor.green=settingsColor->green/255.0f; widgetColor.blue=settingsColor->blue/255.0f; widgetColor.alpha=settingsColor->alpha/255.0f; /* Set converted color at color button */ #if GTK_CHECK_VERSION(3, 4, 0) gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(button), &widgetColor); #else gtk_color_button_set_rgba(button, &widgetColor); #endif }
/** * gtk_color_button_get_alpha: * @button: a #GtkColorButton * * Returns the current alpha value. * * Return value: an integer between 0 and 65535 * * Since: 2.4 * * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead. */ guint16 gtk_color_button_get_alpha (GtkColorButton *button) { g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), 0); return (guint16) (button->priv->rgba.alpha * 65535); }
/** * gtk_color_button_get_title: * @button: a #GtkColorButton * * Gets the title of the color selection dialog. * * Returns: An internal string, do not free the return value * * Since: 2.4 */ const gchar * gtk_color_button_get_title (GtkColorButton *button) { g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), NULL); return button->priv->title; }
void glade_gtk_button_post_create (GladeWidgetAdaptor * adaptor, GObject * button, GladeCreateReason reason) { GladeWidget *gbutton = glade_widget_get_from_gobject (button); g_return_if_fail (GTK_IS_BUTTON (button)); g_return_if_fail (GLADE_IS_WIDGET (gbutton)); if (GTK_IS_FONT_BUTTON (button)) g_signal_connect (button, "font-set", G_CALLBACK (glade_gtk_font_button_refresh_font_name), gbutton); else if (GTK_IS_COLOR_BUTTON (button)) g_signal_connect (button, "color-set", G_CALLBACK (glade_gtk_color_button_refresh_color), gbutton); /* Disabled response-id until its in an action area */ glade_widget_property_set_sensitive (gbutton, "response-id", FALSE, RESPID_INSENSITIVE_MSG); if (reason == GLADE_CREATE_USER) glade_gtk_button_update_stock (gbutton); }
/** * gtk_color_button_get_alpha: * @color_button: a #GtkColorButton. * * Returns the current alpha value. * * Return value: an integer between 0 and 65535. * * Since: 2.4 **/ guint16 gtk_color_button_get_alpha (GtkColorButton *color_button) { g_return_val_if_fail (GTK_IS_COLOR_BUTTON (color_button), 0); return color_button->priv->alpha; }
/** * gtk_color_button_get_use_alpha: * @button: a #GtkColorButton * * Does the color selection dialog use the alpha channel ? * * Returns: %TRUE if the color sample uses alpha channel, %FALSE if not * * Since: 2.4 * * Deprecated: 3.4: Use gtk_color_chooser_get_use_alpha() instead. */ gboolean gtk_color_button_get_use_alpha (GtkColorButton *button) { g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), FALSE); return button->priv->use_alpha; }
/* A new color was chosen at color button */ static void _plugin_on_color_button_color_chosen(GtkColorButton *inButton, gpointer inUserData) { GdkRGBA widgetColor; ClutterColor settingsColor; PluginWidgetSettingsMap *mapping; g_return_if_fail(GTK_IS_COLOR_BUTTON(inButton)); /* Get color from color button */ #if GTK_CHECK_VERSION(3, 4, 0) gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(inButton), &widgetColor); #else gtk_color_button_get_rgba(inButton, &widgetColor); #endif /* Convert color for settings */ settingsColor.red=MIN(255, (gint)(widgetColor.red*255.0f)); settingsColor.green=MIN(255, (gint)(widgetColor.green*255.0f)); settingsColor.blue=MIN(255, (gint)(widgetColor.blue*255.0f)); settingsColor.alpha=MIN(255, (gint)(widgetColor.alpha*255.0f)); /* Set converted color at settings */ mapping=(PluginWidgetSettingsMap*)g_object_get_data(G_OBJECT(inButton), CONFIGURATION_MAPPING); if(mapping) g_object_set(G_OBJECT(mapping->settings), mapping->property, &settingsColor, NULL); }
/** * gtk_color_button_get_rgba: (skip) * @button: a #GtkColorButton * @rgba: (out): a #GdkRGBA to fill in with the current color * * Sets @rgba to be the current color in the #GtkColorButton widget. * * Since: 3.0 * * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead. */ void gtk_color_button_get_rgba (GtkColorButton *button, GdkRGBA *rgba) { g_return_if_fail (GTK_IS_COLOR_BUTTON (button)); g_return_if_fail (rgba != NULL); *rgba = button->priv->rgba; }
/** * gtk_color_button_get_color: * @button: a #GtkColorButton * @color: (out): a #GdkColor to fill in with the current color * * Sets @color to be the current color in the #GtkColorButton widget. * * Since: 2.4 * * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead. */ void gtk_color_button_get_color (GtkColorButton *button, GdkColor *color) { g_return_if_fail (GTK_IS_COLOR_BUTTON (button)); color->red = (guint16) (button->priv->rgba.red * 65535); color->green = (guint16) (button->priv->rgba.green * 65535); color->blue = (guint16) (button->priv->rgba.blue * 65535); }
/** * gtk_color_button_get_color: * @color_button: a #GtkColorButton. * @color: a #GdkColor to fill in with the current color. * * Sets @color to be the current color in the #GtkColorButton widget. * * Since: 2.4 **/ void gtk_color_button_get_color (GtkColorButton *color_button, GdkColor *color) { g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button)); color->red = color_button->priv->color.red; color->green = color_button->priv->color.green; color->blue = color_button->priv->color.blue; }
/** * gtk_color_button_set_alpha: * @color_button: a #GtkColorButton. * @alpha: an integer between 0 and 65535. * * Sets the current opacity to be @alpha. * * Since: 2.4 **/ void gtk_color_button_set_alpha (GtkColorButton *color_button, guint16 alpha) { g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button)); color_button->priv->alpha = alpha; gtk_widget_queue_draw (color_button->priv->draw_area); g_object_notify (G_OBJECT (color_button), "alpha"); }
/** * gtk_color_button_set_rgba: (skip) * @button: a #GtkColorButton * @rgba: a #GdkRGBA to set the current color with * * Sets the current color to be @rgba. * * Since: 3.0 * * Deprecated: 3.4: Use gtk_color_chooser_set_rgba() instead. */ void gtk_color_button_set_rgba (GtkColorButton *button, const GdkRGBA *rgba) { g_return_if_fail (GTK_IS_COLOR_BUTTON (button)); g_return_if_fail (rgba != NULL); button->priv->rgba = *rgba; gtk_widget_queue_draw (button->priv->draw_area); g_object_notify (G_OBJECT (button), "color"); g_object_notify (G_OBJECT (button), "alpha"); g_object_notify (G_OBJECT (button), "rgba"); }
/** * gtk_color_button_set_color: * @color_button: a #GtkColorButton. * @color: A #GdkColor to set the current color with. * * Sets the current color to be @color. * * Since: 2.4 **/ void gtk_color_button_set_color (GtkColorButton *color_button, const GdkColor *color) { g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button)); g_return_if_fail (color != NULL); color_button->priv->color.red = color->red; color_button->priv->color.green = color->green; color_button->priv->color.blue = color->blue; gtk_widget_queue_draw (color_button->priv->draw_area); g_object_notify (G_OBJECT (color_button), "color"); }
/** * gtk_color_button_set_color: * @button: a #GtkColorButton * @color: A #GdkColor to set the current color with * * Sets the current color to be @color. * * Since: 2.4 * * Deprecated: Use gtk_color_chooser_set_rgba() instead. */ void gtk_color_button_set_color (GtkColorButton *button, const GdkColor *color) { g_return_if_fail (GTK_IS_COLOR_BUTTON (button)); g_return_if_fail (color != NULL); button->priv->rgba.red = color->red / 65535.; button->priv->rgba.green = color->green / 65535.; button->priv->rgba.blue = color->blue / 65535.; gtk_widget_queue_draw (button->priv->draw_area); g_object_notify (G_OBJECT (button), "color"); g_object_notify (G_OBJECT (button), "rgba"); }
/** * gtk_color_button_set_use_alpha: * @button: a #GtkColorButton * @use_alpha: %TRUE if color button should use alpha channel, %FALSE if not * * Sets whether or not the color button should use the alpha channel. * * Since: 2.4 * * Deprecated: 3.4: Use gtk_color_chooser_set_use_alpha() instead. */ void gtk_color_button_set_use_alpha (GtkColorButton *button, gboolean use_alpha) { g_return_if_fail (GTK_IS_COLOR_BUTTON (button)); use_alpha = (use_alpha != FALSE); if (button->priv->use_alpha != use_alpha) { button->priv->use_alpha = use_alpha; gtk_widget_queue_draw (button->priv->draw_area); g_object_notify (G_OBJECT (button), "use-alpha"); } }
/** * gtk_color_button_set_title: * @button: a #GtkColorButton * @title: String containing new window title * * Sets the title for the color selection dialog. * * Since: 2.4 */ void gtk_color_button_set_title (GtkColorButton *button, const gchar *title) { gchar *old_title; g_return_if_fail (GTK_IS_COLOR_BUTTON (button)); old_title = button->priv->title; button->priv->title = g_strdup (title); g_free (old_title); if (button->priv->cs_dialog) gtk_window_set_title (GTK_WINDOW (button->priv->cs_dialog), button->priv->title); g_object_notify (G_OBJECT (button), "title"); }
void glade_gtk_button_write_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlContext * context, GladeXmlNode * node) { GladeProperty *prop; gboolean use_stock; gchar *stock = NULL; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* Do not save GtkColorButton GtkFontButton and GtkScaleButton label property */ if (!(GTK_IS_COLOR_BUTTON (glade_widget_get_object (widget)) || GTK_IS_FONT_BUTTON (glade_widget_get_object (widget)) || GTK_IS_SCALE_BUTTON (glade_widget_get_object (widget)))) { /* Make a copy of the GladeProperty, * override its value and ensure non-translatable if use-stock is TRUE */ prop = glade_widget_get_property (widget, "label"); prop = glade_property_dup (prop, widget); glade_widget_property_get (widget, "use-stock", &use_stock); if (use_stock) { glade_widget_property_get (widget, "stock", &stock); glade_property_i18n_set_translatable (prop, FALSE); glade_property_set (prop, stock); } glade_property_write (prop, context, node); g_object_unref (G_OBJECT (prop)); } /* Write out other normal properties and any other class derived custom properties after ... */ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->write_widget (adaptor, widget, context, node); }
/* Set up color button, e.g. set initial color from settings, connect signals * to store newly chosen color or to reflect changed color from settings * in widget etc. */ static void _plugin_configure_setup_color_button(GtkColorButton *inButton, XfdashboardClockViewSettings *inSettings, const gchar *inProperty) { ClutterColor *settingsColor; GdkRGBA widgetColor; gchar *signalName; guint signalID; PluginWidgetSettingsMap *mapping; g_return_if_fail(GTK_IS_COLOR_BUTTON(inButton)); g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(inSettings)); g_return_if_fail(inProperty && *inProperty); /* Create data for later use at color button */ mapping=g_new0(PluginWidgetSettingsMap,1); if(!mapping) { g_critical(_("Cannot allocate memory for mapping")); return; } /* Get current color from settings */ g_object_get(G_OBJECT(inSettings), inProperty, &settingsColor, NULL); /* Convert color for color button */ widgetColor.red=settingsColor->red/255.0f; widgetColor.green=settingsColor->green/255.0f; widgetColor.blue=settingsColor->blue/255.0f; widgetColor.alpha=settingsColor->alpha/255.0f; /* Set converted color at color button */ #if GTK_CHECK_VERSION(3, 4, 0) gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(inButton), &widgetColor); #else gtk_color_button_set_rgba(inButton, &widgetColor); #endif /* Connect signal to store color of new one was chosen at color button */ g_signal_connect(inButton, "color-set", G_CALLBACK(_plugin_on_color_button_color_chosen), NULL); signalName=g_strdup_printf("notify::%s", inProperty); signalID=g_signal_connect(inSettings, signalName, G_CALLBACK(_plugin_on_settings_color_change), inButton); /* Set mapping data at color button */ mapping->settings=g_object_ref(inSettings); mapping->property=g_strdup(inProperty); mapping->settingsPropertyChangedSignalID=signalID; g_object_set_data_full(G_OBJECT(inButton), CONFIGURATION_MAPPING, mapping, (GDestroyNotify)_plugin_widget_settings_map_free); /* Release allocated resources */ if(settingsColor) clutter_color_free(settingsColor); if(signalName) g_free(signalName); }