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

when adding applets or launchers and such things from the context menu,

Thu Feb 21 17:25:56 2002  George Lebl <jirka@5z.com>

	* menu.c, panel.[ch]: when adding applets or launchers and such
	  things from the context menu, add them at the spot where the
	  context menu was triggered.
parent 418a796c
Thu Feb 21 17:25:56 2002 George Lebl <jirka@5z.com>
* menu.c, panel.[ch]: when adding applets or launchers and such
things from the context menu, add them at the spot where the
context menu was triggered.
Thu Feb 21 15:49:33 2002 George Lebl <jirka@5z.com>
* basep-widget.c: properly do hidebutton sensitivities and tooltips
......
......@@ -1178,10 +1178,16 @@ show_help_on (GtkWidget *widget, const char *item_loc)
static void
add_app_to_panel (GtkWidget *widget, const char *item_loc)
{
PanelWidget *panel = get_panel_from_menu_data (widget, TRUE);
Launcher *launcher;
PanelWidget *panel = get_panel_from_menu_data (widget, TRUE);
PanelData *pd;
int insertion_pos = -1;
launcher = load_launcher_applet (item_loc, panel, 0, FALSE, NULL);
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
launcher = load_launcher_applet (item_loc, panel, insertion_pos, FALSE, NULL);
if (launcher != NULL)
launcher_hoard (launcher);
......@@ -1270,13 +1276,20 @@ add_drawers_from_dir (const char *dirname, const char *name,
/*add a drawer with the contents of a menu to the panel*/
static void
add_menudrawer_to_panel(GtkWidget *w, gpointer data)
add_menudrawer_to_panel(GtkWidget *widget, gpointer data)
{
MenuFinfo *mf = data;
PanelWidget *panel = get_panel_from_menu_data (w, TRUE);
g_return_if_fail(mf);
PanelWidget *panel = get_panel_from_menu_data (widget, TRUE);
PanelData *pd;
int insertion_pos = -1;
g_return_if_fail (mf != 0);
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
add_drawers_from_dir (mf->menudir, mf->dir_name, 0, panel);
add_drawers_from_dir (mf->menudir, mf->dir_name, insertion_pos, panel);
}
static void
......@@ -1285,10 +1298,16 @@ add_menu_to_panel (GtkWidget *widget, gpointer data)
const char *menudir = data;
gboolean main_menu;
PanelWidget *panel;
PanelData *pd;
int insertion_pos = -1;
int flags = get_default_menu_flags ();
panel = get_panel_from_menu_data (widget, TRUE);
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
if (menudir == NULL) {
main_menu = TRUE;
menudir = "applications:/";
......@@ -1300,8 +1319,8 @@ add_menu_to_panel (GtkWidget *widget, gpointer data)
TRUE /* global_main */,
FALSE /* custom_icon */,
NULL /* custom_icon_file */,
panel,
0 /* pos */,
panel /* panel */,
insertion_pos /* pos */,
FALSE /* exactpos */,
NULL);
}
......@@ -2103,27 +2122,58 @@ setup_internal_applet_drag (GtkWidget *menuitem, const char *applet_type)
static void
add_drawer_to_panel (GtkWidget *widget, gpointer data)
{
PanelWidget *panel = get_panel_from_menu_data (widget, TRUE);
PanelData *pd;
int insertion_pos = -1;
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
load_drawer_applet (NULL, NULL, NULL,
get_panel_from_menu_data(widget, TRUE), 0, FALSE, NULL);
panel, insertion_pos, FALSE, NULL);
}
static void
add_logout_to_panel (GtkWidget *widget, gpointer data)
{
load_logout_applet (get_panel_from_menu_data(widget, TRUE), 0, FALSE, FALSE);
PanelWidget *panel = get_panel_from_menu_data (widget, TRUE);
PanelData *pd;
int insertion_pos = -1;
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
load_logout_applet (panel, insertion_pos, FALSE, FALSE);
}
static void
add_lock_to_panel (GtkWidget *widget, gpointer data)
{
load_lock_applet (get_panel_from_menu_data(widget, TRUE), 0, FALSE, FALSE);
PanelWidget *panel = get_panel_from_menu_data (widget, TRUE);
PanelData *pd;
int insertion_pos = -1;
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
load_lock_applet (panel, insertion_pos, FALSE, FALSE);
}
static void
try_add_status_to_panel (GtkWidget *widget, gpointer data)
{
if(!load_status_applet(get_panel_from_menu_data(widget, TRUE),
0, FALSE, FALSE)) {
PanelWidget *panel = get_panel_from_menu_data (widget, TRUE);
PanelData *pd;
int insertion_pos = -1;
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
if ( ! load_status_applet (panel, insertion_pos, FALSE, FALSE)) {
GtkWidget *mbox;
mbox = gtk_message_dialog_new (NULL, 0,
GTK_MESSAGE_INFO,
......@@ -2138,12 +2188,20 @@ try_add_status_to_panel (GtkWidget *widget, gpointer data)
}
static void
add_launcher (GtkWidget *w, const char *item_loc)
add_launcher (GtkWidget *widget, const char *item_loc)
{
Launcher *launcher;
PanelWidget *panel;
PanelData *pd;
int insertion_pos = -1;
launcher = load_launcher_applet
(item_loc, get_panel_from_menu_data (w, TRUE), 0, FALSE, NULL);
panel = get_panel_from_menu_data (widget, TRUE);
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
launcher = load_launcher_applet (item_loc, panel, insertion_pos, FALSE, NULL);
if (launcher != NULL)
launcher_hoard (launcher);
......@@ -2674,10 +2732,16 @@ add_bonobo_applet (GtkWidget *widget,
const char *iid)
{
PanelWidget *panel;
PanelData *pd;
int insertion_pos = -1;
panel = get_panel_from_menu_data (widget, TRUE);
panel_applet_frame_load (iid, panel, -1, NULL);
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
panel_applet_frame_load (iid, panel, insertion_pos, NULL);
}
static const gchar applet_requirements [] =
......@@ -3286,15 +3350,35 @@ current_panel_config(GtkWidget *w, gpointer data)
}
static void
ask_about_launcher_cb(GtkWidget *w, gpointer data)
ask_about_launcher_cb(GtkWidget *widget, gpointer data)
{
ask_about_launcher(NULL, get_panel_from_menu_data(w, TRUE), 0, FALSE);
PanelWidget *panel;
PanelData *pd;
int insertion_pos = -1;
panel = get_panel_from_menu_data (widget, TRUE);
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
ask_about_launcher(NULL, panel, insertion_pos, FALSE);
}
static void
ask_about_swallowing_cb(GtkWidget *w, gpointer data)
ask_about_swallowing_cb(GtkWidget *widget, gpointer data)
{
ask_about_swallowing(get_panel_from_menu_data(w, TRUE), 0, FALSE);
PanelWidget *panel;
PanelData *pd;
int insertion_pos = -1;
panel = get_panel_from_menu_data (widget, TRUE);
pd = g_object_get_data (G_OBJECT (panel->panel_parent), "PanelData");
if (pd != NULL)
insertion_pos = pd->insertion_pos;
ask_about_swallowing (panel, insertion_pos, FALSE);
}
#ifdef FIXME
......
......@@ -522,10 +522,23 @@ panel_applet_removed(GtkWidget *widget, GtkWidget *applet, gpointer data)
}
}
static gboolean
deactivate_idle (gpointer data)
{
PanelData *pd = data;
pd->deactivate_idle = 0;
pd->insertion_pos = -1;
return FALSE;
}
static void
menu_deactivate(GtkWidget *w, PanelData *pd)
{
pd->menu_age = 0;
if (pd->deactivate_idle == 0)
pd->deactivate_idle = g_idle_add (deactivate_idle, pd);
if(BASEP_IS_WIDGET(pd->panel))
BASEP_WIDGET(pd->panel)->autohide_inhibit = FALSE;
}
......@@ -616,6 +629,10 @@ panel_destroy (GtkWidget *widget, gpointer data)
pd->panel = NULL;
if (pd->deactivate_idle != 0)
g_source_remove (pd->deactivate_idle);
pd->deactivate_idle = 0;
panel_list = g_slist_remove (panel_list, pd);
g_free (pd);
}
......@@ -783,9 +800,11 @@ static gboolean pointer_in_widget (GtkWidget *widget, GdkEventButton *event)
static gboolean
panel_event(GtkWidget *widget, GdkEvent *event)
{
PanelData *pd;
PanelWidget *panel = NULL;
BasePWidget *basep = NULL;
GdkEventButton *bevent;
int x, y;
if (BASEP_IS_WIDGET (widget)) {
basep = BASEP_WIDGET (widget);
......@@ -799,6 +818,15 @@ panel_event(GtkWidget *widget, GdkEvent *event)
bevent = (GdkEventButton *) event;
switch(bevent->button) {
case 3:
/* Store the point where the popup menu was started to
* insert applets at that point */
pd = g_object_get_data (G_OBJECT (widget), "PanelData");
gtk_widget_get_pointer (GTK_WIDGET (panel), &x, &y);
if (panel->orient == GTK_ORIENTATION_VERTICAL)
pd->insertion_pos = y;
else
pd->insertion_pos = x;
if (panel_do_popup_menu (panel, basep, widget, bevent->button, bevent->time))
return TRUE;
break;
......@@ -1652,10 +1680,12 @@ panel_setup(GtkWidget *panelw)
panel = PANEL_WIDGET (FOOBAR_WIDGET (panelw)->panel);
}
pd = g_new(PanelData,1);
pd = g_new0 (PanelData,1);
pd->menu = NULL;
pd->menu_age = 0;
pd->panel = panelw;
pd->insertion_pos = -1;
pd->deactivate_idle = 0;
if (FOOBAR_IS_WIDGET (panelw) ||
(BASEP_IS_WIDGET (panelw) &&
......
......@@ -14,6 +14,8 @@ struct _PanelData {
GtkWidget *panel;
GtkWidget *menu;
int menu_age;
int insertion_pos;
guint deactivate_idle;
};
void orientation_change(AppletInfo *info, PanelWidget *panel);
......
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