]> git.pld-linux.org Git - packages/xfce4-places-plugin.git/blob - xfce4-places-plugin-position.patch
- rel 7
[packages/xfce4-places-plugin.git] / xfce4-places-plugin-position.patch
1 diff -ur xfce4-places-plugin-1.2.0/panel-plugin/view.c xfce4-places-plugin-1.2.0-position/panel-plugin/view.c
2 --- xfce4-places-plugin-1.2.0/panel-plugin/view.c       2011-03-03 13:43:31.938573607 +0100
3 +++ xfce4-places-plugin-1.2.0-position/panel-plugin/view.c      2011-03-03 13:42:28.099573608 +0100
4 @@ -734,6 +734,55 @@
5  }
6  
7  static void
8 +pview_position_menu (GtkMenu *menu,
9 +                     gint *x,
10 +                     gint *y,
11 +                     gboolean *push_in,
12 +                     PlacesView *view)
13 +{
14 +  GtkWidget *button;
15 +  GtkRequisition requisition;
16 +  GtkOrientation orientation;
17 +
18 +  button = view->button;
19 +  orientation = xfce_panel_plugin_get_orientation (view->plugin);
20 +  gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
21 +  gdk_window_get_origin (GTK_WIDGET (view->plugin)->window, x, y);
22 +
23 +  switch (orientation)
24 +    {
25 +    case GTK_ORIENTATION_HORIZONTAL:
26 +      if (*y + button->allocation.height + requisition.height > gdk_screen_height ())
27 +        /* Show menu above */
28 +        *y -= requisition.height;
29 +      else
30 +        /* Show menu below */
31 +        *y += button->allocation.height;
32 +
33 +      if (*x + requisition.width > gdk_screen_width ())
34 +        /* Adjust horizontal position */
35 +        *x = gdk_screen_width () - requisition.width;
36 +      break;
37 +
38 +    case GTK_ORIENTATION_VERTICAL:
39 +      if (*x + button->allocation.width + requisition.width > gdk_screen_width ())
40 +        /* Show menu on the right */
41 +        *x -= requisition.width;
42 +      else
43 +        /* Show menu on the left */
44 +        *x += button->allocation.width;
45 +
46 +      if (*y + requisition.height > gdk_screen_height ())
47 +        /* Adjust vertical position */
48 +        *y = gdk_screen_height () - requisition.height;
49 +      break;
50 +
51 +    default:
52 +      break;
53 +    }
54 +}
55 +
56 +static void
57  pview_open_menu(PlacesView *pd)
58  {
59      /* check if menu is needed, or it needs an update */
60 @@ -745,8 +794,7 @@
61  
62      /* popup menu */
63      gtk_menu_popup (GTK_MENU (pd->menu), NULL, NULL,
64 -                    xfce_panel_plugin_position_menu,
65 -                    pd->plugin, 0,
66 +                    (GtkMenuPositionFunc)pview_position_menu, pd, 0,
67                      gtk_get_current_event_time ());
68      
69      /* menu timeout to poll for model changes */
This page took 0.089164 seconds and 4 git commands to generate.