Commit e3226cf5 authored by George Lebl's avatar George Lebl

tehpanel widget seems to kind of work ... now to make use of it in the

app - George

(BTW: it will now get built and linked with the panel, there is also some
#if 0'ed code to test it in panel_init)
parent 407043ca
...@@ -18,6 +18,8 @@ panel_SOURCES = \ ...@@ -18,6 +18,8 @@ panel_SOURCES = \
main.c \ main.c \
panel.c \ panel.c \
panel.h \ panel.h \
panel-widget.c \
panel-widget.h \
panel_config.c \ panel_config.c \
panel_config.h panel_config.h
......
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "panel-widget.h"
char *possible_drag_types[] = {"application/panel-applet-pointer"}; char *possible_drag_types[] = {"application/panel-applet-pointer"};
char *accepted_drop_types[] = {"application/panel-applet-pointer"}; char *accepted_drop_types[] = {"application/panel-applet-pointer"};
...@@ -92,25 +93,46 @@ panel_widget_dnd_drop (GtkWidget *widget, GdkEvent *event, gpointer user_data) ...@@ -92,25 +93,46 @@ panel_widget_dnd_drop (GtkWidget *widget, GdkEvent *event, gpointer user_data)
panel->applets[from] = panel->applets[to]; panel->applets[from] = panel->applets[to];
panel->applets[to] = tmp; panel->applets[to] = tmp;
panel_widget_place_applet(panel,panel->applets[from],to); panel_widget_place_applet(panel,panel->applets[from],from);
panel_widget_place_applet(panel,panel->applets[to],from); panel_widget_place_applet(panel,panel->applets[to],to);
/*we know that widget is a placeholder and fromdrag is an applet*/
gtk_widget_dnd_drag_set (widget, TRUE, possible_drag_types, 1);
gtk_widget_dnd_drop_set (button, FALSE, accepted_drop_types, 1, FALSE);
} }
void void
panel_widget_dnd_drag_request (GtkWidget *widget, GdkEvent *event) panel_widget_dnd_drag_request (GtkWidget *widget, GdkEvent *event)
{ {
gtk_widget_dnd_data_set (widget, event, &widget, sizeof(GtkWidget *)); gtk_widget_dnd_data_set (widget, event, &widget, sizeof(GtkWidget *));
/*we know that widget is an applet*/
gtk_widget_dnd_drag_set (button, FALSE, possible_drag_types, 1);
gtk_widget_dnd_drop_set (button, TRUE, accepted_drop_types, 1, FALSE);
} }
void
panel_widget_placeholder_realized (GtkWidget *widget,gpointer data)
{
gtk_signal_connect(GTK_OBJECT (widget),
"drag_request_event",
GTK_SIGNAL_FUNC(panel_widget_dnd_drag_request),
data);
gtk_signal_connect(GTK_OBJECT (widget),
"drop_data_available_event",
GTK_SIGNAL_FUNC(panel_widget_dnd_drop),
data);
gtk_widget_dnd_drop_set(widget, TRUE, accepted_drop_types, 1, FALSE);
gtk_widget_dnd_drag_set(widget, FALSE, possible_drag_types, 1);
}
void
panel_widget_applet_realized (GtkWidget *widget,gpointer data)
{
gtk_signal_connect(GTK_OBJECT (widget),
"drag_request_event",
GTK_SIGNAL_FUNC(panel_widget_dnd_drag_request),
data);
gtk_signal_connect(GTK_OBJECT (widget),
"drop_data_available_event",
GTK_SIGNAL_FUNC(panel_widget_dnd_drop),
data);
gtk_widget_dnd_drag_set(widget, TRUE, possible_drag_types, 1);
gtk_widget_dnd_drop_set(widget, FALSE, accepted_drop_types, 1, FALSE);
}
GtkWidget* GtkWidget*
...@@ -121,7 +143,7 @@ panel_widget_new (gint size, PanelOrientation orient) ...@@ -121,7 +143,7 @@ panel_widget_new (gint size, PanelOrientation orient)
g_return_val_if_fail(size>0,NULL); g_return_val_if_fail(size>0,NULL);
g_return_val_if_fail( g_return_val_if_fail(
(orientation==PANEL_HORIZONTAL || orientation==PANEL_VERTICAL), (orient==PANEL_HORIZONTAL || orient==PANEL_VERTICAL),
NULL); NULL);
panel = gtk_type_new(panel_widget_get_type()); panel = gtk_type_new(panel_widget_get_type());
...@@ -131,7 +153,9 @@ panel_widget_new (gint size, PanelOrientation orient) ...@@ -131,7 +153,9 @@ panel_widget_new (gint size, PanelOrientation orient)
else else
panel->table = gtk_table_new(size,1,TRUE); panel->table = gtk_table_new(size,1,TRUE);
gtk_container_add(GTK_CONTAINER(panel),panel->table); gtk_container_add(GTK_CONTAINER(panel),panel->table);
gtk_widget_show(panel->table);
panel->size = size; panel->size = size;
panel->orientation = orient; panel->orientation = orient;
...@@ -139,25 +163,15 @@ panel_widget_new (gint size, PanelOrientation orient) ...@@ -139,25 +163,15 @@ panel_widget_new (gint size, PanelOrientation orient)
panel->applets = g_new(AppletRecord *,size); panel->applets = g_new(AppletRecord *,size);
for(i=0;i<size;i++) { for(i=0;i<size;i++) {
panel->applets[i] = g_new(AppletRecord,1); panel->applets[i] = g_new(AppletRecord,1);
panel->applets[i]->widget = gtk_event_box(); panel->applets[i]->widget = gtk_event_box_new();
panel->applets[i]->is_applet = FALSE; panel->applets[i]->is_applet = FALSE;
panel_widget_place_applet(panel,panel->applets[i],i); panel_widget_place_applet(panel,panel->applets[i],i);
/*widget needs to be resized*/ gtk_signal_connect_after(GTK_OBJECT(panel->applets[i]->widget),
gtk_widget_realize(panel->applets[i]->widget); "realize",
gtk_signal_connect(GTK_OBJECT (panel->applets[i]->widget), (GtkSignalFunc)
"drag_request_event", panel_widget_placeholder_realized,
GTK_SIGNAL_FUNC(panel_widget_dnd_drag_request), panel);
panel);
gtk_signal_connect(GTK_OBJECT (panel->applets[i]->widget),
"drop_data_available_event",
GTK_SIGNAL_FUNC(panel_widget_dnd_drop),
panel);
gtk_widget_dnd_drop_set(panel->applets[i]->widget, TRUE,
accepted_drop_types, 1, FALSE);
gtk_widget_dnd_drag_set(panel->applets[i]->widget, FALSE,
possible_drag_types, 1);
gtk_widget_show(panel->applets[i]->widget); gtk_widget_show(panel->applets[i]->widget);
} }
...@@ -169,7 +183,6 @@ gint ...@@ -169,7 +183,6 @@ gint
panel_widget_add (PanelWidget *panel, GtkWidget *applet, gint pos) panel_widget_add (PanelWidget *panel, GtkWidget *applet, gint pos)
{ {
gint i; gint i;
gtk_widget_dnd_drag_set (w, TRUE, possible_drag_types, 1);
g_return_val_if_fail(panel,-1); g_return_val_if_fail(panel,-1);
g_return_val_if_fail(applet,-1); g_return_val_if_fail(applet,-1);
...@@ -201,8 +214,26 @@ panel_widget_add (PanelWidget *panel, GtkWidget *applet, gint pos) ...@@ -201,8 +214,26 @@ panel_widget_add (PanelWidget *panel, GtkWidget *applet, gint pos)
panel->applets[i]->is_applet = TRUE; panel->applets[i]->is_applet = TRUE;
panel_widget_place_applet(panel,panel->applets[i],i); panel_widget_place_applet(panel,panel->applets[i],i);
gtk_widget_dnd_drag_set(applet, TRUE, possible_drag_types, 1);
gtk_widget_dnd_drop_set(applet, FALSE, possible_drag_types, 1); if(GTK_WIDGET_REALIZED(GTK_WIDGET(applet))) {
gtk_signal_connect(GTK_OBJECT (applet), "drag_request_event",
GTK_SIGNAL_FUNC(
panel_widget_dnd_drag_request),
panel);
gtk_signal_connect(GTK_OBJECT (applet),
"drop_data_available_event",
GTK_SIGNAL_FUNC(panel_widget_dnd_drop),
panel);
gtk_widget_dnd_drag_set(applet, TRUE, possible_drag_types, 1);
gtk_widget_dnd_drop_set(applet, FALSE, accepted_drop_types, 1,
FALSE);
} else {
gtk_signal_connect_after(GTK_OBJECT(applet), "realize",
(GtkSignalFunc)
panel_widget_applet_realized,
panel);
}
return i; return i;
} }
...@@ -229,14 +260,16 @@ panel_widget_remove (PanelWidget *panel, GtkWidget *applet) ...@@ -229,14 +260,16 @@ panel_widget_remove (PanelWidget *panel, GtkWidget *applet)
gtk_widget_destroy(panel->applets[i]->widget); gtk_widget_destroy(panel->applets[i]->widget);
/*put placeholder in place*/ /*put placeholder in place*/
panel->applets[i]->widget = gtk_event_box(); panel->applets[i]->widget = gtk_event_box_new();
panel->applets[i]->is_applet = FALSE; panel->applets[i]->is_applet = FALSE;
panel_widget_place_applet(panel,panel->applets[i],i); panel_widget_place_applet(panel,panel->applets[i],i);
gtk_widget_show(panel->applets[i]->widget); gtk_widget_show(panel->applets[i]->widget);
gtk_widget_dnd_drag_set(applet, FALSE, possible_drag_types, 1); gtk_signal_connect_after(GTK_OBJECT(panel->applets[i]->widget),
gtk_widget_dnd_drop_set(applet, TRUE, possible_drag_types, 1); "realize",
(GtkSignalFunc)
panel_widget_placeholder_realized,
panel);
return i; return i;
} }
...@@ -279,8 +312,8 @@ panel_widget_foreach(PanelWidget *panel, GFunc func, gpointer user_data) ...@@ -279,8 +312,8 @@ panel_widget_foreach(PanelWidget *panel, GFunc func, gpointer user_data)
{ {
gint i; gint i;
g_return_val_if_fail(panel,NULL); g_return_if_fail(panel);
g_return_val_if_fail(func,NULL); g_return_if_fail(func);
for(i=0;i<panel->size;i++) for(i=0;i<panel->size;i++)
if(panel->applets[i]->widget != NULL) if(panel->applets[i]->widget != NULL)
......
...@@ -40,7 +40,7 @@ struct _PanelWidget ...@@ -40,7 +40,7 @@ struct _PanelWidget
AppletRecord **applets; AppletRecord **applets;
gint applet_count; gint applet_count;
GtkTable *table; GtkWidget *table;
gint size; gint size;
PanelOrientation orientation; PanelOrientation orientation;
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#include <config.h> #include <config.h>
#include <string.h> #include <string.h>
#include "gnome.h" #include "gnome.h"
#include "panel-widget.h"
#include "applet_files.h" #include "applet_files.h"
#include "gdkextra.h" #include "gdkextra.h"
#include "panel_cmds.h" #include "panel_cmds.h"
...@@ -1359,11 +1362,37 @@ get_applet_types(void) ...@@ -1359,11 +1362,37 @@ get_applet_types(void)
void void
panel_init(void) panel_init(void)
{ {
#if 0
GtkWidget *window;
GtkWidget *panel;
GtkWidget *button;
#endif
GtkWidget *pixmap; GtkWidget *pixmap;
char *pixmap_name; char *pixmap_name;
char buf[256]; char buf[256];
int i; int i;
#if 0
window = gtk_window_new(GTK_WINDOW_POPUP);
panel = panel_widget_new(20,PANEL_HORIZONTAL);
gtk_container_add(GTK_CONTAINER(window),panel);
gtk_widget_show(panel);
gtk_widget_set_uposition(window, 50, 50);
gtk_widget_set_usize(window, 20*50,50);
button = gtk_button_new_with_label("TEST");
panel_widget_add(PANEL_WIDGET(panel),button,1);
gtk_widget_show(button);
button = gtk_button_new_with_label("TEST2");
panel_widget_add(PANEL_WIDGET(panel),button,8);
gtk_widget_show(button);
gtk_widget_show(window);
#endif
the_panel = g_new(PanelMain, 1); the_panel = g_new(PanelMain, 1);
the_panel->panel = g_new(Panel, 1); the_panel->panel = g_new(Panel, 1);
......
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