Commit f2ae6ebe authored by Matthias Clasen's avatar Matthias Clasen

Make the fail whale a separate program

This makes it easier to test, and makes gnome-session itself
a bit smaller.
parent 98011855
bin_PROGRAMS = gnome-session
libexec_PROGRAMS = gnome-session-failed
noinst_LTLIBRARIES = libgsmutil.la
noinst_PROGRAMS = \
test-client-dbus \
......@@ -22,8 +23,8 @@ gnome_session_SOURCES = \
gsm-xsmp-client.c \
gsm-dbus-client.h \
gsm-dbus-client.c \
gsm-fail-whale-dialog.h \
gsm-fail-whale-dialog.c \
gsm-fail-whale.h \
gsm-fail-whale.c \
gsm-system.h \
gsm-system.c \
gsm-consolekit.c \
......@@ -32,7 +33,6 @@ gnome_session_SOURCES = \
gsm-systemd.c \
gsm-logout-dialog.h \
gsm-logout-dialog.c \
gsm-icon-names.h \
gsm-inhibit-dialog.h \
gsm-inhibit-dialog.c \
gsm-presence.h \
......@@ -72,7 +72,7 @@ gnome_session_CPPFLAGS = \
-I$(top_srcdir)/egg \
-DLOCALE_DIR=\""$(datadir)/locale"\" \
-DDATA_DIR=\""$(datadir)/gnome-session"\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DGTKBUILDER_DIR=\""$(pkgdatadir)"\" \
-DGCONF_SANITY_CHECK=\""$(GCONF_SANITY_CHECK)"\" \
-DGCONFTOOL_CMD=\"$(GCONFTOOL)\"
......@@ -94,9 +94,24 @@ libgsmutil_la_SOURCES = \
gsm-util.c \
gsm-util.h
libgsmutil_la_CPPFLAGS = \
$(AM_CPPFLAGS)
libgsmutil_la_LIBADD = \
$(GNOME_SESSION_LIBS)
gnome_session_failed_SOURCES = \
gsm-fail-whale-dialog.c \
gsm-fail-whale-dialog.h \
gsm-icon-names.h
gnome_session_failed_CPPFLAGS = \
$(GTK3_CFLAGS) \
-DLOCALE_DIR=\""$(datadir)/locale"\"
gnome_session_failed_LDADD = \
$(GTK3_LIBS)
test_inhibit_SOURCES = test-inhibit.c
test_inhibit_LDADD = $(GNOME_SESSION_LIBS)
......
......@@ -23,6 +23,8 @@
#include <config.h>
#include <stdlib.h>
#include <glib/gi18n.h>
#include <gtk/gtkx.h>
......@@ -30,7 +32,6 @@
#include "gsm-fail-whale-dialog.h"
#include "gsm-icon-names.h"
#include "gsm-shell-extensions.h"
#define GSM_FAIL_WHALE_DIALOG_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_FAIL_WHALE_DIALOG, GsmFailWhaleDialogPrivate))
......@@ -280,14 +281,12 @@ setup_window (GsmFailWhaleDialog *fail_dialog)
gtk_window_set_title (GTK_WINDOW (fail_dialog), "");
gtk_window_set_icon_name (GTK_WINDOW (fail_dialog), GSM_ICON_COMPUTER_FAIL);
if (!fail_dialog->priv->debug_mode) {
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (fail_dialog), TRUE);
gtk_window_set_keep_above (GTK_WINDOW (fail_dialog), TRUE);
gtk_window_stick (GTK_WINDOW (fail_dialog));
gtk_window_set_position (GTK_WINDOW (fail_dialog), GTK_WIN_POS_CENTER_ALWAYS);
/* only works if there is a window manager which is unlikely */
gtk_window_fullscreen (GTK_WINDOW (fail_dialog));
}
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (fail_dialog), TRUE);
gtk_window_set_keep_above (GTK_WINDOW (fail_dialog), TRUE);
gtk_window_stick (GTK_WINDOW (fail_dialog));
gtk_window_set_position (GTK_WINDOW (fail_dialog), GTK_WIN_POS_CENTER_ALWAYS);
/* only works if there is a window manager which is unlikely */
gtk_window_fullscreen (GTK_WINDOW (fail_dialog));
alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (alignment);
......@@ -345,32 +344,44 @@ gsm_fail_whale_dialog_init (GsmFailWhaleDialog *fail_dialog)
fail_dialog->priv = GSM_FAIL_WHALE_DIALOG_GET_PRIVATE (fail_dialog);
}
void
gsm_fail_whale_dialog_we_failed (gboolean debug_mode,
gboolean allow_logout,
GsmShellExtensions *extensions)
static gboolean debug_mode = FALSE;
static gboolean allow_logout = FALSE;
static gboolean extensions = FALSE;
int main (int argc, char *argv[])
{
static GsmFailWhaleDialog *current_dialog = NULL;
GOptionEntry entries[] = {
{ "debug", 0, 0, G_OPTION_ARG_NONE, &debug_mode, N_("Enable debugging code"), NULL },
{ "allow-logout", 0, 0, G_OPTION_ARG_NONE, &allow_logout, N_("Allow logout"), NULL },
{ "extensions", 0, 0, G_OPTION_ARG_NONE, &extensions, N_("Show extension warning"), NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
GsmFailWhaleDialog *fail_dialog;
GError *error = NULL;
if (current_dialog != NULL) {
return;
}
gtk_init_with_args (&argc, &argv, " - fail whale",
entries, GETTEXT_PACKAGE,
&error);
if (error != NULL) {
g_warning ("%s", error->message);
exit (1);
}
fail_dialog = g_object_new (GSM_TYPE_FAIL_WHALE_DIALOG, NULL);
fail_dialog->priv->debug_mode = debug_mode;
fail_dialog->priv->allow_logout = allow_logout;
fail_dialog->priv->extensions = extensions != NULL && gsm_shell_extensions_n_extensions (extensions) > 0;
fail_dialog->priv->extensions = extensions;
setup_window (fail_dialog);
current_dialog = fail_dialog;
g_signal_connect (current_dialog,
"destroy",
G_CALLBACK (gtk_widget_destroyed),
&current_dialog);
g_signal_connect (fail_dialog, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (GTK_WIDGET (fail_dialog));
gtk_main ();
return 0;
}
......@@ -26,8 +26,6 @@
#include <gtk/gtk.h>
#include "gsm-shell-extensions.h"
G_BEGIN_DECLS
#define GSM_TYPE_FAIL_WHALE_DIALOG (gsm_fail_whale_dialog_get_type ())
......@@ -55,10 +53,6 @@ struct _GsmFailWhaleDialogClass
GType gsm_fail_whale_dialog_get_type (void) G_GNUC_CONST;
void gsm_fail_whale_dialog_we_failed (gboolean debug_mode,
gboolean allow_logout,
GsmShellExtensions *extensions);
G_END_DECLS
#endif /* __GSM_FAIL_WHALE_DIALOG_H__ */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
* gsm-fail-whale.c
* Copyright (C) 2012 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <config.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include "gsm-fail-whale.h"
void
gsm_fail_whale_dialog_we_failed (gboolean debug_mode,
gboolean allow_logout,
GsmShellExtensions *extensions)
{
gint i;
gchar *argv[5];
i = 0;
argv[i++] = LIBEXECDIR "/gnome-session-failed";
if (debug_mode)
argv[i++] = "--debug";
if (allow_logout)
argv[i++] = "--allow-logout";
if (extensions != NULL && gsm_shell_extensions_n_extensions (extensions) > 0)
argv[i++] = "--extensions";
argv[i++] = NULL;
g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL);
return 0;
}
/* gsm-fail-whale.h
* Copyright (C) 2012 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef __GSM_FAIL_WHALE_H___
#define __GSM_FAIL_WHALE_H__
#include <glib.h>
#include "gsm-shell-extensions.h"
G_BEGIN_DECLS
void gsm_fail_whale_dialog_we_failed (gboolean debug_mode,
gboolean allow_logout,
GsmShellExtensions *extensions);
G_END_DECLS
#endif /* __GSM_FAIL_WHALE_H__ */
......@@ -58,12 +58,12 @@
#include "gsm-util.h"
#include "gdm.h"
#include "gsm-logout-dialog.h"
#include "gsm-fail-whale-dialog.h"
#include "gsm-icon-names.h"
#include "gsm-inhibit-dialog.h"
#include "gsm-system.h"
#include "gsm-session-save.h"
#include "gsm-shell-extensions.h"
#include "gsm-fail-whale.h"
#define GSM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_MANAGER, GsmManagerPrivate))
......
......@@ -46,7 +46,7 @@
#include "gsm-session-fill.h"
#include "gsm-store.h"
#include "gsm-system.h"
#include "gsm-fail-whale-dialog.h"
#include "gsm-fail-whale.h"
#define GSM_DBUS_NAME "org.gnome.SessionManager"
......
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