PATCH: smart bonobo toolbar popup window.
- From: "Juan Pablo Mendoza M." <pablo_juan yahoo com>
- To: gnome-components-list gnome org
- Subject: PATCH: smart bonobo toolbar popup window.
- Date: Tue, 23 Jan 2001 23:49:15 -0700 (MST)
Saludos,
A little patch to make the toolbar popup window a little more smarter.
--
Juan Pablo Mendoza Mendoza. | "They killed Kenny!
pablo_juan yahoo com | THOSE BASTARDS!"
Index: bonobo-ui-toolbar.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-toolbar.c,v
retrieving revision 1.40
diff -u -5 -r1.40 bonobo-ui-toolbar.c
--- bonobo-ui-toolbar.c 2001/01/09 20:47:59 1.40
+++ bonobo-ui-toolbar.c 2001/01/24 06:30:36
@@ -308,30 +308,66 @@
gtk_grab_add (widget);
}
static void
+popup_window_calc_uposition (BonoboUIToolbar *toolbar, int *x, int *y)
+{
+ BonoboUIToolbarPrivate *priv;
+ int popup_win_width, popup_win_height;
+ int screen_width, screen_height;
+ int popup_item_width, popup_item_height;
+ int popup_item_x, popup_item_y;
+
+ priv = toolbar->priv;
+
+ gtk_widget_realize (priv->popup_window);
+
+ gdk_window_get_origin (GTK_WIDGET (toolbar)->window, x, y);
+
+ screen_width = gdk_screen_width ();
+ screen_height = gdk_screen_height ();
+
+ popup_win_width = priv->popup_window->allocation.width;
+ popup_win_height = priv->popup_window->allocation.height;
+
+ popup_item_width = GTK_WIDGET(priv->popup_item)->allocation.width;
+ popup_item_height = GTK_WIDGET(priv->popup_item)->allocation.height;
+
+ popup_item_x = GTK_WIDGET(priv->popup_item)->allocation.x;
+ popup_item_y = GTK_WIDGET(priv->popup_item)->allocation.y;
+
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) {
+ *x += popup_item_x - popup_win_width;
+ *y += popup_item_y + popup_item_height;
+ if (*x < 0)
+ *x = 0;
+ if (*y + popup_win_height > screen_height)
+ *y -= popup_item_y + popup_item_height + popup_win_height;
+ } else {
+ *x += popup_item_x + popup_item_width;
+ *y += popup_item_y - popup_win_height;
+ if (*x + popup_win_width > screen_width)
+ *x -= popup_item_x + popup_item_width + popup_win_width;
+ if (*y < 0)
+ *y = 0;
+ }
+}
+
+static void
show_popup_window (BonoboUIToolbar *toolbar)
{
BonoboUIToolbarPrivate *priv;
- const GtkAllocation *toolbar_allocation;
int x, y;
priv = toolbar->priv;
priv->items_moved_to_popup_window = TRUE;
create_popup_window (toolbar);
-
- gdk_window_get_origin (GTK_WIDGET (toolbar)->window, &x, &y);
-
- toolbar_allocation = & GTK_WIDGET (toolbar)->allocation;
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- x += toolbar_allocation->x + toolbar_allocation->width;
- else
- y += toolbar_allocation->y + toolbar_allocation->height;
+ popup_window_calc_uposition (toolbar, &x, &y);
gtk_widget_set_uposition (GTK_WIDGET (priv->popup_window), x, y);
gtk_signal_connect (GTK_OBJECT (priv->popup_window), "map",
GTK_SIGNAL_FUNC (popup_window_map_cb), toolbar);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]