Commit 5b4f3f8f authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

[GthImportDestinationButton] use the default color when insensitive

parent e6366877
......@@ -36,36 +36,86 @@ struct _GthImportDestinationButtonPrivate {
static void
gth_import_destination_button_finalize (GObject *object)
_update_subfolder_label_color (GthImportDestinationButton *self)
{
GthImportDestinationButton *self;
if (! gtk_widget_get_realized (GTK_WIDGET (self)))
return;
if ((gtk_widget_get_state (self->priv->subfolder_label) & GTK_STATE_INSENSITIVE) == GTK_STATE_INSENSITIVE) {
gtk_label_set_attributes (GTK_LABEL (self->priv->subfolder_label), NULL);
gtk_widget_queue_resize (self->priv->subfolder_label);
}
else {
PangoAttrList *attr_list;
PangoAttribute *attr;
attr_list = pango_attr_list_new ();
attr = pango_attr_foreground_new (45489, 13107, 1799);
pango_attr_list_insert (attr_list, attr);
gtk_label_set_attributes (GTK_LABEL (self->priv->subfolder_label), attr_list);
pango_attr_list_unref (attr_list);
/* FIXME: the color is NULL for some themes.
GdkColor *color;
color = NULL;
gtk_widget_style_get (GTK_WIDGET (self), "link-color", &color, NULL);
if (color != NULL) {
PangoAttrList *attr_list;
PangoAttribute *attr;
g_print ("(%" G_GUINT16_FORMAT ", %" G_GUINT16_FORMAT ", %" G_GUINT16_FORMAT ")\n", color->red, color->green, color->blue);
attr_list = pango_attr_list_new ();
attr = pango_attr_foreground_new (color->red, color->green, color->blue);
pango_attr_list_insert (attr_list, attr);
gtk_label_set_attributes (GTK_LABEL (self->priv->subfolder_label), attr_list);
pango_attr_list_unref (attr_list);
gdk_color_free (color);
}
else
g_print ("no color\n");
*/
}
}
self = GTH_IMPORT_DESTINATION_BUTTON (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
static void
gth_import_destination_button_realize (GtkWidget *widget)
{
GTK_WIDGET_CLASS (parent_class)->realize (widget);
_update_subfolder_label_color (GTH_IMPORT_DESTINATION_BUTTON (widget));
}
static void
gth_import_destination_button_class_init (GthImportDestinationButtonClass *klass)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (GthImportDestinationButtonPrivate));
object_class = (GObjectClass*) klass;
object_class->finalize = gth_import_destination_button_finalize;
widget_class = (GtkWidgetClass*) klass;
widget_class->realize = gth_import_destination_button_realize;
}
static void
subfolder_label_state_changed_cb (GtkWidget *widget,
GtkStateType state,
gpointer user_data)
{
_update_subfolder_label_color (GTH_IMPORT_DESTINATION_BUTTON (user_data));
}
static void
gth_import_destination_button_init (GthImportDestinationButton *self)
{
GtkWidget *box;
GtkWidget *label_box;
PangoAttrList *attr_list;
PangoAttribute *attr;
GtkWidget *box;
GtkWidget *label_box;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_IMPORT_DESTINATION_BUTTON, GthImportDestinationButtonPrivate);
......@@ -89,14 +139,13 @@ gth_import_destination_button_init (GthImportDestinationButton *self)
gtk_label_set_ellipsize (GTK_LABEL (self->priv->subfolder_label), PANGO_ELLIPSIZE_END);
gtk_misc_set_alignment (GTK_MISC (self->priv->subfolder_label), 0.0, 0.5);
attr_list = pango_attr_list_new ();
attr = pango_attr_foreground_new (45489, 13107, 1799);
pango_attr_list_insert (attr_list, attr);
g_object_set (self->priv->subfolder_label, "attributes", attr_list, NULL);
pango_attr_list_unref (attr_list);
gtk_widget_show (self->priv->subfolder_label);
gtk_box_pack_start (GTK_BOX (label_box), self->priv->subfolder_label, TRUE, TRUE, 0);
g_signal_connect (self->priv->subfolder_label,
"state-changed",
G_CALLBACK (subfolder_label_state_changed_cb),
self);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment