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