Commit 13cce2cf authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

send orientation changes to children on size allocate of drawer and

Wed Dec 29 20:48:59 1999  George Lebl <jirka@5z.com>

	* drawer.c,panel.c: send orientation changes to children on size
	  allocate of drawer and floating widget

	* floating-widget.c,drawer-widget.c: use correct orientation
	  depending on the position of the widget on screen, so that we
	  always point towards the center of the screen.

	* panel.c,extern.c: be a bit gentler with orientation changes and
	  don't issue orientation changes for extern and status unless
	  orientation really changed.
parent dbd93578
Wed Dec 29 20:48:59 1999 George Lebl <jirka@5z.com>
* drawer.c,panel.c: send orientation changes to children on size
allocate of drawer and floating widget
* floating-widget.c,drawer-widget.c: use correct orientation
depending on the position of the widget on screen, so that we
always point towards the center of the screen.
* panel.c,extern.c: be a bit gentler with orientation changes and
don't issue orientation changes for extern and status unless
orientation really changed.
1999-12-29 Jacob Berkman <jberkman@andrew.cmu.edu>
* menu.c: get rid of warnings, and fix panel submenu tearoff
......
Wed Dec 29 20:48:59 1999 George Lebl <jirka@5z.com>
* drawer.c,panel.c: send orientation changes to children on size
allocate of drawer and floating widget
* floating-widget.c,drawer-widget.c: use correct orientation
depending on the position of the widget on screen, so that we
always point towards the center of the screen.
* panel.c,extern.c: be a bit gentler with orientation changes and
don't issue orientation changes for extern and status unless
orientation really changed.
1999-12-29 Jacob Berkman <jberkman@andrew.cmu.edu>
* menu.c: get rid of warnings, and fix panel submenu tearoff
......
......@@ -128,65 +128,40 @@ drawer_pos_set_hidebuttons (BasePWidget *basep)
}
}
static PanelData *
get_lowest_level_master_pd(PanelWidget *panel)
static void
get_widget_pos(GtkWidget *widget, int *x, int *y)
{
GtkObject *parent;
PanelData *pd;
while(panel->master_widget)
panel = PANEL_WIDGET(panel->master_widget->parent);
parent = GTK_OBJECT(panel->panel_parent);
g_return_val_if_fail(parent!=NULL,NULL);
pd = gtk_object_get_user_data(parent);
g_return_val_if_fail(pd!=NULL,NULL);
return pd;
if(!widget->window) {
*x = *y = 0;
return;
}
gdk_window_get_origin (widget->window, x, y);
if(GTK_WIDGET_NO_WINDOW(widget)) {
*x += widget->allocation.x;
*y += widget->allocation.y;
}
}
static PanelOrientType
drawer_pos_get_applet_orient (BasePWidget *basep)
{
PanelWidget *panel = PANEL_WIDGET (basep->panel);
PanelData *tpd = get_lowest_level_master_pd (panel);
PanelOrientType orient = ORIENT_UP;
PanelOrientation porient = panel->orient;
int x,y;
/* unfortunately we must do this */
if (IS_BORDER_WIDGET (tpd->panel)) {
switch (BORDER_POS (BASEP_WIDGET (tpd->panel)->pos)->edge) {
case BORDER_TOP:
orient = (porient == PANEL_VERTICAL)
? ORIENT_RIGHT : ORIENT_DOWN;
break;
case BORDER_BOTTOM:
case BORDER_LEFT:
orient = (porient == PANEL_VERTICAL)
? ORIENT_RIGHT : ORIENT_UP;
break;
case BORDER_RIGHT:
orient = (porient == PANEL_VERTICAL)
? ORIENT_LEFT : ORIENT_UP;
break;
}
} else if (IS_FLOATING_WIDGET (tpd->panel)) {
if (porient == PANEL_VERTICAL)
orient = (FLOATING_POS (BASEP_WIDGET (tpd->panel)->pos)->y <
gdk_screen_height () / 2)
? ORIENT_DOWN : ORIENT_UP;
get_widget_pos(GTK_WIDGET(basep),&x,&y);
if(porient == PANEL_VERTICAL) {
if(x > (gdk_screen_width()/2))
return ORIENT_LEFT;
else
orient = (FLOATING_POS (BASEP_WIDGET (tpd->panel)->pos)->x <
gdk_screen_width () / 2)
? ORIENT_RIGHT : ORIENT_LEFT;
} else if (IS_DRAWER_WIDGET (tpd->panel)) {
orient = (porient == PANEL_VERTICAL)
? ORIENT_RIGHT : ORIENT_UP;
} else {
g_warning (_("Don't know about base panel type: %d\n"), tpd->type);
return ORIENT_RIGHT;
} else {
if(y > (gdk_screen_height()/2))
return ORIENT_UP;
else
return ORIENT_DOWN;
}
return orient;
}
static PanelOrientType
......
......@@ -331,23 +331,34 @@ drawer_setup(Drawer *drawer)
}
static void
drawer_move_foreach(GtkWidget *w, gpointer user_data)
button_size_alloc(GtkWidget *widget, GtkAllocation *alloc, Drawer *drawer)
{
if(!GTK_WIDGET_REALIZED(widget))
return;
gtk_widget_queue_resize(drawer->drawer);
gtk_object_set_data(GTK_OBJECT(widget),"allocated",GINT_TO_POINTER(1));
}
static void
drawer_orient_change_foreach(GtkWidget *w, gpointer data)
{
AppletInfo *info = gtk_object_get_data(GTK_OBJECT(w), "applet_info");
PanelWidget *panel = data;
if(info->type == APPLET_DRAWER) {
Drawer *drawer = info->data;
gtk_widget_queue_resize(drawer->drawer);
}
orientation_change(info,panel);
}
static void
button_size_alloc(GtkWidget *widget, GtkAllocation *alloc, Drawer *drawer)
drawer_size_alloc(BasePWidget *basep, GtkAllocation *alloc, gpointer data)
{
if(!GTK_WIDGET_REALIZED(widget))
if(!GTK_WIDGET_REALIZED(basep))
return;
drawer_move_foreach(widget,NULL);
gtk_object_set_data(GTK_OBJECT(widget),"allocated",GINT_TO_POINTER(1));
gtk_container_foreach(GTK_CONTAINER(basep->panel),
drawer_orient_change_foreach,
basep->panel);
}
void
......@@ -380,6 +391,11 @@ load_drawer_applet(int mypanel, char *pixmap, char *tooltip,
register_toy(drawer->button,drawer, panel, pos, APPLET_DRAWER);
gtk_signal_connect_after(GTK_OBJECT(drawer->drawer),
"size_allocate",
GTK_SIGNAL_FUNC(drawer_size_alloc),
NULL);
gtk_signal_connect_after(GTK_OBJECT(drawer->button),
"size_allocate",
GTK_SIGNAL_FUNC(button_size_alloc),
......
......@@ -492,10 +492,12 @@ load_extern_applet(char *goad_id, char *cfgpath, PanelWidget *panel, int pos, in
ext->started = FALSE;
ext->send_position = FALSE;
ext->send_draw = FALSE;
ext->orient = -1;
ext->send_draw_timeout = 0;
ext->send_draw_queued = FALSE;
panelspot_servant = (POA_GNOME_PanelSpot *)ext;
panelspot_servant->_private = NULL;
panelspot_servant->vepv = &panelspot_vepv;
......@@ -615,6 +617,7 @@ s_panel_add_applet_full(POA_GNOME_Panel *servant,
ext->started = FALSE;
ext->send_position = FALSE;
ext->send_draw = FALSE;
ext->orient = -1;
panelspot_servant = (POA_GNOME_PanelSpot *)ext;
panelspot_servant->_private = NULL;
......
......@@ -22,6 +22,8 @@ struct _Extern {
int started;
gboolean send_position;
gboolean send_draw;
PanelOrientation orient; /* current orient, if it doesn't change,
don't send any orient change */
int send_draw_timeout;
gboolean send_draw_queued;
......
......@@ -145,7 +145,7 @@ floating_pos_get_applet_orient (BasePWidget *basep)
gdk_screen_height () / 2)
? ORIENT_DOWN : ORIENT_UP;
else
return (FLOATING_POS (basep->pos)->x >
return (FLOATING_POS (basep->pos)->x <
gdk_screen_width () /2)
? ORIENT_RIGHT : ORIENT_LEFT;
}
......
......@@ -181,17 +181,25 @@ orientation_change(AppletInfo *info, PanelWidget *panel)
{
if(info->type == APPLET_EXTERN) {
Extern *ext = info->data;
int orient = get_applet_orient(panel);
g_assert(ext);
/*ingore this until we get an ior*/
if(ext->applet) {
if(ext->applet && ext->orient != orient) {
CORBA_Environment ev;
CORBA_exception_init(&ev);
GNOME_Applet_change_orient(ext->applet,
get_applet_orient(panel),
orient,
&ev);
if(ev._major)
panel_clean_applet(ext->info);
CORBA_exception_free(&ev);
/* we have now sent this orientation thus we
save it and don't send it again unless it
changes */
ext->orient = orient;
}
} else if(info->type == APPLET_MENU) {
Menu *menu = info->data;
......@@ -213,8 +221,10 @@ orientation_change(AppletInfo *info, PanelWidget *panel)
set_swallow_applet_orient(swallow,SWALLOW_HORIZONTAL);
} else if(info->type == APPLET_STATUS) {
StatusApplet *status = info->data;
status->orient = panel->orient;
status_applet_update(status);
if(status->orient != panel->orient) {
status->orient = panel->orient;
status_applet_update(status);
}
}
}
......@@ -988,6 +998,17 @@ basep_pos_connect_signals (BasePWidget *basep)
}
}
static void
floating_size_alloc(BasePWidget *basep, GtkAllocation *alloc, gpointer data)
{
if(!GTK_WIDGET_REALIZED(basep))
return;
gtk_container_foreach(GTK_CONTAINER(basep->panel),
orient_change_foreach,
basep->panel);
}
void
panel_setup(GtkWidget *panelw)
{
......@@ -1078,6 +1099,11 @@ panel_setup(GtkWidget *panelw)
gtk_signal_connect_after(GTK_OBJECT(panelw), "realize",
GTK_SIGNAL_FUNC(panel_realize),
NULL);
if(IS_FLOATING_WIDGET(panelw))
gtk_signal_connect_after(GTK_OBJECT(panelw), "size_allocate",
GTK_SIGNAL_FUNC(floating_size_alloc),
NULL);
}
/*send state change to all the panels*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment