]> Pileus Git - ~andy/gtk/blob - gtk/gtkcombo.c
gtk/gtkcombo.[ch] "activate" signal can be disabled now
[~andy/gtk] / gtk / gtkcombo.c
1 /* gtkcombo - combo widget for gtk+
2  * Copyright 1997 Paolo Molaro
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18
19 #include <string.h>
20
21 #include "gtkarrow.h"
22 #include "gtklabel.h"
23 #include "gtklist.h"
24 #include "gtkentry.h"
25 #include "gtkbutton.h"
26 #include "gtklistitem.h"
27 #include "gtkscrolledwindow.h"
28 #include "gtkmain.h"
29 #include "gtksignal.h"
30 #include "gtkwindow.h"
31 #include "gdk/gdkkeysyms.h"
32 #include "gtkcombo.h"
33 #include "gtkframe.h"
34
35 const gchar *gtk_combo_string_key = "gtk-combo-string-value";
36
37 #define COMBO_LIST_MAX_HEIGHT 400
38
39 static void         gtk_combo_class_init      (GtkComboClass *klass);
40 static void         gtk_combo_init            (GtkCombo      *combo);
41 static void         gtk_combo_destroy         (GtkObject     *combo);
42 static GtkListItem *gtk_combo_find            (GtkCombo      *combo);
43 static gchar *      gtk_combo_func            (GtkListItem  *li);
44 static gint         gtk_combo_focus_idle      (GtkCombo      *combo);
45 static gint         gtk_combo_entry_focus_out (GtkEntry      *entry, 
46                                                GdkEventFocus *event, 
47                                                GtkCombo      *combo);
48 static void         gtk_combo_get_pos         (GtkCombo      *combo, 
49                                                gint          *x, 
50                                                gint          *y, 
51                                                gint          *height, 
52                                                gint          *width);
53 static void         gtk_combo_popup_list      (GtkButton     *button, 
54                                                GtkCombo      *combo);
55 static void         gtk_combo_update_entry    (GtkList       *list, 
56                                                GtkCombo      *combo);
57 static void         gtk_combo_update_list     (GtkEntry      *entry, 
58                                                GtkCombo      *combo);
59 static gint         gtk_combo_button_press    (GtkWidget     *widget,
60                                                GdkEvent      *event,
61                                                GtkCombo      *combo);
62 static gint         gtk_combo_list_key_press  (GtkWidget     *widget, 
63                                                GdkEventKey   *event, 
64                                                GtkCombo      *combo);
65 static gint         gtk_combo_entry_key_press (GtkEntry      *widget, 
66                                                GdkEventKey   *event, 
67                                                GtkCombo      *combo);
68 static void         gtk_combo_item_destroy    (GtkObject     *object);
69 static void         gtk_combo_size_allocate   (GtkWidget     *widget,
70                                                GtkAllocation *allocation);
71
72 static GtkHBoxClass *parent_class = NULL;
73
74 static void
75 gtk_combo_class_init (GtkComboClass * klass)
76 {
77   GtkObjectClass *oclass;
78   GtkWidgetClass *widget_class;
79
80   parent_class = gtk_type_class (gtk_hbox_get_type ());
81   oclass = (GtkObjectClass *) klass;
82   widget_class = (GtkWidgetClass *) klass;
83
84   oclass->destroy = gtk_combo_destroy;
85   
86   widget_class->size_allocate = gtk_combo_size_allocate;
87 }
88
89 static void
90 gtk_combo_destroy (GtkObject * combo)
91 {
92   gtk_widget_destroy (GTK_COMBO (combo)->popwin);
93   gtk_widget_unref (GTK_COMBO (combo)->popwin);
94
95   if (GTK_OBJECT_CLASS (parent_class)->destroy)
96     (*GTK_OBJECT_CLASS (parent_class)->destroy) (combo);
97 }
98
99 static int
100 gtk_combo_entry_key_press (GtkEntry * entry, GdkEventKey * event, GtkCombo * combo)
101 {
102   GList *li;
103   /* completion? */
104   /*if ( event->keyval == GDK_Tab ) {
105      gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "key_press_event");
106      return TRUE;
107      } else */
108   if (!combo->use_arrows || !GTK_LIST (combo->list)->children)
109     return FALSE;
110   li = g_list_find (GTK_LIST (combo->list)->children, gtk_combo_find (combo));
111
112   if ((event->keyval == GDK_Up)
113       || (event->keyval == GDK_KP_Up)
114       || ((event->state & GDK_MOD1_MASK) && ((event->keyval == 'p') || (event->keyval == 'P'))))
115     {
116       if (li)
117         li = li->prev;
118       if (!li && combo->use_arrows_always)
119         {
120           li = g_list_last (GTK_LIST (combo->list)->children);
121         }
122       if (li)
123         {
124           gtk_list_select_child (GTK_LIST (combo->list), GTK_WIDGET (li->data));
125           gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "key_press_event");
126           return TRUE;
127         }
128     }
129   else if ((event->keyval == GDK_Down)
130            || (event->keyval == GDK_KP_Down)
131            || ((event->state & GDK_MOD1_MASK) && ((event->keyval == 'n') || (event->keyval == 'N'))))
132     {
133       if (li)
134         li = li->next;
135       if (!li && combo->use_arrows_always)
136         {
137           li = GTK_LIST (combo->list)->children;
138         }
139       if (li)
140         {
141           gtk_list_select_child (GTK_LIST (combo->list), GTK_WIDGET (li->data));
142           gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "key_press_event");
143           return TRUE;
144         }
145     }
146   return FALSE;
147 }
148
149 static GtkListItem *
150 gtk_combo_find (GtkCombo * combo)
151 {
152   gchar *text;
153   gchar *ltext;
154   GList *clist;
155   int (*string_compare) (const char *, const char *);
156
157   if (combo->case_sensitive)
158     string_compare = strcmp;
159   else
160     string_compare = g_strcasecmp;
161
162   text = gtk_entry_get_text (GTK_ENTRY (combo->entry));
163   clist = GTK_LIST (combo->list)->children;
164
165   while (clist && clist->data)
166     {
167       ltext = gtk_combo_func (GTK_LIST_ITEM (clist->data));
168       if (!ltext)
169         continue;
170       if (!(*string_compare) (ltext, text))
171         return (GtkListItem *) clist->data;
172       clist = clist->next;
173     }
174
175   return NULL;
176 }
177
178 static gchar *
179 gtk_combo_func (GtkListItem * li)
180 {
181   GtkWidget *label;
182   gchar *ltext = NULL;
183
184   ltext = (gchar *) gtk_object_get_data (GTK_OBJECT (li), gtk_combo_string_key);
185   if (!ltext)
186     {
187       label = GTK_BIN (li)->child;
188       if (!label || !GTK_IS_LABEL (label))
189         return NULL;
190       gtk_label_get (GTK_LABEL (label), &ltext);
191     }
192   return ltext;
193 }
194
195 static gint
196 gtk_combo_focus_idle (GtkCombo * combo)
197 {
198   if (combo)
199     gtk_widget_grab_focus (combo->entry);
200   return FALSE;
201 }
202
203 static gint
204 gtk_combo_entry_focus_out (GtkEntry * entry, GdkEventFocus * event, GtkCombo * combo)
205 {
206
207   if (combo->value_in_list && !gtk_combo_find (combo))
208     {
209       /* gdk_beep(); *//* this can be annoying */
210       if (combo->ok_if_empty && !strcmp (gtk_entry_get_text (entry), ""))
211         return FALSE;
212 #ifdef TEST
213       printf ("INVALID ENTRY: `%s'\n", gtk_entry_get_text (entry));
214 #endif
215       gtk_grab_add (GTK_WIDGET (combo));
216       /* this is needed because if we call gtk_widget_grab_focus() 
217          it isn't guaranteed it's the *last* call before the main-loop,
218          so the focus can be lost anyway...
219          the signal_emit_stop doesn't seem to work either...
220        */
221       gtk_idle_add ((GtkFunction) gtk_combo_focus_idle, combo);
222       /*gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "focus_out_event"); */
223       return TRUE;
224     }
225   return FALSE;
226 }
227
228 static void
229 gtk_combo_get_pos (GtkCombo * combo, gint * x, gint * y, gint * height, gint * width)
230 {
231   GtkBin *popwin;
232   GtkWidget *widget;
233   GtkScrolledWindow *popup;
234
235   gint real_height;
236   GtkRequisition list_requisition;
237   gboolean show_hscroll = FALSE;
238   gboolean show_vscroll = FALSE;
239   gint avail_height;
240   gint min_height;
241   gint alloc_width;
242   gint work_height;
243   gint old_height;
244   gint old_width;
245
246   widget = GTK_WIDGET(combo);
247   popup  = GTK_SCROLLED_WINDOW (combo->popup);
248   popwin = GTK_BIN (combo->popwin);
249
250   gdk_window_get_origin (combo->entry->window, x, y);
251   real_height = MIN (combo->entry->requisition.height, 
252                      combo->entry->allocation.height);
253   *y += real_height;
254   avail_height = gdk_screen_height () - *y;
255
256   gtk_widget_size_request (combo->list, &list_requisition);
257   min_height = MIN (list_requisition.height, 
258                     popup->vscrollbar->requisition.height);
259
260
261   alloc_width = widget->allocation.width -
262     2 * popwin->child->style->klass->xthickness -
263     2 * GTK_CONTAINER (popwin->child)->border_width -
264     2 * GTK_CONTAINER (combo->popup)->border_width -
265     2 * GTK_CONTAINER (popup->viewport)->border_width - 
266     2 * popup->viewport->style->klass->xthickness;
267
268   work_height =  
269     2 * popwin->child->style->klass->ythickness +
270     2 * GTK_CONTAINER (popwin->child)->border_width +
271     2 * GTK_CONTAINER (combo->popup)->border_width +
272     2 * GTK_CONTAINER (popup->viewport)->border_width +
273     2 * popup->viewport->style->klass->xthickness;
274
275   do 
276     {
277       old_width = alloc_width;
278       old_height = work_height;
279
280       if (!show_hscroll &&
281           alloc_width < list_requisition.width)
282         {
283           work_height += popup->hscrollbar->requisition.height +
284             GTK_SCROLLED_WINDOW_CLASS 
285             (GTK_OBJECT (combo->popup)->klass)->scrollbar_spacing;
286           show_hscroll = TRUE;
287         }
288       if (!show_vscroll && 
289           work_height + list_requisition.height > avail_height)
290         {
291           if (work_height + min_height > avail_height && 
292               *y - real_height > avail_height)
293             {
294               *y -= (work_height +list_requisition.height + real_height);
295               break;
296             }
297           alloc_width -= 
298             popup->vscrollbar->requisition.width +
299             GTK_SCROLLED_WINDOW_CLASS 
300             (GTK_OBJECT (combo->popup)->klass)->scrollbar_spacing;
301           show_vscroll = TRUE;
302         }
303     } while (old_width != alloc_width || old_height != work_height);
304
305   *width = widget->allocation.width;
306   if (show_vscroll)
307       *height = avail_height;
308   else
309     *height = work_height + list_requisition.height;
310   
311   if (*x < 0)
312     *x = 0;
313 }
314
315 static void
316 gtk_combo_popup_list (GtkButton * button, GtkCombo * combo)
317 {
318   gint height, width, x, y;
319   gint old_width, old_height;
320
321   if (!GTK_LIST (combo->list)->children)
322     return;
323
324   old_width = combo->popwin->allocation.width;
325   old_height  = combo->popwin->allocation.height;
326
327   gtk_combo_get_pos (combo, &x, &y, &height, &width);
328
329   /* workaround for gtk_scrolled_window_size_allocate bug */
330   if (old_width != width || old_height != height)
331     {
332       gtk_widget_hide (GTK_SCROLLED_WINDOW (combo->popup)->hscrollbar);
333       gtk_widget_hide (GTK_SCROLLED_WINDOW (combo->popup)->vscrollbar);
334     }
335
336   gtk_widget_set_uposition (combo->popwin, x, y);
337   gtk_widget_set_usize (combo->popwin, width, height);
338   gtk_widget_realize (combo->popwin);
339   gdk_window_resize (combo->popwin->window, width, height);
340   gtk_widget_show (combo->popwin);
341
342   gtk_widget_grab_focus (combo->popwin);
343   gtk_grab_add (combo->popwin);
344   gdk_pointer_grab (combo->popwin->window, TRUE,
345                     GDK_BUTTON_PRESS_MASK, NULL, NULL, GDK_CURRENT_TIME);
346 }
347
348 #if 0
349 static void
350 prelight_bug (GtkButton * b, GtkCombo * combo)
351 {
352   /* avoid prelight state... */
353   gtk_widget_set_state (combo->button, GTK_STATE_NORMAL);
354
355 }
356 #endif
357
358 static void
359 gtk_combo_update_entry (GtkList * list, GtkCombo * combo)
360 {
361   char *text;
362
363   gtk_grab_remove (GTK_WIDGET (combo));
364   gtk_signal_handler_block (GTK_OBJECT (list), combo->list_change_id);
365   if (list->selection)
366     {
367       text = gtk_combo_func (GTK_LIST_ITEM (list->selection->data));
368       if (!text)
369         text = "";
370       gtk_entry_set_text (GTK_ENTRY (combo->entry), text);
371     }
372   gtk_widget_hide (combo->popwin);
373   gtk_grab_remove (combo->popwin);
374   gdk_pointer_ungrab (GDK_CURRENT_TIME);
375   gtk_signal_handler_unblock (GTK_OBJECT (list), combo->list_change_id);
376 }
377
378 static void
379 gtk_combo_update_list (GtkEntry * entry, GtkCombo * combo)
380 {
381   GtkList *list = GTK_LIST (combo->list);
382   GList *slist = list->selection;
383   GtkListItem *li;
384
385   gtk_grab_remove (GTK_WIDGET (combo));
386
387   gtk_signal_handler_block (GTK_OBJECT (entry), combo->entry_change_id);
388   if (slist && slist->data)
389     gtk_list_unselect_child (list, GTK_WIDGET (slist->data));
390   li = gtk_combo_find (combo);
391   if (li)
392     gtk_list_select_child (list, GTK_WIDGET (li));
393   gtk_signal_handler_unblock (GTK_OBJECT (entry), combo->entry_change_id);
394 }
395
396 static gint
397 gtk_combo_button_press (GtkWidget * widget, GdkEvent * event, GtkCombo * combo)
398 {
399   GtkWidget *child;
400
401   child = gtk_get_event_widget (event);
402
403   /* We don't ask for button press events on the grab widget, so
404    *  if an event is reported directly to the grab widget, it must
405    *  be on a window outside the application (and thus we remove
406    *  the popup window). Otherwise, we check if the widget is a child
407    *  of the grab widget, and only remove the popup window if it
408    *  is not.
409    */
410   if (child != widget)
411     {
412       while (child)
413         {
414           if (child == widget)
415             return FALSE;
416           child = child->parent;
417         }
418     }
419
420   gtk_widget_hide (combo->popwin);
421   gtk_grab_remove (combo->popwin);
422   gdk_pointer_ungrab (GDK_CURRENT_TIME);
423
424   return TRUE;
425 }
426
427 static int
428 gtk_combo_list_key_press (GtkWidget * widget, GdkEventKey * event, GtkCombo * combo)
429 {
430   if (event->keyval == GDK_Escape)
431     {
432       gtk_widget_hide (combo->popwin);
433       gtk_grab_remove (combo->popwin);
434       gdk_pointer_ungrab (GDK_CURRENT_TIME);
435       return TRUE;
436     }
437   return FALSE;
438 }
439
440 static void
441 gtk_combo_init (GtkCombo * combo)
442 {
443   GtkWidget *arrow;
444   GtkWidget *frame;
445
446   combo->case_sensitive = 0;
447   combo->value_in_list = 0;
448   combo->ok_if_empty = 1;
449   combo->use_arrows = 1;
450   combo->use_arrows_always = 0;
451   combo->entry = gtk_entry_new ();
452   combo->button = gtk_button_new ();
453   arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
454   gtk_widget_show (arrow);
455   gtk_container_add (GTK_CONTAINER (combo->button), arrow);
456   gtk_box_pack_start (GTK_BOX (combo), combo->entry, TRUE, TRUE, 0);
457   gtk_box_pack_end (GTK_BOX (combo), combo->button, FALSE, FALSE, 0);
458   gtk_widget_show (combo->entry);
459   gtk_widget_show (combo->button);
460   combo->entry_change_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "changed",
461                               (GtkSignalFunc) gtk_combo_update_list, combo);
462   gtk_signal_connect (GTK_OBJECT (combo->entry), "key_press_event",
463                       (GtkSignalFunc) gtk_combo_entry_key_press, combo);
464   gtk_signal_connect_after (GTK_OBJECT (combo->entry), "focus_out_event",
465                             (GtkSignalFunc) gtk_combo_entry_focus_out, combo);
466   combo->activate_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "activate",
467                       (GtkSignalFunc) gtk_combo_popup_list, combo);
468   gtk_signal_connect (GTK_OBJECT (combo->button), "clicked",
469                       (GtkSignalFunc) gtk_combo_popup_list, combo);
470   /*gtk_signal_connect(GTK_OBJECT(combo->button), "clicked",
471      (GtkSignalFunc)prelight_bug, combo); */
472
473   combo->popwin = gtk_window_new (GTK_WINDOW_POPUP);
474   gtk_widget_ref (combo->popwin);
475   gtk_window_set_policy (GTK_WINDOW (combo->popwin), 1, 1, 0);
476
477   frame = gtk_frame_new (NULL);
478   gtk_container_add (GTK_CONTAINER (combo->popwin), frame);
479   gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
480   gtk_widget_show (frame);
481
482   combo->popup = gtk_scrolled_window_new (NULL, NULL);
483   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (combo->popup),
484                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
485   combo->list = gtk_list_new ();
486   gtk_list_set_selection_mode(GTK_LIST(combo->list), GTK_SELECTION_BROWSE);
487   gtk_container_add (GTK_CONTAINER (frame), combo->popup);
488   gtk_container_add (GTK_CONTAINER (combo->popup), combo->list);
489   gtk_widget_show (combo->list);
490   gtk_widget_show (combo->popup);
491   gtk_widget_set_events (combo->popwin, gtk_widget_get_events (combo->popwin) | GDK_KEY_PRESS_MASK);
492   combo->list_change_id = gtk_signal_connect (GTK_OBJECT (combo->list), "selection_changed",
493                              (GtkSignalFunc) gtk_combo_update_entry, combo);
494   gtk_signal_connect (GTK_OBJECT (combo->popwin), "key_press_event",
495                       (GtkSignalFunc) gtk_combo_list_key_press, combo);
496   gtk_signal_connect (GTK_OBJECT (combo->popwin), "button_press_event",
497                       GTK_SIGNAL_FUNC (gtk_combo_button_press), combo);
498   
499 }
500
501 guint
502 gtk_combo_get_type ()
503 {
504   static guint combo_type = 0;
505
506   if (!combo_type)
507     {
508       GtkTypeInfo combo_info =
509       {
510         "GtkCombo",
511         sizeof (GtkCombo),
512         sizeof (GtkComboClass),
513         (GtkClassInitFunc) gtk_combo_class_init,
514         (GtkObjectInitFunc) gtk_combo_init,
515         (GtkArgSetFunc) NULL,
516         (GtkArgGetFunc) NULL,
517       };
518       combo_type = gtk_type_unique (gtk_hbox_get_type (), &combo_info);
519     }
520   return combo_type;
521 }
522
523 GtkWidget *
524 gtk_combo_new ()
525 {
526   return GTK_WIDGET (gtk_type_new (gtk_combo_get_type ()));
527 }
528
529 void
530 gtk_combo_set_value_in_list (GtkCombo * combo, gint val, gint ok_if_empty)
531 {
532   g_return_if_fail (combo != NULL);
533   g_return_if_fail (GTK_IS_COMBO (combo));
534
535   combo->value_in_list = val;
536   combo->ok_if_empty = ok_if_empty;
537 }
538
539 void
540 gtk_combo_set_case_sensitive (GtkCombo * combo, gint val)
541 {
542   g_return_if_fail (combo != NULL);
543   g_return_if_fail (GTK_IS_COMBO (combo));
544
545   combo->case_sensitive = val;
546 }
547
548 void
549 gtk_combo_set_use_arrows (GtkCombo * combo, gint val)
550 {
551   g_return_if_fail (combo != NULL);
552   g_return_if_fail (GTK_IS_COMBO (combo));
553
554   combo->use_arrows = val;
555 }
556
557 void
558 gtk_combo_set_use_arrows_always (GtkCombo * combo, gint val)
559 {
560   g_return_if_fail (combo != NULL);
561   g_return_if_fail (GTK_IS_COMBO (combo));
562
563   combo->use_arrows_always = val;
564   combo->use_arrows = 1;
565 }
566
567 void
568 gtk_combo_set_popdown_strings (GtkCombo * combo, GList * strings)
569 {
570   GList *list;
571   GtkWidget *li;
572
573   g_return_if_fail (combo != NULL);
574   g_return_if_fail (GTK_IS_COMBO (combo));
575   g_return_if_fail (strings != NULL);
576
577   gtk_list_clear_items (GTK_LIST (combo->list), 0, -1);
578   list = strings;
579   while (list)
580     {
581       li = gtk_list_item_new_with_label ((gchar *) list->data);
582       gtk_widget_show (li);
583       gtk_container_add (GTK_CONTAINER (combo->list), li);
584       list = list->next;
585     }
586 }
587
588 static void
589 gtk_combo_item_destroy (GtkObject * object)
590 {
591   gchar *key;
592
593   key = gtk_object_get_data (object, gtk_combo_string_key);
594   if (key)
595     g_free (key);
596 }
597
598 void
599 gtk_combo_set_item_string (GtkCombo * combo, GtkItem * item, const gchar * item_value)
600 {
601   gchar *val;
602   gint connected = 0;
603
604   g_return_if_fail (combo != NULL);
605   g_return_if_fail (GTK_IS_COMBO (combo));
606   g_return_if_fail (item != NULL);
607
608   val = gtk_object_get_data (GTK_OBJECT (item), gtk_combo_string_key);
609   if (val) 
610     {
611       g_free (val);
612       connected = 1;
613     }
614   if (item_value)
615     {
616       val = g_strdup(item_value);
617       gtk_object_set_data (GTK_OBJECT (item), gtk_combo_string_key, val);
618       if (!connected)
619         gtk_signal_connect (GTK_OBJECT (item), "destroy",
620                           (GtkSignalFunc) gtk_combo_item_destroy, val);
621     }
622   else 
623     {
624       gtk_object_set_data (GTK_OBJECT (item), gtk_combo_string_key, NULL);
625       if (connected)
626         gtk_signal_disconnect_by_data(GTK_OBJECT (item), val);
627     }
628 }
629
630 static void
631 gtk_combo_size_allocate (GtkWidget     *widget,
632                          GtkAllocation *allocation)
633 {
634   GtkCombo *combo;
635
636   g_return_if_fail (widget != NULL);
637   g_return_if_fail (GTK_IS_COMBO (widget));
638   g_return_if_fail (allocation != NULL);
639
640   GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
641   
642   combo = GTK_COMBO (widget);
643
644   if (combo->entry->allocation.height > combo->entry->requisition.height)
645     {
646       GtkAllocation button_allocation;
647
648       button_allocation = combo->button->allocation;
649       button_allocation.height = combo->entry->requisition.height;
650       button_allocation.y = combo->entry->allocation.y + 
651         (combo->entry->allocation.height - combo->entry->requisition.height) 
652         / 2;
653       gtk_widget_size_allocate (combo->button, &button_allocation);
654     }
655 }
656
657 void
658 gtk_combo_disable_activate (GtkCombo* combo)
659 {
660   g_return_if_fail (combo != NULL);
661   g_return_if_fail (GTK_IS_COMBO (combo));
662
663   if ( combo->activate_id ) {
664     gtk_signal_disconnect(GTK_OBJECT(combo), combo->activate_id);
665     combo->activate_id = 0;
666   }
667 }