gtranslator r3524 - in trunk: . src
- From: icq svn gnome org
- To: svn-commits-list gnome org
- Subject: gtranslator r3524 - in trunk: . src
- Date: Mon, 24 Mar 2008 23:10:00 +0000 (GMT)
Author: icq
Date: Mon Mar 24 23:10:00 2008
New Revision: 3524
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3524&view=rev
Log:
2008-03-25 Ignacio Casal Quinteiro <nacho resa gmail com>
* src/main.c:
* src/application.ch:
* configure.ac:
Added gio and now you can open a file from console.
(Fixes bug #517913).
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/src/main.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Mon Mar 24 23:10:00 2008
@@ -71,6 +71,7 @@
dnl ==========================================================================
GTK_REQUIRED=2.11.6
+GLIB_REQUIRED=2.15.5
GCONF_REQUIRED=2.18.0
LIBXML_REQUIRED=2.4.12
LIBGLADE_REQUIRED=2.6.0
@@ -81,6 +82,7 @@
GTKSPELL_OPTIONAL=2.0.2
AC_SUBST(GTK_REQUIRED)
+AC_SUBST(GLIB_REQUIRED)
AC_SUBST(GCONF_REQUIRED)
AC_SUBST(LIBXML_REQUIRED)
AC_SUBST(LIBGLADE_REQUIRED)
@@ -93,6 +95,7 @@
gconf-2.0 >= $GCONF_REQUIRED
libglade-2.0 >= $LIBGLADE_REQUIRED
gtksourceview-2.0 >= $SOURCEVIEW_REQUIRED
+gio-2.0 >= $GLIB_REQUIRED
gdl-1.0 >= $GDL_REQUIRED
])
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Mon Mar 24 23:10:00 2008
@@ -25,6 +25,7 @@
#include <config.h>
#endif
+#include "actions.h"
#include "application.h"
#include "prefs-manager-app.h"
#include "plugins-engine.h"
@@ -33,9 +34,55 @@
#include <locale.h>
#include <glib.h>
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <gconf/gconf.h>
+static gchar **file_arguments = NULL;
+
+static const GOptionEntry options [] =
+{
+ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &file_arguments,
+ NULL, N_("[FILE...]") }, /* collects file arguments */
+
+ {NULL}
+};
+
+static GSList *
+get_command_line_data ()
+{
+ GSList *file_list = NULL;
+
+ if (file_arguments)
+ {
+ gint i;
+
+ for (i = 0; file_arguments[i]; i++)
+ {
+ GFile *file;
+ gchar *uri;
+
+ file = g_file_new_for_commandline_arg (file_arguments[i]);
+ uri = g_file_get_uri (file);
+ g_object_unref (file);
+
+
+ if (uri != NULL){
+ file_list = g_slist_prepend (file_list,
+ uri);
+
+ }
+ else
+ g_print (_("%s: malformed file name or URI.\n"),
+ file_arguments[i]);
+ }
+
+ file_list = g_slist_reverse (file_list);
+ }
+
+ return file_list;
+}
+
/*
* The ubiquitous main function...
*/
@@ -45,6 +92,9 @@
{
GError *error = NULL;
GtranslatorPluginsEngine *engine;
+ GtranslatorWindow *window;
+ GSList *file_list = NULL;
+ GOptionContext *context;
/*
* Initialize gettext.
@@ -56,6 +106,10 @@
textdomain(GETTEXT_PACKAGE);
g_set_application_name(_("Gtranslator"));
+
+ /* Setup command line options */
+ context = g_option_context_new (_("- Edit PO files"));
+ g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
/*
* Initialize the GConf library.
@@ -72,6 +126,8 @@
}
gtk_init(&argc, &argv);
+
+ g_option_context_parse(context, &argc, &argv, NULL);
/*
* Show the application window with icon.
@@ -105,7 +161,18 @@
/*
* Create the main app-window.
*/
- gtranslator_application_open_window(GTR_APP);
+ window = gtranslator_application_open_window(GTR_APP);
+
+ /*
+ * Now we open the files passed as arguments
+ */
+ file_list = get_command_line_data ();
+ if (file_list)
+ {
+ gtranslator_actions_load_uris (window, (const GSList *)file_list);
+ g_slist_foreach (file_list, (GFunc) g_free, NULL);
+ g_slist_free (file_list);
+ }
/*
* Enter main GTK loop
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]