177
177
slot = nautilus_window_get_active_slot (window);
178
list = back ? nautilus_window_slot_get_back_history (slot) :
179
nautilus_window_slot_get_forward_history (slot);
179
list = back ? slot->back_list : slot->forward_list;
181
182
while (list != NULL) {
182
183
menu_item = nautilus_bookmark_menu_item_new (NAUTILUS_BOOKMARK (list->data));
198
/* adapted from gtk/gtkmenubutton.c */
200
menu_position_func (GtkMenu *menu,
207
GtkRequisition menu_req;
208
GdkRectangle monitor;
212
GtkAllocation allocation;
214
/* Set the dropdown menu hint on the toplevel, so the WM can omit the top side
217
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu));
218
gtk_window_set_type_hint (GTK_WINDOW (toplevel), GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU);
220
window = gtk_widget_get_window (widget);
221
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
222
monitor_num = gdk_screen_get_monitor_at_window (screen, window);
223
if (monitor_num < 0) {
227
gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
228
gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
229
gtk_widget_get_allocation (widget, &allocation);
230
gdk_window_get_origin (window, x, y);
235
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) {
236
*x -= MAX (menu_req.width - allocation.width, 0);
238
*x += MAX (allocation.width - menu_req.width, 0);
241
if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height) {
242
*y += allocation.height;
243
} else if ((*y - menu_req.height) >= monitor.y) {
244
*y -= menu_req.height;
245
} else if (monitor.y + monitor.height - (*y + allocation.height) > *y) {
246
*y += allocation.height;
248
*y -= menu_req.height;
198
255
show_menu (NautilusToolbar *self,
199
NautilusNavigationDirection direction,
201
258
guint32 event_time)
203
260
NautilusWindow *window;
262
NautilusNavigationDirection direction;
206
264
window = self->priv->window;
207
265
menu = gtk_menu_new ();
267
direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
209
270
switch (direction) {
210
271
case NAUTILUS_NAVIGATION_DIRECTION_FORWARD:
211
272
fill_menu (window, menu, FALSE);
221
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
282
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
283
(GtkMenuPositionFunc) menu_position_func, widget,
222
284
button, event_time);
241
303
ScheduleMenuData *data = user_data;
243
show_menu (data->self, data->direction,
305
show_menu (data->self, data->widget,
244
306
1, gtk_get_current_event_time ());
267
329
data = g_slice_new0 (ScheduleMenuData);
268
330
data->self = self;
269
data->direction = direction;
331
data->widget = widget;
271
333
self->priv->popup_timeout_id =
272
334
g_timeout_add_full (G_PRIORITY_DEFAULT, MENU_POPUP_TIMEOUT,
280
342
gpointer user_data)
282
344
NautilusToolbar *self = user_data;
283
NautilusNavigationDirection direction;
285
direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button),
288
346
if (event->button == 3) {
289
347
/* right click */
290
show_menu (self, direction, event->button, event->time);
348
show_menu (self, GTK_WIDGET (button), event->button, event->time);
294
352
if (event->button == 1) {
295
schedule_menu_popup_timeout (self, direction);
353
schedule_menu_popup_timeout (self, GTK_WIDGET (button));
323
381
G_CALLBACK (tool_button_release_cb), self);
385
gear_menu_key_press (GtkWidget *widget,
389
GdkModifierType mask = gtk_accelerator_get_default_mod_mask ();
391
if ((event->state & mask) == 0 && (event->keyval == GDK_KEY_F10)) {
392
gtk_menu_shell_deactivate (GTK_MENU_SHELL (widget));
327
400
nautilus_toolbar_constructed (GObject *obj)
434
507
gtk_widget_set_halign (menu, GTK_ALIGN_END);
435
508
gtk_menu_button_set_popup (GTK_MENU_BUTTON (tool_button), menu);
436
509
gtk_actionable_set_action_name (GTK_ACTIONABLE (tool_button), "win.gear-menu");
510
g_signal_connect (menu, "key-press-event", G_CALLBACK (gear_menu_key_press), self);
438
512
gtk_container_add (GTK_CONTAINER (tool_item), tool_button);
439
513
gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (tool_item));