[geany/geany] b165de: Fix color of unmodified build commands on GTK3

Colomban Wendling git-noreply at xxxxx
Tue Jun 23 00:54:02 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Tue, 23 Jun 2015 00:54:02 UTC
Commit:      b165de1f77d4c726489b9eaac665df4c81b25962
             https://github.com/geany/geany/commit/b165de1f77d4c726489b9eaac665df4c81b25962

Log Message:
-----------
Fix color of unmodified build commands on GTK3

Also, as changing the color of the label button doesn't currently work
on GTK2, but would on GTK3 with this change, explicitly skip it for
consistency.

Closes #528.


Modified Paths:
--------------
    src/build.c

Modified: src/build.c
28 lines changed, 23 insertions(+), 5 deletions(-)
===================================================================
@@ -1670,14 +1670,28 @@ typedef struct RowWidgets
 	gboolean used_dst;
 } RowWidgets;
 
-static GdkColor *insensitive_color;
+#if GTK_CHECK_VERSION(3,0,0)
+typedef GdkRGBA InsensitiveColor;
+#else
+typedef GdkColor InsensitiveColor;
+#endif
+static InsensitiveColor insensitive_color;
 
-static void set_row_color(RowWidgets *r, GdkColor *color )
+static void set_row_color(RowWidgets *r, InsensitiveColor *color)
 {
 	enum GeanyBuildCmdEntries i;
 
 	for (i = 0; i < GEANY_BC_CMDENTRIES_COUNT; i++)
+	{
+		if (i == GEANY_BC_LABEL)
+			continue;
+
+#if GTK_CHECK_VERSION(3,0,0)
+		gtk_widget_override_color(r->entries[i], GTK_STATE_FLAG_NORMAL, color);
+#else
 		gtk_widget_modify_text(r->entries[i], GTK_STATE_NORMAL, color);
+#endif
+	}
 }
 
 
@@ -1716,7 +1730,7 @@ static void on_clear_dialog_row(GtkWidget *unused, gpointer user_data)
 		}
 	}
 	r->used_dst = FALSE;
-	set_row_color(r, insensitive_color);
+	set_row_color(r, &insensitive_color);
 	r->cleared = TRUE;
 }
 
@@ -1795,7 +1809,11 @@ static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, gui
 	text = g_strdup_printf("%d.", cmd + 1);
 	label = gtk_label_new(text);
 	g_free(text);
-	insensitive_color = &(gtk_widget_get_style(label)->text[GTK_STATE_INSENSITIVE]);
+#if GTK_CHECK_VERSION(3,0,0)
+	gtk_style_context_get_color(gtk_widget_get_style_context(label), GTK_STATE_FLAG_INSENSITIVE, &insensitive_color);
+#else
+	insensitive_color = gtk_widget_get_style(label)->text[GTK_STATE_INSENSITIVE];
+#endif
 	gtk_table_attach(table, label, column, column + 1, row, row + 1, GTK_FILL,
 		GTK_FILL | GTK_EXPAND, entry_x_padding, entry_y_padding);
 	roww = g_new0(RowWidgets, 1);
@@ -1848,7 +1866,7 @@ static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, gui
 		set_build_command_entry_text(roww->entries[i], str);
 	}
 	if (bc != NULL && (dst > src))
-		set_row_color(roww, insensitive_color);
+		set_row_color(roww, &insensitive_color);
 	if (bc != NULL && (src > dst || (grp == GEANY_GBG_FT && (doc == NULL || doc->file_type == NULL))))
 	{
 		for (i = 0; i < GEANY_BC_CMDENTRIES_COUNT; i++)



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list