X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gtk%2Fxoptions.c;h=3a29431e965f7b2cb1d71aa338d4c02d1d55a8fc;hb=406c6ab4dfbef3ace867dbe2ffd54072e4e48113;hp=e1ea6648301843085c8e01ca1067df6c8f014b65;hpb=3267bd2d1fc60f18ac2247f84993923d4765b7af;p=xboard.git diff --git a/gtk/xoptions.c b/gtk/xoptions.c index e1ea664..3a29431 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -270,6 +270,22 @@ SetWidgetFont (GtkWidget *w, char **s) } void +ApplyFont (Option *opt, char *font) +{ + GtkWidget *w = NULL; + if(!font && opt->font) font = *opt->font; + if(!font) return; + switch(opt->type) { + case ListBox: + case Label: w = opt->handle; break; + case Button: if(opt->handle) w = gtk_bin_get_child(GTK_BIN(opt->handle)); break; + case TextBox: w = opt->textValue; if(!w) w = opt->handle; break; + default: ; + } + if(w && font) SetWidgetFont(w, &font); +} + +void SetListBoxItem (GtkListStore *store, int n, char *msg) { GtkTreeIter iter; @@ -599,6 +615,11 @@ AppendColorized (Option *opt, char *s, int count) static GtkTextIter end; static GtkTextTag *fgTags[8], *bgTags[8], *font, *bold, *normal, *attr = NULL; + if(!s) { + font = NULL; + return; + } + if(!font) { 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); @@ -861,7 +882,7 @@ gboolean GenericPopDown(w, resptype, gdata) /* cancel pressed */ { if(dlg == BoardWindow) ExitEvent(0); - PopDown(dlg); + if(dlg == FatalDlg) ErrorOK(1); else PopDown(dlg); } shells[dlg] = sh; // restore return TRUE; @@ -913,6 +934,21 @@ ColorChanged (Widget w, XtPointer data, XEvent *event, Boolean *b) #endif static void +ExposeDraw (Option *graph, GdkEventExpose *eevent) +{ + int w = eevent->area.width; + cairo_t *cr; + if(eevent->area.x + w > graph->max) w--; // cut off fudge pixel + cr = gdk_cairo_create(((GtkWidget *) (graph->handle))->window); + cairo_set_source_surface(cr, (cairo_surface_t *) graph->choice, 0, 0); +//cairo_set_source_rgb(cr, 1, 0, 0); + cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); + cairo_rectangle(cr, eevent->area.x, eevent->area.y, w, eevent->area.height); + cairo_fill(cr); + cairo_destroy(cr); +} + +static void GraphEventProc(GtkWidget *widget, GdkEvent *event, gpointer gdata) { // handle expose and mouse events on Graph widget int w, h; @@ -924,7 +960,6 @@ GraphEventProc(GtkWidget *widget, GdkEvent *event, gpointer gdata) GdkEventMotion *mevent = (GdkEventMotion *) event; GdkEventScroll *sevent = (GdkEventScroll *) event; GtkAllocation a; - cairo_t *cr; // if (!XtIsRealized(widget)) return; @@ -957,26 +992,11 @@ GraphEventProc(GtkWidget *widget, GdkEvent *event, gpointer gdata) // to give drawing routines opportunity to use it before first expose event // (which are only processed when main gets to the event loop, so after all init!) // so only change when size is no longer good - cairo_t *cr; - if(graph->choice) cairo_surface_destroy((cairo_surface_t *) graph->choice); - graph->choice = (char**) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h); - // paint white, to prevent weirdness when people maximize window and drag pieces over space next to board - cr = cairo_create ((cairo_surface_t *) graph->choice); - cairo_rectangle (cr, 0, 0, w, h); - cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0); - cairo_fill(cr); - cairo_destroy (cr); +// NewCanvas(graph); + graph->min |= REPLACE; // defer making new canvas break; } - w = eevent->area.width; - if(eevent->area.x + w > graph->max) w--; // cut off fudge pixel - cr = gdk_cairo_create(((GtkWidget *) (graph->handle))->window); - cairo_set_source_surface(cr, (cairo_surface_t *) graph->choice, 0, 0); -//cairo_set_source_rgb(cr, 1, 0, 0); - cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); - cairo_rectangle(cr, eevent->area.x, eevent->area.y, w, eevent->area.height); - cairo_fill(cr); - cairo_destroy(cr); + ExposeDraw(graph, eevent); default: return; case GDK_SCROLL: @@ -1019,7 +1039,7 @@ GraphExpose (Option *opt, int x, int y, int w, int h) GdkEventExpose e; if(!opt->handle) return; e.area.x = x; e.area.y = y; e.area.width = w; e.area.height = h; e.count = -1; e.type = GDK_EXPOSE; // count = -1: kludge to suppress sizing - GraphEventProc(opt->handle, (GdkEvent *) &e, (gpointer) opt); // fake expose event + ExposeDraw(opt, &e); // fake expose event } void GenericCallback(GtkWidget *widget, gpointer gdata) @@ -1452,7 +1472,7 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); } else if (option[i].type == FileName || option[i].type == PathName) { gtk_table_attach(GTK_TABLE(table), entry, left+1, left+2, top, top+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 2, 1); - button = gtk_button_new_with_label ("Browse"); + button = gtk_button_new_with_label (_("Browse")); gtk_table_attach(GTK_TABLE(table), button, left+2, left+r, top, top+1, GTK_FILL, GTK_FILL, 2, 1); // Browse button does not expand g_signal_connect (button, "clicked", G_CALLBACK (BrowseGTK), (gpointer)(intptr_t) i); option[i].handle = (void*)entry; @@ -1486,7 +1506,7 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); label = frame; } gtk_widget_set_size_request(label, option[i].max ? option[i].max : -1, -1); - if(option[i].target || !strchr(option[i].name, '\n')) { // allow user to specify event handler for button presses + if(option[i].target || dlgNr != ErrorDlg && option[i].name) { // allow user to specify event handler for button presses button = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(button), label); label = button;