Mercurial > pidgin.yaz
comparison src/gtkcombobox.c @ 12505:1ee0a397157f
[gaim-migrate @ 14817]
Better Gtk+ 2.0 support for the GtkComboBox backport
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Fri, 16 Dec 2005 19:40:53 +0000 |
parents | 8cb75ba77f9d |
children | 7ab959eb857e |
comparison
equal
deleted
inserted
replaced
12504:78e69ba4f596 | 12505:1ee0a397157f |
---|---|
293 GtkTreePath *path, | 293 GtkTreePath *path, |
294 GtkTreeIter *iter, | 294 GtkTreeIter *iter, |
295 gpointer data); | 295 gpointer data); |
296 | 296 |
297 /* list */ | 297 /* list */ |
298 #if GTK_CHECK_VERSION(2,2,0) | |
299 static void gtk_combo_box_list_position (GtkComboBox *combo_box, | 298 static void gtk_combo_box_list_position (GtkComboBox *combo_box, |
300 gint *x, | 299 gint *x, |
301 gint *y, | 300 gint *y, |
302 gint *width, | 301 gint *width, |
303 gint *height); | 302 gint *height); |
304 #endif | 303 |
305 static void gtk_combo_box_list_setup (GtkComboBox *combo_box); | 304 static void gtk_combo_box_list_setup (GtkComboBox *combo_box); |
306 static void gtk_combo_box_list_destroy (GtkComboBox *combo_box); | 305 static void gtk_combo_box_list_destroy (GtkComboBox *combo_box); |
307 | 306 |
308 static void gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box); | 307 static void gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box); |
309 | 308 |
1088 | 1087 |
1089 gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data); | 1088 gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data); |
1090 } | 1089 } |
1091 | 1090 |
1092 } | 1091 } |
1092 #endif /* Gtk 2.2 */ | |
1093 | 1093 |
1094 static void | 1094 static void |
1095 gtk_combo_box_list_position (GtkComboBox *combo_box, | 1095 gtk_combo_box_list_position (GtkComboBox *combo_box, |
1096 gint *x, | 1096 gint *x, |
1097 gint *y, | 1097 gint *y, |
1098 gint *width, | 1098 gint *width, |
1099 gint *height) | 1099 gint *height) |
1100 { | 1100 { |
1101 GtkWidget *sample; | 1101 GtkWidget *sample; |
1102 GtkRequisition popup_req; | |
1103 #if GTK_CHECK_VERSION(2,2,0) | |
1102 GdkScreen *screen; | 1104 GdkScreen *screen; |
1103 gint monitor_num; | 1105 gint monitor_num; |
1104 GdkRectangle monitor; | 1106 GdkRectangle monitor; |
1105 GtkRequisition popup_req; | 1107 #endif |
1106 | 1108 |
1107 sample = GTK_BIN (combo_box)->child; | 1109 sample = GTK_BIN (combo_box)->child; |
1108 | 1110 |
1109 *width = sample->allocation.width; | 1111 *width = sample->allocation.width; |
1110 gtk_widget_size_request (combo_box->priv->popup_window, &popup_req); | 1112 gtk_widget_size_request (combo_box->priv->popup_window, &popup_req); |
1124 { | 1126 { |
1125 *x += sample->allocation.x; | 1127 *x += sample->allocation.x; |
1126 *y += sample->allocation.y; | 1128 *y += sample->allocation.y; |
1127 } | 1129 } |
1128 | 1130 |
1131 #if GTK_CHECK_VERSION(2,2,0) | |
1129 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); | 1132 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); |
1130 monitor_num = gdk_screen_get_monitor_at_window (screen, | 1133 monitor_num = gdk_screen_get_monitor_at_window (screen, |
1131 GTK_WIDGET (combo_box)->window); | 1134 GTK_WIDGET (combo_box)->window); |
1132 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); | 1135 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); |
1133 | 1136 |
1138 | 1141 |
1139 if (*y + sample->allocation.height + *height <= monitor.y + monitor.height) | 1142 if (*y + sample->allocation.height + *height <= monitor.y + monitor.height) |
1140 *y += sample->allocation.height; | 1143 *y += sample->allocation.height; |
1141 else | 1144 else |
1142 *y -= *height; | 1145 *y -= *height; |
1146 #endif /* Gtk 2.2 */ | |
1143 } | 1147 } |
1144 #endif /* Gtk 2.2 */ | |
1145 | 1148 |
1146 /** | 1149 /** |
1147 * gtk_combo_box_popup: | 1150 * gtk_combo_box_popup: |
1148 * @combo_box: a #GtkComboBox | 1151 * @combo_box: a #GtkComboBox |
1149 * | 1152 * |
1155 * Since: 2.4 | 1158 * Since: 2.4 |
1156 **/ | 1159 **/ |
1157 void | 1160 void |
1158 gtk_combo_box_popup (GtkComboBox *combo_box) | 1161 gtk_combo_box_popup (GtkComboBox *combo_box) |
1159 { | 1162 { |
1160 gint x, y, width; | 1163 gint x, y, width, height; |
1161 #if GTK_CHECK_VERSION(2,2,0) | |
1162 gint height; | |
1163 #endif | |
1164 | 1164 |
1165 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); | 1165 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); |
1166 | 1166 |
1167 if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget)) | 1167 if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget)) |
1168 return; | 1168 return; |
1193 combo_box, 0, 0); | 1193 combo_box, 0, 0); |
1194 return; | 1194 return; |
1195 } | 1195 } |
1196 | 1196 |
1197 gtk_widget_show_all (combo_box->priv->popup_frame); | 1197 gtk_widget_show_all (combo_box->priv->popup_frame); |
1198 #if GTK_CHECK_VERSION(2,2,0) | |
1199 gtk_combo_box_list_position (combo_box, &x, &y, &width, &height); | 1198 gtk_combo_box_list_position (combo_box, &x, &y, &width, &height); |
1200 #endif | |
1201 | 1199 |
1202 gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1); | 1200 gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1); |
1203 gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y); | 1201 gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y); |
1204 | 1202 |
1205 /* popup */ | 1203 /* popup */ |