[patch] fix for gtkradiobutton not being depressed



i am going to keep the puns to a minimum.

this patch fixes the following screenshot and some other problems when
using radio buttons as buttons.

the second patch adds some of these to testgtk.

http://primates.ximian.com/~jacob/gnome2/radiobuttons.png

should it be done differently?

jacob
-- 
"Beat mixing is 10000 times more fun than even video games."
	-- bt
Index: gtkradiobutton.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkradiobutton.c,v
retrieving revision 1.35
diff -u -r1.35 gtkradiobutton.c
--- gtkradiobutton.c	2001/11/10 22:06:37	1.35
+++ gtkradiobutton.c	2001/11/16 21:22:14
@@ -116,6 +116,7 @@
 
   radio_button->group = g_slist_prepend (NULL, radio_button);
 
+  _gtk_button_set_depressed (GTK_BUTTON (radio_button), TRUE);
   gtk_widget_set_state (GTK_WIDGET (radio_button), GTK_STATE_ACTIVE);
 }
 
@@ -495,6 +496,7 @@
   GtkStateType new_state;
   GSList *tmp_list;
   gint toggled;
+  gboolean depressed;
 
   g_return_if_fail (GTK_IS_RADIO_BUTTON (button));
 
@@ -552,11 +554,20 @@
       new_state = (button->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE);
     }
 
+  if (toggle_button->inconsistent)
+    depressed = FALSE;
+  else if (button->in_button && button->button_down)
+    depressed = !toggle_button->active;
+  else
+    depressed = toggle_button->active;
+
   if (GTK_WIDGET_STATE (button) != new_state)
     gtk_widget_set_state (GTK_WIDGET (button), new_state);
 
   if (toggled)
     gtk_toggle_button_toggled (toggle_button);
+
+  _gtk_button_set_depressed (button, depressed);
 
   gtk_widget_queue_draw (GTK_WIDGET (button));
 
Index: testgtk.c
===================================================================
RCS file: /cvs/gnome/gtk+/tests/testgtk.c,v
retrieving revision 1.283
diff -u -r1.283 testgtk.c
--- testgtk.c	2001/11/14 23:20:31	1.283
+++ testgtk.c	2001/11/16 21:22:38
@@ -680,6 +680,26 @@
       separator = gtk_hseparator_new ();
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
+      button = gtk_radio_button_new_with_label (NULL, "button4");
+      gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
+      button = gtk_radio_button_new_with_label (
+	         gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
+		 "button5");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
+      button = gtk_radio_button_new_with_label (
+                 gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
+		 "button6");
+      gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
+      separator = gtk_hseparator_new ();
+      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
+
       box2 = gtk_vbox_new (FALSE, 10);
       gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]