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

Remove bits of cruft. Add the applet like reload hack for swallowed

Thu Nov 16 21:45:38 2000  George Lebl <jirka@5z.com>

	* applet.c, session.c, swallow.[ch]:  Remove bits of cruft.  Add the
	  applet like reload hack for swallowed thingies.  Also fix a
	  destruction crash by refcounting the swallow structure.

	* panel.c: Accept the nautilus background reset ugly ugly ugly hack

	* session.c: cleanup, remove some cruft, and set the clock format
	  default to use the space padded hour format as that's more correct.
parent 0d0ff2c1
Thu Nov 16 21:45:38 2000 George Lebl <jirka@5z.com>
* applet.c, session.c, swallow.[ch]: Remove bits of cruft. Add the
applet like reload hack for swallowed thingies. Also fix a
destruction crash by refcounting the swallow structure.
* panel.c: Accept the nautilus background reset ugly ugly ugly hack
* session.c: cleanup, remove some cruft, and set the clock format
default to use the space padded hour format as that's more correct.
2000-11-15 Jacob "Ulysses" Berkman <jacob@helixcode.com>
* Makefile.am: remove some cruft, yo
......
Thu Nov 16 21:45:38 2000 George Lebl <jirka@5z.com>
* applet.c, session.c, swallow.[ch]: Remove bits of cruft. Add the
applet like reload hack for swallowed thingies. Also fix a
destruction crash by refcounting the swallow structure.
* panel.c: Accept the nautilus background reset ugly ugly ugly hack
* session.c: cleanup, remove some cruft, and set the clock format
default to use the space padded hour format as that's more correct.
2000-11-15 Jacob "Ulysses" Berkman <jacob@helixcode.com>
* Makefile.am: remove some cruft, yo
......
......@@ -76,6 +76,9 @@ kill_applet_in_idle(gpointer data)
if (info->type == APPLET_EXTERN) {
Extern *ext = info->data;
ext->clean_remove = TRUE;
} else if (info->type == APPLET_SWALLOW) {
Swallow *swallow = info->data;
swallow->clean_remove = TRUE;
}
panel_clean_applet (info);
return FALSE;
......
......@@ -20,6 +20,10 @@
#include "gnome-run.h"
#include "gnome-panel.h"
/* nautilus uses this UTTER HACK to reset backgrounds, ugly ugly ugly,
* broken, ugly ugly, but whatever */
#define RESET_IMAGE_NAME "/nautilus/backgrounds/reset.png"
#define PANEL_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_POINTER_MOTION_MASK | \
......@@ -880,7 +884,7 @@ drop_url(PanelWidget *panel, int pos, char *url)
}
static void
drop_menu(PanelWidget *panel, int pos, char *dir)
drop_menu (PanelWidget *panel, int pos, char *dir)
{
int flags = MAIN_MENU_SYSTEM | MAIN_MENU_USER;
DistributionType distribution = get_distribution_type ();
......@@ -895,15 +899,15 @@ drop_menu(PanelWidget *panel, int pos, char *dir)
}
static void
drop_urilist(PanelWidget *panel, int pos, char *urilist,
gboolean background_drops)
drop_urilist (PanelWidget *panel, int pos, char *urilist,
gboolean background_drops)
{
GList *li, *files;
struct stat s;
files = gnome_uri_list_extract_uris(urilist);
for(li = files; li; li = g_list_next(li)) {
for(li = files; li; li = li->next) {
const char *mimetype;
char *filename;
......@@ -955,10 +959,25 @@ drop_bgimage(PanelWidget *panel, char *bgimage)
char *filename;
filename = extract_filename(bgimage);
if(filename != NULL) {
panel_widget_set_back_pixmap (panel, filename);
if (filename != NULL) {
/* an incredible hack, no, worse, INCREDIBLE FUCKING HACK,
* whatever, we need to work with nautilus on this one */
if (strstr (filename, RESET_IMAGE_NAME) != NULL) {
panel_widget_change_params (panel,
panel->orient,
panel->sz,
PANEL_BACK_NONE,
panel->back_pixmap,
panel->fit_pixmap_bg,
panel->strech_pixmap_bg,
panel->rotate_pixmap_bg,
panel->no_padding_on_ends,
&panel->back_color);
} else {
panel_widget_set_back_pixmap (panel, filename);
}
g_free(filename);
g_free (filename);
}
}
......
......@@ -55,22 +55,23 @@ static int ss_timeout = 500;
/*send the tooltips state to all external applets*/
static void
send_tooltips_state(int enabled)
send_tooltips_state(gboolean enabled)
{
GSList *li;
for(li = applets; li!=NULL; li = g_slist_next(li)) {
for(li = applets; li != NULL; li = li->next) {
AppletInfo *info = li->data;
if(info->type == APPLET_EXTERN) {
if (info->type == APPLET_EXTERN) {
Extern *ext = info->data;
g_assert(ext);
g_assert(ext != NULL);
/*if it's not set yet, don't send it, it will be sent
when the ior is discovered anyhow, so this would be
redundant anyway*/
if(ext->applet) {
if (ext->applet != NULL) {
CORBA_Environment ev;
CORBA_exception_init(&ev);
GNOME_Applet_set_tooltips_state(ext->applet, enabled, &ev);
GNOME_Applet_set_tooltips_state(ext->applet,
enabled, &ev);
if(ev._major)
panel_clean_applet(ext->info);
CORBA_exception_free(&ev);
......@@ -232,7 +233,7 @@ apply_global_config (void)
}
static void
timeout_dlg_realized(GtkWidget *dialog)
timeout_dlg_realized (GtkWidget *dialog)
{
/* always make top layer */
gnome_win_hints_set_layer (GTK_WIDGET(dialog),
......@@ -240,16 +241,16 @@ timeout_dlg_realized(GtkWidget *dialog)
}
static gboolean
session_save_timeout(gpointer data)
session_save_timeout (gpointer data)
{
int cookie = GPOINTER_TO_INT(data);
if(cookie != ss_cookie)
int cookie = GPOINTER_TO_INT (data);
if (cookie != ss_cookie)
return FALSE;
#ifdef PANEL_DEBUG
printf("SAVE TIMEOUT (%u)\n",ss_cookie);
#endif
if (!ss_interactive)
if ( ! ss_interactive)
return FALSE;
ss_timeout_dlg =
......@@ -813,15 +814,13 @@ panel_session_die (GnomeClient *client,
{
GSList *li;
gtk_timeout_remove(config_sync_timeout);
gtk_timeout_remove (config_sync_timeout);
config_sync_timeout = 0;
/*don't catch these any more*/
signal(SIGCHLD, SIG_DFL);
status_inhibit = TRUE;
status_spot_remove_all();
for(li=applets; li!=NULL; li=g_slist_next(li)) {
status_spot_remove_all ();
for (li = applets; li != NULL; li = li->next) {
AppletInfo *info = li->data;
if(info->type == APPLET_EXTERN) {
Extern *ext = info->data;
......@@ -829,6 +828,7 @@ panel_session_die (GnomeClient *client,
gtk_widget_destroy (info->widget);
} else if(info->type == APPLET_SWALLOW) {
Swallow *swallow = info->data;
swallow->clean_remove = TRUE;
if(GTK_SOCKET(swallow->socket)->plug_window)
XKillClient(GDK_DISPLAY(),
GDK_WINDOW_XWINDOW(GTK_SOCKET(swallow->socket)->plug_window));
......@@ -1470,7 +1470,7 @@ init_user_panels(void)
panel = foobar_widget_new ();
/* Don't translate the first part of this string */
s = gnome_config_get_string (_("/panel/Config/clock_format=%I:%M:%S %p"));
s = gnome_config_get_string (_("/panel/Config/clock_format=%l:%M:%S %p"));
if (s != NULL)
foobar_widget_set_clock_format (FOOBAR_WIDGET (panel), s);
g_free (s);
......
......@@ -27,103 +27,154 @@
GList *check_swallows = NULL;
extern GlobalConfig global_config;
extern GSList *applets_last;
#if 0
static int
get_window_id(Window win, char *title, guint32 *wid)
{
Window root_return;
Window parent_return;
Window *children;
unsigned int nchildren;
unsigned int i;
char *tit;
int ret = FALSE;
int (*oldErrorHandler)(Display*, XErrorEvent*);
gdk_error_trap_push ();
XQueryTree(GDK_DISPLAY(),
win,
&root_return,
&parent_return,
&children,
&nchildren);
for(i=0;i<nchildren;i++) {
if (!XFetchName(GDK_DISPLAY(),
children[i],
&tit)) {
continue;
}
if(tit) {
if(strcmp(tit,title)==0) {
XFree(tit);
*wid = children[i];
ret = TRUE;
break ;
}
XFree(tit);
}
}
gdk_flush();
gdk_error_trap_pop ();
for(i=0;!ret && i<nchildren;i++)
ret=get_window_id(children[i],title,wid);
if(children)
XFree(children);
return ret;
}
#endif
static void socket_destroyed (GtkWidget *w, gpointer data);
static void socket_realized (GtkWidget *w, gpointer data);
static int
socket_realized(GtkWidget *w, gpointer data)
static void
socket_realized (GtkWidget *w, gpointer data)
{
Swallow *swallow = gtk_object_get_user_data(GTK_OBJECT(w));
Swallow *swallow = gtk_object_get_user_data (GTK_OBJECT (w));
g_return_val_if_fail(swallow->title!=NULL,FALSE);
g_return_if_fail (swallow->title != NULL);
gdk_error_trap_push ();
if(!get_window_id(GDK_ROOT_WINDOW(), swallow->title,
&swallow->wid, TRUE)) {
check_swallows = g_list_prepend(check_swallows,swallow);
xstuff_reset_need_substructure();
check_swallows = g_list_prepend (check_swallows, swallow);
xstuff_reset_need_substructure ();
} else
gtk_socket_steal(GTK_SOCKET(swallow->socket), swallow->wid);
gtk_socket_steal (GTK_SOCKET(swallow->socket), swallow->wid);
gdk_flush();
gdk_error_trap_pop ();
}
return FALSE;
static void
swallow_launch (Swallow *swallow)
{
if ( ! string_empty (swallow->path)) {
char *p = strrchr (swallow->path, '.');
GnomeDesktopEntry *item;
/*only if such a file exists and ends in a .desktop, should
we try to launch it as such*/
if(p != NULL &&
(strcmp (p, ".desktop") == 0 ||
strcmp (p, ".kdelnk") == 0) &&
g_file_exists (swallow->path) &&
(item = gnome_desktop_entry_load (swallow->path)) != NULL) {
gnome_desktop_entry_launch (item);
gnome_desktop_entry_free (item);
} else {
gnome_execute_shell (NULL, swallow->path);
}
}
}
static gboolean
before_remove (Swallow *swallow)
{
GtkWidget *dlg;
if (swallow->clean_remove)
return TRUE;
dlg = gnome_message_box_new (_("A swallowed application appears to "
"have died unexpectadly.\n"
"Attempt to reload it?"),
GNOME_MESSAGE_BOX_QUESTION,
_("Reload"),
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gnome_dialog_set_close (GNOME_DIALOG (dlg),
TRUE /* click_closes */);
gtk_window_set_wmclass (GTK_WINDOW (dlg),
"swallow_crashed", "Panel");
if (gnome_dialog_run (GNOME_DIALOG (dlg)) == 0) {
/* make the socket again */
swallow->socket = gtk_socket_new ();
gtk_object_set_user_data (GTK_OBJECT (swallow->socket),
swallow);
if (swallow->width != 0 || swallow->height != 0)
gtk_widget_set_usize(swallow->socket,
swallow->width, swallow->height);
gtk_signal_connect_after (GTK_OBJECT (swallow->socket),
"realize",
GTK_SIGNAL_FUNC (socket_realized),
NULL);
gtk_signal_connect (GTK_OBJECT (swallow->socket), "destroy",
GTK_SIGNAL_FUNC (socket_destroyed),
swallow);
gtk_container_add (GTK_CONTAINER (swallow->frame),
swallow->socket);
gtk_widget_show (swallow->socket);
/* launch the command if some exists */
swallow_launch (swallow);
if(!get_window_id(GDK_ROOT_WINDOW(), swallow->title,
&swallow->wid, TRUE)) {
check_swallows = g_list_prepend (check_swallows, swallow);
xstuff_reset_need_substructure ();
} else {
gtk_socket_steal (GTK_SOCKET(swallow->socket), swallow->wid);
}
return FALSE;
}
return TRUE;
}
static void
socket_destroyed(GtkWidget *w, gpointer data)
unref_swallow (Swallow *swallow)
{
Swallow *swallow = data;
gtk_widget_destroy(swallow->ebox);
swallow->ebox = NULL;
swallow->ref_count --;
if (swallow->ref_count == 0) {
g_free (swallow->title);
swallow->title = NULL;
g_free (swallow->path);
swallow->path = NULL;
g_free (swallow);
}
}
check_swallows = g_list_remove(check_swallows,swallow);
static Swallow *
ref_swallow (Swallow *swallow)
{
swallow->ref_count ++;
return swallow;
}
static void
free_swallow (gpointer data)
socket_destroyed (GtkWidget *w, gpointer data)
{
Swallow *swallow = data;
swallow->wid = -1;
g_free(swallow->title);
swallow->title = NULL;
g_free(swallow->path);
swallow->path = NULL;
if ( ! before_remove (swallow))
return;
g_free(swallow);
}
gtk_widget_destroy (swallow->ebox);
swallow->ebox = NULL;
check_swallows = g_list_remove (check_swallows, swallow);
/* here is where the swallow really dies */
unref_swallow (swallow);
}
static void
really_add_swallow(GtkWidget *d,int button, gpointer data)
......@@ -164,7 +215,7 @@ act_really_add_swallow(GtkWidget *w, gpointer data)
GtkWidget *d = data;
/*just call the above handler for the dialog*/
really_add_swallow(d,0,NULL);
really_add_swallow (d, 0, NULL);
}
/*I couldn't resist the naming of this function*/
......@@ -277,56 +328,50 @@ static Swallow *
create_swallow_applet(char *title, char *path, int width, int height, SwallowOrient orient)
{
Swallow *swallow;
GtkWidget *w;
swallow = g_new(Swallow,1);
swallow = g_new (Swallow, 1);
swallow->ref_count = 1;
swallow->ebox = gtk_event_box_new();
gtk_widget_show(swallow->ebox);
swallow->clean_remove = TRUE;
swallow->socket=gtk_socket_new();
if(width != 0 || height != 0)
swallow->ebox = gtk_event_box_new ();
gtk_widget_show (swallow->ebox);
swallow->socket = gtk_socket_new ();
if (width != 0 || height != 0)
gtk_widget_set_usize(swallow->socket, width, height);
gtk_signal_connect_after(GTK_OBJECT(swallow->socket),"realize",
GTK_SIGNAL_FUNC(socket_realized), NULL);
gtk_signal_connect(GTK_OBJECT(swallow->socket),"destroy",
GTK_SIGNAL_FUNC(socket_destroyed), swallow);
gtk_signal_connect_after (GTK_OBJECT (swallow->socket), "realize",
GTK_SIGNAL_FUNC (socket_realized), NULL);
gtk_signal_connect (GTK_OBJECT (swallow->socket), "destroy",
GTK_SIGNAL_FUNC (socket_destroyed), swallow);
swallow->handle_box = gtk_handle_box_new();
gtk_signal_connect(GTK_OBJECT(swallow->handle_box),"event",
GTK_SIGNAL_FUNC(ignore_1st_click),NULL);
swallow->handle_box = gtk_handle_box_new ();
gtk_signal_connect (GTK_OBJECT (swallow->handle_box), "event",
GTK_SIGNAL_FUNC (ignore_1st_click), NULL);
gtk_container_add ( GTK_CONTAINER(swallow->ebox),
swallow->handle_box );
gtk_container_add (GTK_CONTAINER(swallow->ebox),
swallow->handle_box);
w = gtk_frame_new(NULL);
swallow->frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type( GTK_FRAME(w), GTK_SHADOW_IN);
gtk_container_add ( GTK_CONTAINER(swallow->handle_box), w );
gtk_frame_set_shadow_type (GTK_FRAME(swallow->frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER(swallow->handle_box), swallow->frame);
gtk_widget_show ( swallow->handle_box );
/*
FIXME: I want to add the title of the swallowed window.
E.g. a Pager is "sticky", but having a pager in a handlebox
is not -> clicking will change the desktop, but leave the
pager behind :-( Below is one of the non working versions...
*/
/*gdk_window_set_title(GTK_HANDLE_BOX(swallow->handle_box)->float_window,
g_strdup(title));*/
gtk_container_add ( GTK_CONTAINER(w),
swallow->socket );
gtk_widget_show(swallow->socket);
gtk_object_set_user_data(GTK_OBJECT(swallow->socket),swallow);
swallow->title = g_strdup(title);
swallow->path = path?g_strdup(path):NULL;
gtk_widget_show (swallow->handle_box);
gtk_container_add (GTK_CONTAINER (swallow->frame),
swallow->socket);
gtk_widget_show (swallow->socket);
gtk_object_set_user_data (GTK_OBJECT (swallow->socket), swallow);
swallow->title = g_strdup (title);
swallow->path = path ? g_strdup (path) : NULL;
swallow->width = width;
swallow->height = height;
swallow->wid = -1;
set_swallow_applet_orient(swallow, orient);
set_swallow_applet_orient (swallow, orient);
return swallow;
}
......@@ -335,64 +380,52 @@ void
set_swallow_applet_orient(Swallow *swallow, SwallowOrient orient)
{
if (GTK_HANDLE_BOX(swallow->handle_box)->child_detached) {
if(orient==SWALLOW_VERTICAL) {
if (orient == SWALLOW_VERTICAL) {
GTK_HANDLE_BOX(swallow->handle_box)->handle_position = GTK_POS_TOP;
gtk_widget_set_usize( swallow->handle_box, swallow->width,
gtk_widget_set_usize (swallow->handle_box, swallow->width,
DRAG_HANDLE_SIZE);
} else {
GTK_HANDLE_BOX(swallow->handle_box)->handle_position = GTK_POS_LEFT;
gtk_widget_set_usize( swallow->handle_box, DRAG_HANDLE_SIZE,
swallow->height );
gtk_widget_set_usize (swallow->handle_box, DRAG_HANDLE_SIZE,
swallow->height);
}
} else {
if(orient==SWALLOW_VERTICAL) {
if (orient == SWALLOW_VERTICAL) {
GTK_HANDLE_BOX(swallow->handle_box)->handle_position = GTK_POS_TOP;
gtk_widget_set_usize( swallow->handle_box, swallow->width,
gtk_widget_set_usize (swallow->handle_box, swallow->width,
swallow->height + DRAG_HANDLE_SIZE);
} else {
GTK_HANDLE_BOX(swallow->handle_box)->handle_position = GTK_POS_LEFT;
gtk_widget_set_usize( swallow->handle_box,
gtk_widget_set_usize (swallow->handle_box,
swallow->width + DRAG_HANDLE_SIZE,
swallow->height );
swallow->height);
}
}
gtk_object_set_user_data(GTK_OBJECT(swallow->handle_box),
GINT_TO_POINTER(orient));
}
void
load_swallow_applet(char *path, char *params, int width, int height,
PanelWidget *panel, int pos, gboolean exactpos)
load_swallow_applet (char *path, char *params, int width, int height,
PanelWidget *panel, int pos, gboolean exactpos)
{
Swallow *swallow;
swallow = create_swallow_applet(params, path, width, height,
SWALLOW_HORIZONTAL);
if(!swallow)
swallow = create_swallow_applet (params, path, width, height,
SWALLOW_HORIZONTAL);
if (swallow == NULL)
return;
if(!register_toy(swallow->ebox,
swallow, free_swallow,
panel, pos,
exactpos, APPLET_SWALLOW))
if ( ! register_toy (swallow->ebox,
ref_swallow (swallow),
(GDestroyNotify) unref_swallow,
panel, pos,
exactpos, APPLET_SWALLOW))
return;
applet_add_callback(applets_last->data, "help",
GNOME_STOCK_PIXMAP_HELP,
_("Help"));
if(path && *path) {
char *p = strrchr(path,'.');
GnomeDesktopEntry *item;
/*only if such a file exists and ends in a .desktop, should
we try to launch it as such*/
if(p &&
(strcmp(p,".desktop")==0 ||
strcmp(p,".kdelnk")==0) &&
g_file_exists(path) &&
(item = gnome_desktop_entry_load(path))) {
gnome_desktop_entry_launch(item);
gnome_desktop_entry_free(item);
} else {
gnome_execute_shell(NULL, path);
}
}
swallow->clean_remove = FALSE;
applet_add_callback (applets_last->data, "help",
GNOME_STOCK_PIXMAP_HELP,
_("Help"));
swallow_launch (swallow);
}
......@@ -11,16 +11,18 @@ typedef enum {
} SwallowOrient;
typedef struct {
int ref_count;
GtkWidget *ebox;
/* GtkWidget *handle_n; */
/* GtkWidget *handle_w; */
GtkWidget *socket;
GtkWidget *handle_box;
GtkWidget *frame;
char *title;
char *path;
int width;
int height;
guint32 wid;
gboolean clean_remove;
} Swallow;
void load_swallow_applet(char *path, char *params, int width, int height,
......
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