[xchat-gnome] Bug 584887 - Get rid of deprecated libgnome(ui)
- From: Ritesh Khadgaray <rkhadgaray src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [xchat-gnome] Bug 584887 - Get rid of deprecated libgnome(ui)
- Date: Wed, 13 Jan 2010 10:44:32 +0000 (UTC)
commit 3b6b529fb1529ad3d88cbee74df8ceba4dfd4a66
Author: Florian Müllner <florian.muellner%40gmail.com>
Date: Wed Jan 13 16:13:27 2010 +0530
Bug 584887 - Get rid of deprecated libgnome(ui)
Replacing libgnome(ui) with EggSMClient and plain Glib/GTK+
With few minor edits, committed
configure.ac | 14 ++++--
src/Makefile.am | 2 +-
src/fe-gnome/Makefile.am | 3 +-
src/fe-gnome/fe-gnome.c | 119 ++++++++++++++++++++++++---------------------
src/fe-gnome/gui.h | 3 -
src/fe-gnome/util.c | 2 +-
6 files changed, 77 insertions(+), 66 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d2a0f56..c3bf020 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,14 +24,13 @@ IT_PROG_INTLTOOL([0.35.0])
GLIB_REQUIRED=2.18.0
GTK_REQUIRED=2.14.0
LIBGLADE_REQUIRED=2.3.2
-LIBGNOME_REQUIRED=2.16.0
-LIBGNOMEUI_REQUIRED=2.16.0
GCONF_REQUIRED=2.8.0
DBUS_REQUIRED=0.60
DBUS_GLIB_REQUIRED=0.60
LIBSEXY_REQUIRED=0.1.11
LIBNOTIFY_REQUIRED=0.3.2
LIBCANBERRAGTK_REQUIRED=0.3
+SM_REQUIRED=1.0.0
AC_PROG_CC
AM_PROG_CC_C_O
@@ -65,12 +64,18 @@ PKG_CHECK_MODULES([DEPENDENCIES], [\
gio-2.0 >= $GLIB_REQUIRED \
gtk+-2.0 >= $GTK_REQUIRED \
libglade-2.0 >= $LIBGLADE_REQUIRED \
- libgnome-2.0 >= $LIBGNOME_REQUIRED \
- libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED \
gconf-2.0 >= $GCONF_REQUIRED \
libsexy >= $LIBSEXY_REQUIRED \
])
+#EggSMClient replacing GnomeClient in libgnome
+PKG_CHECK_MODULES([EGG_SMCLIENT], [\
+ gtk+-2.0 >= $GTK_REQUIRED \
+ sm >= $SM_REQUIRED \
+ ])
+AC_SUBST(EGG_SMCLIENT_CFLAGS)
+AC_SUBST(EGG_SMCLIENT_LIBS)
+
#D-Bus
AC_MSG_CHECKING([whether D-Bus support is requested])
AC_ARG_ENABLE([dbus],
@@ -482,6 +487,7 @@ src/common/dbus/Makefile
src/common/Makefile
src/fe-gnome/Makefile
src/libcontrast/Makefile
+src/libeggsmclient/Makefile
src/Makefile
])
diff --git a/src/Makefile.am b/src/Makefile.am
index 1e9465d..0e763f6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1 +1 @@
-SUBDIRS = common libcontrast fe-gnome
+SUBDIRS = common libcontrast libeggsmclient fe-gnome
diff --git a/src/fe-gnome/Makefile.am b/src/fe-gnome/Makefile.am
index 098e78d..8faab84 100644
--- a/src/fe-gnome/Makefile.am
+++ b/src/fe-gnome/Makefile.am
@@ -98,7 +98,7 @@ xchat_gnome_CPPFLAGS = \
-DTOPSRCDIR="\"$(top_srcdir)\"" \
-DSYSCONFDIR="\"$(sysconfdir)\"" \
-DICONDIR="\"$(pkgdatadir)/icons\"" \
- -DDATADIR="\"$(pkgdatadir)\"" \
+ -DDATADIR="\"$(datadir)\"" \
-DXCHATSHAREDIR="\"$(pkgdatadir)\"" \
-DLIBDIR="\"$(pkglibdir)\"" \
-DPREFIX="\"$(prefix)\"" \
@@ -119,6 +119,7 @@ xchat_gnome_LDFLAGS = \
xchat_gnome_LDADD = \
$(top_builddir)/src/common/libxchatcommon.la \
$(top_builddir)/src/libcontrast/libcontrast.la \
+ $(top_builddir)/src/libeggsmclient/libeggsmclient.la \
$(DEPENDENCIES_LIBS) \
$(OPENSSL_LIBS) \
$(LIBSEXY_LIBS)
diff --git a/src/fe-gnome/fe-gnome.c b/src/fe-gnome/fe-gnome.c
index fd32bd9..29ea0c3 100644
--- a/src/fe-gnome/fe-gnome.c
+++ b/src/fe-gnome/fe-gnome.c
@@ -22,9 +22,11 @@
#include <config.h>
#include <glib/gi18n.h>
#include <string.h>
+#include <unistd.h>
#include <glib.h>
-#include <libgnomeui/libgnomeui.h>
#include <gconf/gconf-client.h>
+#include "../libeggsmclient/eggsmclient.h"
+#include "../libeggsmclient/eggdesktopfile.h"
#include "gui.h"
#include "navigation-tree.h"
#include "main-window.h"
@@ -54,6 +56,8 @@
#include "../common/cfgfiles.h"
#include "../common/plugin.h"
+#define GNOME_DOT_GNOME ".gnome2"
+
static gboolean opt_fullscreen = FALSE;
static gboolean opt_version = FALSE;
static gboolean opt_noplugins = FALSE;
@@ -72,17 +76,47 @@ static GOptionEntry entries[] = {
static void setup_sm (gint argc,
gchar *argv[]);
-static gint save_session (GnomeClient *client,
- gint phase,
- GnomeSaveStyle save_style,
- gint is_shutdown,
- GnomeInteractStyle interact_style,
- gint is_fast,
- gpointer client_data);
-static void kill_session (GnomeClient *client,
+static void quit_session (EggSMClient *client,
gpointer client_data);
static gboolean not_autoconnect (void);
+static gchar *
+get_accels_filename (void)
+{
+ const char *home;
+
+ home = g_get_home_dir();
+ if (!home)
+ return NULL;
+ return g_build_filename (home, GNOME_DOT_GNOME, "accels", PACKAGE, NULL);
+}
+
+static void
+load_accels (void)
+{
+ char *filename;
+
+ filename = get_accels_filename ();
+ if (!filename)
+ return;
+
+ gtk_accel_map_load (filename);
+ g_free (filename);
+}
+
+static void
+save_accels (void)
+{
+ char *filename;
+
+ filename = get_accels_filename ();
+ if (!filename)
+ return;
+
+ gtk_accel_map_save (filename);
+ g_free (filename);
+}
+
int
fe_args (int argc, char *argv[])
{
@@ -96,34 +130,33 @@ fe_args (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
-
context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- gui.program = gnome_program_init (PACKAGE, VERSION,
- LIBGNOMEUI_MODULE, argc, argv,
- GNOME_PARAM_GOPTION_CONTEXT, context,
- GNOME_PARAM_HUMAN_READABLE_NAME, "IRC Chat",
- GNOME_PROGRAM_STANDARD_PROPERTIES,
- NULL);
-
- if (error) {
- fprintf (stderr, _("xchat-gnome: %s\nTry `xchat-gnome --help' for more information\n"), error->message);
+ g_option_context_add_group (context, gtk_get_option_group (FALSE));
+ g_option_context_add_group (context, egg_sm_client_get_option_group ());
+
+ gtk_init (&argc, &argv);
+
+ if (! g_option_context_parse (context, &argc, &argv, &error)) {
+ g_printerr (_("Failed to parse arguments: %s\n"), error->message);
g_error_free (error);
+ g_option_context_free (context);
return 0;
}
+ g_option_context_free (context);
+
if (opt_version) {
g_print ("xchat-gnome %s\n", PACKAGE_VERSION);
return 0;
}
- g_set_application_name (_("IRC Chat"));
-
if (opt_cfgdir) {
xdir_fs = opt_cfgdir;
}
+ load_accels ();
setup_sm (argc, argv);
return -1;
@@ -186,8 +219,6 @@ fe_main (void)
{
gtk_main ();
- g_object_unref (gui.program);
-
/* sleep for 3 seconds so any QUIT messages are not lost. The */
/* GUI is closed at this point, so the user doesn't even know! */
@@ -202,7 +233,7 @@ fe_main (void)
void
fe_cleanup (void)
{
- gnome_accelerators_sync ();
+ save_accels ();
}
void
@@ -1035,45 +1066,21 @@ void fe_get_file (const char *title,
static void
setup_sm (gint argc, gchar *argv[])
{
- GnomeClient *client;
- const gchar *prefix;
+ EggSMClient *client;
+ gchar *desktop_file;
- client = gnome_master_client ();
+ client = egg_sm_client_get ();
+ desktop_file = g_build_filename (DATADIR, "applications", "xchat-gnome.desktop", NULL);
+ egg_set_desktop_file (desktop_file);
+ g_free (desktop_file);
- g_signal_connect (G_OBJECT (client), "save_yourself", G_CALLBACK (save_session), argv[0]);
- g_signal_connect (G_OBJECT (client), "die", G_CALLBACK (kill_session), NULL);
+ g_signal_connect (G_OBJECT (client), "quit", G_CALLBACK (quit_session), NULL);
- prefix = gnome_client_get_config_prefix (client);
/* FIXME: add discard command to remove saved state */
}
-static gint
-save_session (GnomeClient *client, gint phase, GnomeSaveStyle save_style,
- gint is_shutdown, GnomeInteractStyle interact_style,
- gint is_fast, gpointer client_data)
-{
- gchar **argv;
- gint argc;
- const gchar *prefix;
-
- argv = g_new0 (gchar *, 2);
- argv[0] = client_data;
- argc = 1;
-
- gnome_client_set_restart_style (client, GNOME_RESTART_IF_RUNNING);
- gnome_client_set_restart_command (client, argc, argv);
- gnome_client_set_clone_command (client, argc, argv);
-
- prefix = gnome_client_get_config_prefix (client);
- /* FIXME: save state */
-
- g_free (argv);
-
- return TRUE;
-}
-
static void
-kill_session (GnomeClient* client, gpointer client_data)
+quit_session (EggSMClient* client, gpointer client_data)
{
gtk_widget_hide (GTK_WIDGET (gui.main_window));
gtk_widget_hide (GTK_WIDGET (gui.dcc));
diff --git a/src/fe-gnome/gui.h b/src/fe-gnome/gui.h
index 0af43f4..b27d8ff 100644
--- a/src/fe-gnome/gui.h
+++ b/src/fe-gnome/gui.h
@@ -24,7 +24,6 @@
#include <glade/glade.h>
#include <gtk/gtk.h>
-#include <libgnome/gnome-program.h>
#include "userlist.h"
#include "navigation-tree.h"
#include "dcc-window.h"
@@ -60,8 +59,6 @@ typedef struct
NavModel *tree_model;
NavTree *server_tree;
-
- GnomeProgram *program;
} XChatGUI;
extern XChatGUI gui;
diff --git a/src/fe-gnome/util.c b/src/fe-gnome/util.c
index 75d1e0c..a7540c5 100644
--- a/src/fe-gnome/util.c
+++ b/src/fe-gnome/util.c
@@ -139,7 +139,7 @@ locate_data_file (const gchar *file_name)
path = uninstalled_path;
} else {
g_free (uninstalled_path);
- path = gnome_program_locate_file (gnome_program_get (), GNOME_FILE_DOMAIN_APP_DATADIR, file_name, FALSE, NULL);
+ path = g_build_filename (XCHATSHAREDIR, file_name, NULL);
}
g_return_val_if_fail (path != NULL, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]