Port new configurable document status colors to GTK3

This commit is contained in:
Colomban Wendling 2013-02-11 04:47:21 +01:00
parent a77ac1407a
commit e0104a4bc2
2 changed files with 31 additions and 0 deletions

View File

@ -23,3 +23,14 @@
#geany-search-entry-no-match:selected {
background-color: #771111;
}
/* document status colors */
#geany-document-status-changed {
color: #ff0000;
}
#geany-document-status-disk-changed {
color: #ff7f00;
}
#geany-document-status-readonly {
color: #007f00;
}

View File

@ -2770,6 +2770,25 @@ const GdkColor *document_get_status_color(GeanyDocument *doc)
return NULL;
if (! document_status_styles[status].loaded)
{
#if GTK_CHECK_VERSION(3, 0, 0)
GdkRGBA color;
GtkWidgetPath *path = gtk_widget_path_new();
GtkStyleContext *ctx = gtk_style_context_new();
gtk_widget_path_append_type(path, GTK_TYPE_WINDOW);
gtk_widget_path_append_type(path, GTK_TYPE_BOX);
gtk_widget_path_append_type(path, GTK_TYPE_NOTEBOOK);
gtk_widget_path_append_type(path, GTK_TYPE_LABEL);
gtk_widget_path_iter_set_name(path, -1, document_status_styles[status].name);
gtk_style_context_set_screen(ctx, gtk_widget_get_screen(GTK_WIDGET(doc->editor->sci)));
gtk_style_context_set_path(ctx, path);
gtk_style_context_get_color(ctx, GTK_STATE_NORMAL, &color);
document_status_styles[status].color.red = 0xffff * color.red;
document_status_styles[status].color.green = 0xffff * color.green;
document_status_styles[status].color.blue = 0xffff * color.blue;
document_status_styles[status].loaded = TRUE;
gtk_widget_path_unref(path);
g_object_unref(ctx);
#else
GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(doc->editor->sci));
gchar *path = g_strconcat("GeanyMainWindow.GtkHBox.GtkNotebook.",
document_status_styles[status].name, NULL);
@ -2778,6 +2797,7 @@ const GdkColor *document_get_status_color(GeanyDocument *doc)
document_status_styles[status].color = style->fg[GTK_STATE_NORMAL];
document_status_styles[status].loaded = TRUE;
g_free(path);
#endif
}
return &document_status_styles[status].color;
}