shithub: puzzles

Download patch

ref: d040a921bab05691e4ce8908387a9d5ad2d421de
parent: 0a4c832e9bf37ce3f153e40ea7892d436d4ea7ba
author: Simon Tatham <anakin@pobox.com>
date: Sat May 29 11:43:40 EDT 2010

Patch from Mark Wooding to use GTK stock items for standard 'OK',
'Yes' and 'No' buttons, which means they get the standard icons that
go on those button types. Also reorders yes/no boxes so that they're
the GNOME standard way round.

[originally from svn r8959]

--- a/gtk.c
+++ b/gtk.c
@@ -826,18 +826,18 @@
     gtk_label_set_line_wrap(GTK_LABEL(text), TRUE);
 
     if (type == MB_OK) {
-	titles = "OK\0";
+	titles = GTK_STOCK_OK "\0";
 	def = cancel = 0;
     } else {
 	assert(type == MB_YESNO);
-	titles = "Yes\0No\0";
-	def = 0;
-	cancel = 1;
+	titles = GTK_STOCK_NO "\0" GTK_STOCK_YES "\0";
+	def = 1;
+	cancel = 0;
     }
     i = 0;
     
     while (*titles) {
-	button = gtk_button_new_with_label(titles);
+	button = gtk_button_new_from_stock(titles);
 	gtk_box_pack_end(GTK_BOX(GTK_DIALOG(window)->action_area),
 			 button, FALSE, FALSE, 0);
 	gtk_widget_show(button);
@@ -866,7 +866,7 @@
     gtk_widget_show(window);
     i = -1;
     gtk_main();
-    return (type == MB_YESNO ? i == 0 : TRUE);
+    return (type == MB_YESNO ? i == 1 : TRUE);
 }
 
 void error_box(GtkWidget *parent, char *msg)
@@ -956,22 +956,22 @@
     gtk_window_set_title(GTK_WINDOW(fe->cfgbox), title);
     sfree(title);
 
-    w = gtk_button_new_with_label("OK");
+    w = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
     gtk_box_pack_end(GTK_BOX(GTK_DIALOG(fe->cfgbox)->action_area),
                      w, FALSE, FALSE, 0);
     gtk_widget_show(w);
-    GTK_WIDGET_SET_FLAGS(w, GTK_CAN_DEFAULT);
-    gtk_window_set_default(GTK_WINDOW(fe->cfgbox), w);
     gtk_signal_connect(GTK_OBJECT(w), "clicked",
-                       GTK_SIGNAL_FUNC(config_ok_button_clicked), fe);
+                       GTK_SIGNAL_FUNC(config_cancel_button_clicked), fe);
+    cancel = w;
 
-    w = gtk_button_new_with_label("Cancel");
+    w = gtk_button_new_from_stock(GTK_STOCK_OK);
     gtk_box_pack_end(GTK_BOX(GTK_DIALOG(fe->cfgbox)->action_area),
                      w, FALSE, FALSE, 0);
     gtk_widget_show(w);
+    GTK_WIDGET_SET_FLAGS(w, GTK_CAN_DEFAULT);
+    gtk_window_set_default(GTK_WINDOW(fe->cfgbox), w);
     gtk_signal_connect(GTK_OBJECT(w), "clicked",
-                       GTK_SIGNAL_FUNC(config_cancel_button_clicked), fe);
-    cancel = w;
+                       GTK_SIGNAL_FUNC(config_ok_button_clicked), fe);
 
     table = gtk_table_new(1, 2, FALSE);
     y = 0;