comparison pidgin/pidgincombobox.c @ 25415:584063555949

Remove trailing whitespace
author Mark Doliner <mark@kingant.net>
date Mon, 26 Jan 2009 06:44:00 +0000
parents a368ee78a798
children
comparison
equal deleted inserted replaced
25414:7fc110f70662 25415:584063555949
110 }; 110 };
111 111
112 /* While debugging this evil code, I have learned that 112 /* While debugging this evil code, I have learned that
113 * there are actually 4 modes to this widget, which can 113 * there are actually 4 modes to this widget, which can
114 * be characterized as follows 114 * be characterized as follows
115 * 115 *
116 * 1) menu mode, no child added 116 * 1) menu mode, no child added
117 * 117 *
118 * tree_view -> NULL 118 * tree_view -> NULL
119 * cell_view -> GtkCellView, regular child 119 * cell_view -> GtkCellView, regular child
120 * cell_view_frame -> NULL 120 * cell_view_frame -> NULL
125 * popup_widget -> GtkMenu 125 * popup_widget -> GtkMenu
126 * popup_window -> NULL 126 * popup_window -> NULL
127 * popup_frame -> NULL 127 * popup_frame -> NULL
128 * 128 *
129 * 2) menu mode, child added 129 * 2) menu mode, child added
130 * 130 *
131 * tree_view -> NULL 131 * tree_view -> NULL
132 * cell_view -> NULL 132 * cell_view -> NULL
133 * cell_view_frame -> NULL 133 * cell_view_frame -> NULL
134 * button -> GtkToggleButton set_parent to combo 134 * button -> GtkToggleButton set_parent to combo
135 * box -> NULL 135 * box -> NULL
136 * arrow -> GtkArrow, child of button 136 * arrow -> GtkArrow, child of button
137 * separator -> NULL 137 * separator -> NULL
138 * popup_widget -> GtkMenu 138 * popup_widget -> GtkMenu
139 * popup_window -> NULL 139 * popup_window -> NULL
140 * popup_frame -> NULL 140 * popup_frame -> NULL
141 * 141 *
142 * 3) list mode, no child added 142 * 3) list mode, no child added
143 * 143 *
144 * tree_view -> GtkTreeView, child of popup_frame 144 * tree_view -> GtkTreeView, child of popup_frame
145 * cell_view -> GtkCellView, regular child 145 * cell_view -> GtkCellView, regular child
146 * cell_view_frame -> GtkFrame, set parent to combo 146 * cell_view_frame -> GtkFrame, set parent to combo
147 * button -> GtkToggleButton, set_parent to combo 147 * button -> GtkToggleButton, set_parent to combo
148 * box -> NULL 148 * box -> NULL
162 * arrow -> GtkArrow, child of button 162 * arrow -> GtkArrow, child of button
163 * separator -> NULL 163 * separator -> NULL
164 * popup_widget -> tree_view 164 * popup_widget -> tree_view
165 * popup_window -> GtkWindow 165 * popup_window -> GtkWindow
166 * popup_frame -> GtkFrame, child of popup_window 166 * popup_frame -> GtkFrame, child of popup_window
167 * 167 *
168 */ 168 */
169 169
170 enum { 170 enum {
171 CHANGED, 171 CHANGED,
172 LAST_SIGNAL 172 LAST_SIGNAL
283 GtkTreePath *path, 283 GtkTreePath *path,
284 GtkTreeIter *iter, 284 GtkTreeIter *iter,
285 gpointer data); 285 gpointer data);
286 286
287 /* list */ 287 /* list */
288 static void gtk_combo_box_list_position (GtkComboBox *combo_box, 288 static void gtk_combo_box_list_position (GtkComboBox *combo_box,
289 gint *x, 289 gint *x,
290 gint *y, 290 gint *y,
291 gint *width, 291 gint *width,
292 gint *height); 292 gint *height);
293 293
294 static void gtk_combo_box_list_setup (GtkComboBox *combo_box); 294 static void gtk_combo_box_list_setup (GtkComboBox *combo_box);
295 static void gtk_combo_box_list_destroy (GtkComboBox *combo_box); 295 static void gtk_combo_box_list_destroy (GtkComboBox *combo_box);
639 GtkComboBox *combo_box = GTK_COMBO_BOX (widget); 639 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
640 640
641 if (GTK_WIDGET_REALIZED (widget)) 641 if (GTK_WIDGET_REALIZED (widget))
642 { 642 {
643 if (combo_box->priv->tree_view && combo_box->priv->cell_view) 643 if (combo_box->priv->tree_view && combo_box->priv->cell_view)
644 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), 644 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
645 &widget->style->base[GTK_WIDGET_STATE (widget)]); 645 &widget->style->base[GTK_WIDGET_STATE (widget)]);
646 } 646 }
647 647
648 gtk_widget_queue_draw (widget); 648 gtk_widget_queue_draw (widget);
649 } 649 }
692 GtkComboBox *combo_box = GTK_COMBO_BOX (widget); 692 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
693 693
694 gtk_combo_box_check_appearance (combo_box); 694 gtk_combo_box_check_appearance (combo_box);
695 695
696 if (combo_box->priv->tree_view && combo_box->priv->cell_view) 696 if (combo_box->priv->tree_view && combo_box->priv->cell_view)
697 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), 697 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
698 &widget->style->base[GTK_WIDGET_STATE (widget)]); 698 &widget->style->base[GTK_WIDGET_STATE (widget)]);
699 } 699 }
700 700
701 static void 701 static void
702 gtk_combo_box_button_toggled (GtkWidget *widget, 702 gtk_combo_box_button_toggled (GtkWidget *widget,
723 { 723 {
724 gtk_widget_unparent (combo_box->priv->cell_view); 724 gtk_widget_unparent (combo_box->priv->cell_view);
725 GTK_BIN (container)->child = NULL; 725 GTK_BIN (container)->child = NULL;
726 gtk_widget_queue_resize (GTK_WIDGET (container)); 726 gtk_widget_queue_resize (GTK_WIDGET (container));
727 } 727 }
728 728
729 gtk_widget_set_parent (widget, GTK_WIDGET (container)); 729 gtk_widget_set_parent (widget, GTK_WIDGET (container));
730 GTK_BIN (container)->child = widget; 730 GTK_BIN (container)->child = widget;
731 731
732 if (combo_box->priv->cell_view && 732 if (combo_box->priv->cell_view &&
733 widget != combo_box->priv->cell_view) 733 widget != combo_box->priv->cell_view)
768 768
769 if (!combo_box->priv->tree_view) 769 if (!combo_box->priv->tree_view)
770 appears_as_list = FALSE; 770 appears_as_list = FALSE;
771 else 771 else
772 appears_as_list = TRUE; 772 appears_as_list = TRUE;
773 773
774 if (appears_as_list) 774 if (appears_as_list)
775 gtk_combo_box_list_destroy (combo_box); 775 gtk_combo_box_list_destroy (combo_box);
776 else if (GTK_IS_MENU (combo_box->priv->popup_widget)) 776 else if (GTK_IS_MENU (combo_box->priv->popup_widget))
777 { 777 {
778 gtk_combo_box_menu_destroy (combo_box); 778 gtk_combo_box_menu_destroy (combo_box);
783 if (!combo_box->priv->cell_view) 783 if (!combo_box->priv->cell_view)
784 { 784 {
785 combo_box->priv->cell_view = gtk_cell_view_new (); 785 combo_box->priv->cell_view = gtk_cell_view_new ();
786 gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container)); 786 gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container));
787 GTK_BIN (container)->child = combo_box->priv->cell_view; 787 GTK_BIN (container)->child = combo_box->priv->cell_view;
788 788
789 gtk_widget_show (combo_box->priv->cell_view); 789 gtk_widget_show (combo_box->priv->cell_view);
790 gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view), 790 gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view),
791 combo_box->priv->model); 791 combo_box->priv->model);
792 cell_view_sync_cells (combo_box, GTK_CELL_VIEW (combo_box->priv->cell_view)); 792 cell_view_sync_cells (combo_box, GTK_CELL_VIEW (combo_box->priv->cell_view));
793 } 793 }
854 gtk_combo_box_menu_show, 854 gtk_combo_box_menu_show,
855 combo_box); 855 combo_box);
856 g_signal_handlers_disconnect_by_func (menu, 856 g_signal_handlers_disconnect_by_func (menu,
857 gtk_combo_box_menu_hide, 857 gtk_combo_box_menu_hide,
858 combo_box); 858 combo_box);
859 859
860 combo_box->priv->popup_widget = NULL; 860 combo_box->priv->popup_widget = NULL;
861 } 861 }
862 862
863 static void 863 static void
864 gtk_combo_box_set_popup_widget (GtkComboBox *combo_box, 864 gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
938 GtkWidget *child; 938 GtkWidget *child;
939 GtkRequisition req; 939 GtkRequisition req;
940 GdkScreen *screen; 940 GdkScreen *screen;
941 gint monitor_num; 941 gint monitor_num;
942 GdkRectangle monitor; 942 GdkRectangle monitor;
943 943
944 /* FIXME: is using the size request here broken? */ 944 /* FIXME: is using the size request here broken? */
945 child = GTK_BIN (combo_box)->child; 945 child = GTK_BIN (combo_box)->child;
946 946
947 gdk_window_get_origin (child->window, &sx, &sy); 947 gdk_window_get_origin (child->window, &sx, &sy);
948 948
949 if (GTK_WIDGET_NO_WINDOW (child)) 949 if (GTK_WIDGET_NO_WINDOW (child))
950 { 950 {
951 sx += child->allocation.x; 951 sx += child->allocation.x;
952 sy += child->allocation.y; 952 sy += child->allocation.y;
953 } 953 }
959 else 959 else
960 *x = sx + child->allocation.width - req.width; 960 *x = sx + child->allocation.width - req.width;
961 *y = sy; 961 *y = sy;
962 962
963 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); 963 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
964 monitor_num = gdk_screen_get_monitor_at_window (screen, 964 monitor_num = gdk_screen_get_monitor_at_window (screen,
965 GTK_WIDGET (combo_box)->window); 965 GTK_WIDGET (combo_box)->window);
966 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); 966 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
967 967
968 if (*x < monitor.x) 968 if (*x < monitor.x)
969 *x = monitor.x; 969 *x = monitor.x;
970 else if (*x + req.width > monitor.x + monitor.width) 970 else if (*x + req.width > monitor.x + monitor.width)
971 *x = monitor.x + monitor.width - req.width; 971 *x = monitor.x + monitor.width - req.width;
972 972
973 if (monitor.y + monitor.height - *y - child->allocation.height >= req.height) 973 if (monitor.y + monitor.height - *y - child->allocation.height >= req.height)
974 *y += child->allocation.height; 974 *y += child->allocation.height;
975 else if (*y - monitor.y >= req.height) 975 else if (*y - monitor.y >= req.height)
976 *y -= req.height; 976 *y -= req.height;
977 else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y) 977 else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y)
978 *y += child->allocation.height; 978 *y += child->allocation.height;
979 else 979 else
980 *y -= req.height; 980 *y -= req.height;
981 981
982 *push_in = FALSE; 982 *push_in = FALSE;
999 gint menu_xpos; 999 gint menu_xpos;
1000 gint menu_ypos; 1000 gint menu_ypos;
1001 gint menu_width; 1001 gint menu_width;
1002 1002
1003 g_return_if_fail (GTK_IS_COMBO_BOX (user_data)); 1003 g_return_if_fail (GTK_IS_COMBO_BOX (user_data));
1004 1004
1005 combo_box = GTK_COMBO_BOX (user_data); 1005 combo_box = GTK_COMBO_BOX (user_data);
1006 widget = GTK_WIDGET (combo_box); 1006 widget = GTK_WIDGET (combo_box);
1007 1007
1008 gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition); 1008 gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
1009 menu_width = requisition.width; 1009 menu_width = requisition.width;
1040 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) 1040 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
1041 menu_xpos = menu_xpos + widget->allocation.width - menu_width; 1041 menu_xpos = menu_xpos + widget->allocation.width - menu_width;
1042 1042
1043 /* Clamp the position on screen */ 1043 /* Clamp the position on screen */
1044 screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget)); 1044 screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
1045 1045
1046 if (menu_xpos < 0) 1046 if (menu_xpos < 0)
1047 menu_xpos = 0; 1047 menu_xpos = 0;
1048 else if ((menu_xpos + menu_width) > screen_width) 1048 else if ((menu_xpos + menu_width) > screen_width)
1049 menu_xpos -= ((menu_xpos + menu_width) - screen_width); 1049 menu_xpos -= ((menu_xpos + menu_width) - screen_width);
1050 1050
1064 GtkComboBox *combo_box; 1064 GtkComboBox *combo_box;
1065 GtkWidget *menu_item; 1065 GtkWidget *menu_item;
1066 1066
1067 combo_box = GTK_COMBO_BOX (user_data); 1067 combo_box = GTK_COMBO_BOX (user_data);
1068 1068
1069 if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL) 1069 if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL)
1070 gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data); 1070 gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
1071 else 1071 else
1072 { 1072 {
1073 menu_item = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget)); 1073 menu_item = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
1074 if (menu_item) 1074 if (menu_item)
1075 gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget), 1075 gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget),
1076 menu_item); 1076 menu_item);
1077 1077
1078 gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data); 1078 gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
1079 } 1079 }
1080 1080
1081 } 1081 }
1082 #endif /* Gtk 2.2 */ 1082 #endif /* Gtk 2.2 */
1083 1083
1084 static void 1084 static void
1085 gtk_combo_box_list_position (GtkComboBox *combo_box, 1085 gtk_combo_box_list_position (GtkComboBox *combo_box,
1086 gint *x, 1086 gint *x,
1087 gint *y, 1087 gint *y,
1088 gint *width, 1088 gint *width,
1089 gint *height) 1089 gint *height)
1090 { 1090 {
1091 GtkWidget *sample; 1091 GtkWidget *sample;
1092 GtkRequisition popup_req; 1092 GtkRequisition popup_req;
1093 #if GTK_CHECK_VERSION(2,2,0) 1093 #if GTK_CHECK_VERSION(2,2,0)
1094 GdkScreen *screen; 1094 GdkScreen *screen;
1095 gint monitor_num; 1095 gint monitor_num;
1096 GdkRectangle monitor; 1096 GdkRectangle monitor;
1097 #endif 1097 #endif
1098 1098
1099 sample = GTK_BIN (combo_box)->child; 1099 sample = GTK_BIN (combo_box)->child;
1100 1100
1101 *width = sample->allocation.width; 1101 *width = sample->allocation.width;
1102 gtk_widget_size_request (combo_box->priv->popup_window, &popup_req); 1102 gtk_widget_size_request (combo_box->priv->popup_window, &popup_req);
1103 *height = popup_req.height; 1103 *height = popup_req.height;
1115 if (GTK_WIDGET_NO_WINDOW (sample)) 1115 if (GTK_WIDGET_NO_WINDOW (sample))
1116 { 1116 {
1117 *x += sample->allocation.x; 1117 *x += sample->allocation.x;
1118 *y += sample->allocation.y; 1118 *y += sample->allocation.y;
1119 } 1119 }
1120 1120
1121 #if GTK_CHECK_VERSION(2,2,0) 1121 #if GTK_CHECK_VERSION(2,2,0)
1122 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); 1122 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
1123 monitor_num = gdk_screen_get_monitor_at_window (screen, 1123 monitor_num = gdk_screen_get_monitor_at_window (screen,
1124 GTK_WIDGET (combo_box)->window); 1124 GTK_WIDGET (combo_box)->window);
1125 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); 1125 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
1126 1126
1127 if (*x < monitor.x) 1127 if (*x < monitor.x)
1128 *x = monitor.x; 1128 *x = monitor.x;
1129 else if (*x + *width > monitor.x + monitor.width) 1129 else if (*x + *width > monitor.x + monitor.width)
1130 *x = monitor.x + monitor.width - *width; 1130 *x = monitor.x + monitor.width - *width;
1131 1131
1132 if (*y + sample->allocation.height + *height <= monitor.y + monitor.height) 1132 if (*y + sample->allocation.height + *height <= monitor.y + monitor.height)
1133 *y += sample->allocation.height; 1133 *y += sample->allocation.height;
1134 else 1134 else
1135 *y -= *height; 1135 *y -= *height;
1136 #endif /* Gtk 2.2 */ 1136 #endif /* Gtk 2.2 */
1137 } 1137 }
1138 1138
1139 /** 1139 /**
1140 * gtk_combo_box_popup: 1140 * gtk_combo_box_popup:
1141 * @combo_box: a #GtkComboBox 1141 * @combo_box: a #GtkComboBox
1142 * 1142 *
1143 * Pops up the menu or dropdown list of @combo_box. 1143 * Pops up the menu or dropdown list of @combo_box.
1144 * 1144 *
1145 * This function is mostly intended for use by accessibility technologies; 1145 * This function is mostly intended for use by accessibility technologies;
1146 * applications should have little use for it. 1146 * applications should have little use for it.
1147 * 1147 *
1148 * Since: 2.4 1148 * Since: 2.4
1149 **/ 1149 **/
1150 void 1150 void
1151 gtk_combo_box_popup (GtkComboBox *combo_box) 1151 gtk_combo_box_popup (GtkComboBox *combo_box)
1152 { 1152 {
1153 gint x, y, width, height; 1153 gint x, y, width, height;
1154 1154
1155 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); 1155 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
1156 1156
1157 if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget)) 1157 if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget))
1158 return; 1158 return;
1159 1159
1170 gtk_widget_size_request (combo_box->priv->popup_widget, &requisition); 1170 gtk_widget_size_request (combo_box->priv->popup_widget, &requisition);
1171 1171
1172 gtk_widget_set_size_request (combo_box->priv->popup_widget, 1172 gtk_widget_set_size_request (combo_box->priv->popup_widget,
1173 MAX (width, requisition.width), -1); 1173 MAX (width, requisition.width), -1);
1174 } 1174 }
1175 1175
1176 gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget), 1176 gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget),
1177 NULL, NULL, 1177 NULL, NULL,
1178 #if GTK_CHECK_VERSION(2,2,0) 1178 #if GTK_CHECK_VERSION(2,2,0)
1179 gtk_combo_box_menu_position, 1179 gtk_combo_box_menu_position,
1180 #else 1180 #else
1185 } 1185 }
1186 1186
1187 gtk_widget_show_all (combo_box->priv->popup_frame); 1187 gtk_widget_show_all (combo_box->priv->popup_frame);
1188 gtk_combo_box_list_position (combo_box, &x, &y, &width, &height); 1188 gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
1189 1189
1190 gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1); 1190 gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1);
1191 gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y); 1191 gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y);
1192 1192
1193 /* popup */ 1193 /* popup */
1194 gtk_widget_show (combo_box->priv->popup_window); 1194 gtk_widget_show (combo_box->priv->popup_window);
1195 1195
1215 } 1215 }
1216 1216
1217 /** 1217 /**
1218 * gtk_combo_box_popdown: 1218 * gtk_combo_box_popdown:
1219 * @combo_box: a #GtkComboBox 1219 * @combo_box: a #GtkComboBox
1220 * 1220 *
1221 * Hides the menu or dropdown list of @combo_box. 1221 * Hides the menu or dropdown list of @combo_box.
1222 * 1222 *
1223 * This function is mostly intended for use by accessibility technologies; 1223 * This function is mostly intended for use by accessibility technologies;
1224 * applications should have little use for it. 1224 * applications should have little use for it.
1225 * 1225 *
1303 do 1303 do
1304 { 1304 {
1305 GtkRequisition req; 1305 GtkRequisition req;
1306 1306
1307 if (combo_box->priv->cell_view) 1307 if (combo_box->priv->cell_view)
1308 gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view), 1308 gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view),
1309 path, &req); 1309 path, &req);
1310 else 1310 else
1311 req.width = 0; 1311 req.width = 0;
1312 1312
1313 combo_box->priv->width = MAX (combo_box->priv->width, 1313 combo_box->priv->width = MAX (combo_box->priv->width,
1333 gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req); 1333 gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req);
1334 gtk_combo_box_remeasure (combo_box); 1334 gtk_combo_box_remeasure (combo_box);
1335 bin_req.width = MAX (bin_req.width, combo_box->priv->width); 1335 bin_req.width = MAX (bin_req.width, combo_box->priv->width);
1336 1336
1337 gtk_combo_box_check_appearance (combo_box); 1337 gtk_combo_box_check_appearance (combo_box);
1338 1338
1339 if (!combo_box->priv->tree_view) 1339 if (!combo_box->priv->tree_view)
1340 { 1340 {
1341 /* menu mode */ 1341 /* menu mode */
1342 1342
1343 if (combo_box->priv->cell_view) 1343 if (combo_box->priv->cell_view)
1452 gtk_widget_size_allocate (combo_box->priv->separator, &child); 1452 gtk_widget_size_allocate (combo_box->priv->separator, &child);
1453 1453
1454 if (is_rtl) 1454 if (is_rtl)
1455 { 1455 {
1456 child.x += req.width; 1456 child.x += req.width;
1457 child.width = MAX(1, allocation->x + allocation->width 1457 child.width = MAX(1, allocation->x + allocation->width
1458 - (border_width + 1 + xthickness + 2) - child.x); 1458 - (border_width + 1 + xthickness + 2) - child.x);
1459 } 1459 }
1460 else 1460 else
1461 { 1461 {
1462 child.width = child.x; 1462 child.width = child.x;
1463 child.x = allocation->x + border_width + 1 + xthickness + 2; 1463 child.x = allocation->x + border_width + 1 + xthickness + 2;
1464 child.width = MAX(1, child.width - child.x); 1464 child.width = MAX(1, child.width - child.x);
1465 } 1465 }
1621 GdkEventScroll *event) 1621 GdkEventScroll *event)
1622 { 1622 {
1623 GtkComboBox *combo_box = GTK_COMBO_BOX (widget); 1623 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
1624 gint index; 1624 gint index;
1625 gint items; 1625 gint items;
1626 1626
1627 index = gtk_combo_box_get_active (combo_box); 1627 index = gtk_combo_box_get_active (combo_box);
1628 1628
1629 if (index != -1) 1629 if (index != -1)
1630 { 1630 {
1631 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); 1631 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
1632 1632
1633 if (event->direction == GDK_SCROLL_UP) 1633 if (event->direction == GDK_SCROLL_UP)
1634 index--; 1634 index--;
1635 else 1635 else
1636 index++; 1636 index++;
1637 1637
1638 gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1)); 1638 gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1));
1639 } 1639 }
1640 1640
1692 G_CALLBACK (gtk_combo_box_key_press), combo_box); 1692 G_CALLBACK (gtk_combo_box_key_press), combo_box);
1693 gtk_widget_set_parent (combo_box->priv->button, 1693 gtk_widget_set_parent (combo_box->priv->button,
1694 GTK_BIN (combo_box)->child->parent); 1694 GTK_BIN (combo_box)->child->parent);
1695 1695
1696 combo_box->priv->box = gtk_hbox_new (FALSE, 0); 1696 combo_box->priv->box = gtk_hbox_new (FALSE, 0);
1697 gtk_container_add (GTK_CONTAINER (combo_box->priv->button), 1697 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
1698 combo_box->priv->box); 1698 combo_box->priv->box);
1699 1699
1700 combo_box->priv->separator = gtk_vseparator_new (); 1700 combo_box->priv->separator = gtk_vseparator_new ();
1701 gtk_container_add (GTK_CONTAINER (combo_box->priv->box), 1701 gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
1702 combo_box->priv->separator); 1702 combo_box->priv->separator);
1703 1703
1704 combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); 1704 combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
1705 gtk_container_add (GTK_CONTAINER (combo_box->priv->box), 1705 gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
1706 combo_box->priv->arrow); 1706 combo_box->priv->arrow);
1707 1707
1708 gtk_widget_show_all (combo_box->priv->button); 1708 gtk_widget_show_all (combo_box->priv->button);
1709 } 1709 }
1710 else 1710 else
1790 0, 0, NULL, 1790 0, 0, NULL,
1791 gtk_combo_box_menu_button_press, NULL); 1791 gtk_combo_box_menu_button_press, NULL);
1792 1792
1793 /* unparent will remove our latest ref */ 1793 /* unparent will remove our latest ref */
1794 gtk_widget_unparent (combo_box->priv->button); 1794 gtk_widget_unparent (combo_box->priv->button);
1795 1795
1796 combo_box->priv->box = NULL; 1796 combo_box->priv->box = NULL;
1797 combo_box->priv->button = NULL; 1797 combo_box->priv->button = NULL;
1798 combo_box->priv->arrow = NULL; 1798 combo_box->priv->arrow = NULL;
1799 combo_box->priv->separator = NULL; 1799 combo_box->priv->separator = NULL;
1800 1800
1893 list = gtk_container_get_children (GTK_CONTAINER (menu)); 1893 list = gtk_container_get_children (GTK_CONTAINER (menu));
1894 nth = g_list_nth (list, index); 1894 nth = g_list_nth (list, index);
1895 item = nth->data; 1895 item = nth->data;
1896 if (nth->prev) 1896 if (nth->prev)
1897 last = nth->prev->data; 1897 last = nth->prev->data;
1898 else 1898 else
1899 last = NULL; 1899 last = NULL;
1900 g_list_free (list); 1900 g_list_free (list);
1901 1901
1902 gtk_combo_box_item_get_size (combo_box, index, &cols, &rows); 1902 gtk_combo_box_item_get_size (combo_box, index, &cols, &rows);
1903 1903
1904 if (combo_box->priv->col_column == -1 && 1904 if (combo_box->priv->col_column == -1 &&
1905 combo_box->priv->row_column == -1 && 1905 combo_box->priv->row_column == -1 &&
1906 last) 1906 last)
1907 { 1907 {
1908 gtk_container_child_get (GTK_CONTAINER (menu), 1908 gtk_container_child_get (GTK_CONTAINER (menu),
1909 last, 1909 last,
1910 "right_attach", &current_col, 1910 "right_attach", &current_col,
1911 "top_attach", &current_row, 1911 "top_attach", &current_row,
1912 NULL); 1912 NULL);
1913 if (current_col + cols > combo_box->priv->wrap_width) 1913 if (current_col + cols > combo_box->priv->wrap_width)
1924 if (current_col + cols > combo_box->priv->wrap_width) 1924 if (current_col + cols > combo_box->priv->wrap_width)
1925 { 1925 {
1926 current_col = 0; 1926 current_col = 0;
1927 current_row++; 1927 current_row++;
1928 } 1928 }
1929 1929
1930 if (!menu_occupied (GTK_MENU (menu), 1930 if (!menu_occupied (GTK_MENU (menu),
1931 current_col, current_col + cols, 1931 current_col, current_col + cols,
1932 current_row, current_row + rows)) 1932 current_row, current_row + rows))
1933 break; 1933 break;
1934 1934
1935 current_col++; 1935 current_col++;
1936 } 1936 }
1937 } 1937 }
1938 1938
1939 /* set attach props */ 1939 /* set attach props */
1947 { 1947 {
1948 GList *list, *j; 1948 GList *list, *j;
1949 GtkWidget *menu; 1949 GtkWidget *menu;
1950 1950
1951 menu = combo_box->priv->popup_widget; 1951 menu = combo_box->priv->popup_widget;
1952 1952
1953 /* do nothing unless we are in menu style and realized */ 1953 /* do nothing unless we are in menu style and realized */
1954 if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu)) 1954 if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu))
1955 return; 1955 return;
1956 1956
1957 /* get rid of all children */ 1957 /* get rid of all children */
1958 list = gtk_container_get_children (GTK_CONTAINER (menu)); 1958 list = gtk_container_get_children (GTK_CONTAINER (menu));
1959 1959
1960 for (j = g_list_last (list); j; j = j->prev) 1960 for (j = g_list_last (list); j; j = j->prev)
1961 gtk_container_remove (GTK_CONTAINER (menu), j->data); 1961 gtk_container_remove (GTK_CONTAINER (menu), j->data);
1962 1962
1963 g_list_free (list); 1963 g_list_free (list);
1964 1964
1965 /* and relayout */ 1965 /* and relayout */
1966 gtk_combo_box_menu_fill (combo_box); 1966 gtk_combo_box_menu_fill (combo_box);
1967 } 1967 }
1968 1968
1969 /* callbacks */ 1969 /* callbacks */
1978 return FALSE; 1978 return FALSE;
1979 1979
1980 if (event->type == GDK_BUTTON_PRESS && event->button == 1) 1980 if (event->type == GDK_BUTTON_PRESS && event->button == 1)
1981 { 1981 {
1982 combo_box->priv->popup_in_progress = TRUE; 1982 combo_box->priv->popup_in_progress = TRUE;
1983 1983
1984 gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget), 1984 gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget),
1985 combo_box->priv->active_item); 1985 combo_box->priv->active_item);
1986 1986
1987 if (combo_box->priv->wrap_width == 0) 1987 if (combo_box->priv->wrap_width == 0)
1988 { 1988 {
2051 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); 2051 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
2052 gint index = gtk_tree_path_get_indices (path)[0]; 2052 gint index = gtk_tree_path_get_indices (path)[0];
2053 2053
2054 if (!combo_box->priv->tree_view) 2054 if (!combo_box->priv->tree_view)
2055 gtk_combo_box_menu_row_deleted (model, path, user_data); 2055 gtk_combo_box_menu_row_deleted (model, path, user_data);
2056 2056
2057 if (index == combo_box->priv->active_item) 2057 if (index == combo_box->priv->active_item)
2058 { 2058 {
2059 gint items = gtk_tree_model_iter_n_children (model, NULL); 2059 gint items = gtk_tree_model_iter_n_children (model, NULL);
2060 2060
2061 if (items == 0) 2061 if (items == 0)
2088 } 2088 }
2089 2089
2090 if (!combo_box->priv->tree_view) 2090 if (!combo_box->priv->tree_view)
2091 gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data); 2091 gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data);
2092 } 2092 }
2093 2093
2094 static void 2094 static void
2095 gtk_combo_box_model_row_changed (GtkTreeModel *model, 2095 gtk_combo_box_model_row_changed (GtkTreeModel *model,
2096 GtkTreePath *path, 2096 GtkTreePath *path,
2097 GtkTreeIter *iter, 2097 GtkTreeIter *iter,
2098 gpointer user_data) 2098 gpointer user_data)
2101 gint index = gtk_tree_path_get_indices (path)[0]; 2101 gint index = gtk_tree_path_get_indices (path)[0];
2102 2102
2103 if (index == combo_box->priv->active_item && 2103 if (index == combo_box->priv->active_item &&
2104 combo_box->priv->cell_view) 2104 combo_box->priv->cell_view)
2105 gtk_widget_queue_resize (GTK_WIDGET (combo_box->priv->cell_view)); 2105 gtk_widget_queue_resize (GTK_WIDGET (combo_box->priv->cell_view));
2106 2106
2107 if (combo_box->priv->tree_view) 2107 if (combo_box->priv->tree_view)
2108 gtk_combo_box_list_row_changed (model, path, iter, user_data); 2108 gtk_combo_box_list_row_changed (model, path, iter, user_data);
2109 else 2109 else
2110 gtk_combo_box_menu_row_changed (model, path, iter, user_data); 2110 gtk_combo_box_menu_row_changed (model, path, iter, user_data);
2111 } 2111 }
2172 { 2172 {
2173 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); 2173 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
2174 2174
2175 gtk_combo_box_relayout (combo_box); 2175 gtk_combo_box_relayout (combo_box);
2176 } 2176 }
2177 2177
2178 static void 2178 static void
2179 gtk_combo_box_menu_row_changed (GtkTreeModel *model, 2179 gtk_combo_box_menu_row_changed (GtkTreeModel *model,
2180 GtkTreePath *path, 2180 GtkTreePath *path,
2181 GtkTreeIter *iter, 2181 GtkTreeIter *iter,
2182 gpointer user_data) 2182 gpointer user_data)
2236 gtk_widget_set_parent (combo_box->priv->cell_view_frame, 2236 gtk_widget_set_parent (combo_box->priv->cell_view_frame,
2237 GTK_BIN (combo_box)->child->parent); 2237 GTK_BIN (combo_box)->child->parent);
2238 gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->cell_view_frame), 2238 gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->cell_view_frame),
2239 GTK_SHADOW_IN); 2239 GTK_SHADOW_IN);
2240 2240
2241 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), 2241 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
2242 &GTK_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]); 2242 &GTK_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]);
2243 2243
2244 combo_box->priv->box = gtk_event_box_new (); 2244 combo_box->priv->box = gtk_event_box_new ();
2245 /* 2245 /*
2246 gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->box), 2246 gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->box),
2247 FALSE); 2247 FALSE);
2248 */ 2248 */
2249 2249
2250 gtk_container_add (GTK_CONTAINER (combo_box->priv->cell_view_frame), 2250 gtk_container_add (GTK_CONTAINER (combo_box->priv->cell_view_frame),
2251 combo_box->priv->box); 2251 combo_box->priv->box);
2252 2252
2253 gtk_widget_show_all (combo_box->priv->cell_view_frame); 2253 gtk_widget_show_all (combo_box->priv->cell_view_frame);
2254 2254
2255 g_signal_connect (combo_box->priv->box, "button_press_event", 2255 g_signal_connect (combo_box->priv->box, "button_press_event",
2256 G_CALLBACK (gtk_combo_box_list_button_pressed), 2256 G_CALLBACK (gtk_combo_box_list_button_pressed),
2257 combo_box); 2257 combo_box);
2258 } 2258 }
2259 2259
2260 combo_box->priv->tree_view = gtk_tree_view_new (); 2260 combo_box->priv->tree_view = gtk_tree_view_new ();
2261 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)); 2261 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view));
2267 TRUE); 2267 TRUE);
2268 */ 2268 */
2269 if (combo_box->priv->model) 2269 if (combo_box->priv->model)
2270 gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), 2270 gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view),
2271 combo_box->priv->model); 2271 combo_box->priv->model);
2272 2272
2273 g_signal_connect (combo_box->priv->tree_view, "button_press_event", 2273 g_signal_connect (combo_box->priv->tree_view, "button_press_event",
2274 G_CALLBACK (gtk_combo_box_list_button_pressed), 2274 G_CALLBACK (gtk_combo_box_list_button_pressed),
2275 combo_box); 2275 combo_box);
2276 g_signal_connect (combo_box->priv->tree_view, "button_release_event", 2276 g_signal_connect (combo_box->priv->tree_view, "button_release_event",
2277 G_CALLBACK (gtk_combo_box_list_button_released), 2277 G_CALLBACK (gtk_combo_box_list_button_released),
2492 gint new_index; 2492 gint new_index;
2493 2493
2494 if (combo_box->priv->model) 2494 if (combo_box->priv->model)
2495 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); 2495 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
2496 2496
2497 if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) && 2497 if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) &&
2498 state == GDK_MOD1_MASK) 2498 state == GDK_MOD1_MASK)
2499 { 2499 {
2500 gtk_combo_box_popup (combo_box); 2500 gtk_combo_box_popup (combo_box);
2501 2501
2502 return TRUE; 2502 return TRUE;
2503 } 2503 }
2504 2504
2505 switch (event->keyval) 2505 switch (event->keyval)
2506 { 2506 {
2507 case GDK_Down: 2507 case GDK_Down:
2508 case GDK_KP_Down: 2508 case GDK_KP_Down:
2509 new_index = index + 1; 2509 new_index = index + 1;
2510 break; 2510 break;
2512 case GDK_KP_Up: 2512 case GDK_KP_Up:
2513 new_index = index - 1; 2513 new_index = index - 1;
2514 break; 2514 break;
2515 case GDK_Page_Up: 2515 case GDK_Page_Up:
2516 case GDK_KP_Page_Up: 2516 case GDK_KP_Page_Up:
2517 case GDK_Home: 2517 case GDK_Home:
2518 case GDK_KP_Home: 2518 case GDK_KP_Home:
2519 new_index = 0; 2519 new_index = 0;
2520 break; 2520 break;
2521 case GDK_Page_Down: 2521 case GDK_Page_Down:
2522 case GDK_KP_Page_Down: 2522 case GDK_KP_Page_Down:
2523 case GDK_End: 2523 case GDK_End:
2524 case GDK_KP_End: 2524 case GDK_KP_End:
2525 new_index = items - 1; 2525 new_index = items - 1;
2526 break; 2526 break;
2527 default: 2527 default:
2528 return FALSE; 2528 return FALSE;
2529 } 2529 }
2530 2530
2531 if (items > 0) 2531 if (items > 0)
2532 gtk_combo_box_set_active (combo_box, CLAMP (new_index, 0, items - 1)); 2532 gtk_combo_box_set_active (combo_box, CLAMP (new_index, 0, items - 1));
2533 2533
2534 return TRUE; 2534 return TRUE;
2535 } 2535 }
2540 gpointer data) 2540 gpointer data)
2541 { 2541 {
2542 GtkComboBox *combo_box = GTK_COMBO_BOX (data); 2542 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
2543 guint state = event->state & gtk_accelerator_get_default_mod_mask (); 2543 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
2544 2544
2545 if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && 2545 if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
2546 state == GDK_MOD1_MASK) 2546 state == GDK_MOD1_MASK)
2547 { 2547 {
2548 gtk_combo_box_popdown (combo_box); 2548 gtk_combo_box_popdown (combo_box);
2549 2549
2550 return TRUE; 2550 return TRUE;
2551 } 2551 }
2552 2552
2553 return FALSE; 2553 return FALSE;
2554 } 2554 }
2555 2555
2556 static gboolean 2556 static gboolean
2557 gtk_combo_box_list_key_press (GtkWidget *widget, 2557 gtk_combo_box_list_key_press (GtkWidget *widget,
2560 { 2560 {
2561 GtkComboBox *combo_box = GTK_COMBO_BOX (data); 2561 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
2562 guint state = event->state & gtk_accelerator_get_default_mod_mask (); 2562 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
2563 2563
2564 if (event->keyval == GDK_Escape || 2564 if (event->keyval == GDK_Escape ||
2565 ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && 2565 ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
2566 state == GDK_MOD1_MASK)) 2566 state == GDK_MOD1_MASK))
2567 { 2567 {
2568 /* reset active item -- this is incredibly lame and ugly */ 2568 /* reset active item -- this is incredibly lame and ugly */
2569 gtk_combo_box_set_active (combo_box, 2569 gtk_combo_box_set_active (combo_box,
2570 gtk_combo_box_get_active (combo_box)); 2570 gtk_combo_box_get_active (combo_box));
2571 2571
2572 gtk_combo_box_popdown (combo_box); 2572 gtk_combo_box_popdown (combo_box);
2573 2573
2574 return TRUE; 2574 return TRUE;
2575 } 2575 }
2576 2576
2577 if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || 2577 if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter ||
2578 event->keyval == GDK_space || event->keyval == GDK_KP_Space) 2578 event->keyval == GDK_space || event->keyval == GDK_KP_Space)
2579 { 2579 {
2580 gboolean ret = FALSE; 2580 gboolean ret = FALSE;
2581 GtkTreeIter iter; 2581 GtkTreeIter iter;
2582 GtkTreeModel *model = NULL; 2582 GtkTreeModel *model = NULL;
2583 2583
2584 if (combo_box->priv->model) 2584 if (combo_box->priv->model)
2585 { 2585 {
2586 GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)); 2586 GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view));
2587 2587
2588 ret = gtk_tree_selection_get_selected (sel, &model, &iter); 2588 ret = gtk_tree_selection_get_selected (sel, &model, &iter);
2589 } 2589 }
2590 if (ret) 2590 if (ret)
2591 { 2591 {
2592 GtkTreePath *path; 2592 GtkTreePath *path;
2593 2593
2594 path = gtk_tree_model_get_path (model, &iter); 2594 path = gtk_tree_model_get_path (model, &iter);
2595 if (path) 2595 if (path)
2596 { 2596 {
2597 gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); 2597 gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]);
2598 gtk_tree_path_free (path); 2598 gtk_tree_path_free (path);
2599 } 2599 }
2600 } 2600 }
2601 2601
2602 gtk_combo_box_popdown (combo_box); 2602 gtk_combo_box_popdown (combo_box);
2603 2603
2604 return TRUE; 2604 return TRUE;
2605 } 2605 }
2606 2606
2607 return FALSE; 2607 return FALSE;
2608 } 2608 }
2618 2618
2619 width = gtk_combo_box_calc_requested_width (combo_box, path); 2619 width = gtk_combo_box_calc_requested_width (combo_box, path);
2620 2620
2621 if (width > combo_box->priv->width) 2621 if (width > combo_box->priv->width)
2622 { 2622 {
2623 if (combo_box->priv->cell_view) 2623 if (combo_box->priv->cell_view)
2624 { 2624 {
2625 gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1); 2625 gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1);
2626 gtk_widget_queue_resize (combo_box->priv->cell_view); 2626 gtk_widget_queue_resize (combo_box->priv->cell_view);
2627 } 2627 }
2628 combo_box->priv->width = width; 2628 combo_box->priv->width = width;
2740 gtk_combo_box_cell_layout_clear (GtkCellLayout *layout) 2740 gtk_combo_box_cell_layout_clear (GtkCellLayout *layout)
2741 { 2741 {
2742 GtkWidget *menu; 2742 GtkWidget *menu;
2743 GtkComboBox *combo_box; 2743 GtkComboBox *combo_box;
2744 GSList *i; 2744 GSList *i;
2745 2745
2746 g_return_if_fail (GTK_IS_COMBO_BOX (layout)); 2746 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
2747 2747
2748 combo_box = GTK_COMBO_BOX (layout); 2748 combo_box = GTK_COMBO_BOX (layout);
2749 2749
2750 if (combo_box->priv->cell_view) 2750 if (combo_box->priv->cell_view)
2751 gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box->priv->cell_view)); 2751 gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box->priv->cell_view));
2752 2752
2753 if (combo_box->priv->column) 2753 if (combo_box->priv->column)
2754 gtk_tree_view_column_clear (combo_box->priv->column); 2754 gtk_tree_view_column_clear (combo_box->priv->column);
3080 { 3080 {
3081 combo_box->priv->wrap_width = width; 3081 combo_box->priv->wrap_width = width;
3082 3082
3083 gtk_combo_box_check_appearance (combo_box); 3083 gtk_combo_box_check_appearance (combo_box);
3084 gtk_combo_box_relayout (combo_box); 3084 gtk_combo_box_relayout (combo_box);
3085 3085
3086 g_object_notify (G_OBJECT (combo_box), "wrap_width"); 3086 g_object_notify (G_OBJECT (combo_box), "wrap_width");
3087 } 3087 }
3088 } 3088 }
3089 3089
3090 /** 3090 /**
3110 g_return_if_fail (row_span >= 0 && row_span < col); 3110 g_return_if_fail (row_span >= 0 && row_span < col);
3111 3111
3112 if (row_span != combo_box->priv->row_column) 3112 if (row_span != combo_box->priv->row_column)
3113 { 3113 {
3114 combo_box->priv->row_column = row_span; 3114 combo_box->priv->row_column = row_span;
3115 3115
3116 gtk_combo_box_relayout (combo_box); 3116 gtk_combo_box_relayout (combo_box);
3117 3117
3118 g_object_notify (G_OBJECT (combo_box), "row_span_column"); 3118 g_object_notify (G_OBJECT (combo_box), "row_span_column");
3119 } 3119 }
3120 } 3120 }
3121 3121
3122 /** 3122 /**
3142 g_return_if_fail (column_span >= 0 && column_span < col); 3142 g_return_if_fail (column_span >= 0 && column_span < col);
3143 3143
3144 if (column_span != combo_box->priv->col_column) 3144 if (column_span != combo_box->priv->col_column)
3145 { 3145 {
3146 combo_box->priv->col_column = column_span; 3146 combo_box->priv->col_column = column_span;
3147 3147
3148 gtk_combo_box_relayout (combo_box); 3148 gtk_combo_box_relayout (combo_box);
3149 3149
3150 g_object_notify (G_OBJECT (combo_box), "column_span_column"); 3150 g_object_notify (G_OBJECT (combo_box), "column_span_column");
3151 } 3151 }
3152 } 3152 }
3189 /* -1 means "no item selected" */ 3189 /* -1 means "no item selected" */
3190 g_return_if_fail (index_ >= -1); 3190 g_return_if_fail (index_ >= -1);
3191 3191
3192 if (combo_box->priv->active_item == index_) 3192 if (combo_box->priv->active_item == index_)
3193 return; 3193 return;
3194 3194
3195 gtk_combo_box_set_active_internal (combo_box, index_); 3195 gtk_combo_box_set_active_internal (combo_box, index_);
3196 } 3196 }
3197 3197
3198 static void 3198 static void
3199 gtk_combo_box_set_active_internal (GtkComboBox *combo_box, 3199 gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
3250 3250
3251 /** 3251 /**
3252 * gtk_combo_box_get_active_iter: 3252 * gtk_combo_box_get_active_iter:
3253 * @combo_box: A #GtkComboBox 3253 * @combo_box: A #GtkComboBox
3254 * @iter: The uninitialized #GtkTreeIter. 3254 * @iter: The uninitialized #GtkTreeIter.
3255 * 3255 *
3256 * Sets @iter to point to the current active item, if it exists. 3256 * Sets @iter to point to the current active item, if it exists.
3257 * 3257 *
3258 * Return value: %TRUE, if @iter was set 3258 * Return value: %TRUE, if @iter was set
3259 * 3259 *
3260 * Since: 2.4 3260 * Since: 2.4
3261 **/ 3261 **/
3262 gboolean 3262 gboolean
3291 3291
3292 /** 3292 /**
3293 * gtk_combo_box_set_active_iter: 3293 * gtk_combo_box_set_active_iter:
3294 * @combo_box: A #GtkComboBox 3294 * @combo_box: A #GtkComboBox
3295 * @iter: The #GtkTreeIter. 3295 * @iter: The #GtkTreeIter.
3296 * 3296 *
3297 * Sets the current active item to be the one referenced by @iter. 3297 * Sets the current active item to be the one referenced by @iter.
3298 * @iter must correspond to a path of depth one. 3298 * @iter must correspond to a path of depth one.
3299 * 3299 *
3300 * Since: 2.4 3300 * Since: 2.4
3301 **/ 3301 **/
3302 void 3302 void
3303 gtk_combo_box_set_active_iter (GtkComboBox *combo_box, 3303 gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
3304 GtkTreeIter *iter) 3304 GtkTreeIter *iter)
3308 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); 3308 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
3309 3309
3310 path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo_box), iter); 3310 path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo_box), iter);
3311 g_return_if_fail (path != NULL); 3311 g_return_if_fail (path != NULL);
3312 g_return_if_fail (gtk_tree_path_get_depth (path) == 1); 3312 g_return_if_fail (gtk_tree_path_get_depth (path) == 1);
3313 3313
3314 gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); 3314 gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]);
3315 gtk_tree_path_free (path); 3315 gtk_tree_path_free (path);
3316 } 3316 }
3317 3317
3318 /** 3318 /**
3319 * gtk_combo_box_set_model: 3319 * gtk_combo_box_set_model:
3320 * @combo_box: A #GtkComboBox. 3320 * @combo_box: A #GtkComboBox.
3321 * @model: A #GtkTreeModel. 3321 * @model: A #GtkTreeModel.
3322 * 3322 *
3323 * Sets the model used by @combo_box to be @model. Will unset a previously set 3323 * Sets the model used by @combo_box to be @model. Will unset a previously set
3324 * model (if applicable). If @model is %NULL, then it will unset the model. 3324 * model (if applicable). If @model is %NULL, then it will unset the model.
3325 * 3325 *
3326 * Note that this function does not clear the cell renderers, you have to 3326 * Note that this function does not clear the cell renderers, you have to
3327 * call gtk_combo_box_cell_layout_clear() yourself if you need to set up 3327 * call gtk_combo_box_cell_layout_clear() yourself if you need to set up
3328 * different cell renderers for the new model. 3328 * different cell renderers for the new model.
3329 * 3329 *
3330 * Since: 2.4 3330 * Since: 2.4
3331 */ 3331 */
3332 void 3332 void
3343 3343
3344 g_return_if_fail (GTK_IS_TREE_MODEL (model)); 3344 g_return_if_fail (GTK_IS_TREE_MODEL (model));
3345 3345
3346 if (model == combo_box->priv->model) 3346 if (model == combo_box->priv->model)
3347 return; 3347 return;
3348 3348
3349 if (combo_box->priv->model) 3349 if (combo_box->priv->model)
3350 gtk_combo_box_unset_model (combo_box); 3350 gtk_combo_box_unset_model (combo_box);
3351 3351
3352 combo_box->priv->model = model; 3352 combo_box->priv->model = model;
3353 g_object_ref (G_OBJECT (combo_box->priv->model)); 3353 g_object_ref (G_OBJECT (combo_box->priv->model));
3366 combo_box); 3366 combo_box);
3367 combo_box->priv->changed_id = 3367 combo_box->priv->changed_id =
3368 g_signal_connect (combo_box->priv->model, "row_changed", 3368 g_signal_connect (combo_box->priv->model, "row_changed",
3369 G_CALLBACK (gtk_combo_box_model_row_changed), 3369 G_CALLBACK (gtk_combo_box_model_row_changed),
3370 combo_box); 3370 combo_box);
3371 3371
3372 if (combo_box->priv->tree_view) 3372 if (combo_box->priv->tree_view)
3373 { 3373 {
3374 /* list mode */ 3374 /* list mode */
3375 gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), 3375 gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view),
3376 combo_box->priv->model); 3376 combo_box->priv->model);
3572 static void 3572 static void
3573 gtk_combo_box_destroy (GtkObject *object) 3573 gtk_combo_box_destroy (GtkObject *object)
3574 { 3574 {
3575 GtkComboBox *combo_box = GTK_COMBO_BOX (object); 3575 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
3576 3576
3577 gtk_combo_box_popdown (combo_box); 3577 gtk_combo_box_popdown (combo_box);
3578 3578
3579 combo_box->priv->destroying = 1; 3579 combo_box->priv->destroying = 1;
3580 3580
3581 GTK_OBJECT_CLASS (parent_class)->destroy (object); 3581 GTK_OBJECT_CLASS (parent_class)->destroy (object);
3582 combo_box->priv->cell_view = NULL; 3582 combo_box->priv->cell_view = NULL;
3587 static void 3587 static void
3588 gtk_combo_box_finalize (GObject *object) 3588 gtk_combo_box_finalize (GObject *object)
3589 { 3589 {
3590 GtkComboBox *combo_box = GTK_COMBO_BOX (object); 3590 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
3591 GSList *i; 3591 GSList *i;
3592 3592
3593 if (GTK_IS_MENU (combo_box->priv->popup_widget)) 3593 if (GTK_IS_MENU (combo_box->priv->popup_widget))
3594 { 3594 {
3595 gtk_combo_box_menu_destroy (combo_box); 3595 gtk_combo_box_menu_destroy (combo_box);
3596 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); 3596 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
3597 combo_box->priv->popup_widget = NULL; 3597 combo_box->priv->popup_widget = NULL;
3598 } 3598 }
3599 3599
3600 if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) 3600 if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
3601 gtk_combo_box_list_destroy (combo_box); 3601 gtk_combo_box_list_destroy (combo_box);
3602 3602
3603 if (combo_box->priv->popup_window) 3603 if (combo_box->priv->popup_window)
3604 gtk_widget_destroy (combo_box->priv->popup_window); 3604 gtk_widget_destroy (combo_box->priv->popup_window);
3653 static AttachInfo * 3653 static AttachInfo *
3654 get_attach_info (GtkWidget *child) 3654 get_attach_info (GtkWidget *child)
3655 { 3655 {
3656 GObject *object = G_OBJECT (child); 3656 GObject *object = G_OBJECT (child);
3657 AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY); 3657 AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY);
3658 3658
3659 if (!ai) 3659 if (!ai)
3660 { 3660 {
3661 ai = g_new0 (AttachInfo, 1); 3661 ai = g_new0 (AttachInfo, 1);
3662 g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free); 3662 g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free);
3663 } 3663 }
3664 3664
3665 return ai; 3665 return ai;
3666 } 3666 }
3667 3667
3668 /** 3668 /**
3669 * gtk_menu_attach: 3669 * gtk_menu_attach:
3691 guint right_attach, 3691 guint right_attach,
3692 guint top_attach, 3692 guint top_attach,
3693 guint bottom_attach) 3693 guint bottom_attach)
3694 { 3694 {
3695 GtkMenuShell *menu_shell; 3695 GtkMenuShell *menu_shell;
3696 3696
3697 g_return_if_fail (GTK_IS_MENU (menu)); 3697 g_return_if_fail (GTK_IS_MENU (menu));
3698 g_return_if_fail (GTK_IS_MENU_ITEM (child)); 3698 g_return_if_fail (GTK_IS_MENU_ITEM (child));
3699 g_return_if_fail (child->parent == NULL || 3699 g_return_if_fail (child->parent == NULL ||
3700 child->parent == GTK_WIDGET (menu)); 3700 child->parent == GTK_WIDGET (menu));
3701 g_return_if_fail (left_attach < right_attach); 3701 g_return_if_fail (left_attach < right_attach);
3702 g_return_if_fail (top_attach < bottom_attach); 3702 g_return_if_fail (top_attach < bottom_attach);
3703 3703
3704 menu_shell = GTK_MENU_SHELL (menu); 3704 menu_shell = GTK_MENU_SHELL (menu);
3705 3705
3706 if (!child->parent) 3706 if (!child->parent)
3707 { 3707 {
3708 AttachInfo *ai = get_attach_info (child); 3708 AttachInfo *ai = get_attach_info (child);
3709 3709
3710 ai->left_attach = left_attach; 3710 ai->left_attach = left_attach;
3711 ai->right_attach = right_attach; 3711 ai->right_attach = right_attach;
3712 ai->top_attach = top_attach; 3712 ai->top_attach = top_attach;
3713 ai->bottom_attach = bottom_attach; 3713 ai->bottom_attach = bottom_attach;
3714 3714
3715 menu_shell->children = g_list_append (menu_shell->children, child); 3715 menu_shell->children = g_list_append (menu_shell->children, child);
3716 3716
3717 gtk_widget_set_parent (child, GTK_WIDGET (menu)); 3717 gtk_widget_set_parent (child, GTK_WIDGET (menu));
3718 3718
3719 /* 3719 /*
3739 gchar *text = NULL; 3739 gchar *text = NULL;
3740 3740
3741 /* g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL); */ 3741 /* g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL); */
3742 3742
3743 if (gtk_combo_box_get_active_iter (combo_box, &iter)) 3743 if (gtk_combo_box_get_active_iter (combo_box, &iter))
3744 gtk_tree_model_get (gtk_combo_box_get_model(combo_box), &iter, 3744 gtk_tree_model_get (gtk_combo_box_get_model(combo_box), &iter,
3745 0, &text, -1); 3745 0, &text, -1);
3746 return text; 3746 return text;
3747 } 3747 }
3748 3748
3749 #endif 3749 #endif