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

decorbaized

Sun May 03 02:16:53 1998  George Lebl  <jirka@5z.com>

        * launcher.[ch]: decorbaized

        * panel.[ch],main.c: integrated the launcher applet into the
          main application. this makes things a hellovalot more stable
          actually, also added a way for the panel to read old
          config files so that all of you who have alreay some kind of
          setup won't have to change it

        * panel.sh: removed for good

        * Makefile.am: don't build launcher_applet and don't
          install panel.sh, plus ad dthe launcher sources to
          panel app

        * gnome-panel.idl, mico-glue.(cc|h): removed the launcher
          interface
parent bfd53c80
Sun May 03 02:16:53 1998 George Lebl <jirka@5z.com>
* launcher.[ch]: decorbaized
* panel.[ch],main.c: integrated the launcher applet into the
main application. this makes things a hellovalot more stable
actually, also added a way for the panel to read old
config files so that all of you who have alreay some kind of
setup won't have to change it
* panel.sh: removed for good
* Makefile.am: don't build launcher_applet and don't
install panel.sh, plus ad dthe launcher sources to
panel app
* gnome-panel.idl, mico-glue.(cc|h): removed the launcher
interface
Sat May 02 23:56:34 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch]: dearrayizification is now officially
......
Sun May 03 02:16:53 1998 George Lebl <jirka@5z.com>
* launcher.[ch]: decorbaized
* panel.[ch],main.c: integrated the launcher applet into the
main application. this makes things a hellovalot more stable
actually, also added a way for the panel to read old
config files so that all of you who have alreay some kind of
setup won't have to change it
* panel.sh: removed for good
* Makefile.am: don't build launcher_applet and don't
install panel.sh, plus ad dthe launcher sources to
panel app
* gnome-panel.idl, mico-glue.(cc|h): removed the launcher
interface
Sat May 02 23:56:34 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch]: dearrayizification is now officially
......
......@@ -21,9 +21,7 @@ INCLUDES = -I. -I$(srcdir) \
## FIXME: logout should really be an internal applets since it is just
## too trivial
bin_PROGRAMS = panel logout_applet launcher_applet
bin_SCRIPTS = panel.sh
bin_PROGRAMS = panel logout_applet #launcher_applet
CORBA_SOURCES = \
gnome-panel.cc \
......@@ -78,17 +76,19 @@ panel_SOURCES = \
panel-widget.c \
panel-widget.h \
panel-util.c \
launcher.c \
launcher.h \
$(CORBA_SOURCES)
panel_LDADD = $(GNOME_LIBDIR) $(MICO_LIBS) -lXt $(GNOMEUI_LIBS) $(INTLLIBS)
launcher_applet_SOURCES = \
launcher-lib.cc \
launcher-lib.h \
launcher.c
#launcher_applet_SOURCES = \
# launcher-lib.cc \
# launcher-lib.h \
# launcher.c
launcher_applet_LDADD = libpanel_applet.la $(GNOME_LIBDIR) $(MICO_LIBS) -lXt \
$(GNOMEUI_LIBS) $(INTLLIBS)
#launcher_applet_LDADD = libpanel_applet.la $(GNOME_LIBDIR) $(MICO_LIBS) -lXt \
# $(GNOMEUI_LIBS) $(INTLLIBS)
logout_applet_SOURCES = \
logout.c
......
......@@ -43,10 +43,5 @@ module GNOME {
in string cfgpath,
in string globcfgpath);
};
interface Launcher {
void start_new_launcher (in string cookie, in string path);
void restart_all_launchers (in string cookie);
};
};
......@@ -5,6 +5,7 @@
* Authors: Miguel de Icaza
* Federico Mena
* CORBAized by George Lebl
* de-CORBAized by George Lebl
*/
#include <config.h>
......@@ -14,23 +15,14 @@
#include <dirent.h>
#include <string.h>
#include "gnome.h"
#include "applet-lib.h"
#include "launcher-lib.h"
#include "panel.h"
#define CONFIG_TAG "Launcher"
#define APPLET_DATA "launcher_data"
static int launcher_count = 0;
static GList *launchers = NULL;
extern GtkTooltips *panel_tooltips;
static char *default_app_pixmap;
static char *myinvoc;
typedef struct {
int applet_id;
GtkWidget *plug;
GtkWidget *button;
gint signal_click_tag;
GnomeDesktopEntry *dentry;
......@@ -52,24 +44,6 @@ typedef struct {
GnomeDesktopEntry *dentry;
} Properties;
static Launcher *
find_launcher(int applet_id)
{
GList *list;
if(applet_id < 0)
return NULL;
for(list=launchers;list!=NULL;list=g_list_next(list)) {
Launcher *l = list->data;
if(l->applet_id == applet_id)
return l;
}
return NULL;
}
static void
launch (GtkWidget *widget, void *data)
{
......@@ -78,8 +52,8 @@ launch (GtkWidget *widget, void *data)
gnome_desktop_entry_launch (item);
}
static Launcher *
create_launcher (GtkWidget *window, char *parameters)
Launcher *
create_launcher (char *parameters)
{
GtkWidget *pixmap;
GnomeDesktopEntry *dentry;
......@@ -143,7 +117,6 @@ create_launcher (GtkWidget *window, char *parameters)
launcher->dentry = dentry;
launcher->applet_id = -1;
launcher->plug = NULL;
return launcher;
}
......@@ -240,8 +213,8 @@ properties_apply_callback(GtkWidget *widget, gpointer data)
gnome_desktop_entry_free(prop->dentry);
prop->dentry = dentry;
gnome_panel_applet_add_tooltip(prop->launcher->applet_id,
dentry->comment);
gtk_tooltips_set_tip (panel_tooltips,prop->launcher->button->parent,
dentry->comment,NULL);
pixmap=GTK_BUTTON(prop->launcher->button)->child;
......@@ -352,15 +325,15 @@ create_properties_dialog(GnomeDesktopEntry *dentry, Launcher *launcher)
return dialog;
}
static void
properties(gint applet_id, gpointer data)
void
launcher_properties(Launcher *launcher)
{
GnomeDesktopEntry *dentry;
char *path;
GtkWidget *dialog;
Launcher *launcher;
launcher = find_launcher(applet_id);
/*FIXME:
launcher = find_launcher(applet_id);*/
path = launcher->dentry->location;
......@@ -375,178 +348,3 @@ properties(gint applet_id, gpointer data)
dialog = create_properties_dialog(dentry,launcher);
gtk_widget_show(dialog);
}
/*these are commands sent over corba:*/
void
change_orient(int applet_id, int orient)
{
/*PanelOrientType o = (PanelOrientType)orient;*/
}
int
session_save(int applet_id, const char *cfgpath, const char *globcfgpath)
{
char *query;
Launcher *launcher;
launcher = find_launcher(applet_id);
g_return_if_fail(launcher != NULL);
query = g_copy_strings(cfgpath,"path",NULL);
gnome_config_set_string(query,launcher->dentry->location);
g_free(query);
query = g_copy_strings(globcfgpath,CONFIG_TAG,"/count",NULL);
gnome_config_set_int(query,launcher_count);
g_free(query);
gnome_config_sync();
gnome_config_drop_all();
return TRUE;
}
static gint
destroy_plug(GtkWidget *widget, gpointer data)
{
Launcher *launcher = data;
g_return_val_if_fail(launcher != NULL, FALSE);
launcher_count--;
launchers = g_list_remove(launchers,launcher);
gnome_desktop_entry_free(launcher->dentry);
g_free(launcher);
return FALSE;
}
void
start_new_launcher(const char *path)
{
GtkWidget *plug;
Launcher *launcher;
char *result;
char *cfgpath;
char *globcfgpath;
int applet_id = -1;
guint32 winid;
result = gnome_panel_applet_request_id(myinvoc, &applet_id,
&cfgpath, &globcfgpath,
&winid);
if (result)
g_error ("Could not talk to the Panel: %s\n", result);
plug = gtk_plug_new(winid);
launcher = NULL;
/*no path given, try getting it from config*/
if(!path) {
char *params;
char *query = g_copy_strings(cfgpath,"path=",NULL);
params = gnome_config_get_string(query);
if(params && params[0]!='\0')
launcher = create_launcher (plug, params);
g_free(params);
g_free(query);
} else {
launcher = create_launcher (plug, (char *)path);
}
g_free(globcfgpath);
g_free(cfgpath);
/*we can't start a launcher if we don't know what to start*/
if (!launcher) {
gnome_panel_applet_abort_id(applet_id);
return;
}
launcher->plug = plug;
launcher->applet_id = applet_id;
gtk_container_add (GTK_CONTAINER (plug), launcher->button);
gtk_widget_show (plug);
gtk_signal_connect(GTK_OBJECT(plug),"destroy",
GTK_SIGNAL_FUNC(destroy_plug),
launcher);
result = gnome_panel_applet_register(plug,applet_id);
if (result)
g_error ("Could not talk to the Panel: %s\n", result);
launchers = g_list_append(launchers,launcher);
launcher_count++;
gnome_panel_applet_register_callback(applet_id,
"properties",
_("Properties ..."),
properties,
NULL);
gnome_panel_applet_add_tooltip(applet_id, launcher->dentry->comment);
}
/*destructive call, should be done only on restart*/
void
restart_all_launchers(void)
{
char *globcfg;
char *query;
int i,count;
if (!gnome_panel_applet_reinit_corba ())
g_error ("Could not comunicate with the panel\n");
launcher_count=0;
while(launchers) {
Launcher *launcher=launchers->data;
/*FIXME: somehow unref or something this, so we don't leak,
unref gives me a bunch of warnings here*/
if(launcher->plug)
gtk_widget_destroy(launcher->plug);
launchers = g_list_remove(launchers,launcher);
}
gnome_panel_applet_request_glob_cfg(&globcfg);
query = g_copy_strings(globcfg,CONFIG_TAG,"/count=0",NULL);
count = gnome_config_get_int(query);
g_free(query);
g_free(globcfg);
for(i=0;i<count;i++)
start_new_launcher(NULL);
}
int
main(int argc, char **argv)
{
/*char *mypath;*/
panel_corba_register_arguments ();
gnome_init("launcher_applet", NULL, argc, argv, 0, NULL);
/*we pass '#' plus a comment (our path) to the panel to start,
that will tell the panel to doing nothing (next session),
but it will reserve a spot for us on the correct place, and
this is the string that we identify as when we ask for the
spot*/
/*
mypath = get_full_path(argv[0]);
if(!mypath)
return 1;*/
/* we pass an id starting with # to the panel to identify us,
but not by path, this is so mc can take the place of the
launcher_applet or any other filemanager */
myinvoc = "#panel.application.launcher";
/*myinvoc = g_copy_strings("#",mypath,NULL);
g_free(mypath);*/
launcher_corba_gtk_main ("IDL:GNOME/Launcher:1.0");
return 0;
}
/*
* GNOME panel launcher module.
* (C) 1997 The Free Software Foundation
*
* Authors: Miguel de Icaza
* Federico Mena
* CORBAized by George Lebl
* de-CORBAized by George Lebl
*/
#ifndef LAUNCHER_H
#define LAUNCHER_H
typedef struct {
int applet_id;
GtkWidget *button;
gint signal_click_tag;
GnomeDesktopEntry *dentry;
} Launcher;
Launcher * create_launcher (char *parameters);
void launcher_properties(Launcher *launcher);
#endif
......@@ -20,13 +20,10 @@
#include "mico-glue.h"
#include "mico-parse.h"
#include "panel-util.h"
#include "launcher.h"
#include "cookie.h"
#ifdef USE_INTERNAL_LAUNCHER
int launcher_pid=0;
#endif
/*GList *panels = NULL;*/
GArray *applets;
gint applet_count;
......@@ -147,6 +144,18 @@ load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
params[0] == '\0')
return;
/*VERY UGLY compatibility hack for the old launcher applet*/
if(strcmp(params,"#panel.application.launcher")==0) {
gchar *p;
p = g_copy_strings(cfgpath,"path=",NULL);
fullparams = gnome_config_get_string(p);
g_free(p);
load_applet(LAUNCHER_ID,fullparams,pos,panel,cfgpath);
g_free(fullparams);
return;
}
/*make it an absolute path, same as the applets will
interpret it and the applets will sign themselves as
this, so it has to be exactly the same*/
......@@ -194,6 +203,19 @@ load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
register_toy(menu->button,menu->menu,menu,MENU_ID,params,pos,
panel,NULL,APPLET_MENU);
} else if(strcmp(id_str,LAUNCHER_ID) == 0) {
Launcher *launcher;
launcher = create_launcher(params);
register_toy(launcher->button,NULL,launcher,LAUNCHER_ID,
params,pos,panel,NULL,APPLET_LAUNCHER);
gtk_tooltips_set_tip (panel_tooltips,launcher->button->parent,
launcher->dentry->comment,NULL);
applet_add_callback(applet_count-1,"properties",
_("Properties..."));
} else if(strcmp(id_str,DRAWER_ID) == 0) {
Drawer *drawer;
PanelWidget *parent;
......@@ -773,14 +795,6 @@ init_user_panels(void)
}
}
gint
call_launcher_timeout(gpointer data)
{
puts("Waiting for launcher ...");
return !(panel_corba_restart_launchers());
}
/*I guess this should be called after we load up, but the problem is
we never know when all the applets are going to finish loading and
we don't want to clean the file before they load up, so now we
......@@ -903,18 +917,6 @@ main(int argc, char **argv)
cookie = create_cookie ();
gnome_config_private_set_string ("/panel/Secret/cookie", cookie);
#ifdef USE_INTERNAL_LAUNCHER
launcher_pid=fork();
if(launcher_pid==-1)
g_error("Can't fork!");
if(launcher_pid==0) {
execlp("launcher_applet","launcher_applet",NULL);
g_error("Can't execlp!");
_exit(1);
}
#endif
applets = g_array_new(FALSE);
applet_count=0;
......@@ -950,8 +952,6 @@ main(int argc, char **argv)
apply_global_config();
gtk_timeout_add(300,call_launcher_timeout,NULL);
/*everything is erady ... load up the applets*/
load_queued_applets();
......
......@@ -119,9 +119,7 @@ add_app_to_panel (GtkWidget *widget, void *data)
{
GnomeDesktopEntry *ii = data;
panel_corba_call_launcher(ii->location);
return TRUE;
return add_to_panel (LAUNCHER_ID, ii->location);
}
static gint
......
......@@ -168,70 +168,6 @@ panel_corba_clean_up(void)
g_free (name);
}
int
panel_corba_call_launcher(const char *path)
{
char *name;
char *iior;
char hostname [1024];
gethostname (hostname, sizeof (hostname));
if (hostname [0] == 0)
strcpy (hostname, "unknown-host");
name = g_copy_strings ("/CORBA-servers/Launcher-", hostname,
"/DISPLAY-", getenv ("DISPLAY"), NULL);
iior = gnome_config_get_string (name);
g_free (name);
if (!iior)
return FALSE;
CORBA::Object_var obj = orb_ptr->string_to_object (iior);
GNOME::Launcher_var launcher_client = GNOME::Launcher::_narrow (obj);
try {
launcher_client->start_new_launcher(cookie, path);
} catch( ... ) {
return FALSE;
}
return TRUE;
}
int
panel_corba_restart_launchers(void)
{
char *name;
char *iior;
char hostname [1024];
gethostname (hostname, sizeof (hostname));
if (hostname [0] == 0)
strcpy (hostname, "unknown-host");
name = g_copy_strings ("/CORBA-servers/Launcher-", hostname,
"/DISPLAY-", getenv ("DISPLAY"), NULL);
iior = gnome_config_get_string (name);
g_free (name);
if (!iior)
return FALSE;
CORBA::Object_var obj = orb_ptr->string_to_object (iior);
GNOME::Launcher_var launcher_client = GNOME::Launcher::_narrow (obj);
try {
launcher_client->restart_all_launchers(cookie);
} catch( ... ) {
return FALSE;
}
return TRUE;
}
int
send_applet_session_save (const char *ior, int applet_id, const char *cfgpath,
const char *globcfgpath)
......
......@@ -9,10 +9,6 @@ void panel_corba_gtk_main (char *service_name);
void panel_corba_clean_up(void);
int panel_corba_call_launcher(const char *path);
int panel_corba_restart_launchers(void);
int send_applet_session_save (const char *ior, int id,
const char *cfgpath,
const char *globcfgpath);
......
......@@ -42,10 +42,6 @@ extern GlobalConfig global_config;
extern char *panel_cfg_path;
extern char *old_panel_cfg_path;
#ifdef USE_INTERNAL_LAUNCHER
extern int launcher_pid;
#endif
void
apply_global_config(void)
{
......@@ -299,10 +295,6 @@ panel_session_save (GnomeClient *client,
/*clean up corba stuff*/
panel_corba_clean_up();
#ifdef USE_INTERNAL_LAUNCHER
puts("killing launcher");
kill(launcher_pid,SIGTERM);
#endif
gtk_exit (0);
}
......@@ -420,10 +412,9 @@ applet_callback_callback(GtkWidget *widget, gpointer data)
send_applet_do_callback(info->id_str,
info->applet_id,
menu->name);
} else if(info->type != APPLET_EXTERN_PENDING &&
info->type==APPLET_EXTERN_RESERVED &&
info->type != APPLET_EMPTY) {
/*handle internal applet callbacks here*/
} else if(info->type == APPLET_LAUNCHER) {
if(strcmp(menu->name,"properties")==0)
launcher_properties(info->data);
}
}
......
......@@ -11,6 +11,7 @@ BEGIN_GNOME_DECLS
#define LOGOUT_ID "Logout"
#define SWALLOW_ID "Swallow"
#define EXTERN_ID "Extern"
#define LAUNCHER_ID "Launcher"
#define DEFAULT_AUTO_HIDE_STEP_SIZE 10
#define DEFAULT_EXPLICIT_HIDE_STEP_SIZE 50
......@@ -44,6 +45,7 @@ typedef enum {
APPLET_MENU,
APPLET_LOGOUT,
APPLET_SWALLOW,
APPLET_LAUNCHER,
APPLET_EMPTY
} AppletType;
......
#!/bin/sh
#this is a temporary script to launch the launcher and the panel
#this will kill the launcher from before if it is still running
#it's a little dirty, but it works
kill `ps x|awk '/[l]auncher_applet/ {print $1}'`
#now started in panel binary
#launcher_applet &
panel
......@@ -43,10 +43,5 @@ module GNOME {
in string cfgpath,
in string globcfgpath);
};
interface Launcher {
void start_new_launcher (in string cookie, in string path);
void restart_all_launchers (in string cookie);
};
};
......@@ -43,10 +43,5 @@ module GNOME {
in string cfgpath,
in string globcfgpath);
};
interface Launcher {
void start_new_launcher (in string cookie, in string path);
void restart_all_launchers (in string cookie);
};
};
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