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

Make logout and lock also draggable, and move by default.

Tue Dec 19 20:52:17 2000  George Lebl <jirka@5z.com>

	* logout.c, panel.c:  Make logout and lock also draggable, and move
	  by default.
parent 03227d76
Tue Dec 19 20:52:17 2000 George Lebl <jirka@5z.com>
* logout.c, panel.c: Make logout and lock also draggable, and move
by default.
Tue Dec 19 17:34:35 2000 George Lebl <jirka@5z.com>
* panel.c, launcher.[ch]: Allow _MOVE of icons under a special
......
Tue Dec 19 20:52:17 2000 George Lebl <jirka@5z.com>
* logout.c, panel.c: Make logout and lock also draggable, and move
by default.
Tue Dec 19 17:34:35 2000 George Lebl <jirka@5z.com>
* panel.c, launcher.[ch]: Allow _MOVE of icons under a special
......
......@@ -7,6 +7,7 @@
#include "panel-include.h"
extern GSList *applets;
extern GSList *applets_last;
extern GtkTooltips *panel_tooltips;
......@@ -14,9 +15,9 @@ extern GtkTooltips *panel_tooltips;
extern GlobalConfig global_config;
static void
logout(GtkWidget *widget)
logout (GtkWidget *widget)
{
if(global_config.drawer_auto_close) {
if (global_config.drawer_auto_close) {
GtkWidget *parent = PANEL_WIDGET(widget->parent)->panel_parent;
g_return_if_fail(parent!=NULL);
if(IS_DRAWER_WIDGET(parent)) {
......@@ -32,24 +33,81 @@ logout(GtkWidget *widget)
panel_quit();
}
static int
find_applet (GtkWidget *widget)
{
int i;
GSList *li;
for (i = 0, li = applets; li != NULL; i++, li = li->next) {
AppletInfo *info = li->data;
if (info->widget == widget)
return i;
}
return i;
}
static void
drag_data_get_cb (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
char *type = data;
char *foo;
foo = g_strdup_printf ("%s:%d", type, find_applet (widget));
gtk_selection_data_set (selection_data,
selection_data->target, 8, (guchar *)foo,
strlen (foo));
g_free (foo);
}
static GtkWidget *
create_logout_widget(void)
create_logout_widget (void)
{
static GtkTargetEntry dnd_targets[] = {
{ "application/x-panel-applet-internal", 0, 0 }
};
GtkWidget *button;
char *pixmap_name;
pixmap_name = gnome_pixmap_file("gnome-term-night.png");
pixmap_name = gnome_pixmap_file ("gnome-term-night.png");
button = button_widget_new(pixmap_name,-1,
MISC_TILE,
FALSE,
ORIENT_UP,
_("Log out"));
g_free(pixmap_name);
gtk_tooltips_set_tip (panel_tooltips,button,_("Log out of GNOME"),NULL);
button = button_widget_new (pixmap_name, -1,
MISC_TILE,
FALSE,
ORIENT_UP,
_("Log out"));
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(logout), NULL);
/*A hack since this function only pretends to work on window
widgets (which we actually kind of are) this will select
some (already selected) events on the panel instead of
the button window (where they are also selected) but
we don't mind*/
GTK_WIDGET_UNSET_FLAGS (button, GTK_NO_WINDOW);
gtk_drag_source_set (button,
GDK_BUTTON1_MASK,
dnd_targets, 1,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
GTK_WIDGET_SET_FLAGS (button, GTK_NO_WINDOW);
gtk_signal_connect (GTK_OBJECT (button), "drag_data_get",
GTK_SIGNAL_FUNC (drag_data_get_cb),
"LOGOUT");
g_free (pixmap_name);
gtk_tooltips_set_tip (panel_tooltips, button, _("Log out of GNOME"), NULL);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (logout), NULL);
return button;
}
......@@ -75,21 +133,41 @@ load_logout_applet(PanelWidget *panel, int pos, gboolean exactpos)
static GtkWidget *
create_lock_widget(void)
{
static GtkTargetEntry dnd_targets[] = {
{ "application/x-panel-applet-internal", 0, 0 }
};
GtkWidget *button;
char *pixmap_name;
pixmap_name = gnome_pixmap_file("gnome-lockscreen.png");
button = button_widget_new(pixmap_name,-1,
MISC_TILE,
FALSE,
ORIENT_UP,
_("Lock screen"));
g_free(pixmap_name);
gtk_tooltips_set_tip (panel_tooltips,button,_("Lock screen"),NULL);
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(panel_lock), NULL);
button = button_widget_new (pixmap_name, -1,
MISC_TILE,
FALSE,
ORIENT_UP,
_("Lock screen"));
/*A hack since this function only pretends to work on window
widgets (which we actually kind of are) this will select
some (already selected) events on the panel instead of
the button window (where they are also selected) but
we don't mind*/
GTK_WIDGET_UNSET_FLAGS (button, GTK_NO_WINDOW);
gtk_drag_source_set (button,
GDK_BUTTON1_MASK,
dnd_targets, 1,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
GTK_WIDGET_SET_FLAGS (button, GTK_NO_WINDOW);
gtk_signal_connect (GTK_OBJECT (button), "drag_data_get",
GTK_SIGNAL_FUNC (drag_data_get_cb),
"LOCK");
g_free (pixmap_name);
gtk_tooltips_set_tip (panel_tooltips, button, _("Lock screen"), NULL);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (panel_lock), NULL);
return button;
}
......
......@@ -40,6 +40,9 @@ static int panel_been_moved = FALSE;
go below 1*/
int base_panels = 0;
extern GSList *applets;
extern GSList *applets_last;
extern int config_sync_timeout;
extern int applets_to_sync;
extern int panels_to_sync;
......@@ -1031,8 +1034,12 @@ drop_internal_icon (PanelWidget *panel, int pos, const char *icon_name,
}
static void
drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type)
drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type,
int action)
{
int applet_num = -1;
gboolean remove_applet = FALSE;
if (applet_type == NULL)
return;
......@@ -1042,21 +1049,44 @@ drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type)
drop_menu (panel, pos, NULL);
else
drop_menu (panel, pos, menu);
} else if(strcmp(applet_type,"DRAWER:NEW")==0) {
} else if (strcmp(applet_type,"DRAWER:NEW")==0) {
load_drawer_applet(-1, NULL, NULL, panel, pos, TRUE);
} else if(strcmp(applet_type,"LOGOUT:NEW")==0) {
load_logout_applet(panel, pos, TRUE);
} else if(strcmp(applet_type,"LOCK:NEW")==0) {
load_lock_applet(panel, pos, TRUE);
} else if(strcmp(applet_type,"SWALLOW:ASK")==0) {
} else if (strcmp (applet_type, "LOGOUT:NEW") == 0) {
load_logout_applet (panel, pos, TRUE);
} else if (sscanf (applet_type, "LOGOUT:%d", &applet_num) == 1) {
load_logout_applet (panel, pos, TRUE);
remove_applet = TRUE;
} else if (strcmp (applet_type, "LOCK:NEW") == 0) {
load_lock_applet (panel, pos, TRUE);
} else if (sscanf (applet_type, "LOCK:%d", &applet_num) == 1) {
load_lock_applet (panel, pos, TRUE);
remove_applet = TRUE;
} else if (strcmp (applet_type, "SWALLOW:ASK") == 0) {
ask_about_swallowing(panel, pos, TRUE);
} else if(strcmp(applet_type,"LAUNCHER:ASK")==0) {
ask_about_launcher(NULL, panel, pos, TRUE);
} else if(strcmp(applet_type,"STATUS:TRY")==0) {
load_status_applet(panel, pos, TRUE);
} else if(strcmp(applet_type,"RUN:NEW")==0) {
load_run_applet(panel, pos, TRUE);
}
if (remove_applet &&
action == GDK_ACTION_MOVE) {
AppletInfo *info = g_slist_nth_data (applets, applet_num);
if (info != NULL)
panel_clean_applet (info);
}
}
static void
......@@ -1152,15 +1182,20 @@ drag_motion_cb (GtkWidget *widget,
if ( ! is_this_drop_ok (widget, context, &info, NULL))
return FALSE;
/* always prefer copy, except for internal icons, where we prefer move */
if (info != TARGET_ICON_INTERNAL &&
(context->actions & GDK_ACTION_COPY))
/* always prefer copy, except for internal icons/applets,
* where we prefer move */
if (info == TARGET_ICON_INTERNAL ||
info == TARGET_APPLET_INTERNAL) {
if (context->actions & GDK_ACTION_MOVE) {
gdk_drag_status (context, GDK_ACTION_MOVE, time);
} else {
gdk_drag_status (context, context->suggested_action, time);
}
} else if (context->actions & GDK_ACTION_COPY) {
gdk_drag_status (context, GDK_ACTION_COPY, time);
else if (info == TARGET_ICON_INTERNAL &&
(context->actions & GDK_ACTION_MOVE))
gdk_drag_status (context, GDK_ACTION_MOVE, time);
else
} else {
gdk_drag_status (context, context->suggested_action, time);
}
do_highlight (widget, TRUE);
......@@ -1266,7 +1301,8 @@ drag_data_recieved_cb (GtkWidget *widget,
panel, pos, TRUE, FALSE);
break;
case TARGET_APPLET_INTERNAL:
drop_internal_applet (panel, pos, (char *)selection_data->data);
drop_internal_applet (panel, pos, (char *)selection_data->data,
context->action);
break;
case TARGET_ICON_INTERNAL:
drop_internal_icon (panel, pos, (char *)selection_data->data,
......
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