Commit 4f63ead3 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

added que_pop_down and a way to inhibit the pop_down.

Sun May 24 16:45:37 1998  George Lebl  <jirka@5z.com>

        * panel-widget.[ch]: added que_pop_down and a way to inhibit
          the pop_down.

        * main.c, menu.c: use the above to make the panel menu and
          "Menu" menus act sanely with autohide

        * panel.c: made applet menus also play nice with autohide
parent 20418e8b
Sun May 24 16:45:37 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch]: added que_pop_down and a way to inhibit
the pop_down.
* main.c, menu.c: use the above to make the panel menu and
"Menu" menus act sanely with autohide
* panel.c: made applet menus also play nice with autohide
Sun May 24 01:19:50 1998 George Lebl <jirka@5z.com>
* main.c, panel.c: if there is no config file, pass a dummy
......
Sun May 24 16:45:37 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch]: added que_pop_down and a way to inhibit
the pop_down.
* main.c, menu.c: use the above to make the panel menu and
"Menu" menus act sanely with autohide
* panel.c: made applet menus also play nice with autohide
Sun May 24 01:19:50 1998 George Lebl <jirka@5z.com>
* main.c, panel.c: if there is no config file, pass a dummy
......
......@@ -776,14 +776,24 @@ panel_menu_position (GtkMenu *menu, gint *x, gint *y, gpointer data)
if(*y < 0) *y =0;
}
static void
menu_deactivate(GtkWidget *w, gpointer data)
{
PanelWidget *panel = data;
panel->autohide_inhibit = FALSE;
}
static int
panel_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
PanelWidget *panel = PANEL_WIDGET(widget);
if((event->button==3 || event->button==1) &&
!PANEL_WIDGET(widget)->currently_dragged_applet) {
!panel->currently_dragged_applet) {
panel->autohide_inhibit = TRUE;
panel_widget_queue_pop_down(panel);
gtk_menu_popup(GTK_MENU(data), NULL, NULL, panel_menu_position,
widget, event->button, time(NULL));
widget, event->button, event->time);
return TRUE;
}
return FALSE;
......@@ -862,6 +872,11 @@ panel_setup(PanelWidget *panel)
GTK_SIGNAL_FUNC(panel_destroy),
panel_menu);
gtk_signal_connect(GTK_OBJECT(panel_menu),
"deactivate",
GTK_SIGNAL_FUNC(menu_deactivate),
panel);
if(GTK_WIDGET_REALIZED(GTK_WIDGET(panel)))
panel_realize(GTK_WIDGET(panel),NULL);
else
......
......@@ -372,21 +372,45 @@ menu_position (GtkMenu *menu, gint *x, gint *y, gpointer data)
if(*y < 0) *y =0;
}
void
static void
destroy_menu (GtkWidget *widget, gpointer data)
{
Menu *menu = data;
if(menu->menu != root_menu)
gtk_widget_unref(menu->menu);
else
/*this will disconnect the "deactivate" signal*/
gtk_signal_disconnect_by_data(GTK_OBJECT(root_menu),menu);
g_free(menu);
}
static void
menu_deactivate(GtkWidget *w, gpointer data)
{
Menu *menu = data;
PanelWidget *panel =
gtk_object_get_data(GTK_OBJECT(menu->button->parent),
PANEL_APPLET_PARENT_KEY);
/* allow the panel to hide again */
panel->autohide_inhibit = FALSE;
}
static gint
menu_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
Menu *menu = data;
if(event->button==1) {
PanelWidget *panel =
gtk_object_get_data(GTK_OBJECT(menu->button->parent),
PANEL_APPLET_PARENT_KEY);
/*so that the panel doesn't pop down until we're done with
the menu */
panel->autohide_inhibit = TRUE;
panel_widget_queue_pop_down(panel);
gtk_menu_popup(GTK_MENU(menu->menu), 0,0, menu_position,
data, event->button, event->time);
return TRUE;
......@@ -675,6 +699,8 @@ create_panel_menu (char *menudir, int main_menu,
GTK_SIGNAL_FUNC (menu_button_press), menu);
gtk_signal_connect (GTK_OBJECT (menu->button), "destroy",
GTK_SIGNAL_FUNC (destroy_menu), menu);
gtk_signal_connect (GTK_OBJECT (menu->menu), "deactivate",
GTK_SIGNAL_FUNC (menu_deactivate), menu);
g_free (pixmap_name);
return menu;
......
......@@ -1187,6 +1187,25 @@ move_vert(PanelWidget *panel, gint src_y, gint dest_y, gint step)
move_window(GTK_WIDGET(panel), x, dest_y);
}
static gint
panel_widget_is_cursor(PanelWidget *panel, int overlap)
{
gint x,y;
gint w,h;
if(!GTK_WIDGET_VISIBLE(GTK_WIDGET(panel)))
return FALSE;
gtk_widget_get_pointer(GTK_WIDGET(panel), &x, &y);
gdk_window_get_size(GTK_WIDGET(panel)->window, &w, &h);
if((x+overlap)>=0 &&
(x-overlap)<=w &&
(y+overlap)>=0 &&
(y-overlap)<=h)
return TRUE;
return FALSE;
}
void
......@@ -1245,11 +1264,17 @@ panel_widget_pop_down(gpointer data)
int width, height;
int swidth, sheight;
if(panel->autohide_inhibit)
return TRUE;
if((panel->state != PANEL_SHOWN) ||
(panel->snapped == PANEL_DRAWER) ||
(panel->snapped == PANEL_FREE)) {
panel->leave_notify_timer_tag = 0;
return FALSE;
if(panel_widget_is_cursor(panel,0)) {
panel->leave_notify_timer_tag = 0;
return FALSE;
}
return TRUE;
}
/*we are moving, or have drawers open, so wait with the
pop_down*/
......@@ -1554,17 +1579,13 @@ panel_enter_notify(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
return FALSE;
}
static gint
panel_leave_notify(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
void
panel_widget_queue_pop_down(PanelWidget *panel)
{
PanelWidget *panel = data;
if ((panel->mode == PANEL_EXPLICIT_HIDE) ||
(event->detail == GDK_NOTIFY_INFERIOR) ||
(panel->state == PANEL_HIDDEN_LEFT) ||
(panel->state == PANEL_HIDDEN_RIGHT))
return FALSE;
return;
/* check if there's already a timeout set, and delete it if
* there was */
......@@ -1575,7 +1596,19 @@ panel_leave_notify(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
panel->leave_notify_timer_tag =
gtk_timeout_add (pw_minimize_delay,
panel_widget_pop_down, panel);
}
static gint
panel_leave_notify(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
{
PanelWidget *panel = data;
if (event->detail == GDK_NOTIFY_INFERIOR)
return FALSE;
panel_widget_queue_pop_down(panel);
return FALSE;
}
......@@ -1973,6 +2006,8 @@ panel_widget_new (gint size,
panel->thick = PANEL_MINIMUM_WIDTH;
panel->autohide_inhibit = FALSE;
/*sanity sets, ignore settings that would/might cause bad behaviour*/
if(snapped == PANEL_FREE) {
panel->size = size;
......@@ -2199,26 +2234,6 @@ artificial_drag_start (GtkWidget *widget, int x, int y)
#endif
static gint
panel_widget_is_cursor(PanelWidget *panel, int overlap)
{
gint x,y;
gint w,h;
if(!GTK_WIDGET_VISIBLE(GTK_WIDGET(panel)))
return FALSE;
gtk_widget_get_pointer(GTK_WIDGET(panel), &x, &y);
gdk_window_get_size(GTK_WIDGET(panel)->window, &w, &h);
if((x+overlap)>=0 &&
(x-overlap)<=w &&
(y+overlap)>=0 &&
(y-overlap)<=h)
return TRUE;
return FALSE;
}
/*calculates the value to move the applet by*/
static gint
panel_widget_get_moveby(PanelWidget *panel, gint pos)
......
......@@ -117,6 +117,8 @@ struct _PanelWidget
char *back_pixmap;
gint pixmap_enabled;
GdkColor back_color;
gint autohide_inhibit;
};
struct _PanelWidgetClass
......@@ -232,6 +234,9 @@ void panel_widget_change_global (gint explicit_step,
/*popup the widget if it's popped down (autohide)*/
void panel_widget_pop_up (PanelWidget *panel);
/*queue a pop_down in autohide mode*/
void panel_widget_queue_pop_down (PanelWidget *panel);
void panel_widget_enable_buttons (PanelWidget *panel);
void panel_widget_disable_buttons (PanelWidget *panel);
......
......@@ -514,6 +514,15 @@ applet_callback_callback(GtkWidget *widget, gpointer data)
}
}
static void
applet_menu_deactivate(GtkWidget *w, gpointer data)
{
GtkWidget *applet = data;
PanelWidget *panel = gtk_object_get_data(GTK_OBJECT(applet),
PANEL_APPLET_PARENT_KEY);
panel->autohide_inhibit = FALSE;
}
static void
create_applet_menu(AppletInfo *info)
{
......@@ -552,6 +561,12 @@ create_applet_menu(AppletInfo *info)
gtk_menu_append(GTK_MENU(info->menu), menuitem);
gtk_widget_show(menuitem);
}
/*connect the deactivate signal, so that we can "re-allow" autohide
when the menu is deactivated*/
gtk_signal_connect(GTK_OBJECT(info->menu),"deactivate",
GTK_SIGNAL_FUNC(applet_menu_deactivate),
info->widget);
}
static void
......@@ -608,15 +623,17 @@ applet_menu_position (GtkMenu *menu, gint *x, gint *y, gpointer data)
}
static void
show_applet_menu(gint applet_id)
{
AppletInfo *info = get_applet_info(applet_id);
PanelWidget *panel;
g_return_if_fail(info!=NULL);
panel = gtk_object_get_data(GTK_OBJECT(info->widget),
PANEL_APPLET_PARENT_KEY);
if (!info->menu)
create_applet_menu(info);
......@@ -630,6 +647,8 @@ show_applet_menu(gint applet_id)
else
gtk_widget_set_sensitive(info->remove_item,TRUE);
panel->autohide_inhibit = TRUE;
panel_widget_queue_pop_down(panel);
gtk_menu_popup(GTK_MENU(info->menu), NULL, NULL, applet_menu_position,
ITOP(applet_id), 0/*3*/, time(NULL));
}
......@@ -680,15 +699,21 @@ applet_show_menu(gint applet_id)
{
static GdkCursor *arrow = NULL;
AppletInfo *info = get_applet_info(applet_id);
PanelWidget *panel;
g_return_if_fail(info != NULL);
panel = gtk_object_get_data(GTK_OBJECT(info->widget),
PANEL_APPLET_PARENT_KEY);
if (!info->menu)
create_applet_menu(info);
if(!arrow)
arrow = gdk_cursor_new(GDK_ARROW);
panel->autohide_inhibit = TRUE;
panel_widget_queue_pop_down(panel);
gtk_menu_popup(GTK_MENU(info->menu), NULL, NULL, applet_menu_position,
ITOP(applet_id), 0/*3*/, time(NULL));
gtk_grab_add(info->menu);
......
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