From: H.G.Muller Date: Tue, 9 Sep 2014 19:43:39 +0000 (+0200) Subject: Let message field and button bar use GTK -messageFont X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=e677df018f76f76bace476a381866294282e9f3f;p=xboard.git Let message field and button bar use GTK -messageFont The -messageFont spec (using the default coordFont pixel size, like the others) is now used to modify the fonts of message field and buttons in the button bar. They pass a pointer to the appData font variable in their Option's textField. This conflicts with the use of this field in buttons for specifying a color, as done in the New Variant buttons. This is resolved by checking if the first byte of the pointed-to value is a #. The Xaw version must ignore the textField if it does not specify a color. --- diff --git a/dialogs.c b/dialogs.c index 3640866..8da6557 100644 --- a/dialogs.c +++ b/dialogs.c @@ -2460,13 +2460,13 @@ Option mainOptions[] = { // description of main window in terms of generic dialo { 13, R2R|T2T|SAME_ROW, 200, NULL, (void*) &CCB, NULL, NULL, Label, "Black" }, // black clock { 50, RR|TT|SAME_ROW, 100, NULL, (void*) &LogoB, NULL, NULL, Skip, "" }, // black logo { 0, LR|T2T|BORDER, 401, NULL, NULL, "", NULL, Skip, "2" }, // backup for title in window (if no room for other) -{ 0, LR|T2T|BORDER, 270, NULL, NULL, "", NULL, Label, "message" }, // message field +{ 0, LR|T2T|BORDER, 270, NULL, NULL, (char*)&appData.font, NULL, Label, "message" }, // message field { 0, RR|TT|SAME_ROW, 125, NULL, NULL, "", NULL, BoxBegin, "" }, // (optional) button bar - { 0, 0, 0, NULL, (void*) &ToStartEvent, NULL, NULL, Button, N_("<<") }, - { 0, SAME_ROW, 0, NULL, (void*) &BackwardEvent, NULL, NULL, Button, N_("<") }, - { 0, SAME_ROW, 0, NULL, (void*) &PauseEvent, NULL, NULL, Button, N_(PAUSE_BUTTON) }, - { 0, SAME_ROW, 0, NULL, (void*) &ForwardEvent, NULL, NULL, Button, N_(">") }, - { 0, SAME_ROW, 0, NULL, (void*) &ToEndEvent, NULL, NULL, Button, N_(">>") }, + { 0, 0, 0, NULL, (void*) &ToStartEvent, (char*)&appData.font, NULL, Button, N_("<<") }, + { 0, SAME_ROW, 0, NULL, (void*) &BackwardEvent, (char*)&appData.font, NULL, Button, N_("<") }, + { 0, SAME_ROW, 0, NULL, (void*) &PauseEvent, (char*)&appData.font, NULL, Button, N_(PAUSE_BUTTON) }, + { 0, SAME_ROW, 0, NULL, (void*) &ForwardEvent, (char*)&appData.font, NULL, Button, N_(">") }, + { 0, SAME_ROW, 0, NULL, (void*) &ToEndEvent, (char*)&appData.font, NULL, Button, N_(">>") }, { 0, 0, 0, NULL, NULL, "", NULL, BoxEnd, "" }, { 401, LR|TB, 401, NULL, (char*) &Exp, NULL, NULL, Graph, "shadow board" }, // board { 2, COMBO_CALLBACK, 0, NULL, (void*) &PMSelect, NULL, pieceMenuStrings[0], PopUp, "menuW" }, diff --git a/gtk/xboard.c b/gtk/xboard.c index e72a3aa..a7cbd45 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -669,7 +669,7 @@ InitializeFonts (int clockFontPxlSize, int coordFontPxlSize, int fontPxlSize) if(!fontIsSet[GAMELIST_FONT] && fontValid[GAMELIST_FONT][squareSize]) appData.gameListFont = fontTable[GAMELIST_FONT][squareSize]; - appData.font = InsertPxlSize(appData.font, fontPxlSize); + appData.font = InsertPxlSize(appData.font, coordFontPxlSize); appData.clockFont = InsertPxlSize(appData.clockFont, clockFontPxlSize); appData.coordFont = InsertPxlSize(appData.coordFont, coordFontPxlSize); appData.icsFont = InsertPxlSize(appData.icsFont, coordFontPxlSize); diff --git a/gtk/xoptions.c b/gtk/xoptions.c index 564b865..e144e3d 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -259,6 +259,16 @@ SetDialogTitle (DialogClass dlg, char *title) gtk_window_set_title(GTK_WINDOW(shells[dlg]), title); } +int +SetWidgetFont (GtkWidget *w, char *s) +{ + PangoFontDescription *pfd; + if (!s || !*s || *s == '#') return 0; // no spec, empty spec or spec of color: fail + pfd = pango_font_description_from_string(*(char**)s); + gtk_widget_modify_font(w, pfd); + return 1; +} + void SetListBoxItem (GtkListStore *store, int n, char *msg) { @@ -693,7 +703,6 @@ printf("*** selected\n"); void AddHandler (Option *opt, DialogClass dlg, int nr) { - PangoFontDescription *pfd; switch(nr) { case 0: // history (now uses generic textview callback) case 1: // comment (likewise) @@ -704,8 +713,7 @@ AddHandler (Option *opt, DialogClass dlg, int nr) g_signal_connect(opt->handle, "key-press-event", G_CALLBACK (TypeInProc), (gpointer) (dlg<<16 | (opt - dialogOptions[dlg]))); break; case 5: // game list - pfd = pango_font_description_from_string(appData.gameListFont); - gtk_widget_modify_font(opt->handle, pfd); + SetWidgetFont(opt->handle, (char*) &appData.gameListFont); g_signal_connect(opt->handle, "button-press-event", G_CALLBACK (GameListEvent), (gpointer) 0 ); case 4: // game-list filter g_signal_connect(opt->handle, "key-press-event", G_CALLBACK (GameListEvent), (gpointer) (intptr_t) nr ); @@ -1352,11 +1360,7 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); /* no label so let textview occupy all columns */ Pack(hbox, table, sw, left, left+r, top, GTK_EXPAND); } - if ( option[i].textValue != NULL ) { - PangoFontDescription *pfd; - pfd = pango_font_description_from_string(*(char**)option[i].textValue); - gtk_widget_modify_font(textview, pfd); - } + SetWidgetFont(textview, option[i].textValue); if ( *(char**)option[i].target != NULL ) gtk_text_buffer_set_text (textbuffer, *(char**)option[i].target, -1); else @@ -1423,6 +1427,7 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); option[i].handle = (void *) (label = gtk_label_new(option[i].name)); /* Left Justify */ gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + SetWidgetFont(label, option[i].textValue); if(option[i].min & BORDER) { GtkWidget *frame = gtk_frame_new(NULL); gtk_container_add(GTK_CONTAINER(frame), label); @@ -1450,6 +1455,7 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); } /* set button color on new variant dialog */ + if(!SetWidgetFont(gtk_bin_get_child(GTK_BIN(button)), option[i].textValue)) if(option[i].textValue) { gdk_color_parse( option[i].textValue, &color ); gtk_widget_modify_bg ( GTK_WIDGET(button), GTK_STATE_NORMAL, &color ); diff --git a/xaw/xoptions.c b/xaw/xoptions.c index e183cf2..e855beb 100644 --- a/xaw/xoptions.c +++ b/xaw/xoptions.c @@ -1129,7 +1129,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent j = SetPositionAndSize(args, last, lastrow, 3 /* border */, option[i].max /* w */, shrink ? textHeight : 0 /* h */, option[i].min & 0xE | chain /* chain */); XtSetArg(args[j], XtNlabel, _(option[i].name)); j++; - if(option[i].textValue) { // special for buttons of New Variant dialog + if(option[i].textValue && *option[i].textValue == '#') { // special for buttons of New Variant dialog XtSetArg(args[j], XtNsensitive, option[i].value >= 0 && (appData.noChessProgram || strstr(first.variants, VariantName(option[i].value)))); j++; XtSetArg(args[j], XtNborderWidth, (gameInfo.variant == option[i].value)+1); j++;