Add extra font field to Option struct
[xboard.git] / gtk / xoptions.c
index 0caa125..cd78c9f 100644 (file)
@@ -138,16 +138,6 @@ static Arg formArgs[] = {
 };
 #endif
 
-void
-MarkMenuItem (char *menuRef, int state)
-{
-    MenuItem *item = MenuNameToItem(menuRef);
-
-    if(item && item->handle) {
-        ((GtkCheckMenuItem *) (item->handle))->active = state;
-    }
-}
-
 void GetWidgetTextGTK(GtkWidget *w, char **buf)
 {
     GtkTextIter start;
@@ -260,6 +250,15 @@ SetDialogTitle (DialogClass dlg, char *title)
 }
 
 void
+SetWidgetFont (GtkWidget *w, char **s)
+{
+    PangoFontDescription *pfd;
+    if (!s || !*s || !**s) return; // uses no font, no font spec or empty font spec
+    pfd = pango_font_description_from_string(*s);
+    gtk_widget_modify_font(w, pfd);
+}
+
+void
 SetListBoxItem (GtkListStore *store, int n, char *msg)
 {
     GtkTreeIter iter;
@@ -558,7 +557,7 @@ AppendColorized (Option *opt, char *s, int count)
     static GtkTextTag *fgTags[8], *bgTags[8], *font, *bold, *normal, *attr = NULL;
 
     if(!font) {
-       font = gtk_text_buffer_create_tag(opt->handle, NULL, "font", "Monospace normal", NULL);
+       font = gtk_text_buffer_create_tag(opt->handle, NULL, "font", appData.icsFont, NULL);
        gtk_widget_modify_base(GTK_WIDGET(opt->textValue), GTK_STATE_NORMAL, &backgroundColor);
     }
 
@@ -1349,6 +1348,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);
                 }
+                SetWidgetFont(textview, option[i].font);
                 if ( *(char**)option[i].target != NULL )
                     gtk_text_buffer_set_text (textbuffer, *(char**)option[i].target, -1);
                 else
@@ -1415,6 +1415,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].font);
            if(option[i].min & BORDER) {
                GtkWidget *frame = gtk_frame_new(NULL);
                 gtk_container_add(GTK_CONTAINER(frame), label);
@@ -1434,6 +1435,7 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width);
           case SaveButton:
           case Button:
             button = gtk_button_new_with_label (option[i].name);
+            SetWidgetFont(gtk_bin_get_child(GTK_BIN(button)), option[i].font);
 
             /* set button color on view board dialog */
             if(option[i].choice && ((char*)option[i].choice)[0] == '#' && !currentCps) {
@@ -1495,6 +1497,7 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width);
                 GtkListStore *store;
 
                 option[i].handle = (void *) (list = gtk_tree_view_new());
+                SetWidgetFont(option[i].handle, option[i].font);
                 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);
                 renderer = gtk_cell_renderer_text_new();
                 column = gtk_tree_view_column_new_with_attributes("List Items", renderer, "text", 0, NULL);