@@ -132,84 +132,19 @@ zoom_popup_menu_show (GdkEventButton *event, CajaZoomControl *zoom_control)
132132 event );
133133}
134134
135- static void
136- menu_position_under_widget (GtkMenu * menu ,
137- gint * x ,
138- gint * y ,
139- gboolean * push_in ,
140- gpointer user_data )
141- {
142- GtkWidget * widget ;
143- GtkWidget * container ;
144- GtkRequisition req ;
145- GtkRequisition menu_req ;
146- GdkRectangle monitor ;
147- GdkMonitor * monitor_num ;
148- GdkDisplay * display ;
149- GtkAllocation allocation ;
150-
151- widget = GTK_WIDGET (user_data );
152- g_assert (GTK_IS_WIDGET (widget ));
153-
154- container = gtk_widget_get_ancestor (widget , GTK_TYPE_CONTAINER );
155- g_assert (container != NULL );
156-
157- gtk_widget_get_preferred_size (GTK_WIDGET (menu ), & menu_req , NULL );
158- gtk_widget_get_preferred_size (widget , & req , NULL );
159- gtk_widget_get_allocation (widget , & allocation );
160-
161- display = gtk_widget_get_display (GTK_WIDGET (menu ));
162- monitor_num = gdk_display_get_monitor_at_window (display , gtk_widget_get_window (widget ));
163- if (monitor_num == NULL )
164- monitor_num = gdk_display_get_monitor (display , 0 );
165- gdk_monitor_get_geometry (monitor_num , & monitor );
166-
167- gdk_window_get_origin (gtk_widget_get_window (widget ), x , y );
168- if (!gtk_widget_get_has_window (widget ))
169- {
170- * x += allocation .x ;
171- * y += allocation .y ;
172- }
173-
174- if (gtk_widget_get_direction (container ) == GTK_TEXT_DIR_LTR )
175- {
176- * x += allocation .width - req .width ;
177- }
178- else
179- {
180- * x += req .width - menu_req .width ;
181- }
182-
183- if ((* y + allocation .height + menu_req .height ) <= monitor .y + monitor .height )
184- {
185- * y += allocation .height ;
186- }
187- else if ((* y - menu_req .height ) >= monitor .y )
188- {
189- * y -= menu_req .height ;
190- }
191- else if (monitor .y + monitor .height - (* y + allocation .height ) > * y )
192- {
193- * y += allocation .height ;
194- }
195- else
196- {
197- * y -= menu_req .height ;
198- }
199-
200- * push_in = FALSE;
201- }
202-
203-
204135static void
205136zoom_popup_menu (GtkWidget * widget , CajaZoomControl * zoom_control )
206137{
207138 GtkMenu * menu ;
139+ GdkEvent * event ;
208140
209141 menu = create_zoom_menu (zoom_control );
210- gtk_menu_popup (menu , NULL , NULL ,
211- menu_position_under_widget , widget ,
212- 0 , gtk_get_current_event_time ());
142+ gtk_menu_popup_at_widget (menu ,
143+ widget ,
144+ GDK_GRAVITY_SOUTH_WEST ,
145+ GDK_GRAVITY_NORTH_WEST ,
146+ (const GdkEvent * ) event );
147+
213148 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu ), FALSE);
214149}
215150
0 commit comments