Commit c588f9ee authored by George Lebl's avatar George Lebl

orientation set sanely for everything. size of drawers reset when the

applet moves ...
parent 590f1ceb
...@@ -27,18 +27,14 @@ static char *gnome_folder = NULL; ...@@ -27,18 +27,14 @@ static char *gnome_folder = NULL;
extern GlobalConfig global_config; extern GlobalConfig global_config;
static gint void
drawer_click(GtkWidget *widget, gpointer data) reposition_drawer(Drawer *drawer)
{ {
Drawer *drawer = data; if(PANEL_WIDGET(drawer->drawer)->state == PANEL_SHOWN) {
gint x,y; gint x,y;
gint wx, wy; gint wx, wy;
if(PANEL_WIDGET(drawer->drawer)->state == PANEL_SHOWN) { gdk_window_get_origin (drawer->button->window, &wx, &wy);
gtk_widget_hide(drawer->drawer);
PANEL_WIDGET(drawer->drawer)->state = PANEL_HIDDEN;
} else {
gdk_window_get_origin (widget->window, &wx, &wy);
switch(drawer->orient) { switch(drawer->orient) {
case DRAWER_UP: case DRAWER_UP:
...@@ -47,21 +43,34 @@ drawer_click(GtkWidget *widget, gpointer data) ...@@ -47,21 +43,34 @@ drawer_click(GtkWidget *widget, gpointer data)
break; break;
case DRAWER_DOWN: case DRAWER_DOWN:
x = wx; x = wx;
y = wy + widget->allocation.height; y = wy + drawer->button->allocation.height;
break; break;
case DRAWER_LEFT: case DRAWER_LEFT:
x = wx - drawer->drawer->allocation.width; x = wx - drawer->drawer->allocation.width;
y = wy; y = wy;
break; break;
case DRAWER_RIGHT: case DRAWER_RIGHT:
x = wx + widget->allocation.width; x = wx + drawer->button->allocation.width;
y = wy; y = wy;
break; break;
} }
gtk_widget_set_uposition(drawer->drawer,x,y); gtk_widget_set_uposition(drawer->drawer,x,y);
gtk_widget_show(drawer->drawer); }
}
static gint
drawer_click(GtkWidget *widget, gpointer data)
{
Drawer *drawer = data;
if(PANEL_WIDGET(drawer->drawer)->state == PANEL_SHOWN) {
gtk_widget_hide(drawer->drawer);
PANEL_WIDGET(drawer->drawer)->state = PANEL_HIDDEN;
} else {
PANEL_WIDGET(drawer->drawer)->state = PANEL_SHOWN; PANEL_WIDGET(drawer->drawer)->state = PANEL_SHOWN;
reposition_drawer(drawer);
gtk_widget_show(drawer->drawer);
} }
return TRUE; return TRUE;
} }
......
...@@ -23,6 +23,9 @@ void set_drawer_applet_orient(Drawer *drawer, DrawerOrient orient); ...@@ -23,6 +23,9 @@ void set_drawer_applet_orient(Drawer *drawer, DrawerOrient orient);
Drawer * create_empty_drawer_applet(GtkWidget *window, DrawerOrient orient); Drawer * create_empty_drawer_applet(GtkWidget *window, DrawerOrient orient);
void reposition_drawer(Drawer *drawer);
END_GNOME_DECLS END_GNOME_DECLS
#endif #endif
...@@ -157,14 +157,12 @@ panel_realize(GtkWidget *widget, gpointer data) ...@@ -157,14 +157,12 @@ panel_realize(GtkWidget *widget, gpointer data)
change_window_cursor(widget->window, GDK_ARROW); change_window_cursor(widget->window, GDK_ARROW);
} }
static void /*we call this recursively*/
orient_change_foreach(gpointer data, gpointer user_data) static void orient_change_foreach(gpointer data, gpointer user_data);
{
AppletInfo *info = gtk_object_get_user_data(GTK_OBJECT(data));
PanelWidget *panel = user_data;
if(!info) return;
void
orientation_change(AppletInfo *info, PanelWidget *panel)
{
if(info->type == APPLET_EXTERN) { if(info->type == APPLET_EXTERN) {
/*FIXME: call corba*/ /*FIXME: call corba*/
} else if(info->type == APPLET_MENU) { } else if(info->type == APPLET_MENU) {
...@@ -216,6 +214,7 @@ orient_change_foreach(gpointer data, gpointer user_data) ...@@ -216,6 +214,7 @@ orient_change_foreach(gpointer data, gpointer user_data)
orient = DRAWER_LEFT; orient = DRAWER_LEFT;
break; break;
} }
reposition_drawer(drawer);
set_drawer_applet_orient(drawer,orient); set_drawer_applet_orient(drawer,orient);
panel_widget_foreach(PANEL_WIDGET(info->assoc), panel_widget_foreach(PANEL_WIDGET(info->assoc),
orient_change_foreach, orient_change_foreach,
...@@ -223,6 +222,18 @@ orient_change_foreach(gpointer data, gpointer user_data) ...@@ -223,6 +222,18 @@ orient_change_foreach(gpointer data, gpointer user_data)
} }
} }
static void
orient_change_foreach(gpointer data, gpointer user_data)
{
AppletInfo *info = gtk_object_get_user_data(GTK_OBJECT(data));
PanelWidget *panel = user_data;
if(!info) return;
orientation_change(info,panel);
}
static int static int
panel_orient_change(GtkWidget *widget, panel_orient_change(GtkWidget *widget,
PanelOrientation orient, PanelOrientation orient,
...@@ -289,6 +300,33 @@ panel_state_change(GtkWidget *widget, ...@@ -289,6 +300,33 @@ panel_state_change(GtkWidget *widget,
} }
} }
static void
applet_move_foreach(gpointer data, gpointer user_data)
{
AppletInfo *info = gtk_object_get_user_data(GTK_OBJECT(data));
PanelWidget *panel = user_data;
if(!info) return;
if(info->type == APPLET_DRAWER) {
if(PANEL_WIDGET(info->assoc)->state == PANEL_SHOWN) {
Drawer *drawer = info->data;
reposition_drawer(drawer);
panel_widget_foreach(PANEL_WIDGET(info->assoc),
state_restore_foreach,
(gpointer)info->assoc);
}
}
}
static void
panel_applet_move(GtkWidget *widget, GtkWidget *applet, gpointer data)
{
applet_move_foreach(applet,widget);
}
static int static int
panel_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data) panel_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data)
{ {
...@@ -374,6 +412,10 @@ init_user_panels(void) ...@@ -374,6 +412,10 @@ init_user_panels(void)
"state_change", "state_change",
GTK_SIGNAL_FUNC(panel_state_change), GTK_SIGNAL_FUNC(panel_state_change),
NULL); NULL);
gtk_signal_connect(GTK_OBJECT(panel),
"applet_move",
GTK_SIGNAL_FUNC(panel_applet_move),
NULL);
gtk_signal_connect(GTK_OBJECT(panel), gtk_signal_connect(GTK_OBJECT(panel),
"button_press_event", "button_press_event",
GTK_SIGNAL_FUNC(panel_button_press), GTK_SIGNAL_FUNC(panel_button_press),
......
...@@ -22,6 +22,10 @@ typedef void (*PanelWidgetStateSignal) (GtkObject * object, ...@@ -22,6 +22,10 @@ typedef void (*PanelWidgetStateSignal) (GtkObject * object,
PanelState state, PanelState state,
gpointer data); gpointer data);
typedef void (*PanelWidgetAppletSignal) (GtkObject * object,
GtkWidget * applet,
gpointer data);
guint guint
panel_widget_get_type () panel_widget_get_type ()
{ {
...@@ -47,7 +51,7 @@ panel_widget_get_type () ...@@ -47,7 +51,7 @@ panel_widget_get_type ()
enum { enum {
ORIENT_CHANGE_SIGNAL, ORIENT_CHANGE_SIGNAL,
STATE_CHANGE_SIGNAL, STATE_CHANGE_SIGNAL,
RESTORE_STATE_SIGNAL, APPLET_MOVE_SIGNAL,
LAST_SIGNAL LAST_SIGNAL
}; };
...@@ -82,6 +86,20 @@ gtk_panel_widget_marshal_signal_orient (GtkObject * object, ...@@ -82,6 +86,20 @@ gtk_panel_widget_marshal_signal_orient (GtkObject * object,
func_data); func_data);
} }
static void
gtk_panel_widget_marshal_signal_applet (GtkObject * object,
GtkSignalFunc func,
gpointer func_data,
GtkArg * args)
{
PanelWidgetAppletSignal rfunc;
rfunc = (PanelWidgetAppletSignal) func;
(*rfunc) (object, GTK_VALUE_POINTER (args[0]),
func_data);
}
static void static void
panel_widget_class_init (PanelWidgetClass *class) panel_widget_class_init (PanelWidgetClass *class)
{ {
...@@ -110,23 +128,23 @@ panel_widget_class_init (PanelWidgetClass *class) ...@@ -110,23 +128,23 @@ panel_widget_class_init (PanelWidgetClass *class)
GTK_TYPE_NONE, GTK_TYPE_NONE,
1, 1,
GTK_TYPE_ENUM); GTK_TYPE_ENUM);
panel_widget_signals[RESTORE_STATE_SIGNAL] = panel_widget_signals[APPLET_MOVE_SIGNAL] =
gtk_signal_new("restore_state", gtk_signal_new("applet_move",
GTK_RUN_LAST, GTK_RUN_LAST,
object_class->type, object_class->type,
GTK_SIGNAL_OFFSET(PanelWidgetClass, GTK_SIGNAL_OFFSET(PanelWidgetClass,
restore_state), applet_move),
gtk_panel_widget_marshal_signal_state, gtk_panel_widget_marshal_signal_applet,
GTK_TYPE_NONE, GTK_TYPE_NONE,
1, 1,
GTK_TYPE_ENUM); GTK_TYPE_POINTER);
gtk_object_class_add_signals(object_class,panel_widget_signals, gtk_object_class_add_signals(object_class,panel_widget_signals,
LAST_SIGNAL); LAST_SIGNAL);
class->orient_change = NULL; class->orient_change = NULL;
class->state_change = NULL; class->state_change = NULL;
class->restore_state = NULL; class->applet_move = NULL;
} }
static void static void
...@@ -651,6 +669,10 @@ panel_widget_applet_size_allocate (GtkWidget *widget, ...@@ -651,6 +669,10 @@ panel_widget_applet_size_allocate (GtkWidget *widget,
panel = gtk_object_get_data(GTK_OBJECT(widget),PANEL_APPLET_PARENT_KEY); panel = gtk_object_get_data(GTK_OBJECT(widget),PANEL_APPLET_PARENT_KEY);
panel_widget_adjust_applet(panel,widget); panel_widget_adjust_applet(panel,widget);
gtk_signal_emit(GTK_OBJECT(panel),
panel_widget_signals[APPLET_MOVE_SIGNAL],
widget);
return TRUE; return TRUE;
} }
...@@ -1283,6 +1305,9 @@ panel_widget_applet_move_to_cursor(PanelWidget *panel) ...@@ -1283,6 +1305,9 @@ panel_widget_applet_move_to_cursor(PanelWidget *panel)
panel->currently_dragged_applet_pos = panel->currently_dragged_applet_pos =
panel_widget_switch_move(panel, pos, moveby); panel_widget_switch_move(panel, pos, moveby);
gtk_signal_emit(GTK_OBJECT(panel),
panel_widget_signals[APPLET_MOVE_SIGNAL],
panel->currently_dragged_applet);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
...@@ -1762,9 +1787,6 @@ panel_widget_restore_state(PanelWidget *panel) ...@@ -1762,9 +1787,6 @@ panel_widget_restore_state(PanelWidget *panel)
/*is this needed, probably ... in case we move the panel, this /*is this needed, probably ... in case we move the panel, this
function should do a complete restore*/ function should do a complete restore*/
panel_widget_set_size(panel,panel->size); panel_widget_set_size(panel,panel->size);
gtk_signal_emit(GTK_OBJECT(panel),
panel_widget_signals[RESTORE_STATE_SIGNAL],
panel->state);
} }
#if 0 #if 0
......
...@@ -111,8 +111,8 @@ struct _PanelWidgetClass ...@@ -111,8 +111,8 @@ struct _PanelWidgetClass
PanelSnapped snapped); PanelSnapped snapped);
void (* state_change) (PanelWidget *panel, void (* state_change) (PanelWidget *panel,
PanelState state); PanelState state);
void (* restore_state) (PanelWidget *panel, void (* applet_move) (PanelWidget *panel,
PanelState state); GtkWidget *applet);
}; };
guint panel_widget_get_type (void); guint panel_widget_get_type (void);
......
...@@ -86,12 +86,6 @@ apply_global_config(void) ...@@ -86,12 +86,6 @@ apply_global_config(void)
} }
/*FIXME this should be somehow done through signals and panel-widget*/
static void
applet_orientation_notify(GtkWidget *widget, gpointer data)
{
}
static gint static gint
find_panel(PanelWidget *panel) find_panel(PanelWidget *panel)
{ {
...@@ -674,7 +668,6 @@ set_tooltip(GtkWidget *applet, char *tooltip) ...@@ -674,7 +668,6 @@ set_tooltip(GtkWidget *applet, char *tooltip)
gtk_tooltips_set_tip (panel_tooltips,applet,tooltip,NULL); gtk_tooltips_set_tip (panel_tooltips,applet,tooltip,NULL);
} }
void void
register_toy(GtkWidget *applet, register_toy(GtkWidget *applet,
GtkWidget * assoc, GtkWidget * assoc,
...@@ -688,10 +681,14 @@ register_toy(GtkWidget *applet, ...@@ -688,10 +681,14 @@ register_toy(GtkWidget *applet,
{ {
GtkWidget *eventbox; GtkWidget *eventbox;
AppletInfo *info; AppletInfo *info;
PanelWidget *panelw;
g_assert(applet != NULL); g_assert(applet != NULL);
g_assert(id != NULL); g_assert(id != NULL);
panelw = PANEL_WIDGET(g_list_nth(panels,panel)->data);
g_assert(panelw != NULL);
/* We wrap the applet in a GtkEventBox so that we can capture events over it */ /* We wrap the applet in a GtkEventBox so that we can capture events over it */
eventbox = gtk_event_box_new(); eventbox = gtk_event_box_new();
...@@ -713,8 +710,7 @@ register_toy(GtkWidget *applet, ...@@ -713,8 +710,7 @@ register_toy(GtkWidget *applet,
if(pos==PANEL_UNKNOWN_APPLET_POSITION) if(pos==PANEL_UNKNOWN_APPLET_POSITION)
pos = 0; pos = 0;
panel_widget_add(PANEL_WIDGET(g_list_nth(panels,panel)->data), panel_widget_add(panelw, eventbox, pos);
eventbox, pos);
gtk_widget_show(applet); gtk_widget_show(applet);
gtk_widget_show(eventbox); gtk_widget_show(eventbox);
...@@ -726,8 +722,7 @@ register_toy(GtkWidget *applet, ...@@ -726,8 +722,7 @@ register_toy(GtkWidget *applet,
GTK_SIGNAL_FUNC(applet_button_press), GTK_SIGNAL_FUNC(applet_button_press),
info); info);
/*notify the applet of the orientation of the panel!*/ orientation_change(info,panelw);
/*applet_orientation_notify(eventbox,NULL);*/
if(strcmp(id,"Menu")==0) if(strcmp(id,"Menu")==0)
menu_count++; menu_count++;
......
...@@ -101,6 +101,7 @@ void applet_add_callback(short id, char *callback_name, char *menuitem_text); ...@@ -101,6 +101,7 @@ void applet_add_callback(short id, char *callback_name, char *menuitem_text);
/*this is in main.c*/ /*this is in main.c*/
void load_applet(char *id, char *params, int pos, int panel); void load_applet(char *id, char *params, int pos, int panel);
void orientation_change(AppletInfo *info, PanelWidget *panel);
END_GNOME_DECLS END_GNOME_DECLS
......
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