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

add support for corner widget, so it kind of works, though there are no

Tue Jul 07 03:17:12 1998  George Lebl  <jirka@5z.com>

        * main.c,panel.c,menu.c: add support for corner widget, so it
          kind of works, though there are no options for the corner
          widget yet .. that will soon change though, also there's some
          weird flicker as well ... should get fixed
parent df9f9be4
Tue Jul 07 03:17:12 1998 George Lebl <jirka@5z.com>
* main.c,panel.c,menu.c: add support for corner widget, so it
kind of works, though there are no options for the corner
widget yet .. that will soon change though, also there's some
weird flicker as well ... should get fixed
Tue Jul 07 02:33:05 1998 George Lebl <jirka@5z.com>
* corner-widget.[ch]: initial coding of corner-widget, it seemed
......
Tue Jul 07 03:17:12 1998 George Lebl <jirka@5z.com>
* main.c,panel.c,menu.c: add support for corner widget, so it
kind of works, though there are no options for the corner
widget yet .. that will soon change though, also there's some
weird flicker as well ... should get fixed
Tue Jul 07 02:33:05 1998 George Lebl <jirka@5z.com>
* corner-widget.[ch]: initial coding of corner-widget, it seemed
......
......@@ -528,12 +528,12 @@ corner_widget_new (CornerPos pos,
corner = gtk_type_new(corner_widget_get_type());
corner->panel = panel_widget_new(FALSE,
orient,
back_type,
back_pixmap,
fit_pixmap_bg,
back_color);
corner->panel = panel_widget_new(TRUE,
orient,
back_type,
back_pixmap,
fit_pixmap_bg,
back_color);
gtk_object_set_data(GTK_OBJECT(corner->panel),PANEL_PARENT,
corner);
PANEL_WIDGET(corner->panel)->drop_widget = GTK_WIDGET(corner);
......
......@@ -14,6 +14,7 @@
#include "panel-widget.h"
#include "snapped-widget.h"
#include "drawer-widget.h"
#include "corner-widget.h"
#include "panel.h"
#include "panel_config.h"
#include "panel_config_global.h"
......@@ -253,6 +254,8 @@ get_def_panel_widget(GtkWidget *panel)
g_return_val_if_fail(panel!=NULL,NULL);
if(IS_SNAPPED_WIDGET(panel)) {
return PANEL_WIDGET(SNAPPED_WIDGET(panel)->panel);
} else if(IS_CORNER_WIDGET(panel)) {
return PANEL_WIDGET(CORNER_WIDGET(panel)->panel);
} else if(IS_DRAWER_WIDGET(panel)) {
return PANEL_WIDGET(DRAWER_WIDGET(panel)->panel);
}
......@@ -346,9 +349,6 @@ get_applet_orient(PanelWidget *panel)
ORIENT_RIGHT:ORIENT_DOWN;
break;
case SNAPPED_BOTTOM:
orient=(porient==PANEL_VERTICAL)?
ORIENT_RIGHT:ORIENT_UP;
break;
case SNAPPED_LEFT:
orient=(porient==PANEL_VERTICAL)?
ORIENT_RIGHT:ORIENT_UP;
......@@ -359,6 +359,25 @@ get_applet_orient(PanelWidget *panel)
break;
}
break;
case CORNER_PANEL:
switch(CORNER_WIDGET(tpd->panel)->pos) {
case CORNER_NE:
orient=(porient==PANEL_VERTICAL)?
ORIENT_LEFT:ORIENT_DOWN;
break;
case CORNER_SE:
orient=(porient==PANEL_VERTICAL)?
ORIENT_LEFT:ORIENT_UP;
break;
case CORNER_SW:
orient=(porient==PANEL_VERTICAL)?
ORIENT_RIGHT:ORIENT_UP;
break;
case CORNER_NW:
orient=(porient==PANEL_VERTICAL)?
ORIENT_RIGHT:ORIENT_DOWN;
break;
}
default: break;
}
break;
......@@ -370,6 +389,31 @@ get_applet_orient(PanelWidget *panel)
case SNAPPED_RIGHT: orient = ORIENT_LEFT; break;
}
break;
case CORNER_PANEL:
if(PANEL_WIDGET(CORNER_WIDGET(panelw)->panel)->orient ==
PANEL_HORIZONTAL) {
switch(CORNER_WIDGET(panelw)->pos) {
case CORNER_SE:
case CORNER_SW:
orient = ORIENT_UP;
break;
case CORNER_NE:
case CORNER_NW:
orient = ORIENT_DOWN;
break;
}
} else { /*vertical*/
switch(CORNER_WIDGET(panelw)->pos) {
case CORNER_SE:
case CORNER_NE:
orient = ORIENT_LEFT;
break;
case CORNER_SW:
case CORNER_NW:
orient = ORIENT_RIGHT;
break;
}
}
default: break;
}
return orient;
......@@ -684,6 +728,8 @@ panel_realize(GtkWidget *widget, gpointer data)
if(IS_SNAPPED_WIDGET(widget))
snapped_widget_enable_buttons(SNAPPED_WIDGET(widget));
else if(IS_CORNER_WIDGET(widget))
corner_widget_enable_buttons(CORNER_WIDGET(widget));
}
/*we call this recursively*/
......@@ -753,6 +799,19 @@ snapped_pos_change(GtkWidget *widget,
update_config_orient(widget);
}
static void
corner_pos_change(GtkWidget *widget,
CornerPos pos,
gpointer data)
{
panel_widget_foreach(PANEL_WIDGET(CORNER_WIDGET(widget)->panel),
orient_change_foreach,
SNAPPED_WIDGET(widget)->panel);
config_changed = TRUE;
/*update the configuration box if it is displayed*/
update_config_orient(widget);
}
void
back_change(int applet_id,
PanelWidget *panel)
......@@ -841,6 +900,24 @@ snapped_state_change(GtkWidget *widget,
return TRUE;
}
static int
corner_state_change(GtkWidget *widget,
CornerState state,
gpointer data)
{
if(state==CORNER_SHOWN)
panel_widget_foreach(PANEL_WIDGET(CORNER_WIDGET(widget)->panel),
state_restore_foreach,
(gpointer)widget);
else
panel_widget_foreach(PANEL_WIDGET(CORNER_WIDGET(widget)->panel),
state_hide_foreach,
(gpointer)widget);
config_changed = TRUE;
return TRUE;
}
static int
drawer_state_change(GtkWidget *widget,
DrawerState state,
gpointer data)
......@@ -961,6 +1038,39 @@ panel_menu_position (GtkMenu *menu, int *x, int *y, gpointer data)
*y += wy;
break;
}
} else if(IS_CORNER_WIDGET(w)) {
PanelWidget *panel = PANEL_WIDGET(CORNER_WIDGET(w)->panel);
if(panel->orient==PANEL_HORIZONTAL) {
switch(CORNER_WIDGET(w)->pos) {
case CORNER_NE:
case CORNER_NW:
gtk_widget_get_pointer(w, x, NULL);
*x += wx;
*y = wy + w->allocation.height;
break;
case CORNER_SE:
case CORNER_SW:
gtk_widget_get_pointer(w, x, NULL);
*x += wx;
*y = wy - GTK_WIDGET (menu)->allocation.height;
break;
}
} else { /*vertical*/
switch(CORNER_WIDGET(w)->pos) {
case CORNER_NE:
case CORNER_SE:
gtk_widget_get_pointer(w, NULL, y);
*x = wx - GTK_WIDGET (menu)->allocation.width;
*y += wy;
break;
case CORNER_SW:
case CORNER_NW:
gtk_widget_get_pointer(w, NULL, y);
*x = wx + w->allocation.width;
*y += wy;
break;
}
}
}
if(*x + GTK_WIDGET (menu)->allocation.width > gdk_screen_width())
......@@ -1048,7 +1158,8 @@ panel_destroy(GtkWidget *widget, gpointer data)
info->assoc = NULL;
panel_clean_applet(applet_id);
}
} else if(IS_SNAPPED_WIDGET(widget)) {
} else if(IS_SNAPPED_WIDGET(widget) ||
IS_CORNER_WIDGET(widget)) {
/*this is a base panel and we just lost it*/
base_panels--;
}
......@@ -1122,6 +1233,18 @@ panel_event(GtkWidget *widget, GdkEvent *event, gpointer data)
gtk_widget_set_sensitive(rem,TRUE);
snapped->autohide_inhibit = TRUE;
snapped_widget_queue_pop_down(snapped);
} else if(IS_CORNER_WIDGET(widget)) {
CornerWidget *corner =
CORNER_WIDGET(widget);
PanelWidget *panel = PANEL_WIDGET(corner->panel);
GtkWidget *rem =
gtk_object_get_data(GTK_OBJECT(widget),
"remove_item");
if(panel_widget_get_applet_count(panel)>0 ||
base_panels <= 1)
gtk_widget_set_sensitive(rem,FALSE);
else
gtk_widget_set_sensitive(rem,TRUE);
}
gtk_menu_popup(GTK_MENU(data), NULL, NULL,
panel_menu_position,
......@@ -1284,8 +1407,8 @@ panel_setup(GtkWidget *panelw)
} else if(IS_SNAPPED_WIDGET(panelw)) {
PanelWidget *panel =
PANEL_WIDGET(SNAPPED_WIDGET(panelw)->panel);
panel_widget_setup(panel);
snapped_widget_disable_buttons(SNAPPED_WIDGET(panelw));
panel_widget_setup(panel);
gtk_signal_connect(GTK_OBJECT(panelw),
"pos_change",
GTK_SIGNAL_FUNC(snapped_pos_change),
......@@ -1295,6 +1418,22 @@ panel_setup(GtkWidget *panelw)
GTK_SIGNAL_FUNC(snapped_state_change),
NULL);
/*this is a base panel*/
base_panels++;
} else if(IS_CORNER_WIDGET(panelw)) {
PanelWidget *panel =
PANEL_WIDGET(CORNER_WIDGET(panelw)->panel);
corner_widget_disable_buttons(CORNER_WIDGET(panelw));
panel_widget_setup(panel);
gtk_signal_connect(GTK_OBJECT(panelw),
"pos_change",
GTK_SIGNAL_FUNC(corner_pos_change),
NULL);
gtk_signal_connect(GTK_OBJECT(panelw),
"state_change",
GTK_SIGNAL_FUNC(corner_state_change),
NULL);
/*this is a base panel*/
base_panels++;
} else
......@@ -1446,6 +1585,31 @@ init_user_panels(void)
&back_color);
break;
}
case CORNER_PANEL:
{
CornerPos pos;
PanelOrientation orient;
CornerState state;
g_snprintf(buf,256,"pos=%d", CORNER_NE);
pos=gnome_config_get_int(buf);
g_snprintf(buf,256,"orient=%d",
PANEL_HORIZONTAL);
orient=gnome_config_get_int(buf);
g_snprintf(buf,256,"state=%d", CORNER_SHOWN);
state=gnome_config_get_int(buf);
panel = corner_widget_new(pos,
orient,
state,
back_type,
back_pixmap,
fit_pixmap_bg,
&back_color);
break;
}
default: break;
}
......
......@@ -9,7 +9,7 @@ BEGIN_GNOME_DECLS
typedef enum {
SNAPPED_PANEL,
DRAWER_PANEL,
CORNER_PANEL, /*not yet implemented*/
CORNER_PANEL,
FREE_PANEL, /*not yet implemented*/
TABBED_PANEL /*not yet implemented*/
} PanelType;
......
......@@ -16,6 +16,7 @@
#include "panel-widget.h"
#include "snapped-widget.h"
#include "drawer-widget.h"
#include "corner-widget.h"
#include "panel-util.h"
#include "panel.h"
#include "main.h"
......@@ -686,6 +687,17 @@ create_new_panel(GtkWidget *w,gpointer data)
panel_setup(panel);
gtk_widget_show(panel);
break;
case CORNER_PANEL:
panel = corner_widget_new(CORNER_NE,
PANEL_HORIZONTAL,
CORNER_SHOWN,
PANEL_BACK_NONE,
NULL,
TRUE,
&bcolor);
panel_setup(panel);
gtk_widget_show(panel);
break;
}
}
......@@ -711,6 +723,13 @@ create_add_panel_submenu (void)
(GtkSignalFunc) create_new_panel,
(gpointer)SNAPPED_PANEL);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem, 0, _("Corner Panel"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
(GtkSignalFunc) create_new_panel,
(gpointer)CORNER_PANEL);
return menu;
}
......
......@@ -14,6 +14,7 @@
#include "panel-widget.h"
#include "snapped-widget.h"
#include "drawer-widget.h"
#include "corner-widget.h"
#include "gdkextra.h"
#include "panel.h"
#include "main.h"
......@@ -215,6 +216,11 @@ save_panel_configuration(gpointer data, gpointer user_data)
gnome_config_set_int("pos", snapped->pos);
gnome_config_set_int("mode", snapped->mode);
gnome_config_set_int("state", snapped->state);
} else if(pd->type == CORNER_PANEL) {
CornerWidget *corner = CORNER_WIDGET(pd->panel);
gnome_config_set_int("pos", corner->pos);
gnome_config_set_int("orient",panel->orient);
gnome_config_set_int("state", corner->state);
} else if(pd->type == DRAWER_PANEL) {
DrawerWidget *drawer = DRAWER_WIDGET(pd->panel);
gnome_config_set_int("orient",panel->orient);
......@@ -829,6 +835,34 @@ applet_menu_position (GtkMenu *menu, int *x, int *y, gpointer data)
*y = wy;
break;
}
} else if(IS_CORNER_WIDGET(w)) {
if(panel->orient==PANEL_HORIZONTAL) {
switch(CORNER_WIDGET(w)->pos) {
case CORNER_SE:
case CORNER_SW:
*x = wx;
*y = wy - GTK_WIDGET (menu)->allocation.height;
break;
case CORNER_NE:
case CORNER_NW:
*x = wx;
*y = wy + info->widget->allocation.height;
break;
}
} else {
switch(CORNER_WIDGET(w)->pos) {
case CORNER_NW:
case CORNER_SW:
*x = wx + info->widget->allocation.width;
*y = wy;
break;
case CORNER_NE:
case CORNER_SE:
*x = wx - GTK_WIDGET (menu)->allocation.width;
*y = wy;
break;
}
}
}
if(*x + GTK_WIDGET (menu)->allocation.width > gdk_screen_width())
......
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