Commit 377bc956 authored by Vincent Untz's avatar Vincent Untz Committed by Vincent Untz
Browse files

Use dbus-based uniquification instead of bonobo-based, and makes it

2008-12-08  Vincent Untz  <vuntz@gnome.org>

	Use dbus-based uniquification instead of bonobo-based, and makes it
	possible to replace a currently running panel.
	Based on patch by Colin Walters <walters@verbum.org>
	Fix bug #558534.

	* GNOME_Panel.server.in: kill
	* Makefile.am: updated for file removal
	* main.c: (main): add a --replace option to replace the current panel
	* panel-session.c: (panel_session_handle_die_request): just call
	panel_shell_quit()
	* panel-shell.[ch]: this is pretty much rewritten

2008-12-08  Vincent Untz  <vuntz@gnome.org>

	* GNOME_Panel.idl: remove PanelShell stuff

svn path=/trunk/; revision=11369
parent 2d3b7267
2008-12-08 Vincent Untz <vuntz@gnome.org>
Use dbus-based uniquification instead of bonobo-based, and makes it
possible to replace a currently running panel.
Based on patch by Colin Walters <walters@verbum.org>
Fix bug #558534.
* GNOME_Panel.server.in: kill
* Makefile.am: updated for file removal
* main.c: (main): add a --replace option to replace the current panel
* panel-session.c: (panel_session_handle_die_request): just call
panel_shell_quit()
* panel-shell.[ch]: this is pretty much rewritten
2008-12-08 Vincent Untz <vuntz@gnome.org>
 
* libpanel-util/panel-cleanup.c: (panel_cleanup_register),
......
<oaf_info>
<oaf_server iid="OAFIID:GNOME_PanelShell" type="exe" location="gnome-panel">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/Vertigo/PanelShell:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" _value="GNOME Panel Shell"/>
<oaf_attribute name="description" type="string" _value="GNOME Panel Shell"/>
</oaf_server>
</oaf_info>
......@@ -180,7 +180,6 @@ glade_DATA = \
panel-run-dialog.glade
EXTRA_DIST = \
GNOME_Panel.server.in \
$(glade_DATA) \
nothing.cP \
nothing.h \
......@@ -235,15 +234,9 @@ panel-typebuiltins.h: @REBUILD@ $(panel_enum_headers)
uidir = $(datadir)/gnome-2.0/ui
ui_DATA = GNOME_Panel_Popup.xml
serverdir = $(libdir)/bonobo/servers
server_in_files = GNOME_Panel.server.in
server_DATA = $(server_in_files:.server.in=.server)
rcdir = $(datadir)
rc_DATA = gnome-panelrc
@INTLTOOL_SERVER_RULE@
entriesdir = $(GCONF_SCHEMA_FILE_DIR)
entries_DATA = panel-default-setup.entries
......@@ -278,7 +271,6 @@ endif
CLEANFILES = \
$(BUILT_SOURCES) \
$(schemas_in_files:.schemas.in=.schemas) \
$(server_DATA) \
$(sys_DATA) \
$(desktop_DATA)
......
......@@ -36,9 +36,11 @@
GSList *panels = NULL;
GSList *panel_list = NULL;
static char *deprecated_profile;
static char *deprecated_profile;
static gboolean replace = FALSE;
static const GOptionEntry options[] = {
{ "replace", 0, 0, G_OPTION_ARG_NONE, &replace, N_("Replace a currently running panel"), NULL },
/* keep this for compatibilty with old GNOME < 2.10 */
{ "profile", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &deprecated_profile, NULL, NULL },
{ NULL }
......@@ -68,7 +70,7 @@ main (int argc, char **argv)
gtk_window_set_default_icon_name (PANEL_ICON_PANEL);
if (!panel_shell_register ()) {
if (!panel_shell_register (replace)) {
panel_cleanup_do ();
return -1;
}
......
......@@ -25,28 +25,19 @@
#include <config.h>
#include <libgnomeui/gnome-client.h>
#include "panel-session.h"
#include <stdlib.h>
#include "panel-profile.h"
#include "panel-shell.h"
#include "panel-session.h"
static void
panel_session_handle_die_request (GnomeClient *client)
{
GSList *toplevels_to_destroy, *l;
g_return_if_fail (GNOME_IS_CLIENT (client));
toplevels_to_destroy = g_slist_copy (panel_toplevel_list_toplevels ());
for (l = toplevels_to_destroy; l; l = l->next)
gtk_widget_destroy (l->data);
g_slist_free (toplevels_to_destroy);
panel_shell_unregister ();
gtk_main_quit ();
panel_shell_quit ();
}
void
......
......@@ -2,6 +2,8 @@
* panel-shell.c: panel shell interface implementation
*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -20,147 +22,154 @@
*
* Authors:
* Jacob Berkman <jacob@ximian.com>
* Colin Walters <walters@verbum.org>
* Vincent Untz <vuntz@gnome.org>
*/
#include <config.h>
#include <glib/gi18n.h>
#include <string.h>
#include <gtk/gtk.h>
#include <dbus/dbus-glib.h>
#include <libpanel-util/panel-error.h>
#include <libpanel-util/panel-cleanup.h>
#include "panel-shell.h"
#include "panel-profile.h"
#include "panel-session.h"
#include "panel-util.h"
/*
* PanelShell is a singleton.
*/
static PanelShell *panel_shell = NULL;
#include "panel-shell.h"
static Bonobo_RegistrationResult
panel_shell_bonobo_activation_register_for_display (const char *iid,
Bonobo_Unknown ref)
{
const char *display_name;
GSList *reg_env ;
Bonobo_RegistrationResult result;
display_name = gdk_display_get_name (gdk_display_get_default ());
reg_env = bonobo_activation_registration_env_set (NULL,
"DISPLAY",
display_name);
result = bonobo_activation_register_active_server (iid, ref, reg_env);
bonobo_activation_registration_env_free (reg_env);
return result;
}
#define PANEL_DBUS_SERVICE "org.gnome.Panel"
static DBusGConnection *dbus_connection = NULL;
static DBusGProxy *session_bus = NULL;
static void
panel_shell_register_error_dialog (int reg_res)
panel_shell_on_name_lost (DBusGProxy *proxy,
const char *name,
gpointer user_data)
{
GtkWidget *dlg;
GtkWidget *checkbox;
char *secondary;
secondary = g_strdup_printf (_("The panel could not register with the "
"bonobo-activation server (error code: "
"%d) and will exit.\n"
"It may be automatically restarted."),
reg_res);
dlg = panel_error_dialog (NULL,
gdk_screen_get_default (),
"panel_shell_register_error",
FALSE,
_("The panel has encountered a fatal error"),
secondary);
g_free (secondary);
//FIXME: the checkbox is not correctly aligned in the dialog...
checkbox = gtk_check_button_new_with_mnemonic (_("Force the panel to "
"not be automatically "
"restarted"));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
checkbox, FALSE, FALSE, 0);
gtk_widget_show (checkbox);
gtk_dialog_run (GTK_DIALOG (dlg));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)))
panel_session_do_not_restart ();
if (strcmp (name, PANEL_DBUS_SERVICE) != 0)
return;
/* We lost our DBus name, and there is something replacing us.
* Tell the SM not to restart us automatically, then exit. */
g_printerr ("Panel leaving: a new panel shell is starting.\n");
gtk_widget_destroy (dlg);
panel_session_do_not_restart ();
panel_shell_quit ();
}
gboolean
panel_shell_register (void)
static void
panel_shell_cleanup (gpointer data)
{
gboolean retval;
retval = TRUE;
if (!panel_shell) {
Bonobo_RegistrationResult reg_res;
panel_shell = g_object_new (PANEL_SHELL_TYPE, NULL);
bonobo_object_set_immortal (BONOBO_OBJECT (panel_shell), TRUE);
reg_res = panel_shell_bonobo_activation_register_for_display
("OAFIID:GNOME_PanelShell",
BONOBO_OBJREF (panel_shell));
switch (reg_res) {
case Bonobo_ACTIVATION_REG_SUCCESS:
break;
case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE:
retval = FALSE;
g_printerr ("A panel is already running.\n");
panel_session_do_not_restart ();
break;
default:
retval = FALSE;
panel_shell_register_error_dialog (reg_res);
break;
}
if (dbus_connection != NULL) {
dbus_g_connection_unref (dbus_connection);
dbus_connection = NULL;
}
return retval;
if (session_bus != NULL) {
g_object_unref (session_bus);
session_bus = NULL;
}
}
void
panel_shell_unregister (void)
gboolean
panel_shell_register (gboolean replace)
{
bonobo_activation_unregister_active_server ("OAFIID:GNOME_PanelShell",
BONOBO_OBJREF (panel_shell));
}
GError *error;
guint request_name_reply;
guint32 flags;
gboolean retval;
static void
impl_displayRunDialog (PortableServer_Servant servant,
const CORBA_char *initial_string,
CORBA_Environment *ev)
{
PanelShell *shell;
if (session_bus != NULL)
return TRUE;
shell = PANEL_SHELL (bonobo_object (servant));
retval = FALSE;
g_message ("displayRunDialog: %s\n", initial_string);
}
panel_cleanup_register (PANEL_CLEAN_FUNC (panel_shell_cleanup), NULL);
static void
panel_shell_class_init (PanelShellClass *klass)
{
klass->epv.displayRunDialog = impl_displayRunDialog;
dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
if (dbus_connection == NULL) {
g_warning ("Cannot register the panel shell: cannot connect "
"to the session bus.");
goto register_out;
}
session_bus = dbus_g_proxy_new_for_name (dbus_connection,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus");
if (session_bus == NULL) {
g_warning ("Cannot register the panel shell: cannot connect "
"to the session bus.");
goto register_out;
}
dbus_g_proxy_add_signal (session_bus,
"NameLost",
G_TYPE_STRING,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal (session_bus,
"NameLost",
G_CALLBACK (panel_shell_on_name_lost),
NULL,
NULL);
flags = DBUS_NAME_FLAG_DO_NOT_QUEUE|DBUS_NAME_FLAG_ALLOW_REPLACEMENT;
if (replace)
flags |= DBUS_NAME_FLAG_REPLACE_EXISTING;
error = NULL;
if (!dbus_g_proxy_call (session_bus,
"RequestName",
&error,
G_TYPE_STRING, PANEL_DBUS_SERVICE,
G_TYPE_UINT, flags,
G_TYPE_INVALID,
G_TYPE_UINT, &request_name_reply,
G_TYPE_INVALID)) {
g_warning ("Cannot register the panel shell: %s",
error->message);
g_error_free (error);
goto register_out;
}
if (request_name_reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER ||
request_name_reply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER)
retval = TRUE;
else if (request_name_reply == DBUS_REQUEST_NAME_REPLY_EXISTS)
g_printerr ("Cannot register the panel shell: there is "
"already one running.\n");
else if (request_name_reply == DBUS_REQUEST_NAME_REPLY_IN_QUEUE)
/* This should never happen since we don't want to be queued. */
g_warning ("Cannot register the panel shell: it was queued "
"after the running one, but this should not "
"happen.");
else
g_warning ("Cannot register the panel shell: unhandled "
"reply %u from RequestName", request_name_reply);
register_out:
if (!retval) {
panel_session_do_not_restart ();
panel_shell_cleanup (NULL);
}
return retval;
}
static void
panel_shell_init (PanelShell *shell)
void
panel_shell_quit (void)
{
}
GSList *toplevels_to_destroy, *l;
BONOBO_TYPE_FUNC_FULL (PanelShell,
GNOME_Vertigo_PanelShell,
BONOBO_OBJECT_TYPE,
panel_shell)
toplevels_to_destroy = g_slist_copy (panel_toplevel_list_toplevels ());
for (l = toplevels_to_destroy; l; l = l->next)
gtk_widget_destroy (l->data);
g_slist_free (toplevels_to_destroy);
gtk_main_quit ();
}
......@@ -2,6 +2,8 @@
* panel-shell.h: panel shell interface implementation
*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -20,32 +22,16 @@
*
* Authors:
* Jacob Berkman <jacob@ximian.com>
* Colin Walters <walters@verbum.org>
* Vincent Untz <vuntz@gnome.org>
*/
#ifndef __PANEL_SHELL_H__
#define __PANEL_SHELL_H__
#include "GNOME_Panel.h"
#include <glib.h>
#include <bonobo/bonobo-object.h>
#define PANEL_SHELL_TYPE (panel_shell_get_type ())
#define PANEL_SHELL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_SHELL_TYPE, PanelShell))
#define PANEL_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), PANEL_SHELL_TYPE, PanelShellClass))
#define PANEL_IS_SHELL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_SHELL_TYPE))
#define PANEL_IS_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_SHELL_TYPE))
typedef BonoboObject PanelShell;
typedef struct {
BonoboObjectClass parent_class;
POA_GNOME_Vertigo_PanelShell__epv epv;
} PanelShellClass;
GType panel_shell_get_type (void) G_GNUC_CONST;
gboolean panel_shell_register (void);
void panel_shell_unregister (void);
gboolean panel_shell_register (gboolean replace);
void panel_shell_quit (void);
#endif /* __PANEL_SHELL_H__ */
2008-12-08 Vincent Untz <vuntz@gnome.org>
* GNOME_Panel.idl: remove PanelShell stuff
==================== 2.24.2 ====================
==================== 2.24.1 ====================
......
......@@ -42,18 +42,6 @@ module GNOME {
*/
typedef string PanelBackground;
interface PanelShell : Bonobo::Unknown {
/*
* GNOME::PanelShell::displayRunDialog
* @initialString: string to display in dialog.
*
* Instructs the Panel to display the GNOME 'run'
* dialog box.
*/
void displayRunDialog (in string initialString);
};
interface PanelAppletShell : Bonobo::Unknown {
oneway void popup_menu (in long button, in long time);
};
......
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