[gtranslator] Present the window properly.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtranslator] Present the window properly.
- Date: Thu, 11 Feb 2010 19:29:09 +0000 (UTC)
commit 7fb46cbf2d87cb82694badf816ae5757829444de
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Feb 11 20:28:40 2010 +0100
Present the window properly.
src/gtr-application.c | 7 +++----
src/main.c | 44 +++++++++++++++++++++++++++++++++++++-------
2 files changed, 40 insertions(+), 11 deletions(-)
---
diff --git a/src/gtr-application.c b/src/gtr-application.c
index e8eab01..10f820b 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -325,13 +325,12 @@ gtr_application_create_window (GtrApplication *app)
* is never NULL when at least a window exists.
*/
if (app->priv->windows == NULL)
- {
- window = g_object_new (GTR_TYPE_WINDOW, NULL);
- set_active_window (app, window);
- }
+ window = g_object_new (GTR_TYPE_WINDOW, NULL);
else
window = g_object_new (GTR_TYPE_WINDOW, NULL);
+ set_active_window (app, window);
+
app->priv->windows = g_list_prepend (app->priv->windows,
window);
diff --git a/src/main.c b/src/main.c
index 6466d11..973f386 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,12 +32,18 @@
#include "gtr-utils.h"
#include "gtr-dirs.h"
+#include <errno.h>
#include <locale.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gconf/gconf.h>
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
#ifdef G_OS_WIN32
#define SAVE_DATADIR DATADIR
#undef DATADIR
@@ -140,9 +146,24 @@ unique_app_message_cb (UniqueApp *unique_app,
}
}
- gtk_window_present (GTK_WINDOW (window));
+ /* set the proper interaction time on the window.
+ * Fall back to roundtripping to the X server when we
+ * don't have the timestamp, e.g. when launched from
+ * terminal. We also need to make sure that the window
+ * has been realized otherwise it will not work. lame.
+ */
+ if (!GTK_WIDGET_REALIZED (window))
+ gtk_widget_realize (GTK_WIDGET (window));
+
+#ifdef GDK_WINDOWING_X11
+ timestamp = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)));
+#else
+ timestamp = GDK_CURRENT_TIME;
+#endif
+
+ gtk_window_present_with_time (GTK_WINDOW (window), timestamp);
- return UNIQUE_RESPONSE_OK;
+ return UNIQUE_RESPONSE_OK;
}
static void
@@ -209,6 +230,10 @@ main (gint argc, gchar * argv[])
gchar *pixmaps_dir;
gchar **uris;
+ /* Init type system and threads as soon as possible */
+ g_type_init ();
+ g_thread_init (NULL);
+
/* Initialize gettext. */
setlocale (LC_ALL, "");
@@ -239,11 +264,17 @@ main (gint argc, gchar * argv[])
g_clear_error (&error);
}
- if (!g_thread_supported ())
- g_thread_init (NULL);
gtk_init (&argc, &argv);
- g_option_context_parse (context, &argc, &argv, NULL);
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ g_print(_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
+ error->message, argv[0]);
+ g_error_free (error);
+ return 1;
+ }
+
+ g_option_context_free (context);
/* Init preferences manager */
gtr_prefs_manager_app_init ();
@@ -305,11 +336,10 @@ main (gint argc, gchar * argv[])
g_slist_free (file_list);
}
- g_option_context_free (context);
-
/* Enter main GTK loop */
gtk_main ();
+ g_object_unref (engine);
gtr_prefs_manager_app_shutdown ();
g_object_unref (app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]