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 = \
main.c \
panel.c \
panel.h \
panel-widget.c \
panel-widget.h \
panel_config.c \
panel_config.h
......
#include <gtk/gtk.h>
#include "panel-widget.h"
char *possible_drag_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)
panel->applets[from] = panel->applets[to];
panel->applets[to] = tmp;
panel_widget_place_applet(panel,panel->applets[from],to);
panel_widget_place_applet(panel,panel->applets[to],from);
/*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);
panel_widget_place_applet(panel,panel->applets[from],from);
panel_widget_place_applet(panel,panel->applets[to],to);
}
void
panel_widget_dnd_drag_request (GtkWidget *widget, GdkEvent *event)
{
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*
......@@ -121,7 +143,7 @@ panel_widget_new (gint size, PanelOrientation orient)
g_return_val_if_fail(size>0,NULL);
g_return_val_if_fail(
(orientation==PANEL_HORIZONTAL || orientation==PANEL_VERTICAL),
(orient==PANEL_HORIZONTAL || orient==PANEL_VERTICAL),
NULL);
panel = gtk_type_new(panel_widget_get_type());
......@@ -131,7 +153,9 @@ panel_widget_new (gint size, PanelOrientation orient)
else
panel->table = gtk_table_new(size,1,TRUE);
gtk_container_add(GTK_CONTAINER(panel),panel->table);
gtk_widget_show(panel->table);
panel->size = size;
panel->orientation = orient;
......@@ -139,25 +163,15 @@ panel_widget_new (gint size, PanelOrientation orient)
panel->applets = g_new(AppletRecord *,size);
for(i=0;i<size;i++) {
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_widget_place_applet(panel,panel->applets[i],i);
/*widget needs to be resized*/
gtk_widget_realize(panel->applets[i]->widget);
gtk_signal_connect(GTK_OBJECT (panel->applets[i]->widget),
"drag_request_event",
GTK_SIGNAL_FUNC(panel_widget_dnd_drag_request),
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_signal_connect_after(GTK_OBJECT(panel->applets[i]->widget),
"realize",
(GtkSignalFunc)
panel_widget_placeholder_realized,
panel);
gtk_widget_show(panel->applets[i]->widget);
}
......@@ -169,7 +183,6 @@ gint
panel_widget_add (PanelWidget *panel, GtkWidget *applet, gint pos)
{
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(applet,-1);
......@@ -201,8 +214,26 @@ panel_widget_add (PanelWidget *panel, GtkWidget *applet, gint pos)
panel->applets[i]->is_applet = TRUE;
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;
}
......@@ -229,14 +260,16 @@ panel_widget_remove (PanelWidget *panel, GtkWidget *applet)
gtk_widget_destroy(panel->applets[i]->widget);
/*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_widget_place_applet(panel,panel->applets[i],i);
gtk_widget_show(panel->applets[i]->widget);
gtk_widget_dnd_drag_set(applet, FALSE, possible_drag_types, 1);
gtk_widget_dnd_drop_set(applet, TRUE, possible_drag_types, 1);
gtk_signal_connect_after(GTK_OBJECT(panel->applets[i]->widget),
"realize",
(GtkSignalFunc)
panel_widget_placeholder_realized,
panel);
return i;
}
......@@ -279,8 +312,8 @@ panel_widget_foreach(PanelWidget *panel, GFunc func, gpointer user_data)
{
gint i;
g_return_val_if_fail(panel,NULL);
g_return_val_if_fail(func,NULL);
g_return_if_fail(panel);
g_return_if_fail(func);
for(i=0;i<panel->size;i++)
if(panel->applets[i]->widget != NULL)
......
......@@ -40,7 +40,7 @@ struct _PanelWidget
AppletRecord **applets;
gint applet_count;
GtkTable *table;
GtkWidget *table;
gint size;
PanelOrientation orientation;
......
......@@ -8,6 +8,9 @@
#include <config.h>
#include <string.h>
#include "gnome.h"
#include "panel-widget.h"
#include "applet_files.h"
#include "gdkextra.h"
#include "panel_cmds.h"
......@@ -1359,11 +1362,37 @@ get_applet_types(void)
void
panel_init(void)
{
#if 0
GtkWidget *window;
GtkWidget *panel;
GtkWidget *button;
#endif
GtkWidget *pixmap;
char *pixmap_name;
char buf[256];
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->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