[gnome-latex: 33/205] open a file from the command line exemple: ./latexila test.tex minimal.tex
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 33/205] open a file from the command line exemple: ./latexila test.tex minimal.tex
- Date: Fri, 14 Dec 2018 10:49:39 +0000 (UTC)
commit 715356e8ebf205596b422d838ebbdedae1c94f36
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Thu Aug 27 14:35:22 2009 +0200
open a file from the command line
exemple: ./latexila test.tex minimal.tex
TODO | 2 --
src/callbacks.c | 19 +++++++++----------
src/callbacks.h | 2 ++
src/main.c | 10 ++++++++++
4 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/TODO b/TODO
index 9b9ec5f..c628bd3 100644
--- a/TODO
+++ b/TODO
@@ -10,8 +10,6 @@ Mon Aug 24, 2009 to Mon Aug 31, 2009
[x] copy, cut, paste, delete and select all
-[-] printing
-
[x] enlarge/shrink font
[-] Preferences
diff --git a/src/callbacks.c b/src/callbacks.c
index 6b552b7..ff13c66 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -15,7 +15,6 @@
#include "callbacks.h"
#include "print.h"
-static void document_get_content (const gchar *filename, const gchar *uri);
static void create_document_in_new_tab (const gchar *path, const gchar *text,
const gchar *title);
static void close_document (gint index);
@@ -65,7 +64,7 @@ cb_open (void)
gchar *uri = gtk_file_chooser_get_uri (
GTK_FILE_CHOOSER (dialog));
- document_get_content (filename, uri);
+ open_new_document (filename, uri);
g_free (filename);
g_free (uri);
@@ -683,17 +682,13 @@ cb_recent_item_activated (GtkRecentAction *action, gpointer user_data)
const gchar *filename = gtk_recent_info_get_uri_display (info);
const gchar *uri = gtk_recent_info_get_uri (info);
- document_get_content (filename, uri);
+ open_new_document (filename, uri);
}
-/******************************************************************************
- * local functions
- *****************************************************************************/
-
-static void
-document_get_content (const gchar *filename, const gchar *uri)
+void
+open_new_document (const gchar *filename, const gchar *uri)
{
- print_info ("Open file: \"%s\"", filename);
+ print_info ("open file: \"%s\"", filename);
gchar *contents = NULL;
if (g_file_get_contents (filename, &contents, NULL, NULL))
@@ -714,6 +709,10 @@ document_get_content (const gchar *filename, const gchar *uri)
print_warning ("impossible to open the file \"%s\"", filename);
}
+/******************************************************************************
+ * local functions
+ *****************************************************************************/
+
static void
create_document_in_new_tab (const gchar *path, const gchar *text, const gchar *title)
{
diff --git a/src/callbacks.h b/src/callbacks.h
index 048d84f..bf23aba 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -40,4 +40,6 @@ gboolean cb_delete_event (GtkWidget *widget, GdkEvent *event,
void cb_line_numbers (GtkToggleAction *action, gpointer user_data);
void cb_recent_item_activated (GtkRecentAction *action, gpointer user_data);
+void open_new_document (const gchar *filename, const gchar *uri);
+
#endif /* CALLBACKS_H */
diff --git a/src/main.c b/src/main.c
index 64e5f8b..87b41a2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -306,6 +306,16 @@ main (int argc, char *argv[])
gtk_widget_show_all (window);
+
+ for (int i = 1 ; i < argc ; i++)
+ {
+ gchar *uri = g_filename_to_uri (argv[i], NULL, NULL);
+ if (uri != NULL)
+ open_new_document (argv[i], uri);
+ else
+ print_warning ("can not open the file \"%s\"", argv[i]);
+ }
+
gtk_main ();
return EXIT_SUCCESS;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]