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

fixes, made pressed return bool

Thu Aug 27 02:33:44 1998  George Lebl  <jirka@5z.com>

        * button-widget.c: fixes, made pressed return bool

        * panel-widget.c: don't consider it a beginning of a clicked
          if true is returned from pressed

        * drawer.c,menu.c: converted to button-widget

        * main.c: loads up the default tiles and enables them, this will
          be configurable in the future, but for now it's hardcoded
parent d765eae8
Thu Aug 27 02:33:44 1998 George Lebl <jirka@5z.com>
* button-widget.c: fixes, made pressed return bool
* panel-widget.c: don't consider it a beginning of a clicked
if true is returned from pressed
* drawer.c,menu.c: converted to button-widget
* main.c: loads up the default tiles and enables them, this will
be configurable in the future, but for now it's hardcoded
Wed Aug 26 02:14:11 1998 George Lebl <jirka@5z.com>
* button-widget.[ch],panel-widget.[ch]: redid the icon stuff, now
......
Thu Aug 27 02:33:44 1998 George Lebl <jirka@5z.com>
* button-widget.c: fixes, made pressed return bool
* panel-widget.c: don't consider it a beginning of a clicked
if true is returned from pressed
* drawer.c,menu.c: converted to button-widget
* main.c: loads up the default tiles and enables them, this will
be configurable in the future, but for now it's hardcoded
Wed Aug 26 02:14:11 1998 George Lebl <jirka@5z.com>
* button-widget.[ch],panel-widget.[ch]: redid the icon stuff, now
......
......@@ -17,9 +17,11 @@ static void button_widget_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void button_widget_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void button_widget_pressed (ButtonWidget *button);
static int button_widget_pressed (ButtonWidget *button);
static void button_widget_unpressed (ButtonWidget *button);
typedef int (*IntSignal) (GtkObject * object,
gpointer data);
typedef void (*VoidSignal) (GtkObject * object,
gpointer data);
......@@ -69,6 +71,22 @@ enum {
static int button_widget_signals[LAST_SIGNAL] = {0};
static void
marshal_signal_int (GtkObject * object,
GtkSignalFunc func,
gpointer func_data,
GtkArg * args)
{
IntSignal rfunc;
int *retval;
rfunc = (IntSignal) func;
retval = GTK_RETLOC_BOOL(args[0]);
*retval = (*rfunc) (object, func_data);
}
static void
marshal_signal_void (GtkObject * object,
GtkSignalFunc func,
......@@ -101,12 +119,12 @@ button_widget_class_init (ButtonWidgetClass *class)
0);
button_widget_signals[PRESSED_SIGNAL] =
gtk_signal_new("pressed",
GTK_RUN_FIRST,
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET(ButtonWidgetClass,
pressed),
marshal_signal_void,
GTK_TYPE_NONE,
marshal_signal_int,
GTK_TYPE_BOOL,
0);
button_widget_signals[UNPRESSED_SIGNAL] =
gtk_signal_new("unpressed",
......@@ -121,7 +139,7 @@ button_widget_class_init (ButtonWidgetClass *class)
LAST_SIGNAL);
class->clicked = NULL;
class->pressed = button_widget_pressed;
class->pressed = NULL; /*FIXME:button_widget_pressed;*/
class->unpressed = button_widget_unpressed;
widget_class->size_allocate = button_widget_size_allocate;
......@@ -200,8 +218,14 @@ button_widget_draw(ButtonWidget *button, GdkPixmap *pixmap)
gc = gdk_gc_new(pixmap);
if(button->arrow)
if(button->arrow) {
int i;
draw_arrow(points,button->orient);
for(i=0;i<3;i++) {
points[i].x+=widget->allocation.x;
points[i].y+=widget->allocation.y;
}
}
if(tiles_enabled) {
if(button->pressed) {
......@@ -303,12 +327,13 @@ button_widget_clicked(ButtonWidget *button)
button_widget_signals[CLICKED_SIGNAL]);
}
static void
static int
button_widget_pressed(ButtonWidget *button)
{
button->pressed = TRUE;
panel_widget_draw_icon(PANEL_WIDGET(GTK_WIDGET(button)->parent),
button);
return FALSE;
}
static void
button_widget_unpressed(ButtonWidget *button)
......@@ -318,11 +343,19 @@ button_widget_unpressed(ButtonWidget *button)
button);
}
void
int
button_widget_down(ButtonWidget *button)
{
int retval=FALSE;
/*FIXME:*/
button_widget_pressed(button);
gtk_signal_emit(GTK_OBJECT(button),
button_widget_signals[PRESSED_SIGNAL]);
button_widget_signals[PRESSED_SIGNAL],
&retval);
printf ("retval: %d\n",retval);
return retval;
}
void
button_widget_up(ButtonWidget *button)
......@@ -355,9 +388,17 @@ button_widget_new(GdkPixmap *pixmap,
static void
loadup_file(GdkPixmap **pixmap, GdkBitmap **mask, char *file)
{
GdkImlibImage *im;
im = gdk_imlib_load_image (file);
GdkImlibImage *im = NULL;
if(*file!='/') {
char *f;
f = gnome_unconditional_pixmap_file (file);
if(f) {
im = gdk_imlib_load_image (f);
g_free(f);
}
} else
im = gdk_imlib_load_image (file);
if(!im) {
*pixmap = NULL;
*mask = NULL;
......
......@@ -37,7 +37,7 @@ struct _ButtonWidgetClass
GtkWidgetClass parent_class;
void (* clicked) (ButtonWidget *button);
void (* pressed) (ButtonWidget *button);
int (* pressed) (ButtonWidget *button);
void (* unpressed) (ButtonWidget *button);
};
......@@ -68,14 +68,14 @@ void button_widget_set_params (ButtonWidget *button,
PanelOrientType orient);
void button_widget_clicked (ButtonWidget *button);
void button_widget_down (ButtonWidget *button);
int button_widget_down (ButtonWidget *button);
void button_widget_up (ButtonWidget *button);
void button_widget_load_tile (int tile,
char *tile_up,
char *tile_down);
void button_widget_tile_enamble (int enabled);
void button_widget_tile_enable (int enabled);
#ifdef __cplusplus
}
......
......@@ -155,7 +155,12 @@ drawer_widget_get_pos(DrawerWidget *drawer, gint16 *x, gint16 *y,
PANEL_APPLET_PARENT_KEY);
if (GTK_WIDGET_REALIZED (ppanel)) {
gdk_window_get_origin (panel->master_widget->window, &bx, &by);
gdk_window_get_size (panel->master_widget->window, &bw, &bh);
if(GTK_WIDGET_NO_WINDOW(panel->master_widget)) {
bx+=panel->master_widget->allocation.x;
by+=panel->master_widget->allocation.y;
}
bw = panel->master_widget->allocation.width;
bh = panel->master_widget->allocation.height;
gdk_window_get_origin (ppanel->window, &px, &py);
gdk_window_get_size (ppanel->window, &pw, &ph);
......
......@@ -30,10 +30,10 @@ extern GList *panel_list;
static void
properties_apply_callback(GtkWidget *widget, int page, gpointer data)
{
Drawer *drawer = data;
GtkWidget *pixentry = gtk_object_get_data(GTK_OBJECT(widget),
Drawer *drawer = data;
GtkWidget *pixentry = gtk_object_get_data(GTK_OBJECT(widget),
"pixmap");
GtkWidget *tipentry = gtk_object_get_data(GTK_OBJECT(widget),
GtkWidget *tipentry = gtk_object_get_data(GTK_OBJECT(widget),
"tooltip");
char *s;
......@@ -45,11 +45,21 @@ properties_apply_callback(GtkWidget *widget, int page, gpointer data)
if(drawer->tooltip)
g_free(drawer->tooltip);
s = gtk_entry_get_text(GTK_ENTRY(pixentry));
if(!s || !*s)
if(!s || !*s) {
drawer->pixmap =
gnome_unconditional_pixmap_file ("panel-drawer.png");
else
drawer->pixmap = g_strdup(s);
button_widget_set_pixmap_from_file (BUTTON_WIDGET(drawer->button),
drawer->pixmap);
} else {
if(button_widget_set_pixmap_from_file(BUTTON_WIDGET(drawer->button), s))
drawer->pixmap = g_strdup(s);
else {
drawer->pixmap =
gnome_unconditional_pixmap_file ("panel-drawer.png");
button_widget_set_pixmap_from_file (BUTTON_WIDGET(drawer->button),
drawer->pixmap);
}
}
s = gtk_entry_get_text(GTK_ENTRY(tipentry));
if(!s || !*s)
drawer->tooltip = NULL;
......@@ -58,11 +68,6 @@ properties_apply_callback(GtkWidget *widget, int page, gpointer data)
gtk_tooltips_set_tip (panel_tooltips,drawer->button,
drawer->tooltip,NULL);
/*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
......@@ -124,7 +129,7 @@ add_drawer_properties_page(GtkWidget *dialog, Drawer *drawer)
}
static void
drawer_click(Drawer *drawer)
drawer_click(GtkWidget *w, Drawer *drawer)
{
DrawerWidget *drawerw = DRAWER_WIDGET(drawer->drawer);
PanelWidget *parent =
......@@ -146,38 +151,6 @@ drawer_click(Drawer *drawer)
}
}
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
destroy_drawer(GtkWidget *widget, gpointer data)
{
......@@ -200,7 +173,8 @@ enter_notify_drawer(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
}
static Drawer *
create_drawer_applet(GtkWidget * drawer_panel, char *tooltip, char *pixmap)
create_drawer_applet(GtkWidget * drawer_panel, char *tooltip, char *pixmap,
PanelOrientType orient)
{
Drawer *drawer;
......@@ -211,43 +185,35 @@ create_drawer_applet(GtkWidget * drawer_panel, char *tooltip, char *pixmap)
drawer->tooltip = NULL;
else
drawer->tooltip = g_strdup(tooltip);
if(!pixmap ||
!*pixmap)
if(!pixmap || !*pixmap) {
drawer->pixmap =
gnome_unconditional_pixmap_file ("panel-drawer.png");
else
drawer->pixmap = g_strdup(pixmap);
/*we need to overlay the arrow*/
/*switch(orient) {
case ORIENT_DOWN:
pixmap_name = gnome_unconditional_pixmap_file ("gnome-menu-down.png");
break;
case ORIENT_UP:
pixmap_name = gnome_unconditional_pixmap_file ("gnome-menu-up.png");
break;
case ORIENT_RIGHT:
pixmap_name = gnome_unconditional_pixmap_file ("gnome-menu-right.png");
break;
case ORIENT_LEFT:
pixmap_name = gnome_unconditional_pixmap_file ("gnome-menu-left.png");
break;
}*/
/*make the pixmap*/
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);
drawer->button = button_widget_new_from_file (drawer->pixmap,
DRAWER_TILE,
TRUE,orient);
} else {
drawer->button = button_widget_new_from_file(pixmap,
DRAWER_TILE,
TRUE,orient);
if(drawer->button)
drawer->pixmap = g_strdup(pixmap);
else {
drawer->pixmap =
gnome_unconditional_pixmap_file ("panel-drawer.png");
drawer->button =
button_widget_new_from_file (drawer->pixmap,
DRAWER_TILE,
TRUE,orient);
}
}
gtk_widget_show(drawer->button);
drawer->drawer = drawer_panel;
gtk_signal_connect (GTK_OBJECT (drawer->button), "event",
GTK_SIGNAL_FUNC (drawer_event), drawer);
gtk_signal_connect (GTK_OBJECT (drawer->button), "clicked",
GTK_SIGNAL_FUNC (drawer_click), 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",
......@@ -268,13 +234,16 @@ create_empty_drawer_applet(char *tooltip, char *pixmap,
DRAWER_SHOWN,
PANEL_BACK_NONE, NULL,
TRUE, NULL),
tooltip,pixmap);
tooltip,pixmap,orient);
}
void
set_drawer_applet_orient(Drawer *drawer, PanelOrientType orient)
{
g_return_if_fail(drawer!=NULL);
button_widget_set_params(BUTTON_WIDGET(drawer->button),
DRAWER_TILE,TRUE,orient);
/*ignore orient events until we are realized, this will only
be the initial one and we have already set the orientation*/
......@@ -282,20 +251,6 @@ set_drawer_applet_orient(Drawer *drawer, PanelOrientType orient)
return;
drawer_widget_change_orient(DRAWER_WIDGET(drawer->drawer), orient);
/*this was when we were chaning the pixmap on the fly*/
/*pixmap_name = gnome_unconditional_pixmap_file("gnome-menu-left.png");*/
/*pixmap=GTK_BUTTON(drawer->button)->child;
gtk_container_remove(GTK_CONTAINER(drawer->button),pixmap);
pixmap = gnome_pixmap_new_from_file (pixmap_name);
gtk_container_add (GTK_CONTAINER(drawer->button), pixmap);
gtk_widget_show (pixmap);
g_free(pixmap_name);*/
}
static void
......@@ -341,10 +296,10 @@ load_drawer_applet(char *params, char *pixmap, char *tooltip,
PanelWidget *panel, int pos)
{
Drawer *drawer;
PanelOrientType orient = get_applet_orient(panel);
if(!params) {
drawer = create_empty_drawer_applet(tooltip,pixmap,
get_applet_orient(panel));
drawer = create_empty_drawer_applet(tooltip,pixmap,orient);
if(drawer) panel_setup(drawer->drawer);
} else {
int i;
......@@ -352,11 +307,13 @@ load_drawer_applet(char *params, char *pixmap, char *tooltip,
sscanf(params,"%d",&i);
dr_pd = g_list_nth(panel_list,i)->data;
drawer=create_drawer_applet(dr_pd->panel, tooltip,pixmap);
drawer=create_drawer_applet(dr_pd->panel, tooltip,pixmap,
orient);
drawer_widget_change_orient(DRAWER_WIDGET(dr_pd->panel),
get_applet_orient(panel));
orient);
}
if(!drawer)
......
......@@ -215,6 +215,12 @@ main(int argc, char **argv)
applet_count = 0;
panel_tooltips = gtk_tooltips_new();
/*FIXME: make this configurable*/
button_widget_load_tile(MENU_TILE,"tile-green-up.png","tile-green-down.png");
button_widget_load_tile(DRAWER_TILE,"tile-purple-up.png","tile-purple-down.png");
button_widget_load_tile(LAUNCHER_TILE,"tile-normal-up.png","tile-normal-down.png");
button_widget_tile_enable(TRUE);
/*set the globals*/
load_up_globals();
......
......@@ -1082,6 +1082,7 @@ menu_deactivate(GtkWidget *w, gpointer data)
/* allow the panel to hide again */
if(IS_SNAPPED_WIDGET(panel))
SNAPPED_WIDGET(panel)->autohide_inhibit = FALSE;
button_widget_up(BUTTON_WIDGET(menu->button));
}
static char *
......@@ -1510,48 +1511,32 @@ add_menu_widget (Menu *menu, GList *menudirl, int main_menu, int fake_subs)
GTK_SIGNAL_FUNC (menu_deactivate), menu);
}
static GtkWidget *
listening_parent(GtkWidget *widget)
{
if (GTK_WIDGET_NO_WINDOW(widget))
return listening_parent(widget->parent);
return widget;
}
static int
menu_button_press(GtkWidget *widget, GdkEvent *event, gpointer data)
menu_button_pressed(GtkWidget *widget, gpointer data)
{
Menu *menu = data;
if(event->type == GDK_BUTTON_PRESS) {
GdkEventButton *bevent = (GdkEventButton *)event;
if(bevent->button==1) {
GtkWidget *wpanel =
get_panel_parent(menu->button);
int main_menu = (strcmp (menu->path, ".") == 0);
check_and_reread(menu->menu,menu,main_menu);
/*so that the panel doesn't pop down until we're
done with the menu */
if(IS_SNAPPED_WIDGET(wpanel)) {
SNAPPED_WIDGET(wpanel)->autohide_inhibit = TRUE;
snapped_widget_queue_pop_down(SNAPPED_WIDGET(wpanel));
}
GdkEventButton *bevent = (GdkEventButton*)gtk_get_current_event();
GtkWidget *wpanel = get_panel_parent(menu->button);
int main_menu = (strcmp (menu->path, ".") == 0);
/*this HAS to be set everytime we popup the menu*/
current_panel =
gtk_object_get_data(GTK_OBJECT(menu->button),
PANEL_APPLET_PARENT_KEY);
check_and_reread(menu->menu,menu,main_menu);
gtk_menu_popup(GTK_MENU(menu->menu), 0,0, menu_position,
data, bevent->button, bevent->time);
return TRUE;
}
return gtk_widget_event(listening_parent(widget->parent), event);
} else if(event->type == GDK_BUTTON_RELEASE)
return gtk_widget_event(listening_parent(widget->parent), event);
return FALSE;
/*so that the panel doesn't pop down until we're
done with the menu */
if(IS_SNAPPED_WIDGET(wpanel)) {
SNAPPED_WIDGET(wpanel)->autohide_inhibit = TRUE;
snapped_widget_queue_pop_down(SNAPPED_WIDGET(wpanel));
}
/*this HAS to be set everytime we popup the menu*/
current_panel =
gtk_object_get_data(GTK_OBJECT(menu->button),
PANEL_APPLET_PARENT_KEY);
gtk_menu_popup(GTK_MENU(menu->menu), 0,0, menu_position,
data, bevent->button, bevent->time);
return TRUE;
}
static char *
......@@ -1559,20 +1544,7 @@ get_pixmap(char *menudir, PanelOrientType orient, int main_menu)
{
char *pixmap_name;
if (main_menu) {
switch(orient) {
case ORIENT_DOWN:
pixmap_name = gnome_unconditional_pixmap_file ("gnome-menu-down.png");
break;
case ORIENT_UP:
pixmap_name = gnome_unconditional_pixmap_file ("gnome-menu-up.png");
break;
case ORIENT_RIGHT:
pixmap_name = gnome_unconditional_pixmap_file ("gnome-menu-right.png");
break;
case ORIENT_LEFT:
pixmap_name = gnome_unconditional_pixmap_file ("gnome-menu-left.png");
break;
}
pixmap_name = gnome_unconditional_pixmap_file ("panel-menu-main.xpm");
} else {
char *dentry_name;
GnomeDesktopEntry *item_info;
......@@ -1596,8 +1568,8 @@ create_panel_menu (char *menudir, int main_menu,
PanelOrientType orient, MainMenuType main_menu_type)
{
Menu *menu;
char *pixmap_name = NULL;
char *pixmap_name;
menu = g_new(Menu,1);
......@@ -1610,17 +1582,11 @@ create_panel_menu (char *menudir, int main_menu,
/*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);
menu->button = button_widget_new_from_file (pixmap_name,
MENU_TILE,
TRUE,orient);
gtk_signal_connect (GTK_OBJECT (menu->button), "pressed",
GTK_SIGNAL_FUNC (menu_button_pressed), menu);
gtk_signal_connect (GTK_OBJECT (menu->button), "destroy",
GTK_SIGNAL_FUNC (destroy_menu), menu);
gtk_widget_show(menu->button);
......@@ -1637,7 +1603,8 @@ create_panel_menu (char *menudir, int main_menu,
}
static Menu *
create_menu_applet(char *arguments, PanelOrientType orient, MainMenuType main_menu_type)
create_menu_applet(char *arguments, PanelOrientType orient,
MainMenuType main_menu_type)
{
Menu *menu;
int main_menu;
......@@ -1692,29 +1659,12 @@ set_show_small_icons(void)
void
set_menu_applet_orient(Menu *menu, PanelOrientType orient)
{
char *pixmap_name = NULL;
char *this_menu;
char *menu_base;
g_return_if_fail(menu!=NULL);
g_return_if_fail(menu->path!=NULL);
menu->orient = orient;
menu_base = gnome_unconditional_datadir_file ("apps");
this_menu = get_real_menu_path(menu->path,menu_base);
pixmap_name = get_pixmap(this_menu,menu->orient,
strcmp (menu->path, ".") == 0);
g_free(menu_base);
g_free(this_menu);
/*make the pixmap*/
gnome_pixmap_load_file_at_size (GNOME_PIXMAP(menu->button),
pixmap_name,
BIG_ICON_SIZE,
BIG_ICON_SIZE);
g_free(pixmap_name);
button_widget_set_params(BUTTON_WIDGET(menu->button),
MENU_TILE,TRUE,orient);
}
static void
......
......@@ -1294,15 +1294,16 @@ panel_widget_event(GtkWidget *widget, GdkEvent *event, gpointer data)
event,data);
} else if(event->type == GDK_BUTTON_PRESS) {
if(IS_BUTTON_WIDGET(ad->applet)) {
pressed_applet = ad->applet;
button_widget_down(BUTTON_WIDGET(pressed_applet));
gtk_grab_add(pressed_applet);
gdk_pointer_grab(widget->window,
FALSE,
APPLET_EVENT_MASK,
NULL,
NULL,
GDK_CURRENT_TIME);
if(!button_widget_down(BUTTON_WIDGET(ad->applet))) {
pressed_applet = ad->applet;
gtk_grab_add(pressed_applet);
gdk_pointer_grab(widget->window,
FALSE,
APPLET_EVENT_MASK,
NULL,
NULL,
GDK_CURRENT_TIME);
}
} else {
int return_val = FALSE;
gtk_signal_emit(GTK_OBJECT(panel),
......@@ -1321,7 +1322,6 @@ panel_widget_event(GtkWidget *widget, GdkEvent *event, gpointer data)
return FALSE;
}
static void
panel_widget_init (PanelWidget *panel)
{
......
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