summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmate-desktop/mate-colorsel.c17
-rw-r--r--tools/mate-color-select.c29
2 files changed, 44 insertions, 2 deletions
diff --git a/libmate-desktop/mate-colorsel.c b/libmate-desktop/mate-colorsel.c
index 9586952..5c12799 100644
--- a/libmate-desktop/mate-colorsel.c
+++ b/libmate-desktop/mate-colorsel.c
@@ -73,7 +73,8 @@ enum {
PROP_HAS_PALETTE,
PROP_HAS_OPACITY_CONTROL,
PROP_CURRENT_COLOR,
- PROP_CURRENT_ALPHA
+ PROP_CURRENT_ALPHA,
+ PROP_HEX_STRING
};
enum {
@@ -327,7 +328,15 @@ mate_color_selection_class_init (MateColorSelectionClass *klass)
_("The current opacity value (0 fully transparent, 65535 fully opaque)"),
0, 65535, 65535,
G_PARAM_READWRITE));
-
+ g_object_class_install_property (gobject_class,
+ PROP_HEX_STRING,
+ g_param_spec_string ("hex-string",
+ _("HEX String"),
+ _("The hexadecimal string of current color"),
+ "",
+ G_PARAM_READABLE));
+
+
color_selection_signals[COLOR_CHANGED] =
g_signal_new ("color-changed",
G_OBJECT_CLASS_TYPE (gobject_class),
@@ -571,6 +580,7 @@ mate_color_selection_get_property (GObject *object,
GParamSpec *pspec)
{
MateColorSelection *colorsel = MATE_COLOR_SELECTION (object);
+ ColorSelectionPrivate *priv = colorsel->private_data;
GdkColor color;
switch (prop_id)
@@ -588,6 +598,9 @@ mate_color_selection_get_property (GObject *object,
case PROP_CURRENT_ALPHA:
g_value_set_uint (value, mate_color_selection_get_current_alpha (colorsel));
break;
+ case PROP_HEX_STRING:
+ g_value_set_string (value, gtk_editable_get_chars (GTK_EDITABLE (priv->hex_entry), 0, -1));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/tools/mate-color-select.c b/tools/mate-color-select.c
index ed4f18c..198c7df 100644
--- a/tools/mate-color-select.c
+++ b/tools/mate-color-select.c
@@ -26,16 +26,35 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libmate-desktop/mate-colorseldialog.h>
+#include <libmate-desktop/mate-colorsel.h>
#define mate_gettext(package, locale, codeset) \
bindtextdomain(package, locale); \
bind_textdomain_codeset(package, codeset); \
textdomain(package);
+#if !GTK_CHECK_VERSION (3, 0, 0)
+gboolean
+copy_color (GtkWidget *widget, GdkEvent *event, MateColorSelectionDialog *color_dialog)
+{
+ GdkColor color;
+ gchar *color_string;
+
+ mate_color_selection_get_current_color (color_dialog->colorsel, &color);
+ g_object_get (color_dialog->colorsel, "hex-string", &color_string, NULL);
+ g_print ("%s\n", color_string);
+
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), color_string, -1);
+
+ g_free (color_string);
+}
+#endif
+
int
main (int argc, char **argv)
{
GtkWidget *color_dialog = NULL;
+ GtkWidget *widget;
mate_gettext (GETTEXT_PACKAGE, LOCALE_DIR, "UTF-8");
@@ -54,6 +73,16 @@ main (int argc, char **argv)
/* quit signal */
g_signal_connect (color_dialog, "destroy", gtk_main_quit, NULL);
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ widget = gtk_button_new_from_stock (GTK_STOCK_COPY);
+ gtk_container_add (gtk_dialog_get_action_area (GTK_DIALOG (color_dialog)), widget);
+ g_signal_connect (widget, "button-release-event", copy_color, color_dialog);
+
+ widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+ gtk_container_add (gtk_dialog_get_action_area (GTK_DIALOG (color_dialog)), widget);
+ g_signal_connect (widget, "button-release-event", gtk_main_quit, NULL);
+#endif
+
gtk_widget_show_all (color_dialog);
gtk_widget_hide (MATE_COLOR_SELECTION_DIALOG (color_dialog)->ok_button);
gtk_widget_hide (MATE_COLOR_SELECTION_DIALOG (color_dialog)->cancel_button);