SF.net SVN: geany: [2129] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Dec 23 17:06:17 UTC 2007


Revision: 2129
          http://geany.svn.sourceforge.net/geany/?rev=2129&view=rev
Author:   eht16
Date:     2007-12-23 09:06:11 -0800 (Sun, 23 Dec 2007)

Log Message:
-----------
Enable parsing command line options without a valid X display.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/main.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-12-23 15:22:55 UTC (rev 2128)
+++ trunk/ChangeLog	2007-12-23 17:06:11 UTC (rev 2129)
@@ -3,6 +3,8 @@
  * src/keybindings.c: Fix inverted move tab first/last commands.
  * src/templates.c:
    Add Python filetype template (patch by Elena of Valhalla, thanks).
+ * src/main.c:
+   Enable parsing command line options without a valid X display.
 
 
 2007-12-21  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2007-12-23 15:22:55 UTC (rev 2128)
+++ trunk/src/main.c	2007-12-23 17:06:11 UTC (rev 2129)
@@ -423,14 +423,20 @@
 static void parse_command_line_options(gint *argc, gchar ***argv)
 {
 	GError *error = NULL;
+	GOptionContext *context;
 
+	context = g_option_context_new(_("[FILES...]"));
+	g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
+	g_option_group_set_translation_domain(g_option_context_get_main_group(context), GETTEXT_PACKAGE);
+	g_option_context_add_group(context, gtk_get_option_group(FALSE));
+	g_option_context_parse(context, argc, argv, &error);
+	g_option_context_free(context);
+
 	// first initialise cl_options fields with default values
 	cl_options.load_session = TRUE;
 	cl_options.goto_line = -1;
 	cl_options.goto_column = -1;
 
-	gtk_init_with_args(argc, argv, _("[FILES...]"), entries, GETTEXT_PACKAGE, &error);
-
 	if (error != NULL)
 	{
 		g_printerr("Geany: %s\n", error->message);
@@ -514,6 +520,12 @@
 	vte_info.lib_vte = lib_vte;
 #endif
 	cl_options.ignore_global_tags = ignore_global_tags;
+
+	if (! gtk_init_check(NULL, NULL))
+	{	// check whether we have a valid X display and exit if not
+		g_printerr("Geany: cannot open display\n");
+		exit(1);
+	}
 }
 
 
@@ -641,11 +653,8 @@
 
 	setup_paths();
 	locale_init();
-	// gtk_init() is called within parse_command_line_options()
 	parse_command_line_options(&argc, &argv);
 
-	gtk_set_locale();
-
 	signal(SIGTERM, signal_cb);
 #ifdef G_OS_UNIX
 	// SIGQUIT is used to kill spawned children and we get also this signal, so ignore


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list