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

added support for no_window widgets, not fully but it's something, I don't

Sat Aug 01 01:20:56 1998  George Lebl  <jirka@5z.com>

        * panel-widget.[ch]: added support for no_window widgets, not fully
          but it's something, I don't currently use it however

        * drawer.c,launcher.c,menu.c,panel.c,applet.c: got rid of a lot
          of redundant eventboxing and the internal applets (except for
          logout which shall follow) are now just gnome pixmaps, and the
          click event is simulated. this adds good basis for the backing tile
          support, plus it greatly increases performance especially when
          dealing with very large drawer structures (there is 1/3rd the
          windows to worry about)

        * session.c: tweaked the session saving/loading to maximize performance
          ... however there now isn't backward compatibility so everyone needs
          to delete his panel.d dir

        * panel-widget.c: minor fix for adding applets
parent 6f31e842
Sat Aug 01 01:20:56 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch]: added support for no_window widgets, not fully
but it's something, I don't currently use it however
* drawer.c,launcher.c,menu.c,panel.c,applet.c: got rid of a lot
of redundant eventboxing and the internal applets (except for
logout which shall follow) are now just gnome pixmaps, and the
click event is simulated. this adds good basis for the backing tile
support, plus it greatly increases performance especially when
dealing with very large drawer structures (there is 1/3rd the
windows to worry about)
* session.c: tweaked the session saving/loading to maximize performance
... however there now isn't backward compatibility so everyone needs
to delete his panel.d dir
* panel-widget.c: minor fix for adding applets
Fri Jul 31 18:58:12 1998 George Lebl <jirka@5z.com>
* *.c: minor cleanups after -Wall compilation
......
Sat Aug 01 01:20:56 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch]: added support for no_window widgets, not fully
but it's something, I don't currently use it however
* drawer.c,launcher.c,menu.c,panel.c,applet.c: got rid of a lot
of redundant eventboxing and the internal applets (except for
logout which shall follow) are now just gnome pixmaps, and the
click event is simulated. this adds good basis for the backing tile
support, plus it greatly increases performance especially when
dealing with very large drawer structures (there is 1/3rd the
windows to worry about)
* session.c: tweaked the session saving/loading to maximize performance
... however there now isn't backward compatibility so everyone needs
to delete his panel.d dir
* panel-widget.c: minor fix for adding applets
Fri Jul 31 18:58:12 1998 George Lebl <jirka@5z.com>
* *.c: minor cleanups after -Wall compilation
......
......@@ -506,14 +506,22 @@ register_toy(GtkWidget *applet,
g_return_val_if_fail(applet != NULL, FALSE);
g_return_val_if_fail(panel != NULL, FALSE);
/* We wrap the applet in a GtkEventBox so that we can capture
events over it */
eventbox = gtk_event_box_new();
gtk_widget_set_events(eventbox, (gtk_widget_get_events(eventbox) |
APPLET_EVENT_MASK) &
~( GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK));
gtk_container_add(GTK_CONTAINER(eventbox), applet);
if(GTK_WIDGET_NO_WINDOW(applet) || GTK_IS_SOCKET(applet)) {
/* We wrap the applet in a GtkEventBox so that we can capture
events over it */
eventbox = gtk_event_box_new();
gtk_widget_set_events(eventbox, (gtk_widget_get_events(eventbox) |
APPLET_EVENT_MASK) &
~( GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK));
gtk_container_add(GTK_CONTAINER(eventbox), applet);
} else {
gtk_widget_set_events(applet, (gtk_widget_get_events(applet) |
APPLET_EVENT_MASK) &
~( GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK));
eventbox = applet;
}
info.applet_id = applet_count;
info.type = type;
......@@ -523,8 +531,8 @@ register_toy(GtkWidget *applet,
info.data = data;
info.user_menu = NULL;
gtk_object_set_user_data(GTK_OBJECT(eventbox),
GINT_TO_POINTER(applet_count));
gtk_object_set_data(GTK_OBJECT(eventbox),"applet_id",
GINT_TO_POINTER(applet_count));
if(type == APPLET_DRAWER) {
Drawer *drawer = data;
......
......@@ -24,7 +24,6 @@ extern int applet_count;
extern GlobalConfig global_config;
extern GtkTooltips *panel_tooltips;
static char *default_drawer_pixmap=NULL;
extern GList *panel_list;
......@@ -32,7 +31,6 @@ static void
properties_apply_callback(GtkWidget *widget, int page, gpointer data)
{
Drawer *drawer = data;
GtkWidget *pixmap;
GtkWidget *pixentry = gtk_object_get_data(GTK_OBJECT(widget),
"pixmap");
GtkWidget *tipentry = gtk_object_get_data(GTK_OBJECT(widget),
......@@ -58,28 +56,13 @@ properties_apply_callback(GtkWidget *widget, int page, gpointer data)
else
drawer->tooltip = g_strdup(s);
gtk_tooltips_set_tip (panel_tooltips,drawer->button->parent,
gtk_tooltips_set_tip (panel_tooltips,drawer->button,
drawer->tooltip,NULL);
pixmap=GTK_BUTTON(drawer->button)->child;
gtk_container_remove(GTK_CONTAINER(drawer->button),pixmap);
pixmap = gnome_pixmap_new_from_file (drawer->pixmap);
if (!pixmap) {
if (default_drawer_pixmap)
pixmap = gnome_pixmap_new_from_file (default_drawer_pixmap);
else
pixmap = gtk_label_new (_("Drawer"));
}
gtk_container_add (GTK_CONTAINER(drawer->button), pixmap);
gtk_widget_show(pixmap);
/*FIXME: a bad hack to keep it all 48x48*/
gtk_widget_set_usize (drawer->button, 48, 48);
/*gtk_widget_set_usize (prop->launcher->button, pixmap->requisition.width,
pixmap->requisition.height);*/
/*it also might be a button/label (in the future)*/
if(GNOME_IS_PIXMAP(drawer->button))
gnome_pixmap_load_file (GNOME_PIXMAP(drawer->button),
drawer->pixmap);
}
static int
......@@ -163,7 +146,7 @@ reposition_drawer(Drawer *drawer)
/*get's the panel data from the event box that is the applet's
parent*/
panel = gtk_object_get_data(GTK_OBJECT(drawer->button->parent),
panel = gtk_object_get_data(GTK_OBJECT(drawer->button),
PANEL_APPLET_PARENT_KEY);
gdk_window_get_origin (drawer->button->window, &bx, &by);
......@@ -197,18 +180,59 @@ reposition_drawer(Drawer *drawer)
drawer_widget_set_pos(DRAWER_WIDGET(drawer->drawer),x,y);
}
static int
drawer_click(GtkWidget *widget, gpointer data)
static void
drawer_click(Drawer *drawer)
{
Drawer *drawer = data;
DrawerWidget *drawerw = DRAWER_WIDGET(drawer->drawer);
PanelWidget *parent =
gtk_object_get_data(GTK_OBJECT(drawer->button),
PANEL_APPLET_PARENT_KEY);
GtkWidget *panelw = gtk_object_get_data(GTK_OBJECT(parent),
PANEL_PARENT);
reposition_drawer(drawer);
if(DRAWER_WIDGET(drawer->drawer)->state == DRAWER_SHOWN)
if(drawerw->state == DRAWER_SHOWN) {
drawer_widget_close_drawer(DRAWER_WIDGET(drawer->drawer));
else
if(IS_SNAPPED_WIDGET(panelw))
SNAPPED_WIDGET(panelw)->drawers_open++;
} else {
drawer_widget_open_drawer(DRAWER_WIDGET(drawer->drawer));
return TRUE;
if(IS_SNAPPED_WIDGET(panelw))
SNAPPED_WIDGET(panelw)->drawers_open--;
}
}
static int
drawer_event (GtkWidget *widget, GdkEvent *event, void *data)
{
static int in_button = FALSE;
Drawer *drawer = data;
GdkEventButton *bevent = (GdkEventButton *)event;
/*this is a release after a press inside a button*/
if(event->type == GDK_BUTTON_RELEASE && in_button) {
in_button = FALSE;
gtk_grab_remove(widget);
/*if it's inside it's a click*/
if(bevent->x >= 0 &&
bevent->x < widget->allocation.width &&
bevent->y >= 0 &&
bevent->y < widget->allocation.height)
drawer_click (drawer);
return TRUE;
/*if it's inside and press, set in_button*/
} else if(event->type == GDK_BUTTON_PRESS &&
bevent->button == 1 &&
bevent->x >= 0 &&
bevent->x < widget->allocation.width &&
bevent->y >= 0 &&
bevent->y < widget->allocation.height) {
gtk_grab_add(widget);
in_button = TRUE;
return TRUE;
}
return FALSE;
}
static int
......@@ -232,14 +256,10 @@ static Drawer *
create_drawer_applet(GtkWidget * drawer_panel, char *tooltip, char *pixmap,
PanelOrientType orient)
{
GtkWidget *pix;
Drawer *drawer;
drawer = g_new(Drawer,1);
if (!default_drawer_pixmap)
default_drawer_pixmap = gnome_pixmap_file ("panel-drawer.png");
if(!tooltip ||
!*tooltip)
drawer->tooltip = NULL;
......@@ -252,7 +272,7 @@ create_drawer_applet(GtkWidget * drawer_panel, char *tooltip, char *pixmap,
else
drawer->pixmap = g_strdup(pixmap);
/*well ... I think we should just drop this*/
/*we need to overlay the arrow*/
/*switch(orient) {
case ORIENT_DOWN:
pixmap_name = gnome_unconditional_pixmap_file ("gnome-menu-down.png");
......@@ -270,32 +290,20 @@ create_drawer_applet(GtkWidget * drawer_panel, char *tooltip, char *pixmap,
drawer->orient = orient;
/* main button */
drawer->button = gtk_button_new ();
/*make the pixmap*/
pix = gnome_pixmap_new_from_file (drawer->pixmap);
if (!pix) {
if (default_drawer_pixmap)
pix = gnome_pixmap_new_from_file (default_drawer_pixmap);
else
pix = gtk_label_new (_("Drawer"));
}
gtk_widget_show(pix);
/*FIXME:this is not right, but it's how we can get the buttons to
be 48x48 (given the icons are 48x48)*/
gtk_widget_set_usize (drawer->button,48,48);
/*gtk_widget_set_usize (drawer->button, pixmap->requisition.width,
pixmap->requisition.height);*/
/* put pixmap in button */
gtk_container_add (GTK_CONTAINER(drawer->button), pix);
gtk_widget_show (drawer->button);
drawer->button = gnome_pixmap_new_from_file (drawer->pixmap);
gtk_widget_set_events(drawer->button,
gtk_widget_get_events(drawer->button) |
GDK_LEAVE_NOTIFY_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
gtk_widget_show(drawer->button);
drawer->drawer = drawer_panel;
gtk_signal_connect (GTK_OBJECT (drawer->button), "clicked",
GTK_SIGNAL_FUNC (drawer_click), drawer);
gtk_signal_connect (GTK_OBJECT (drawer->button), "event",
GTK_SIGNAL_FUNC (drawer_event), drawer);
gtk_signal_connect (GTK_OBJECT (drawer->button), "destroy",
GTK_SIGNAL_FUNC (destroy_drawer), drawer);
gtk_signal_connect (GTK_OBJECT (drawer->button), "enter_notify_event",
......@@ -395,25 +403,6 @@ set_drawer_applet_orient(Drawer *drawer, PanelOrientType orient)
g_free(pixmap_name);*/
}
static void
monitor_drawers(GtkWidget *w, PanelWidget *panel)
{
DrawerWidget *drawer = gtk_object_get_data(GTK_OBJECT(panel),
PANEL_PARENT);
PanelWidget *parent =
gtk_object_get_data(GTK_OBJECT(panel->master_widget),
PANEL_APPLET_PARENT_KEY);
GtkWidget *panelw = gtk_object_get_data(GTK_OBJECT(parent),
PANEL_PARENT);
if(IS_SNAPPED_WIDGET(panelw)) {
if(drawer->state==DRAWER_SHOWN)
SNAPPED_WIDGET(panelw)->drawers_open++;
else
SNAPPED_WIDGET(panelw)->drawers_open--;
}
}
static void
drawer_realize_cb(GtkWidget *button, Drawer *drawer)
{
......@@ -430,7 +419,7 @@ drawer_realize_cb(GtkWidget *button, Drawer *drawer)
static void
drawer_move_foreach(gpointer data, gpointer user_data)
{
int applet_id = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(data)));
int applet_id = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(data),"applet_id"));
AppletInfo *info = get_applet_info(applet_id);
if(info->type == APPLET_DRAWER) {
......@@ -456,7 +445,6 @@ load_drawer_applet(char *params, char *pixmap, char *tooltip,
int pos, PanelWidget *panel)
{
Drawer *drawer;
PanelWidget *dr_panel;
if(!params) {
drawer = create_empty_drawer_applet(tooltip,pixmap,
......@@ -481,17 +469,10 @@ load_drawer_applet(char *params, char *pixmap, char *tooltip,
register_toy(drawer->button,drawer, pos, panel, APPLET_DRAWER);
/*the panel of the drawer*/
dr_panel = PANEL_WIDGET(DRAWER_WIDGET(drawer->drawer)->panel);
/*slight quick hack*/
gtk_signal_connect_after(GTK_OBJECT(drawer->button->parent),
gtk_signal_connect_after(GTK_OBJECT(drawer->button),
"size_allocate",
GTK_SIGNAL_FUNC(button_size_alloc),
drawer);
gtk_signal_connect(GTK_OBJECT(drawer->button), "clicked",
GTK_SIGNAL_FUNC(monitor_drawers),
dr_panel);
if(DRAWER_WIDGET(drawer->drawer)->state == DRAWER_SHOWN) {
GtkWidget *wpanel;
......@@ -507,7 +488,7 @@ load_drawer_applet(char *params, char *pixmap, char *tooltip,
panel_widget_add_forbidden(PANEL_WIDGET(DRAWER_WIDGET(drawer->drawer)->panel));
gtk_tooltips_set_tip (panel_tooltips,drawer->button->parent,
gtk_tooltips_set_tip (panel_tooltips,drawer->button,
drawer->tooltip,NULL);
if(GTK_WIDGET_REALIZED(drawer->button)) {
reposition_drawer(drawer);
......
......@@ -27,18 +27,43 @@ static char *default_app_pixmap=NULL;
extern PanelWidget *current_panel;
static void
launch (GtkWidget *widget, void *data)
static int
launch (GtkWidget *widget, GdkEvent *event, void *data)
{
static int in_button = FALSE;
GnomeDesktopEntry *item = data;
gnome_desktop_entry_launch (item);
GdkEventButton *bevent = (GdkEventButton *)event;
/*this is a release after a press inside a button*/
if(event->type == GDK_BUTTON_RELEASE && in_button) {
in_button = FALSE;
gtk_grab_remove(widget);
/*if it's inside it's a click*/
if(bevent->x >= 0 &&
bevent->x < widget->allocation.width &&
bevent->y >= 0 &&
bevent->y < widget->allocation.height)
gnome_desktop_entry_launch (item);
return TRUE;
/*if it's inside and press, set in_button*/
} else if(event->type == GDK_BUTTON_PRESS &&
bevent->button == 1 &&
bevent->x >= 0 &&
bevent->x < widget->allocation.width &&
bevent->y >= 0 &&
bevent->y < widget->allocation.height) {
gtk_grab_add(widget);
in_button = TRUE;
return TRUE;
}
return FALSE;
}
Launcher *
create_launcher (char *parameters, GnomeDesktopEntry *dentry)
{
GtkWidget *pixmap;
char *icon;
Launcher *launcher;
......@@ -74,9 +99,8 @@ create_launcher (char *parameters, GnomeDesktopEntry *dentry)
launcher = g_new(Launcher,1);
launcher->button = gtk_button_new ();
launcher->button = NULL;
launcher->dedit = NULL;
pixmap = NULL;
icon = dentry->icon;
if (icon && *icon) {
/* Sigh, now we need to make them local to the gnome install */
......@@ -84,27 +108,25 @@ create_launcher (char *parameters, GnomeDesktopEntry *dentry)
dentry->icon = gnome_pixmap_file (icon);
g_free (icon);
}
pixmap = gnome_pixmap_new_from_file (dentry->icon);
launcher->button = gnome_pixmap_new_from_file (dentry->icon);
}
if (!pixmap) {
if (!launcher->button) {
if (default_app_pixmap)
pixmap = gnome_pixmap_new_from_file(default_app_pixmap);
launcher->button = gnome_pixmap_new_from_file(default_app_pixmap);
else
pixmap = gtk_label_new (_("App"));
launcher->button = gtk_button_new_with_label (_("App"));
}
gtk_container_add (GTK_CONTAINER(launcher->button), pixmap);
gtk_widget_show (pixmap);
/*gtk_widget_set_usize (launcher->button, pixmap->requisition.width,
pixmap->requisition.height);*/
/*FIXME: we'll do this better alter, but this makes it look fine with
normal icons*/
gtk_widget_set_usize (launcher->button, 48, 48);
gtk_widget_set_events(launcher->button,
gtk_widget_get_events(launcher->button) |
GDK_LEAVE_NOTIFY_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
gtk_widget_show (launcher->button);
launcher->signal_click_tag =
gtk_signal_connect (GTK_OBJECT(launcher->button),
"clicked",
"event",
(GtkSignalFunc) launch,
dentry);
......@@ -124,7 +146,6 @@ static void
properties_apply_callback(GtkWidget *widget, int page, gpointer data)
{
Launcher *launcher = data;
GtkWidget *pixmap;
char *icon;
if (page != -1)
......@@ -134,42 +155,34 @@ properties_apply_callback(GtkWidget *widget, int page, gpointer data)
launcher->dentry =
gnome_dentry_get_dentry(GNOME_DENTRY_EDIT(launcher->dedit));
gtk_tooltips_set_tip (panel_tooltips,launcher->button->parent,
gtk_tooltips_set_tip (panel_tooltips,launcher->button,
launcher->dentry->comment,NULL);
pixmap=GTK_BUTTON(launcher->button)->child;
gtk_container_remove(GTK_CONTAINER(launcher->button),pixmap);
icon = launcher->dentry->icon;
if (icon && *icon) {
/* Sigh, now we need to make them local to the gnome install */
if (*icon != '/') {
launcher->dentry->icon = gnome_pixmap_file (icon);
g_free (icon);
/*it also might be a button*/
if(GNOME_IS_PIXMAP(launcher->button)) {
icon = launcher->dentry->icon;
if (icon && *icon) {
/* Sigh, now we need to make them local to the gnome
install */
if (*icon != '/') {
launcher->dentry->icon = gnome_pixmap_file (icon);
g_free (icon);
}
gnome_pixmap_load_file (GNOME_PIXMAP(launcher->button),
launcher->dentry->icon);
} else {
/*we know default_app_pixmap is ok since otherwise we
wouldn't get here*/
gnome_pixmap_load_file (GNOME_PIXMAP(launcher->button),
default_app_pixmap);
}
pixmap = gnome_pixmap_new_from_file (launcher->dentry->icon);
}
if (!pixmap) {
if (default_app_pixmap)
pixmap = gnome_pixmap_new_from_file (default_app_pixmap);
else
pixmap = gtk_label_new (_("App"));
}
gtk_container_add (GTK_CONTAINER(launcher->button), pixmap);
gtk_widget_show(pixmap);
/*FIXME: a bad hack to keep it all 48x48*/
gtk_widget_set_usize (launcher->button, 48, 48);
/*gtk_widget_set_usize (launcher->button, pixmap->requisition.width,
pixmap->requisition.height);*/
gtk_signal_disconnect(GTK_OBJECT(launcher->button),
launcher->signal_click_tag);
launcher->signal_click_tag =
gtk_signal_connect (GTK_OBJECT(launcher->button), "clicked",
gtk_signal_connect (GTK_OBJECT(launcher->button), "event",
GTK_SIGNAL_FUNC(launch),
launcher->dentry);
}
......@@ -256,7 +269,7 @@ _load_launcher_applet(char *params, GnomeDesktopEntry *dentry,
APPLET_LAUNCHER);
gtk_tooltips_set_tip (panel_tooltips,
launcher->button->parent,
launcher->button,
launcher->dentry->comment,NULL);
applet_add_callback(applet_count-1,"properties",
......
......@@ -954,7 +954,7 @@ static void
menu_deactivate(GtkWidget *w, gpointer data)
{
Menu *menu = data;
GtkWidget *panel = get_panel_parent(menu->button->parent);
GtkWidget *panel = get_panel_parent(menu->button);
/* allow the panel to hide again */
if(IS_SNAPPED_WIDGET(panel))
SNAPPED_WIDGET(panel)->autohide_inhibit = FALSE;
......@@ -1388,7 +1388,7 @@ menu_button_press(GtkWidget *widget, GdkEvent *event, gpointer data)
GdkEventButton *bevent = (GdkEventButton *)event;
if(bevent->button==1) {
GtkWidget *wpanel =
get_panel_parent(menu->button->parent);
get_panel_parent(menu->button);
int main_menu = (strcmp (menu->path, ".") == 0);
check_and_reread(menu->menu,menu,main_menu);
......@@ -1402,7 +1402,7 @@ menu_button_press(GtkWidget *widget, GdkEvent *event, gpointer data)
/*this HAS to be set everytime we popup the menu*/
current_panel =
gtk_object_get_data(GTK_OBJECT(menu->button->parent),
gtk_object_get_data(GTK_OBJECT(menu->button),
PANEL_APPLET_PARENT_KEY);
gtk_menu_popup(GTK_MENU(menu->menu), 0,0, menu_position,
......@@ -1456,7 +1456,6 @@ static Menu *
create_panel_menu (char *menudir, int main_menu,
PanelOrientType orient, MainMenuType main_menu_type)
{
GtkWidget *pixmap;
Menu *menu;
char *pixmap_name = NULL;
......@@ -1469,28 +1468,23 @@ create_panel_menu (char *menudir, int main_menu,
menu->main_menu_type = main_menu_type;
/* main button */
menu->button = gtk_button_new ();
/*make the pixmap*/
menu->button = gnome_pixmap_new_from_file_at_size (pixmap_name,
BIG_ICON_SIZE,
BIG_ICON_SIZE);
gtk_widget_set_events(menu->button,
gtk_widget_get_events(menu->button) |
GDK_LEAVE_NOTIFY_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
gtk_signal_connect (GTK_OBJECT (menu->button), "event",
GTK_SIGNAL_FUNC (menu_button_press), menu);
gtk_signal_connect (GTK_OBJECT (menu->button), "destroy",
GTK_SIGNAL_FUNC (destroy_menu), menu);
/*make the pixmap*/
pixmap = gnome_pixmap_new_from_file_at_size (pixmap_name,
BIG_ICON_SIZE,
BIG_ICON_SIZE);
gtk_widget_show(pixmap);
/*FIXME:this is not right, but it's how we can get the buttons to
be 48x48 (given the icons are 48x48)*/
/*gtk_widget_set_usize (menu->button, pixmap->requisition.width,
pixmap->requisition.height);*/
gtk_widget_set_usize (menu->button, 48,48);
/* put pixmap in button */
gtk_container_add (GTK_CONTAINER(menu->button), pixmap);
gtk_widget_show (menu->button);
gtk_widget_show(menu->button);
{
GList *list = g_list_append(NULL,menudir);
......@@ -1559,7 +1553,6 @@ set_show_small_icons(void)
void
set_menu_applet_orient(Menu *menu, PanelOrientType orient)
{
GtkWidget *pixmap;
char *pixmap_name = NULL;
char *this_menu;
char *menu_base;
......@@ -1576,18 +1569,11 @@ set_menu_applet_orient(Menu *menu, PanelOrientType orient)
g_free(menu_base);
g_free(this_menu);
pixmap=GTK_BUTTON(menu->button)->child;
gtk_container_remove(GTK_CONTAINER(menu->button),pixmap);
/*this is done by remove right?*/
/*gtk_widget_unref(pixmap);*/
/*make the pixmap*/
pixmap = gnome_pixmap_new_from_file_at_size (pixmap_name,
BIG_ICON_SIZE,
BIG_ICON_SIZE);
gtk_container_add (GTK_CONTAINER(menu->button), pixmap);
gtk_widget_show (pixmap);
gnome_pixmap_load_file_at_size (GNOME_PIXMAP(menu->button),
pixmap_name,
BIG_ICON_SIZE,
BIG_ICON_SIZE);
g_free(pixmap_name);
}
......
......@@ -63,8 +63,9 @@ typedef void (*AppletSignal) (GtkObject * object,
GtkWidget * applet,
gpointer data);
typedef void (*VoidSignal) (GtkObject * object,
gpointer data);
typedef int (*Button1Signal) (GtkObject * object,
GtkWidget * applet,
gpointer data);
/************************
debugging
......@@ -124,6 +125,8 @@ enum {
APPLET_ADDED_SIGNAL,
APPLET_REMOVED_SIGNAL,
BACK_CHANGE_SIGNAL,
APPLET_CLICKED_SIGNAL, /*these two are only for NO WINDOW applets, other*/
APPLET_BUTTON1_SIGNAL, /*applets won't get these two*/
LAST_SIGNAL
};
......@@ -173,7 +176,24 @@ marshal_signal_back (GtkObject * object,
func_data);
}
static void
marshal_signal_button1 (GtkObject * object,
GtkSignalFunc func,
gpointer func_data,
GtkArg * args)
{
Button1Signal rfunc;
int *retval;
rfunc = (Button1Signal) func;
retval = GTK_RETLOC_BOOL(args[1]);
*retval = (*rfunc) (object, GTK_VALUE_POINTER (args[0]),
func_data);
}
static void
panel_widget_class_init (PanelWidgetClass *class)
{
......@@ -232,6 +252,26 @@ panel_widget_class_init (PanelWidgetClass *class)
GTK_TYPE_ENUM,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
panel_widget_signals[APPLET_CLICKED_SIGNAL] =
gtk_signal_new("applet_clicked",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET(PanelWidgetClass,
applet_clicked),
marshal_signal_applet,
GTK_TYPE_NONE,
1,
GTK_TYPE_POINTER);
panel_widget_signals[APPLET_BUTTON1_SIGNAL] =
gtk_signal_new("applet_button1",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET(PanelWidgetClass,
applet_button1),
marshal_signal_button1,
GTK_TYPE_BOOL,
1,
GTK_TYPE_POINTER);
gtk_object_class_add_signals(object_class,panel_widget_signals,
LAST_SIGNAL);
......@@ -326,7 +366,6 @@ panel_widget_switch_applet_right(PanelWidget *panel, GList *list)
if(nlist)
nad = nlist->data;
if(!nlist || nad->pos > ad->pos+ad->cells) {
gtk_widget_queue_resize(GTK_WIDGET(panel));
ad->pos++;
gtk_widget_queue_resize(GTK_WIDGET(panel));
return;
......@@ -896,6 +935,67 @@ panel_widget_destroy(GtkWidget *w, gpointer data)
return FALSE;
}
static int panel_widget_applet_event(GtkWidget *widget, GdkEvent *event, gpointer data);
static int is_in_widget(GdkEventButton *bevent, GtkWidget *widget)
{
if(bevent->x >= widget->allocation.x &&
bevent->x < (widget->allocation.x + widget->allocation.width) &&
bevent->y >= widget->allocation.y &&
bevent->y < (widget->allocation.y + widget->allocation.height))
return TRUE;
return FALSE;
}
static GtkWidget *pressed_applet = NULL;
static int
panel_widget_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
PanelWidget *panel = PANEL_WIDGET(widget);
GList *list;
GdkEventButton *bevent = (GdkEventButton *) event;
if(event->type != GDK_BUTTON_PRESS &&
event->type != GDK_BUTTON_RELEASE)
return FALSE;
/*this would be a button release event and it would be right after
a button press*/
if(pressed_applet) {
gtk_grab_remove(pressed_applet);
if(is_in_widget(bevent,pressed_applet)) {
gtk_signal_emit(GTK_OBJECT(panel),
panel_widget_signals[APPLET_CLICKED_SIGNAL],
pressed_applet);