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

ripped out all the stuff that was for the shared lib type applets, now it

Sat Feb 14 00:50:44 1998  George Lebl  <jirka@5z.com>

        * Makefile.am, panel.c main.c, panel.h: ripped out all the
          stuff that was for the shared lib type applets, now it should
          be just adding of corba applets. note that it now doesn't work

There should be a tag with (partly) working panel ... this one DOES NOT
work ... it's missing all applet loading code as this will be replaced
by corba (hopefully shortly:)

- George
parent b5908905
Sat Feb 14 00:50:44 1998 George Lebl <jirka@5z.com>
* Makefile.am, panel.c main.c, panel.h: ripped out all the
stuff that was for the shared lib type applets, now it should
be just adding of corba applets. note that it now doesn't work
1998-02-14 Raja R Harinath <harinath@cs.umn.edu> 1998-02-14 Raja R Harinath <harinath@cs.umn.edu>
* Makefile.am (INCLUDES): Add $(X_CFLAGS). * Makefile.am (INCLUDES): Add $(X_CFLAGS).
......
Sat Feb 14 00:50:44 1998 George Lebl <jirka@5z.com>
* Makefile.am, panel.c main.c, panel.h: ripped out all the
stuff that was for the shared lib type applets, now it should
be just adding of corba applets. note that it now doesn't work
1998-02-14 Raja R Harinath <harinath@cs.umn.edu> 1998-02-14 Raja R Harinath <harinath@cs.umn.edu>
* Makefile.am (INCLUDES): Add $(X_CFLAGS). * Makefile.am (INCLUDES): Add $(X_CFLAGS).
......
...@@ -9,10 +9,6 @@ bin_PROGRAMS = panel clock_applet ...@@ -9,10 +9,6 @@ bin_PROGRAMS = panel clock_applet
panel_SOURCES = \ panel_SOURCES = \
gdkextra.c \ gdkextra.c \
gdkextra.h \ gdkextra.h \
applet_files.c \
applet_files.h \
applet_cmds.h \
panel_cmds.h \
main.c \ main.c \
panel.c \ panel.c \
panel.h \ panel.h \
...@@ -23,6 +19,8 @@ panel_SOURCES = \ ...@@ -23,6 +19,8 @@ panel_SOURCES = \
panel_LDADD = $(GNOME_LIBDIR) $(GNOMEUI_LIBS) $(DL_LIB) panel_LDADD = $(GNOME_LIBDIR) $(GNOMEUI_LIBS) $(DL_LIB)
## FIXME: move clock applet into clock
clock_applet_SOURCES = \ clock_applet_SOURCES = \
clock.c clock.c
......
...@@ -152,7 +152,6 @@ create_clock_widget (GtkWidget *window) ...@@ -152,7 +152,6 @@ create_clock_widget (GtkWidget *window)
gtk_signal_connect(GTK_OBJECT(clock), "destroy", gtk_signal_connect(GTK_OBJECT(clock), "destroy",
(GtkSignalFunc) destroy_clock, (GtkSignalFunc) destroy_clock,
NULL); NULL);
/* Call the clock's update function so that it paints its first state */ /* Call the clock's update function so that it paints its first state */
time(&current_time); time(&current_time);
...@@ -166,22 +165,16 @@ int ...@@ -166,22 +165,16 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
GtkWidget *clock; GtkWidget *clock;
GtkWidget *eb;
GtkWidget *window; GtkWidget *window;
gnome_init(&argc, &argv); gnome_init(&argc, &argv);
eb = gtk_event_box_new();
gtk_widget_show(eb);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL); window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
clock = create_clock_widget (GTK_WIDGET(window)); clock = create_clock_widget (GTK_WIDGET(window));
gtk_widget_show(clock); gtk_widget_show(clock);
gtk_container_add(GTK_CONTAINER(eb),clock); gtk_container_add(GTK_CONTAINER(window),clock);
gtk_container_add(GTK_CONTAINER(window),eb);
gtk_widget_show(window); gtk_widget_show(window);
......
...@@ -8,22 +8,9 @@ ...@@ -8,22 +8,9 @@
#include <config.h> #include <config.h>
#include <string.h> #include <string.h>
#include "gnome.h" #include "gnome.h"
#include "applet_files.h"
#include "panel_cmds.h"
#include "applet_cmds.h"
#include "panel-widget.h" #include "panel-widget.h"
#include "panel.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 *panels = NULL;
GList *drawers = NULL; GList *drawers = NULL;
GList *applets = NULL; GList *applets = NULL;
...@@ -36,32 +23,17 @@ gint tooltips_enabled = TRUE; ...@@ -36,32 +23,17 @@ gint tooltips_enabled = TRUE;
static void static void
load_applet(char *id, char *params, int pos, int panel) load_applet(char *id, char *params, int pos, int panel)
{ {
PanelCommand cmd; /*FIXME: somehow load the applet and call register_toy ... this
thing has to exec the applet or if it is a local applet then it
cmd.cmd = PANEL_CMD_CREATE_APPLET; just calls a function to create the appropriate widget and use
cmd.params.create_applet.id = id; register_toy*/
cmd.params.create_applet.params = params;
cmd.params.create_applet.pos = pos;
cmd.params.create_applet.panel = panel;
panel_command(&cmd);
} }
static void static void
load_drawer(char *name, char *iconopen, char *iconclosed, int step_size, load_drawer(char *name, char *iconopen, char *iconclosed, int step_size,
int pos, int panel) int pos, int panel)
{ {
PanelCommand cmd; /*FIXME: drawers*/
cmd.cmd = PANEL_CMD_CREATE_DRAWER;
cmd.params.create_drawer.name = name;
cmd.params.create_drawer.iconopen = iconopen;
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);
} }
static void static void
...@@ -70,9 +42,12 @@ load_default_applets(void) ...@@ -70,9 +42,12 @@ load_default_applets(void)
/* XXX: the IDs for these applets are hardcoded here. */ /* XXX: the IDs for these applets are hardcoded here. */
/* Here we use NULL to request querying of default applet parameters */ /* Here we use NULL to request querying of default applet parameters */
/*
load_applet("Menu", NULL, PANEL_UNKNOWN_APPLET_POSITION,0); load_applet("Menu", NULL, PANEL_UNKNOWN_APPLET_POSITION,0);
load_applet("Clock", NULL, PANEL_UNKNOWN_APPLET_POSITION,0); load_applet("Clock", NULL, PANEL_UNKNOWN_APPLET_POSITION,0);
load_applet("Mail check", NULL, PANEL_UNKNOWN_APPLET_POSITION,0); load_applet("Mail check", NULL, PANEL_UNKNOWN_APPLET_POSITION,0);
*/
/*FIXME: fix applet loading with corba*/
} }
static void static void
...@@ -119,6 +94,7 @@ init_user_drawers(void) ...@@ -119,6 +94,7 @@ init_user_drawers(void)
static void static void
init_user_applets(void) init_user_applets(void)
{ {
/*FIXME: change fields so that we can start corba applets*/
char *applet_name; char *applet_name;
char *applet_params; char *applet_params;
int pos=0,panel; int pos=0,panel;
...@@ -275,8 +251,6 @@ main(int argc, char **argv) ...@@ -275,8 +251,6 @@ main(int argc, char **argv)
init_session_management (argc, argv); init_session_management (argc, argv);
applet_files_init();
create_applet_menu(); create_applet_menu();
/*set up the tooltips*/ /*set up the tooltips*/
...@@ -289,9 +263,6 @@ main(int argc, char **argv) ...@@ -289,9 +263,6 @@ main(int argc, char **argv)
gtk_tooltips_disable(panel_tooltips); gtk_tooltips_disable(panel_tooltips);
init_user_panels(); init_user_panels();
panel_init_applet_modules();
init_user_drawers(); init_user_drawers();
init_user_applets(); init_user_applets();
......
...@@ -11,20 +11,13 @@ ...@@ -11,20 +11,13 @@
#include "panel-widget.h" #include "panel-widget.h"
#include "applet_files.h"
#include "gdkextra.h" #include "gdkextra.h"
#include "panel_cmds.h"
#include "applet_cmds.h"
#include "panel.h" #include "panel.h"
#include "menu.h" #include "menu.h"
#include "panel_config.h" #include "panel_config.h"
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#define APPLET_CMD_FUNC "panel_applet_cmd_func"
#define APPLET_FLAGS "panel_applet_flags"
static GtkWidget *applet_menu; static GtkWidget *applet_menu;
static GtkWidget *applet_menu_remove_item; static GtkWidget *applet_menu_remove_item;
static GtkWidget *applet_menu_prop_separator; static GtkWidget *applet_menu_prop_separator;
...@@ -50,27 +43,13 @@ extern gint tooltips_enabled; ...@@ -50,27 +43,13 @@ extern gint tooltips_enabled;
/*extern GtkMenu *root_menu; /*extern GtkMenu *root_menu;
extern GList *small_icons;*/ extern GList *small_icons;*/
/*FIXME: a hack for current code to work*/ static void
#define the_panel (PANEL_WIDGET(panels->data)) properties(PanelWidget *panel)
/* some prototypes */
static void properties(PanelWidget *panel);
static AppletCmdFunc
applet_cmd_func(GtkWidget *applet)
{ {
return gtk_object_get_data(GTK_OBJECT(applet), APPLET_CMD_FUNC); panel_config(panel);
} }
static long
applet_flags(GtkWidget *applet)
{
return (long) gtk_object_get_data(GTK_OBJECT(applet), APPLET_FLAGS);
}
static void static void
get_applet_geometry(GtkWidget *applet, int *x, int *y, int *width, int *height) get_applet_geometry(GtkWidget *applet, int *x, int *y, int *width, int *height)
...@@ -88,77 +67,15 @@ get_applet_geometry(GtkWidget *applet, int *x, int *y, int *width, int *height) ...@@ -88,77 +67,15 @@ get_applet_geometry(GtkWidget *applet, int *x, int *y, int *width, int *height)
*height = applet->allocation.height; *height = applet->allocation.height;
} }
static gpointer
call_applet(GtkWidget *applet, AppletCommand *cmd)
{
AppletCmdFunc cmd_func;
cmd->panel = the_panel;
cmd->applet = GTK_BIN(applet)->child;
cmd_func = applet_cmd_func(applet);
return (*cmd_func) (cmd);
}
/*FIXME this should be somehow done through signals and panel-widget*/ /*FIXME this should be somehow done through signals and panel-widget*/
static void static void
applet_orientation_notify(GtkWidget *widget, gpointer data) applet_orientation_notify(GtkWidget *widget, gpointer data)
{ {
AppletCommand cmd;
cmd.cmd = APPLET_CMD_ORIENTATION_CHANGE_NOTIFY;
cmd.params.orientation_change_notify.snapped = the_panel->snapped;
cmd.params.orientation_change_notify.orient = the_panel->orient;
call_applet(widget, &cmd);
}
static char *
get_applet_id(AppletInfo *info)
{
AppletCommand cmd;
switch(info->type) {
case APPLET_EXTERN:
cmd.cmd = APPLET_CMD_QUERY;
return call_applet(info->widget, &cmd);
case APPLET_DRAWER:
/*FIXME: is this the way I want to do drawers?????*/
return DRAWER_ID;
case APPLET_MENU:
return MENU_ID;
case APPLET_LAUNCHER:
return LAUNCHER_ID;
}
}
static char *
get_applet_params(AppletInfo *info)
{
AppletCommand cmd;
switch(info->type) {
case APPLET_EXTERN:
cmd.cmd = APPLET_CMD_GET_INSTANCE_PARAMS;
return call_applet(info->widget, &cmd);
case APPLET_DRAWER:
/*FIXME: is this the way I want to do drawers?????*/
return NULL /*FIXME:?????*/;
case APPLET_MENU:
/*FIXME: integrate menu.[ch]*/
/*return g_strdup(((Menu *)info->data)->path);*/
return NULL;
case APPLET_LAUNCHER:
return NULL /*FIXME:?????*/;
}
} }
static void static void
save_applet_configuration(gpointer data, gpointer user_data) save_applet_configuration(gpointer data, gpointer user_data)
{ {
char *id;
char *params = NULL;
char *path; char *path;
char *fullpath; char *fullpath;
char buf[256]; char buf[256];
...@@ -178,14 +95,11 @@ save_applet_configuration(gpointer data, gpointer user_data) ...@@ -178,14 +95,11 @@ save_applet_configuration(gpointer data, gpointer user_data)
if(pos == -1) if(pos == -1)
return; return;
id = get_applet_id(info);
params = get_applet_params(info);
sprintf(buf, "_%d/", (*num)++); sprintf(buf, "_%d/", (*num)++);
path = g_copy_strings("/panel/Applet", buf, NULL); path = g_copy_strings("/panel/Applet", buf, NULL);
fullpath = g_copy_strings(path,"id",NULL); fullpath = g_copy_strings(path,"id",NULL);
gnome_config_set_string(fullpath, id); gnome_config_set_string(fullpath, info->id);
g_free(fullpath); g_free(fullpath);
fullpath = g_copy_strings(path,"position",NULL); fullpath = g_copy_strings(path,"position",NULL);
...@@ -197,11 +111,9 @@ save_applet_configuration(gpointer data, gpointer user_data) ...@@ -197,11 +111,9 @@ save_applet_configuration(gpointer data, gpointer user_data)
g_free(fullpath); g_free(fullpath);
fullpath = g_copy_strings(path,"parameters",NULL); fullpath = g_copy_strings(path,"parameters",NULL);
gnome_config_set_string(fullpath, params); gnome_config_set_string(fullpath, info->params);
g_free(fullpath); g_free(fullpath);
if(params) g_free(params);
g_free(path); g_free(path);
} }
...@@ -285,22 +197,6 @@ save_drawer_configuration(gpointer data, gpointer user_data) ...@@ -285,22 +197,6 @@ save_drawer_configuration(gpointer data, gpointer user_data)
} }
static void
destroy_applet_module(gpointer key, gpointer value, gpointer user_data)
{
AppletCommand cmd;
AppletFile *af;
cmd.cmd = APPLET_CMD_DESTROY_MODULE;
cmd.panel = NULL; /*the_panel;*/
cmd.applet = NULL;
af = value;
(*af->cmd_func) (&cmd);
}
static void static void
destroy_widget_list(gpointer data, gpointer user_data) destroy_widget_list(gpointer data, gpointer user_data)
{ {
...@@ -354,12 +250,11 @@ panel_session_save (gpointer client_data, ...@@ -354,12 +250,11 @@ panel_session_save (gpointer client_data,
gnome_config_sync(); gnome_config_sync();
/*FIXME: tell applets to go kill themselves*/
g_list_foreach(drawers,destroy_widget_list,NULL); g_list_foreach(drawers,destroy_widget_list,NULL);
g_list_foreach(panels,destroy_widget_list,NULL); g_list_foreach(panels,destroy_widget_list,NULL);
g_hash_table_foreach(applet_files_ht, destroy_applet_module, NULL);
applet_files_destroy();
gtk_widget_unref(applet_menu); gtk_widget_unref(applet_menu);
gtk_widget_unref(panel_tooltips); gtk_widget_unref(panel_tooltips);
...@@ -380,69 +275,26 @@ panel_session_save (gpointer client_data, ...@@ -380,69 +275,26 @@ panel_session_save (gpointer client_data,
static void static void
panel_quit(void) panel_quit(void)
{ {
if (! gnome_session_connected_p ()) if (! gnome_session_connected_p ()) {
{ panel_session_save (NULL, GNOME_SAVE_BOTH, 1,
panel_session_save (NULL, GNOME_SAVE_BOTH, 1, GNOME_INTERACT_NONE, 0); GNOME_INTERACT_NONE, 0);
gtk_main_quit (); gtk_main_quit ();
/* We don't want to return, because we've probably been called from an /* We don't want to return, because we've probably been
* applet which has since been dlclose()'d, and we'd end up with a SEGV called from an applet which has since been dlclose()'d,
* when we tried to return to the now-nonexistent code page. */ and we'd end up with a SEGV when we tried to return to
exit(0); the now-nonexistent code page. */
} exit(0);
else } else {
{ /* We request a completely interactive, full, slow shutdown. */
/* We request a completely interactive, full, slow shutdown. */ gnome_session_request_save (GNOME_SAVE_BOTH, 1,
gnome_session_request_save (GNOME_SAVE_BOTH, 1, GNOME_INTERACT_ANY, GNOME_INTERACT_ANY, 0, 1);
0, 1); }
}
} }
/*FIXME: how will we handle adding of applets????*/
static void static void
create_applet(char *id, char *params, int pos, int panel) create_applet(char *id, char *params, int pos, int panel)
{ {
AppletCommand cmd;
AppletCmdFunc cmd_func;
int requested;
g_assert(id != NULL);
cmd_func = get_applet_cmd_func(id);
if (!cmd_func) {
fprintf(stderr, "create_applet: could not find applet \"%s\"\n", id);
return;
}
requested = FALSE;
if (!params) {
cmd.cmd = APPLET_CMD_GET_DEFAULT_PARAMS;
cmd.panel = the_panel;
cmd.applet = NULL;
params = (*cmd_func) (&cmd);
if (!params) {
fprintf(stderr,
"create_applet: warning: applet \"%s\" returned NULL default parameters\n"
" using empty parameter string \"\"\n",
id);
params = g_strdup("");
}
requested = TRUE;
}
cmd.cmd = APPLET_CMD_CREATE_INSTANCE;
cmd.panel = PANEL_WIDGET(g_list_nth(panels,panel)->data);
cmd.applet = NULL;
cmd.params.create_instance.params = params;
cmd.params.create_instance.pos = pos;
cmd.params.create_instance.panel = panel;
(*cmd_func) (&cmd);
if (requested)
g_free(params);
} }
static PanelWidget * static PanelWidget *
...@@ -461,33 +313,30 @@ find_applet_panel(GtkWidget *applet) ...@@ -461,33 +313,30 @@ find_applet_panel(GtkWidget *applet)
static void static void
move_applet_callback(GtkWidget *widget, gpointer data) move_applet_callback(GtkWidget *widget, gpointer data)
{ {
GtkWidget *applet; AppletInfo *info;
PanelWidget *panel; PanelWidget *panel;
applet = gtk_object_get_user_data(GTK_OBJECT(applet_menu)); info = gtk_object_get_user_data(GTK_OBJECT(applet_menu));
if(!(panel = find_applet_panel(applet))) if(!(panel = find_applet_panel(info->widget)))
return; return;
panel_widget_applet_drag_start(panel,applet); panel_widget_applet_drag_start(panel,info->widget);
} }
static void static void
remove_applet_callback(GtkWidget *widget, gpointer data) remove_applet_callback(GtkWidget *widget, gpointer data)
{ {
GtkWidget *applet;
AppletInfo *info; AppletInfo *info;
gchar *id; gchar *id;
gint pos; gint pos;
PanelWidget *panel; PanelWidget *panel;
applet = gtk_object_get_user_data(GTK_OBJECT(applet_menu)); info = gtk_object_get_user_data(GTK_OBJECT(applet_menu));
info = gtk_object_get_user_data(GTK_OBJECT(applet));
id = get_applet_id(info);
if(strcmp(id,"Menu")==0) { /*FIXME: this will go*/
if(strcmp(info->id,"Menu")==0) {
if(menu_count<=1) if(menu_count<=1)
return; return;
/*FIXME: do something to make the user aware that this was /*FIXME: do something to make the user aware that this was
...@@ -496,27 +345,24 @@ remove_applet_callback(GtkWidget *widget, gpointer data) ...@@ -496,27 +345,24 @@ remove_applet_callback(GtkWidget *widget, gpointer data)
} }
applets=g_list_remove(applets,info); applets=g_list_remove(applets,info);
if(!(panel = find_applet_panel(applet))) if(!(panel = find_applet_panel(info->widget)))
return; return;
panel_widget_remove(panel,applet); panel_widget_remove(panel,info->widget);
gtk_widget_unref(applet); gtk_widget_unref(info->widget);
if(info->assoc) if(info->assoc)
gtk_widget_unref(info->assoc); gtk_widget_unref(info->assoc);
g_free(info->id);
if(info->params) g_free(info->params);
g_free(info);
} }
/*tell applet to do properties*/
static void static void
applet_properties_callback(GtkWidget *widget, gpointer data) applet_properties_callback(GtkWidget *widget, gpointer data)
{ {
GtkWidget *applet;
AppletCommand cmd;
applet = gtk_object_get_user_data(GTK_OBJECT(applet_menu));
cmd.cmd = APPLET_CMD_PROPERTIES;
call_applet(applet, &cmd);
} }
void void
...@@ -559,17 +405,9 @@ create_applet_menu(void) ...@@ -559,17 +405,9 @@ create_applet_menu(void)
static void static void
show_applet_menu(GtkWidget *applet) show_applet_menu(AppletInfo *info)
{ {
long flags; if (info->flags & APPLET_HAS_PROPERTIES) {
AppletCommand cmd;
gchar *id;
/*FIXME: DRAWERS crash on this, fix that */
flags = applet_flags(applet);
if (flags & APPLET_HAS_PROPERTIES) {
gtk_widget_show(applet_menu_prop_separator); gtk_widget_show(applet_menu_prop_separator);
gtk_widget_show(applet_menu_prop_item); gtk_widget_show(applet_menu_prop_item);
} else { } else {
...@@ -577,14 +415,12 @@ show_applet_menu(GtkWidget *applet) ...@@ -577,14 +415,12 @@ show_applet_menu(GtkWidget *applet)
gtk_widget_hide(applet_menu_prop_item); gtk_widget_hide(applet_menu_prop_item);
} }
cmd.cmd = APPLET_CMD_QUERY; /*FIMXE: this should go*/
id = call_applet(applet, &cmd); if(strcmp(info->id,"Menu")!=0 || menu_count>1)
if(strcmp(id,"Menu")!=0 || menu_count>1)
gtk_widget_show(applet_menu_remove_item); gtk_widget_show(applet_menu_remove_item);
else else
gtk_widget_hide(applet_menu_remove_item); gtk_widget_hide(applet_menu_remove_item);
gtk_object_set_user_data(GTK_OBJECT(applet_menu), applet); gtk_object_set_user_data(GTK_OBJECT(applet_menu), info);
gtk_menu_popup(GTK_MENU(applet_menu), NULL, NULL, NULL, NULL, 3, time(NULL)); gtk_menu_popup(GTK_MENU(applet_menu), NULL, NULL, NULL, NULL, 3, time(NULL));
/*FIXME: make it pop-up on some title bar of the applet menu or /*FIXME: make it pop-up on some title bar of the applet menu or
...@@ -595,7 +431,7 @@ static gint ...@@ -595,7 +431,7 @@ static gint
applet_button_press(GtkWidget *widget,GdkEventButton *event, gpointer data) applet_button_press(GtkWidget *widget,GdkEventButton *event, gpointer data)
{ {
if(event->button==3) { if(event->button==3) {
show_applet_menu(widget); show_applet_menu((AppletInfo *)data);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
...@@ -621,6 +457,7 @@ add_main_menu(GtkWidget *widget, gpointer data) ...@@ -621,6 +457,7 @@ add_main_menu(GtkWidget *widget, gpointer data)
create_applet("Menu",".:1",PANEL_UNKNOWN_APPLET_POSITION,1); create_applet("Menu",".:1",PANEL_UNKNOWN_APPLET_POSITION,1);
} }
/*FIXME: add a function that does this, so generalize register_toy for this*/
static void static void
add_reparent(GtkWidget *widget, gpointer data) add_reparent(GtkWidget *widget, gpointer data)
{ {
...@@ -688,47 +525,6 @@ create_panel_root_menu(PanelWidget *panel) ...@@ -688,47 +525,6 @@ create_panel_root_menu(PanelWidget *panel)
} }
static void
get_applet_type(gpointer key, gpointer value, gpointer user_data)
{
GList **list = user_data;