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

external (corba) applets will move now

Sat Feb 21 17:08:23 1998  George Lebl  <jirka@5z.com>

        * gnome-panel.idl, panel.c mico-glue.cc,applet-lib.cc
          panel-widget.c: external (corba) applets will move now
parent 990b1b11
Sat Feb 21 17:08:23 1998 George Lebl <jirka@5z.com>
* gnome-panel.idl, panel.c mico-glue.cc,applet-lib.cc
panel-widget.c: external (corba) applets will move now
Sat Feb 21 16:48:35 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* panel.c: Simple stub routine that demostrates calling a CORBA
......
Sat Feb 21 17:08:23 1998 George Lebl <jirka@5z.com>
* gnome-panel.idl, panel.c mico-glue.cc,applet-lib.cc
panel-widget.c: external (corba) applets will move now
Sat Feb 21 16:48:35 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* panel.c: Simple stub routine that demostrates calling a CORBA
......
......@@ -5,6 +5,8 @@
static void applet_widget_class_init (AppletWidgetClass *klass);
static void applet_widget_init (AppletWidget *applet_widget);
static GdkCursor *fleur_cursor;
guint
applet_widget_get_type ()
{
......@@ -43,6 +45,9 @@ applet_widget_init (AppletWidget *applet_widget)
gtk_container_add(GTK_CONTAINER(applet_widget),applet_widget->eb);
gtk_window_set_policy (GTK_WINDOW (applet_widget), 1, 1, 1);
if(!fleur_cursor)
fleur_cursor = gdk_cursor_new(GDK_FLEUR);
}
GtkWidget*
......@@ -72,3 +77,27 @@ applet_widget_remove (AppletWidget *applet, GtkWidget *widget)
gtk_container_remove(GTK_CONTAINER(applet->eb),widget);
}
#define APPLET_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK)
void
applet_widget_move_grab_add (AppletWidget *applet)
{
gtk_grab_add(GTK_WIDGET(applet));
gdk_pointer_grab(GTK_WIDGET(applet)->window,
TRUE,
APPLET_EVENT_MASK,
NULL,
fleur_cursor,
GDK_CURRENT_TIME);
}
void
applet_widget_move_grab_remove (AppletWidget *applet)
{
gdk_pointer_ungrab(GDK_CURRENT_TIME);
gtk_grab_remove(GTK_WIDGET(applet));
}
......@@ -36,6 +36,9 @@ void applet_widget_add (AppletWidget *applet,
/*remove a widget from the applet*/
void applet_widget_remove (AppletWidget *applet,
GtkWidget *widget);
void applet_widget_move_grab_add (AppletWidget *applet);
void applet_widget_move_grab_remove (AppletWidget *applet);
#ifdef __cplusplus
}
......
......@@ -43,13 +43,19 @@ public:
return ::applet_get_pos (id);
}
void applet_moved_to (CORBA::Short id,
CORBA::Short x,
CORBA::Short y) {
printf ("APPLET_MOVED_TO!\n");
void applet_drag_start (CORBA::Short id) {
printf ("APPLET_DRAG_START!\n");
::applet_drag_start (id);
}
void applet_drag_stop (CORBA::Short id) {
printf ("APPLET_DRAG_STOP!\n");
::applet_drag_stop (id);
}
void applet_remove_from_panel (CORBA::Short id) {
printf ("APPLET_REMOVE_FROM_PANEL!\n");
/*FIXME: */
}
};
......
......@@ -1113,11 +1113,23 @@ panel_widget_new (gint size,
}
void
panel_widget_applet_drag_start(PanelWidget *panel, GtkWidget *applet)
panel_widget_applet_drag_start_no_grab(PanelWidget *panel, GtkWidget *applet)
{
panel->currently_dragged_applet = applet;
panel->currently_dragged_applet_pos =
panel_widget_get_pos(panel,applet);
}
void
panel_widget_applet_drag_end_no_grab(PanelWidget *panel)
{
panel->currently_dragged_applet = NULL;
}
void
panel_widget_applet_drag_start(PanelWidget *panel, GtkWidget *applet)
{
panel_widget_applet_drag_start_no_grab(panel,applet);
/*if (warp)
gdk_pointer_warp(NULL, applet->window,
......@@ -1139,9 +1151,47 @@ panel_widget_applet_drag_end(PanelWidget *panel)
{
gdk_pointer_ungrab(GDK_CURRENT_TIME);
gtk_grab_remove(panel->currently_dragged_applet);
panel->currently_dragged_applet = NULL;
panel_widget_applet_drag_end_no_grab(panel);
}
int
panel_widget_applet_move_to_cursor(PanelWidget *panel)
{
if (panel->currently_dragged_applet) {
gint x,y;
gint moveby;
gint pos = panel->currently_dragged_applet_pos;
gtk_widget_get_pointer(panel->fixed, &x, &y);
printf("%d %d\n",x,y);
if(panel->orient == PANEL_HORIZONTAL)
moveby = (x/PANEL_CELL_SIZE)- pos;
else
moveby = (y/PANEL_CELL_SIZE)- pos;
panel->currently_dragged_applet_pos =
panel_widget_switch_move(panel, pos, moveby);
return TRUE;
}
return FALSE;
}
static gint
move_timeout_handler(gpointer data)
{
return panel_widget_applet_move_to_cursor(PANEL_WIDGET(data));
}
void
panel_widget_applet_move_use_idle(PanelWidget *panel)
{
gtk_timeout_add (30,move_timeout_handler,panel);
}
static gint
panel_widget_applet_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
......@@ -1175,24 +1225,7 @@ panel_widget_applet_event(GtkWidget *widget, GdkEvent *event, gpointer data)
break;
case GDK_MOTION_NOTIFY:
if (panel->currently_dragged_applet) {
gint x,y;
gint moveby;
gint pos = panel->currently_dragged_applet_pos;
gtk_widget_get_pointer(panel->fixed, &x, &y);
if(panel->orient == PANEL_HORIZONTAL)
moveby = (x/PANEL_CELL_SIZE)- pos;
else
moveby = (y/PANEL_CELL_SIZE)- pos;
panel->currently_dragged_applet_pos =
panel_widget_switch_move(panel, pos,
moveby);
return TRUE;
}
break;
return panel_widget_applet_move_to_cursor(panel);
default:
break;
......
......@@ -144,6 +144,13 @@ void panel_widget_foreach (PanelWidget *panel,
void panel_widget_applet_drag_start (PanelWidget *panel,
GtkWidget *applet);
/*needed for corba*/
void panel_widget_applet_drag_start_no_grab(PanelWidget *panel,
GtkWidget *applet);
void panel_widget_applet_drag_end_no_grab(PanelWidget *panel);
int panel_widget_applet_move_to_cursor(PanelWidget *panel);
void panel_widget_applet_move_use_idle(PanelWidget *panel);
/*changing parameters*/
void panel_widget_change_params (PanelWidget *panel,
PanelOrientation orient,
......
......@@ -31,6 +31,7 @@ static menu_count=0; /*how many "menu" applets we have ....*/
GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK)
/*FIXME: THESE CANNOT REALLY BE LINKED LISTS!! THEY SHOULD BE ARRAYS*/
extern GList *panels;
extern GList *applets;
......@@ -500,6 +501,26 @@ applet_get_pos(int id)
return 0;
}
void
applet_drag_start(int id)
{
AppletInfo *info = g_list_nth(applets,id)->data;
PanelWidget *panel = find_applet_panel(info->widget);
panel_widget_applet_drag_start_no_grab(panel,info->widget);
panel_widget_applet_move_use_idle(panel);
}
void
applet_drag_stop(int id)
{
AppletInfo *info = g_list_nth(applets,id)->data;
PanelWidget *panel = find_applet_panel(info->widget);
panel_widget_applet_drag_end_no_grab(panel);
}
/*int
applet_button_press_event(int id, int button)
{
......
......@@ -83,8 +83,11 @@ void apply_global_config(void);
int reparent_window_id (unsigned long id, int panel, int pos);
/*stuff for corba*/
int applet_get_panel(int id);
int applet_get_pos(int id);
void applet_drag_start(int id);
void applet_drag_stop(int id);
/*this is in main.c*/
......
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