[gimp] libgimpwidgets: merge some GimpColorButton API from gtk3-port
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: merge some GimpColorButton API from gtk3-port
- Date: Wed, 7 Sep 2016 00:23:37 +0000 (UTC)
commit f91a19b1ef6ec86387ed6e4052b584f390dc3ff8
Author: Michael Natterer <mitch gimp org>
Date: Wed Sep 7 02:22:57 2016 +0200
libgimpwidgets: merge some GimpColorButton API from gtk3-port
app/widgets/gimpcolorpanel.c | 14 ++++---
libgimpwidgets/gimpcolorbutton.c | 84 ++++++++++++++++++++++++++++++++++++-
libgimpwidgets/gimpcolorbutton.h | 49 +++++++++++++---------
libgimpwidgets/gimpwidgets.def | 4 ++
4 files changed, 122 insertions(+), 29 deletions(-)
---
diff --git a/app/widgets/gimpcolorpanel.c b/app/widgets/gimpcolorpanel.c
index dbc4e62..9a338ee 100644
--- a/app/widgets/gimpcolorpanel.c
+++ b/app/widgets/gimpcolorpanel.c
@@ -112,7 +112,7 @@ gimp_color_panel_button_press (GtkWidget *widget,
color_button = GIMP_COLOR_BUTTON (widget);
color_panel = GIMP_COLOR_PANEL (widget);
- ui_manager = GTK_UI_MANAGER (color_button->popup_menu);
+ ui_manager = gimp_color_button_get_ui_manager (color_button);
group = gtk_ui_manager_get_action_groups (ui_manager)->data;
@@ -162,15 +162,17 @@ gimp_color_panel_clicked (GtkButton *button)
if (! panel->color_dialog)
{
+ GimpColorButton *color_button = GIMP_COLOR_BUTTON (button);
+
panel->color_dialog =
gimp_color_dialog_new (NULL, panel->context,
- GIMP_COLOR_BUTTON (button)->title,
+ gimp_color_button_get_title (color_button),
NULL, NULL,
GTK_WIDGET (button),
NULL, NULL,
&color,
- gimp_color_button_get_update (GIMP_COLOR_BUTTON (button)),
- gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (button)));
+ gimp_color_button_get_update (color_button),
+ gimp_color_button_has_alpha (color_button));
g_signal_connect (panel->color_dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
@@ -252,8 +254,8 @@ gimp_color_panel_set_context (GimpColorPanel *panel,
panel->context = context;
if (context)
- gimp_color_area_set_color_config (GIMP_COLOR_AREA (GIMP_COLOR_BUTTON (panel)->color_area),
- context->gimp->config->color_management);
+ gimp_color_button_set_color_config (GIMP_COLOR_BUTTON (panel),
+ context->gimp->config->color_management);
}
diff --git a/libgimpwidgets/gimpcolorbutton.c b/libgimpwidgets/gimpcolorbutton.c
index 6b67d6f..c9e6f74 100644
--- a/libgimpwidgets/gimpcolorbutton.c
+++ b/libgimpwidgets/gimpcolorbutton.c
@@ -27,6 +27,7 @@
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
+#include "libgimpconfig/gimpconfig.h"
#include "gimpwidgetstypes.h"
@@ -228,7 +229,7 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
g_param_spec_string ("title", NULL, NULL,
NULL,
GIMP_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_CONSTRUCT));
/**
* GimpColorButton:color:
*
@@ -449,8 +450,7 @@ gimp_color_button_set_property (GObject *object,
switch (property_id)
{
case PROP_TITLE:
- g_free (button->title);
- button->title = g_value_dup_string (value);
+ gimp_color_button_set_title (button, g_value_get_string (value));
break;
case PROP_COLOR:
@@ -641,6 +641,47 @@ gimp_color_button_new (const gchar *title,
}
/**
+ * gimp_color_button_set_title:
+ * @button: a #GimpColorButton.
+ * @color: the new title.
+ *
+ * Sets the @button dialog's title.
+ *
+ * Since: GIMP 2.10
+ **/
+void
+gimp_color_button_set_title (GimpColorButton *button,
+ const gchar *title)
+{
+ g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
+ g_return_if_fail (title != NULL);
+
+ g_free (button->title);
+ button->title = g_strdup (title);
+
+ if (button->dialog)
+ gtk_window_set_title (GTK_WINDOW (button->dialog), title);
+
+ g_object_notify (G_OBJECT (button), "title");
+}
+
+/**
+ * gimp_color_button_get_title:
+ * @button: a #GimpColorButton.
+ *
+ * Returns: The @button dialog's title.
+ *
+ * Since: GIMP 2.10
+ **/
+const gchar *
+gimp_color_button_get_title (GimpColorButton *button)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (button), NULL);
+
+ return button->title;
+}
+
+/**
* gimp_color_button_set_color:
* @button: Pointer to a #GimpColorButton.
* @color: Pointer to the new #GimpRGB color.
@@ -770,6 +811,43 @@ gimp_color_button_set_update (GimpColorButton *button,
}
}
+/**
+ * gimp_color_button_set_color_config:
+ * @button: a #GimpColorButton widget.
+ * @config: a #GimpColorConfig object.
+ *
+ * Sets the color management configuration to use with this color button's
+ * #GimpColorArea.
+ *
+ * Since: 2.10
+ */
+void
+gimp_color_button_set_color_config (GimpColorButton *button,
+ GimpColorConfig *config)
+{
+ g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
+ g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config));
+
+ gimp_color_area_set_color_config (GIMP_COLOR_AREA (button->color_area),
+ config);
+}
+
+/**
+ * gimp_color_button_get_ui_manager:
+ * @button: a #GimpColorButton.
+ *
+ * Returns: The @button's #GtkUIManager.
+ *
+ * Since: GIMP 2.10
+ **/
+GtkUIManager *
+gimp_color_button_get_ui_manager (GimpColorButton *button)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (button), NULL);
+
+ return button->popup_menu;
+}
+
/* private functions */
diff --git a/libgimpwidgets/gimpcolorbutton.h b/libgimpwidgets/gimpcolorbutton.h
index 10fe9d7..1347488 100644
--- a/libgimpwidgets/gimpcolorbutton.h
+++ b/libgimpwidgets/gimpcolorbutton.h
@@ -78,26 +78,35 @@ struct _GimpColorButtonClass
};
-GType gimp_color_button_get_type (void) G_GNUC_CONST;
-
-GtkWidget * gimp_color_button_new (const gchar *title,
- gint width,
- gint height,
- const GimpRGB *color,
- GimpColorAreaType type);
-
-void gimp_color_button_set_color (GimpColorButton *button,
- const GimpRGB *color);
-void gimp_color_button_get_color (GimpColorButton *button,
- GimpRGB *color);
-
-gboolean gimp_color_button_has_alpha (GimpColorButton *button);
-void gimp_color_button_set_type (GimpColorButton *button,
- GimpColorAreaType type);
-
-gboolean gimp_color_button_get_update (GimpColorButton *button);
-void gimp_color_button_set_update (GimpColorButton *button,
- gboolean continuous);
+GType gimp_color_button_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_color_button_new (const gchar *title,
+ gint width,
+ gint height,
+ const GimpRGB *color,
+ GimpColorAreaType type);
+
+void gimp_color_button_set_title (GimpColorButton *button,
+ const gchar *title);
+const gchar * gimp_color_button_get_title (GimpColorButton *button);
+
+void gimp_color_button_set_color (GimpColorButton *button,
+ const GimpRGB *color);
+void gimp_color_button_get_color (GimpColorButton *button,
+ GimpRGB *color);
+
+gboolean gimp_color_button_has_alpha (GimpColorButton *button);
+void gimp_color_button_set_type (GimpColorButton *button,
+ GimpColorAreaType type);
+
+gboolean gimp_color_button_get_update (GimpColorButton *button);
+void gimp_color_button_set_update (GimpColorButton *button,
+ gboolean continuous);
+
+void gimp_color_button_set_color_config (GimpColorButton *button,
+ GimpColorConfig *config);
+
+GtkUIManager * gimp_color_button_get_ui_manager (GimpColorButton *button);
G_END_DECLS
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index dc8e2c2..65f67ad 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -34,11 +34,15 @@ EXPORTS
gimp_color_area_set_type
gimp_color_area_type_get_type
gimp_color_button_get_color
+ gimp_color_button_get_title
gimp_color_button_get_type
+ gimp_color_button_get_ui_manager
gimp_color_button_get_update
gimp_color_button_has_alpha
gimp_color_button_new
gimp_color_button_set_color
+ gimp_color_button_set_color_config
+ gimp_color_button_set_title
gimp_color_button_set_type
gimp_color_button_set_update
gimp_color_display_changed
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]