From aaf935747f65a1084ba4ffa3cf32a1e1ea93c987 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Thu, 4 Jun 2009 23:49:00 +0200 Subject: [PATCH] Make smclient optional Add --with-smclient configure option, and conditionalise the code. Use --without-smclient to disable smclient. Smclient is disabled by default on hildon platform. --- configure.ac | 40 ++++++++++++++++++---- cut-n-paste/smclient/Makefile.am | 57 +++++++++++++++++--------------- shell/ev-application.c | 16 ++++++++- shell/main.c | 20 +++++++---- 4 files changed, 93 insertions(+), 40 deletions(-) diff --git a/configure.ac b/configure.ac index 1f341593..25aaa7f4 100644 --- a/configure.ac +++ b/configure.ac @@ -136,14 +136,41 @@ PKG_CHECK_MODULES(FRONTEND_CORE, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 > PKG_CHECK_MODULES(PREVIEWER, gtk+-2.0 >= $GTK_REQUIRED gtk+-unix-print-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED) PKG_CHECK_MODULES(SHELL_CORE, libxml-2.0 >= $LIBXML_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gtk+-unix-print-2.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gthread-2.0) -if test "$os_win32" = no; then - PKG_CHECK_MODULES(SMCLIENT, gtk+-2.0 gthread-2.0 sm >= 1.0.0) -else - PKG_CHECK_MODULES(SMCLIENT, gtk+-2.0 gthread-2.0) +# ********* +# SM client +# ********* + +GDK_TARGET="$($PKG_CONFIG --variable target gdk-2.0)" + +SMCLIENT_PKGS= +AC_MSG_CHECKING([which smclient backend to use]) +AC_ARG_WITH([smclient], + [AS_HELP_STRING([--with-smclient-backend],[which smclient backend to use (no|xsmp|win32|quartz)])], + [], + [case "$GDK_TARGET" in + x11) case "$with_platform" in + gnome) with_smclient=xsmp SMCLIENT_PKGS="sm >= 1.0.0" ;; + *) with_smclient=no ;; + esac ;; + win32|quartz) with_smclient=$GDK_TARGET ;; + *) with_smclient=no ;; + esac]) +AC_MSG_RESULT([$with_smclient]) + +if test "$with_smclient" != "no"; then + AC_DEFINE([WITH_SMCLIENT],[1],[Define if smclient is enabled]) + + PKG_CHECK_MODULES([SMCLIENT],[gtk+-2.0 gthread-2.0 $SMCLIENT_PKGS]) + AC_SUBST([SMCLIENT_CFLAGS]) + AC_SUBST([SMCLIENT_LIBS]) fi -AC_SUBST(SMCLIENT_CFLAGS) -AC_SUBST(SMCLIENT_LIBS) +AM_CONDITIONAL([WITH_SMCLIENT],[test "$with_smclient" != "no"]) +AM_CONDITIONAL([WITH_SMCLIENT_XSMP],[test "$with_smclient" = "xsmp"]) +AM_CONDITIONAL([WITH_SMCLIENT_WIN32],[test "$with_smclient" = "win32"]) +AM_CONDITIONAL([WITH_SMCLIENT_QUARTZ],[test "$with_smclient" = "quartz"]) + +# *** BACKEND_LIBTOOL_FLAGS="-module -avoid-version -no-undefined -export-symbols \$(top_srcdir)/backend/backend.symbols" AC_SUBST(BACKEND_LIBTOOL_FLAGS) @@ -697,6 +724,7 @@ Configure summary: GTK+ Unix Print....: $with_gtk_unix_print Keyring Support....: $with_keyring DBUS Support.......: $enable_dbus + SM client support..: $with_smclient Nautilus Plugin....: $enable_nautilus Thumbnailer........: $enable_thumbnailer Previewer..........: $enable_previewer diff --git a/cut-n-paste/smclient/Makefile.am b/cut-n-paste/smclient/Makefile.am index 44939227..cbf5f351 100644 --- a/cut-n-paste/smclient/Makefile.am +++ b/cut-n-paste/smclient/Makefile.am @@ -1,33 +1,38 @@ noinst_LTLIBRARIES = libsmclient.la -if OS_WIN32 -platform_sources = eggsmclient-win32.c -else -platform_sources = \ - eggsmclient-xsmp.c \ - eggdesktopfile.c \ - eggdesktopfile.h -platform_defines = -DEGG_SM_CLIENT_BACKEND_XSMP -endif +NULL = + +if WITH_SMCLIENT +libsmclient_la_SOURCES = \ + eggdesktopfile.c \ + eggdesktopfile.h \ + eggsmclient.c \ + eggsmclient.h \ + eggsmclient-private.h \ + $(NULL) -libsmclient_la_SOURCES = \ - eggsmclient.c \ - eggsmclient.h \ - eggsmclient-private.h \ - $(platform_sources) +libsmclient_la_CPPFLAGS = \ + -DG_LOG_DOMAIN=\""EggSMClient"\" \ + $(DISABLE_DEPRECATED) \ + $(AM_CPPFLAGS) -libsmclient_la_CFLAGS = \ - -DG_LOG_DOMAIN=\""EggSMClient"\" \ - $(platform_defines) \ - $(SMCLIENT_CFLAGS) \ - $(WARNING_CFLAGS) \ - $(DISABLE_DEPRECATED) +libsmclient_la_CFLAGS = \ + $(SMCLIENT_CFLAGS) \ + $(WARNING_CFLAGS) \ + $(AM_CFLAGS) -libsmclient_la_LIBADD = $(SMCLIENT_LIBS) +libsmclient_la_LIBADD = \ + $(SMCLIENT_LIBS) -EXTRA_DIST = \ - eggsmclient-win32.c \ - eggsmclient-xsmp.c \ - eggdesktopfile.c \ - eggdesktopfile.h +if WITH_SMCLIENT_XSMP +libsmclient_la_SOURCES += eggsmclient-xsmp.c +libsmclient_la_CPPFLAGS += -DEGG_SM_CLIENT_BACKEND_XSMP +endif +if WITH_SMCLIENT_WIN32 +libsmclient_la_SOURCES += eggsmclient-win32.c +endif +if WITH_SMCLIENT_QUARTZ +libsmclient_la_SOURCES += eggsmclient-osx.c +endif +endif # WITH_SMCLIENT diff --git a/shell/ev-application.c b/shell/ev-application.c index 3d4afb1b..dc6d5b89 100644 --- a/shell/ev-application.c +++ b/shell/ev-application.c @@ -33,7 +33,10 @@ #endif #include "totem-scrsaver.h" + +#ifdef WITH_SMCLIENT #include "eggsmclient.h" +#endif #include "ev-application.h" #include "ev-document-factory.h" @@ -67,7 +70,9 @@ struct _EvApplication { TotemScrsaver *scr_saver; +#ifdef WITH_SMCLIENT EggSMClient *smclient; +#endif gchar *filechooser_open_uri; gchar *filechooser_save_uri; @@ -287,11 +292,14 @@ ev_application_load_session (EvApplication *application) GKeyFile *state_file; gchar **uri_list; +#ifdef WITH_SMCLIENT if (egg_sm_client_is_resumed (application->smclient)) { state_file = egg_sm_client_get_state_file (application->smclient); if (!state_file) return FALSE; - } else if (g_file_test (application->crashed_file, G_FILE_TEST_IS_REGULAR)) { + } else +#endif /* WITH_SMCLIENT */ + if (g_file_test (application->crashed_file, G_FILE_TEST_IS_REGULAR)) { if (ev_application_run_crash_recovery_dialog (application)) { state_file = g_key_file_new (); g_key_file_load_from_file (state_file, @@ -325,6 +333,8 @@ ev_application_load_session (EvApplication *application) return TRUE; } +#ifdef WITH_SMCLIENT + static void smclient_save_state_cb (EggSMClient *client, GKeyFile *state_file, @@ -346,12 +356,15 @@ smclient_quit_cb (EggSMClient *client, ev_application_shutdown (application); } +#endif /* WITH_SMCLIENT */ + static void ev_application_init_session (EvApplication *application) { application->crashed_file = g_build_filename (application->dot_dir, "evince-crashed", NULL); +#ifdef WITH_SMCLIENT application->smclient = egg_sm_client_get (); g_signal_connect (application->smclient, "save_state", G_CALLBACK (smclient_save_state_cb), @@ -359,6 +372,7 @@ ev_application_init_session (EvApplication *application) g_signal_connect (application->smclient, "quit", G_CALLBACK (smclient_quit_cb), application); +#endif } /** diff --git a/shell/main.c b/shell/main.c index 43fca484..41fd85f1 100644 --- a/shell/main.c +++ b/shell/main.c @@ -37,10 +37,13 @@ #include "ev-init.h" #include "ev-file-helpers.h" #include "ev-stock-icons.h" + +#ifdef WITH_SMCLIENT #include "eggsmclient.h" #ifndef G_OS_WIN32 #include "eggdesktopfile.h" #endif +#endif /* WITH_SMCLIENT */ static gchar *ev_page_label; static gchar *ev_find_string; @@ -398,8 +401,11 @@ main (int argc, char *argv[]) context = g_option_context_new (N_("GNOME Document Viewer")); g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); g_option_context_add_main_entries (context, goption_options, GETTEXT_PACKAGE); - + +#ifdef WITH_SMCLIENT g_option_context_add_group (context, egg_sm_client_get_option_group ()); +#endif + g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { @@ -436,13 +442,13 @@ main (int argc, char *argv[]) ev_stock_icons_init (); -#ifdef G_OS_WIN32 - /* Manually set name and icon in win32 */ - g_set_application_name (_("Evince")); - gtk_window_set_default_icon_name ("evince"); -#else +#if defined(WITH_SMCLIENT) && !defined(G_OS_WIN32) egg_set_desktop_file (GNOMEDATADIR "/applications/evince.desktop"); -#endif /* G_OS_WIN32 */ +#else + /* Manually set name and icon */ + g_set_application_name (_("Document Viewer")); + gtk_window_set_default_icon_name ("evince"); +#endif /* WITH_SMCLIENT && !G_OS_WIN32 */ ev_application_load_session (EV_APP); load_files (file_arguments, args); -- 2.43.5