[Freeciv-Dev] (PR#10861) GTK client players dialog doesn't pay attention
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10861 >
> [r_q_smith@xxxxxxxxx - Wed Nov 03 21:40:34 2004]:
>
> When using a GTK color scheme with a black base color, the players
> dialog text is invisible (black-on-black) for nations the player is
> neither at war or allied with. It's fairly easily worked around (the
> highlight bar shows them up as black-on-theme-highlight-color) but it's
> still a bit annoying.
This patch makes that use styles instead of colours.
Index: client/gui-gtk-2.0/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/plrdlg.c,v
retrieving revision 1.42
diff -u -u -r1.42 plrdlg.c
--- client/gui-gtk-2.0/plrdlg.c 9 Nov 2004 19:32:38 -0000 1.42
+++ client/gui-gtk-2.0/plrdlg.c 14 Nov 2004 01:56:56 -0000
@@ -58,6 +58,8 @@
static GtkWidget *players_sship_command;
static GtkListStore *store;
+static gint ncolumns;
+
static void create_players_dialog(void);
static void players_meet_callback(GtkMenuItem *item, gpointer data);
static void players_war_callback(GtkMenuItem *item, gpointer data);
@@ -112,7 +114,7 @@
struct player *plr;
gint plrno;
- gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
+ gtk_tree_model_get(model, &it, ncolumns - 1, &plrno, -1);
plr = get_player(plrno);
if (plr->spaceship.state != SSHIP_NONE) {
@@ -171,7 +173,7 @@
gtk_tree_path_free(path);
gtk_tree_model_get(GTK_TREE_MODEL(store), &it,
- (num_player_dlg_columns+1), &id, -1);
+ ncolumns - 1, &id, -1);
plr = get_player(id);
if (ev->button == 1) {
@@ -191,7 +193,7 @@
**************************************************************************/
static void create_store(void)
{
- GType model_types[num_player_dlg_columns + 2];
+ GType model_types[num_player_dlg_columns + 3];
int i;
for (i = 0; i < num_player_dlg_columns; i++) {
@@ -211,11 +213,13 @@
break;
}
}
- /* special (invisible rows) - Text color and player id */
- model_types[i] = GDK_TYPE_COLOR;
- model_types[i+1] = G_TYPE_INT;
+ /* special (invisible rows) - Text style, weight and player id */
+ model_types[i++] = G_TYPE_INT;
+ model_types[i++] = G_TYPE_INT;
+ model_types[i++] = G_TYPE_INT;
- store = gtk_list_store_newv(num_player_dlg_columns + 2, model_types);
+ ncolumns = i;
+ store = gtk_list_store_newv(ncolumns, model_types);
}
/**************************************************************************
@@ -307,18 +311,24 @@
break;
case COL_TEXT:
renderer = gtk_cell_renderer_text_new();
- g_object_set(renderer, "weight", "bold", NULL);
+ g_object_set(renderer, "style-set", TRUE, "weight-set", TRUE, NULL);
col = gtk_tree_view_column_new_with_attributes(pcol->title, renderer,
- "text", i, "foreground-gdk", num_player_dlg_columns, NULL);
+ "text", i,
+ "style", num_player_dlg_columns,
+ "weight", num_player_dlg_columns + 1,
+ NULL);
gtk_tree_view_column_set_sort_column_id(col, i);
break;
case COL_RIGHT_TEXT:
renderer = gtk_cell_renderer_text_new();
- g_object_set(renderer, "weight", "bold", NULL);
+ g_object_set(renderer, "style-set", TRUE, "weight-set", TRUE, NULL);
col = gtk_tree_view_column_new_with_attributes(pcol->title, renderer,
- "text", i, "foreground-gdk", num_player_dlg_columns, NULL);
+ "text", i,
+ "style", num_player_dlg_columns,
+ "weight", num_player_dlg_columns + 1,
+ NULL);
gtk_tree_view_column_set_sort_column_id(col, i);
if (pcol->type == COL_RIGHT_TEXT) {
@@ -484,7 +494,7 @@
{
struct player *plr = get_player(i);
GdkPixbuf *flag;
- GdkColor *state_col;
+ gint style, weight;
int k;
gchar *p;
@@ -513,22 +523,29 @@
/* The playerid */
gtk_list_store_set(store, it,
- num_player_dlg_columns+1, (gint)i,
+ ncolumns - 1, (gint)i,
-1);
/* now add some eye candy ... */
switch (pplayer_get_diplstate(game.player_ptr, plr)->type) {
case DS_WAR:
- state_col = colors_standard[COLOR_STD_RED];
+ weight = PANGO_WEIGHT_BOLD;
+ style = PANGO_STYLE_NORMAL;
break;
case DS_ALLIANCE:
case DS_TEAM:
- state_col = colors_standard[COLOR_STD_GROUND];
+ weight = PANGO_WEIGHT_NORMAL;
+ style = PANGO_STYLE_ITALIC;
break;
default:
- state_col = colors_standard[COLOR_STD_BLACK];
+ weight = PANGO_WEIGHT_NORMAL;
+ style = PANGO_STYLE_NORMAL;
+ break;
}
- gtk_list_store_set(store, it, num_player_dlg_columns, state_col, -1);
+ gtk_list_store_set(store, it,
+ num_player_dlg_columns, style,
+ num_player_dlg_columns + 1, weight,
+ -1);
}
@@ -553,7 +570,7 @@
it_next = it;
itree_next(&it_next);
- itree_get(&it, (num_player_dlg_columns+1), &plrno, -1);
+ itree_get(&it, ncolumns - 1, &plrno, -1);
/*
* The nation already had a row in the player report. In that
@@ -606,7 +623,7 @@
if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
gint plrno;
- gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
+ gtk_tree_model_get(model, &it, ncolumns - 1, &plrno, -1);
dsend_packet_diplomacy_init_meeting_req(&aconnection, plrno);
}
@@ -623,7 +640,7 @@
if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
gint plrno;
- gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
+ gtk_tree_model_get(model, &it, ncolumns - 1, &plrno, -1);
/* can be any pact clause */
dsend_packet_diplomacy_cancel_pact(&aconnection, plrno,
@@ -642,8 +659,7 @@
if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
gint plrno;
- gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
-
+ gtk_tree_model_get(model, &it, ncolumns - 1, &plrno, -1);
dsend_packet_diplomacy_cancel_pact(&aconnection, plrno, CLAUSE_VISION);
}
}
@@ -659,7 +675,7 @@
if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
gint plrno;
- gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
+ gtk_tree_model_get(model, &it, ncolumns - 1, &plrno, -1);
if (can_intel_with_player(&game.players[plrno])) {
popup_intel_dialog(&game.players[plrno]);
@@ -677,8 +693,8 @@
if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
gint plrno;
- gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
+ gtk_tree_model_get(model, &it, ncolumns - 1, &plrno, -1);
popup_spaceship_dialog(&game.players[plrno]);
}
}
@@ -695,7 +711,7 @@
gint plrno;
char buf[512];
- gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
+ gtk_tree_model_get(model, &it, ncolumns - 1, &plrno, -1);
my_snprintf(buf, sizeof(buf), "/aitoggle %s", get_player(plrno)->name);
send_chat(buf);
@@ -714,7 +730,7 @@
gint plrno;
char buf[512];
- gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
+ gtk_tree_model_get(model, &it, ncolumns - 1, &plrno, -1);
my_snprintf(buf, sizeof(buf), "/%s %s",
skill_level_names[GPOINTER_TO_UINT(data)],
|
|