summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac24
-rw-r--r--src/Makefile.am2
-rw-r--r--src/terminal-app.c10
-rw-r--r--src/terminal.c97
4 files changed, 46 insertions, 87 deletions
diff --git a/configure.ac b/configure.ac
index c6a3c42..ce859c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,7 +57,28 @@ PKG_CHECK_MODULES([TERM],
# smclient
# ********
-PKG_CHECK_MODULES(SMCLIENT, sm >= 1.0.0)
+# $enable_xsmp will be set to "yes" or "no"
+AC_ARG_ENABLE(smclient,
+ [AC_HELP_STRING([--enable-smclient],
+ [Explicitly enable or disable smclient])],
+ [enable_smclient=$enableval],
+ [enable_smclient=yes])
+
+have_sm=no
+if test "x$enable_smclient" != "xno"; then
+ PKG_CHECK_MODULES(SMCLIENT, sm >= 1.0.0, have_sm=yes, [
+ if test "x$enable_smclient" = "xyes"; then
+ AC_MSG_ERROR([smclient enabled but SM library not found])
+ fi
+ ])
+fi
+
+AM_CONDITIONAL(ENABLE_SMCLIENT, [test "x$have_sm" = "xyes"])
+
+if test "x$have_sm" = "xyes"; then
+ AC_DEFINE(HAVE_SMCLIENT, 1, [Have the SM development library])
+fi
+
AC_SUBST([SMCLIENT_CFLAGS])
AC_SUBST([SMCLIENT_LIBS])
@@ -150,5 +171,6 @@ echo "
warning flags: ${WARN_CFLAGS}
linker flags: ${LDFLAGS}
+ smclient support: ${have_sm}
s/key support: ${enable_skey}
"
diff --git a/src/Makefile.am b/src/Makefile.am
index df984f5..7692030 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -97,6 +97,7 @@ mate_terminal_LDADD += \
skey/libskey.la
endif
+if ENABLE_SMCLIENT
mate_terminal_SOURCES += \
eggdesktopfile.c \
eggdesktopfile.h \
@@ -109,6 +110,7 @@ mate_terminal_SOURCES += \
mate_terminal_CFLAGS += $(SMCLIENT_CFLAGS)
mate_terminal_CPPFLAGS += -DEGG_SM_CLIENT_BACKEND_XSMP
mate_terminal_LDADD += $(SMCLIENT_LIBS)
+endif
TYPES_H_FILES = \
terminal-profile.h \
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 3a7ce5f..db9fbf4 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -41,8 +41,10 @@
#include <stdlib.h>
#include <time.h>
+#ifdef HAVE_SMCLIENT
#include "eggsmclient.h"
#include "eggdesktopfile.h"
+#endif /* HAVE_SMCLIENT */
#define FALLBACK_PROFILE_ID "default"
@@ -1376,6 +1378,7 @@ terminal_app_manage_profiles (TerminalApp *app,
gtk_window_present (GTK_WINDOW (app->manage_profiles_dialog));
}
+#ifdef HAVE_SMCLIENT
static void
terminal_app_save_state_cb (EggSMClient *client,
GKeyFile *key_file,
@@ -1390,6 +1393,7 @@ terminal_app_client_quit_cb (EggSMClient *client,
{
g_signal_emit (app, signals[QUIT], 0);
}
+#endif /* HAVE_SMCLIENT */
/* Class implementation */
@@ -1470,6 +1474,7 @@ terminal_app_init (TerminalApp *app)
terminal_accels_init ();
+#ifdef HAVE_SMCLIENT
EggSMClient *sm_client;
char *desktop_file;
@@ -1485,6 +1490,7 @@ terminal_app_init (TerminalApp *app)
G_CALLBACK (terminal_app_save_state_cb), app);
g_signal_connect (sm_client, "quit",
G_CALLBACK (terminal_app_client_quit_cb), app);
+#endif /* HAVE_SMCLIENT */
}
static void
@@ -1492,11 +1498,13 @@ terminal_app_finalize (GObject *object)
{
TerminalApp *app = TERMINAL_APP (object);
+#ifdef HAVE_SMCLIENT
EggSMClient *sm_client;
sm_client = egg_sm_client_get ();
g_signal_handlers_disconnect_matched (sm_client, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, app);
+#endif /* HAVE_SMCLIENT */
g_signal_handlers_disconnect_by_func (settings_global,
G_CALLBACK(terminal_app_profile_list_notify_cb),
@@ -1741,6 +1749,7 @@ terminal_app_handle_options (TerminalApp *app,
/* fall-through on success */
}
+#ifdef HAVE_SMCLIENT
EggSMClient *sm_client;
sm_client = egg_sm_client_get ();
@@ -1754,6 +1763,7 @@ terminal_app_handle_options (TerminalApp *app,
!terminal_options_merge_config (options, key_file, SOURCE_SESSION, error))
return FALSE;
}
+#endif /* HAVE_SMCLIENT */
/* Make sure we open at least one window */
terminal_options_ensure_window (options);
diff --git a/src/terminal.c b/src/terminal.c
index 1cd29b3..a5e07c7 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -34,7 +34,9 @@
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
+#ifdef HAVE_SMCLIENT
#include "eggsmclient.h"
+#endif /* HAVE_SMCLIENT */
#include "terminal-accels.h"
#include "terminal-app.h"
@@ -406,79 +408,6 @@ name_lost_cb (GDBusConnection *connection,
gtk_main_quit ();
}
-/* Settings storage works as follows:
- * /apps/mate-terminal/global/
- * /apps/mate-terminal/profiles/Foo/
- *
- * It's somewhat tricky to manage the profiles/ dir since we need to track
- * the list of profiles, but GSettings doesn't have a concept of notifying that
- * a directory has appeared or disappeared.
- *
- * Session state is stored entirely in the RestartCommand command line.
- *
- * The number one rule: all stored information is EITHER per-session,
- * per-profile, or set from a command line option. THERE CAN BE NO
- * OVERLAP. The UI and implementation totally break if you overlap
- * these categories. See mate-terminal 1.x for why.
- *
- * Don't use this code as an example of how to use GSettings - it's hugely
- * overcomplicated due to the profiles stuff. Most apps should not
- * have to do scary things of this nature, and should not have
- * a profiles feature.
- *
- */
-
-/* Copied from libcaja/caja-program-choosing.c; Needed in case
- * we have no DESKTOP_STARTUP_ID (with its accompanying timestamp).
- */
-static Time
-slowly_and_stupidly_obtain_timestamp (Display *xdisplay)
-{
- Window xwindow;
- XEvent event;
-
- {
- XSetWindowAttributes attrs;
- Atom atom_name;
- Atom atom_type;
- const char *name;
-
- attrs.override_redirect = True;
- attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
-
- xwindow =
- XCreateWindow (xdisplay,
- RootWindow (xdisplay, 0),
- -100, -100, 1, 1,
- 0,
- CopyFromParent,
- CopyFromParent,
- (Visual *)CopyFromParent,
- CWOverrideRedirect | CWEventMask,
- &attrs);
-
- atom_name = XInternAtom (xdisplay, "WM_NAME", TRUE);
- g_assert (atom_name != None);
- atom_type = XInternAtom (xdisplay, "STRING", TRUE);
- g_assert (atom_type != None);
-
- name = "Fake Window";
- XChangeProperty (xdisplay,
- xwindow, atom_name,
- atom_type,
- 8, PropModeReplace, (unsigned char *)name, strlen (name));
- }
-
- XWindowEvent (xdisplay,
- xwindow,
- PropertyChangeMask,
- &event);
-
- XDestroyWindow(xdisplay, xwindow);
-
- return event.xproperty.time;
-}
-
static char *
get_factory_name_for_display (const char *display_name)
{
@@ -529,8 +458,7 @@ main (int argc, char **argv)
int i;
char **argv_copy;
int argc_copy;
- const char *startup_id, *display_name, *home_dir;
- GdkDisplay *display;
+ const char *startup_id, *home_dir;
TerminalOptions *options;
GError *error = NULL;
char *working_directory;
@@ -574,8 +502,10 @@ main (int argc, char **argv)
FALSE,
&argc, &argv,
&error,
+#ifdef HAVE_SMCLIENT
gtk_get_option_group (TRUE),
egg_sm_client_get_option_group (),
+#endif /* HAVE_SMCLIENT */
NULL);
g_free (working_directory);
@@ -596,20 +526,15 @@ main (int argc, char **argv)
g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE");
- display = gdk_display_get_default ();
- display_name = gdk_display_get_name (display);
- options->display_name = g_strdup (display_name);
-
if (options->startup_id == NULL)
{
- /* Create a fake one containing a timestamp that we can use */
- Time timestamp;
-
- timestamp = slowly_and_stupidly_obtain_timestamp (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
-
- options->startup_id = g_strdup_printf ("_TIME%lu", timestamp);
+ options->startup_id = g_strdup_printf ("_TIME%lu", g_get_monotonic_time () / 1000);
}
+ gdk_init (&argc, &argv);
+ const char *display_name = gdk_display_get_name (gdk_display_get_default ());
+ options->display_name = g_strdup (display_name);
+
if (options->use_factory)
{
OwnData *data;
@@ -644,7 +569,7 @@ main (int argc, char **argv)
}
else
{
-
+ gtk_init(&argc, &argv);
terminal_app_handle_options (terminal_app_get (), options, TRUE /* allow resume */, &error);
terminal_options_free (options);