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

worked a bit on config saving, and multiple panel support, compiles and

Fri Feb 06 22:56:04 1998  George Lebl  <jirka@5z.com>

        * panel.c, main.c, ... : worked a bit on config saving,
          and multiple panel support, compiles and mostly works
          due to a hack which will disappear soon :)
parent 61ebc57d
Fri Feb 06 22:56:04 1998 George Lebl <jirka@5z.com>
* panel.c, main.c, ... : worked a bit on config saving,
and multiple panel support, compiles and mostly works
due to a hack which will disappear soon :)
Thu Feb 05 23:45:06 1998 George Lebl <jirka@5z.com>
* panel.[ch],main.c,applet_cmds.h,panel_cmds.h,ALL APPLETS:
......
Fri Feb 06 22:56:04 1998 George Lebl <jirka@5z.com>
* panel.c, main.c, ... : worked a bit on config saving,
and multiple panel support, compiles and mostly works
due to a hack which will disappear soon :)
Thu Feb 05 23:45:06 1998 George Lebl <jirka@5z.com>
* panel.[ch],main.c,applet_cmds.h,panel_cmds.h,ALL APPLETS:
......
......@@ -14,9 +14,26 @@
#include "panel-widget.h"
#include "panel.h"
#define DEFAULT_STEP_SIZE 40
/* amount of time in ms. to wait before lowering panel */
#define DEFAULT_MINIMIZE_DELAY 300
/* number of pixels it'll stick up from the bottom when using
* PANEL_AUTO_HIDE */
#define DEFAULT_MINIMIZED_SIZE 6
GList *panels = NULL;
GList *applets = NULL;
GtkTooltips *panel_tooltips;
gint tooltips_enabled = TRUE;
static void
load_applet(char *id, char *params, int pos)
load_applet(char *id, char *params, int pos, int panel)
{
PanelCommand cmd;
......@@ -24,13 +41,14 @@ load_applet(char *id, char *params, int pos)
cmd.params.create_applet.id = id;
cmd.params.create_applet.params = params;
cmd.params.create_applet.pos = pos;
cmd.params.create_applet.panel = panel;
panel_command(&cmd);
}
static void
load_drawer(char *name, char *iconopen, char *iconclosed, int step_size,
int pos)
int pos, int panel)
{
PanelCommand cmd;
......@@ -40,6 +58,7 @@ load_drawer(char *name, char *iconopen, char *iconclosed, int step_size,
cmd.params.create_drawer.iconclosed = iconclosed;
cmd.params.create_drawer.step_size = step_size;
cmd.params.create_drawer.pos = pos;
cmd.params.create_drawer.panel = panel;
panel_command(&cmd);
}
......@@ -50,30 +69,27 @@ load_default_applets(void)
/* XXX: the IDs for these applets are hardcoded here. */
/* Here we use NULL to request querying of default applet parameters */
load_applet("Menu", NULL, PANEL_UNKNOWN_APPLET_POSITION);
load_applet("Clock", NULL, PANEL_UNKNOWN_APPLET_POSITION);
load_applet("Mail check", NULL, PANEL_UNKNOWN_APPLET_POSITION);
}
static void
load_default_drawers(void)
{
load_applet("Menu", NULL, PANEL_UNKNOWN_APPLET_POSITION,1);
load_applet("Clock", NULL, PANEL_UNKNOWN_APPLET_POSITION,1);
load_applet("Mail check", NULL, PANEL_UNKNOWN_APPLET_POSITION,1);
}
static void
init_user_drawers(void)
{
/*FIXME: DRAWERS*/
/*
char *drawer_name;
char *drawer_iconopen;
char *drawer_iconclosed;
int pos;
int pos,panel;
int step_size;
char buf[256];
int count,num;
count=gnome_config_get_int("/panel/Config/drawer_count=0");
if(count<=0)
load_default_drawers();
for(num=1;num<=count;num++) {
sprintf(buf,"/panel/Drawer_%d/name=Drawer",num);
drawer_name = gnome_config_get_string(buf);
......@@ -83,17 +99,20 @@ init_user_drawers(void)
drawer_iconclosed = gnome_config_get_string(buf);
sprintf(buf,"/panel/Drawer_%d/step_size=%d",num,
PANEL_UNKNOWN_STEP_SIZE);
DEFAULT_STEP_SIZE);
step_size = gnome_config_get_int(buf);
sprintf(buf,"/panel/Drawer_%d/geometry=%d",num,
PANEL_UNKNOWN_APPLET_POSITION);
pos = gnome_config_get_int(buf);
sprintf(buf,"/panel/Drawer_%d/panel=1",num);
panel = gnome_config_get_int(buf);
load_drawer(drawer_name,drawer_iconopen,drawer_iconclosed,
step_size,pos);
step_size,pos,panel);
g_free(drawer_name);
g_free(drawer_iconopen);
g_free(drawer_iconclosed);
}
*/
}
static void
......@@ -101,7 +120,7 @@ init_user_applets(void)
{
char *applet_name;
char *applet_params;
int pos=0;
int pos=0,panel;
char buf[256];
int count,num;
......@@ -116,12 +135,106 @@ init_user_applets(void)
sprintf(buf,"/panel/Applet_%d/geometry=%d",num,
PANEL_UNKNOWN_APPLET_POSITION);
pos = gnome_config_get_int(buf);
load_applet(applet_name, applet_params, pos);
sprintf(buf,"/panel/Applet_%d/panel=1",num);
panel = gnome_config_get_int(buf);
load_applet(applet_name, applet_params, pos, panel);
g_free(applet_name);
g_free(applet_params);
}
}
static void
change_window_cursor(GdkWindow *window, GdkCursorType cursor_type)
{
GdkCursor *cursor;
cursor = gdk_cursor_new(cursor_type);
gdk_window_set_cursor(window, cursor);
gdk_cursor_destroy(cursor);
}
static void
panel_realize(GtkWidget *widget, gpointer data)
{
change_window_cursor(widget->window, GDK_ARROW);
}
static void
init_user_panels(void)
{
char buf[256];
int count,num;
int length,x,y;
PanelConfig config;
GtkWidget *panel;
count=gnome_config_get_int("/panel/Config/panel_count=0");
if(count<=0) count++; /*this will load up a single panel with
default settings*/
for(num=1;num<=count;num++) {
/*these are only for free floating non-drawer like panels */
sprintf(buf,"/panel/Panel_%d/length=%d",num, 300);
length=gnome_config_get_int(buf);
sprintf(buf,"/panel/Panel_%d/geomx=0",num);
x=gnome_config_get_int(buf);
sprintf(buf,"/panel/Panel_%d/geomy=0",num);
y=gnome_config_get_int(buf);
sprintf(buf,"/panel/Panel_%d/snapped=%d",num,
PANEL_BOTTOM);
config.snapped=gnome_config_get_int(buf);
sprintf(buf,"/panel/Panel_%d/orient=%d",num,
PANEL_HORIZONTAL);
config.orient=gnome_config_get_int(buf);
sprintf(buf,"/panel/Panel_%d/mode=%d",num,
PANEL_EXPLICIT_HIDE);
config.mode=gnome_config_get_int(buf);
sprintf(buf,"/panel/Panel_%d/state=%d",num,
PANEL_SHOWN);
config.state=gnome_config_get_int(buf);
sprintf(buf,"/panel/Panel_%d/step_size=%d",num,
DEFAULT_STEP_SIZE);
config.step_size=gnome_config_get_int(buf);
sprintf(buf,"/panel/Panel_%d/minimize_delay=%d",num,
DEFAULT_MINIMIZE_DELAY);
config.minimize_delay=gnome_config_get_int(buf);
sprintf(buf,"/panel/Panel_%d/minimized_size=%d",num,
DEFAULT_MINIMIZED_SIZE);
config.minimized_size=gnome_config_get_int(buf);
panel = panel_widget_new(length,
config.orient,
config.snapped,
config.mode,
config.state,
config.step_size,
config.minimized_size,
config.minimize_delay);
/*FIXME: move panel_menu into this file or move this
function*/
/*gtk_signal_connect(GTK_OBJECT(panel),
"button_press_event",
GTK_SIGNAL_FUNC(panel_button_press),
NULL);*/
gtk_signal_connect_after(GTK_OBJECT(panel), "realize",
GTK_SIGNAL_FUNC(panel_realize),
NULL);
/*FIXME: panel menu*/
/*create_panel_menu();*/
panels = g_list_append(panels,panel);
gtk_widget_show(panel);
}
}
/* FIXME: session management not complete. In particular, we should:
1. Actually save state in a useful way.
......@@ -139,19 +252,34 @@ init_session_management (int argc, char *argv[])
int
main(int argc, char **argv)
{
GtkWidget *base_panel;
gnome_init(&argc, &argv);
textdomain(PACKAGE);
init_session_management (argc, argv);
applet_files_init();
panel_init();
/*FIXME: make this work*/
/*create_applet_menu();*/
/*set up the tooltips*/
tooltips_enabled =
gnome_config_get_int("/panel/Config/tooltips_enabled=TRUE");
panel_tooltips=gtk_tooltips_new();
if(tooltips_enabled)
gtk_tooltips_enable(panel_tooltips);
else
gtk_tooltips_disable(panel_tooltips);
init_user_panels();
panel_init_applet_modules();
init_user_drawers();
init_user_applets();
gtk_widget_show(GTK_WIDGET(the_panel));
gtk_main();
return 0;
}
......@@ -127,7 +127,8 @@ add_to_panel (char *applet, char *arg)
cmd.cmd = PANEL_CMD_CREATE_APPLET;
cmd.params.create_applet.id = applet;
cmd.params.create_applet.params = arg;
cmd.params.create_applet.pos = PANEL_UNKNOWN_APPLET_POSITION;
cmd.params.create_applet.pos = PANEL_UNKNOWN_APPLET_POSITION;
cmd.params.create_applet.panel = 1;
(*panel_cmd_func) (&cmd);
}
......@@ -157,6 +158,7 @@ add_drawer (GtkWidget *widget, void *data)
cmd.params.create_drawer.iconclosed = "???";
cmd.params.create_drawer.step_size = PANEL_UNKNOWN_STEP_SIZE;
cmd.params.create_drawer.pos = PANEL_UNKNOWN_APPLET_POSITION;
cmd.params.create_drawer.panel = 1;
(*panel_cmd_func) (&cmd);
}
......
......@@ -17,15 +17,7 @@
/* used to temporarily store config values until the 'Apply'
* button is pressed. */
struct {
PanelOrientation orient;
PanelSnapped snapped;
PanelMode mode;
PanelState state;
gint step_size;
gint minimized_size;
gint minimize_delay;
} panel_config_struct;
PanelConfig panel_config_struct;
GtkWidget *config_window;
......
......@@ -22,17 +22,6 @@
#define APPLET_CMD_FUNC "panel_applet_cmd_func"
#define APPLET_FLAGS "panel_applet_flags"
#define DEFAULT_STEP_SIZE 40
#define DEFAULT_DELAY 0
#define DEFAULT_HEIGHT DEFAULT_APPLET_HEIGHT
/* amount of time in ms. to wait before lowering panel */
#define DEFAULT_MINIMIZE_DELAY 300
/* number of pixels it'll stick up from the bottom when using
* PANEL_GETS_HIDDEN */
#define DEFAULT_MINIMIZED_SIZE 6
static GtkWidget *applet_menu;
static GtkWidget *applet_menu_remove_item;
static GtkWidget *applet_menu_prop_separator;
......@@ -40,31 +29,21 @@ static GtkWidget *applet_menu_prop_item;
static GtkWidget *panel_menu;
/*FIXME: get rid of this, menu will be part of panel not an applet*/
static menu_count=0; /*how many "menu" applets we have ....*/
/*FIXME: this should only count "main" menus!*/
PanelWidget *the_panel;
extern GList *panels;
extern GList *applets;
static GtkTooltips *panel_tooltips;
extern GtkTooltips *panel_tooltips;
/* some prototypes */
static void properties(void);
/*FIXME: a hack for current code to work*/
#define the_panel (PANEL_WIDGET(panels->data))
static void
change_window_cursor(GdkWindow *window, GdkCursorType cursor_type)
{
GdkCursor *cursor;
cursor = gdk_cursor_new(cursor_type);
gdk_window_set_cursor(window, cursor);
gdk_cursor_destroy(cursor);
}
static void
panel_realize(GtkWidget *widget, gpointer data)
{
change_window_cursor(widget->window, GDK_ARROW);
}
/* some prototypes */
static void properties(void);
static AppletCmdFunc
......@@ -315,7 +294,7 @@ panel_quit(void)
}
static void
create_applet(char *id, char *params, int pos)
create_applet(char *id, char *params, int pos, int panel)
{
AppletCommand cmd;
AppletCmdFunc cmd_func;
......@@ -508,7 +487,8 @@ panel_log_out_callback(GtkWidget *widget, gpointer data)
static void
add_main_menu(GtkWidget *widget, gpointer data)
{
create_applet("Menu",".:1",PANEL_UNKNOWN_APPLET_POSITION);
/*FIXME: 1) doesn't work at all, 2)should add to current panel*/
create_applet("Menu",".:1",PANEL_UNKNOWN_APPLET_POSITION,1);
}
static void
......@@ -576,63 +556,6 @@ get_applet_types(void)
return list;
}
void
panel_init(void)
{
GtkWidget *pixmap;
char *pixmap_name;
char buf[256];
int i;
/*FIXME: do configuration! also get RID of the_panel!!!!!!!!!!*/
the_panel = PANEL_WIDGET(panel_widget_new(0,
PANEL_HORIZONTAL,
PANEL_BOTTOM,
PANEL_EXPLICIT_HIDE,
PANEL_SHOWN,
5,
5,
100));
/*FIXME: (see above)
sprintf(buf,"/panel/Config/position=%d",PANEL_POS_BOTTOM);
the_panel->panel->pos=gnome_config_get_int(buf);
sprintf(buf,"/panel/Config/mode=%d",PANEL_STAYS_PUT);
the_panel->mode=gnome_config_get_int(buf);
sprintf(buf,"/panel/Config/step_size=%d",DEFAULT_STEP_SIZE);
the_panel->panel->step_size=gnome_config_get_int(buf);
sprintf(buf,"/panel/Config/delay=%d",DEFAULT_DELAY);
the_panel->delay=gnome_config_get_int(buf);
sprintf(buf,"/panel/Config/minimize_delay=%d",DEFAULT_MINIMIZE_DELAY);
the_panel->minimize_delay=gnome_config_get_int(buf);
sprintf(buf,"/panel/Config/minimized_size=%d",DEFAULT_MINIMIZED_SIZE);
the_panel->minimized_size=gnome_config_get_int(buf);
the_panel->tooltips_enabled=gnome_config_get_bool(
"/panel/Config/tooltips_enabled=true");
*/
gtk_signal_connect(GTK_OBJECT(the_panel),
"button_press_event",
GTK_SIGNAL_FUNC(panel_button_press),
NULL);
gtk_signal_connect_after(GTK_OBJECT(the_panel), "realize",
GTK_SIGNAL_FUNC(panel_realize),
NULL);
create_applet_menu();
create_panel_menu();
/*set up the tooltips*/
panel_tooltips=gtk_tooltips_new();
/*FIXME!*/
if(1/*the_panel->tooltips_enabled*/)
gtk_tooltips_enable(panel_tooltips);
else
gtk_tooltips_disable(panel_tooltips);
}
static void
init_applet_module(gpointer key, gpointer value, gpointer user_data)
{
......@@ -700,7 +623,7 @@ register_toy(GtkWidget *applet, char *id, int pos, long flags)
static void
create_drawer(char *name, char *iconopen, char* iconclosed, int step_size,
int pos)
int pos, int drawer)
{
/*FIXME: add drawers*/
return;
......@@ -731,7 +654,8 @@ panel_command(PanelCommand *cmd)
case PANEL_CMD_CREATE_APPLET:
create_applet(cmd->params.create_applet.id,
cmd->params.create_applet.params,
cmd->params.create_applet.pos);
cmd->params.create_applet.pos,
cmd->params.create_applet.panel);
break;
case PANEL_CMD_REGISTER_TOY:
......@@ -746,7 +670,8 @@ panel_command(PanelCommand *cmd)
cmd->params.create_drawer.iconopen,
cmd->params.create_drawer.iconclosed,
cmd->params.create_drawer.step_size,
cmd->params.create_drawer.pos);
cmd->params.create_drawer.pos,
cmd->params.create_drawer.panel);
break;
case PANEL_CMD_SET_TOOLTIP:
......
......@@ -7,7 +7,16 @@
BEGIN_GNOME_DECLS
extern PanelWidget *the_panel;
typedef struct _PanelConfig PanelConfig;
struct _PanelConfig {
PanelOrientation orient;
PanelSnapped snapped;
PanelMode mode;
PanelState state;
gint step_size;
gint minimized_size;
gint minimize_delay;
};
void panel_init(void);
......
......@@ -37,6 +37,7 @@ typedef struct {
char *id;
char *params;
int pos;
int panel;
} create_applet;
/* Register toy parameters */
......@@ -44,6 +45,7 @@ typedef struct {
GtkWidget *applet;
char *id;
int pos;
int panel;
long flags;
} register_toy;
......@@ -54,6 +56,7 @@ typedef struct {
char *iconclosed;
int step_size;
int pos;
int panel;
} create_drawer;
/* Tooltip */
......
......@@ -17,15 +17,7 @@
/* used to temporarily store config values until the 'Apply'
* button is pressed. */
struct {
PanelOrientation orient;
PanelSnapped snapped;
PanelMode mode;
PanelState state;
gint step_size;
gint minimized_size;
gint minimize_delay;
} panel_config_struct;
PanelConfig panel_config_struct;
GtkWidget *config_window;
......
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