diff --git a/po/de.po b/po/de.po index ae8cadf..543140d 100644 --- a/po/de.po +++ b/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Editor 0.1.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-25 13:16+0200\n" +"POT-Creation-Date: 2011-10-25 15:13+0200\n" "PO-Revision-Date: 2010-04-07 22:05+0200\n" "Last-Translator: Pierre Pronchery \n" "Language-Team: German\n" @@ -73,167 +73,179 @@ msgid "_Preferences" msgstr "_Einstellungen" #: ../src/editor.c:138 +msgid "_File..." +msgstr "_Datei..." + +#: ../src/editor.c:144 msgid "_About" msgstr "_Info" -#: ../src/editor.c:149 +#: ../src/editor.c:155 msgid "_File" msgstr "_Datei" -#: ../src/editor.c:150 +#: ../src/editor.c:156 msgid "_Edit" msgstr "_Bearbeitung" -#: ../src/editor.c:151 +#: ../src/editor.c:157 +msgid "_Insert" +msgstr "" + +#: ../src/editor.c:158 msgid "_Help" msgstr "_Hilfe" -#: ../src/editor.c:158 +#: ../src/editor.c:165 msgid "New" msgstr "" -#: ../src/editor.c:159 +#: ../src/editor.c:166 msgid "Open" msgstr "" -#: ../src/editor.c:161 +#: ../src/editor.c:168 msgid "Save" msgstr "" -#: ../src/editor.c:162 +#: ../src/editor.c:169 msgid "Save as" msgstr "" -#: ../src/editor.c:165 +#: ../src/editor.c:172 msgid "Cut" msgstr "" -#: ../src/editor.c:166 +#: ../src/editor.c:173 msgid "Copy" msgstr "" -#: ../src/editor.c:167 +#: ../src/editor.c:174 msgid "Paste" msgstr "" -#: ../src/editor.c:170 +#: ../src/editor.c:177 msgid "Preferences" msgstr "Einstellungen" -#: ../src/editor.c:182 +#: ../src/editor.c:189 msgid "none" msgstr "" -#: ../src/editor.c:183 +#: ../src/editor.c:190 msgid "characters" msgstr "" -#: ../src/editor.c:184 +#: ../src/editor.c:191 msgid "words" msgstr "" -#: ../src/editor.c:185 +#: ../src/editor.c:192 msgid "words then characters" msgstr "" -#: ../src/editor.c:268 +#: ../src/editor.c:275 msgid "Text editor - " msgstr "" -#: ../src/editor.c:269 +#: ../src/editor.c:276 msgid "(Untitled)" msgstr "" -#: ../src/editor.c:382 +#: ../src/editor.c:389 msgid "translator-credits" msgstr "Pierre Pronchery " -#: ../src/editor.c:418 +#: ../src/editor.c:425 msgid "Could not save configuration" msgstr "" -#: ../src/editor.c:432 ../src/editor.c:437 +#: ../src/editor.c:439 ../src/editor.c:444 msgid "Error" msgstr "Fehler" -#: ../src/editor.c:464 ../src/editor.c:474 ../src/editor.c:616 -#: ../src/editor.c:630 ../src/editor.c:779 ../src/editor.c:784 +#: ../src/editor.c:471 ../src/editor.c:481 ../src/editor.c:709 +#: ../src/editor.c:723 ../src/editor.c:876 ../src/editor.c:881 msgid "Warning" msgstr "Achtung" -#: ../src/editor.c:468 +#: ../src/editor.c:475 msgid "" "There are unsaved changes.\n" "Discard or save them?" msgstr "" -#: ../src/editor.c:532 +#: ../src/editor.c:539 msgid "Find text" msgstr "" -#: ../src/editor.c:543 +#: ../src/editor.c:550 msgid "Text:" msgstr "Text:" -#: ../src/editor.c:550 +#: ../src/editor.c:557 msgid "Case-sensitive" msgstr "" -#: ../src/editor.c:552 +#: ../src/editor.c:559 msgid "Wrap" msgstr "" -#: ../src/editor.c:575 +#: ../src/editor.c:582 msgid "Text not found" msgstr "" -#: ../src/editor.c:620 +#: ../src/editor.c:661 +msgid "Insert file..." +msgstr "" + +#: ../src/editor.c:667 ../src/editor.c:790 +msgid "Text files" +msgstr "" + +#: ../src/editor.c:671 ../src/editor.c:794 +msgid "All files" +msgstr "" + +#: ../src/editor.c:713 msgid "" "There are unsaved changes.\n" "Are you sure you want to discard them?" msgstr "" -#: ../src/editor.c:627 +#: ../src/editor.c:720 msgid "Discard" msgstr "" -#: ../src/editor.c:687 +#: ../src/editor.c:784 msgid "Open file..." msgstr "Offnen..." -#: ../src/editor.c:693 -msgid "Text files" -msgstr "" - -#: ../src/editor.c:697 -msgid "All files" -msgstr "" - -#: ../src/editor.c:755 +#: ../src/editor.c:852 msgid "Partial write" msgstr "" -#: ../src/editor.c:783 +#: ../src/editor.c:880 msgid "This file already exists. Overwrite?" msgstr "" -#: ../src/editor.c:792 +#: ../src/editor.c:889 msgid "Allocation error" msgstr "" -#: ../src/editor.c:807 +#: ../src/editor.c:904 msgid "Save as..." msgstr "" -#: ../src/editor.c:864 +#: ../src/editor.c:961 msgid "Text editor preferences" msgstr "Text Editor Einstellungen" -#: ../src/editor.c:881 +#: ../src/editor.c:978 msgid "Font:" msgstr "" -#: ../src/editor.c:891 +#: ../src/editor.c:988 msgid "Wrap mode:" msgstr "" diff --git a/po/es.po b/po/es.po index a0ff904..7d4e872 100644 --- a/po/es.po +++ b/po/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Editor 0.1.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-25 13:16+0200\n" +"POT-Creation-Date: 2011-10-25 15:13+0200\n" "PO-Revision-Date: 2010-04-07 22:07+0200\n" "Last-Translator: Pierre Pronchery \n" "Language-Team: Spanish\n" @@ -73,167 +73,179 @@ msgid "_Preferences" msgstr "_Preferencias" #: ../src/editor.c:138 +msgid "_File..." +msgstr "" + +#: ../src/editor.c:144 msgid "_About" msgstr "" -#: ../src/editor.c:149 +#: ../src/editor.c:155 msgid "_File" msgstr "" -#: ../src/editor.c:150 +#: ../src/editor.c:156 msgid "_Edit" msgstr "" -#: ../src/editor.c:151 -msgid "_Help" +#: ../src/editor.c:157 +msgid "_Insert" msgstr "" #: ../src/editor.c:158 -msgid "New" -msgstr "" - -#: ../src/editor.c:159 -msgid "Open" -msgstr "" - -#: ../src/editor.c:161 -msgid "Save" -msgstr "" - -#: ../src/editor.c:162 -msgid "Save as" +msgid "_Help" msgstr "" #: ../src/editor.c:165 -msgid "Cut" +msgid "New" msgstr "" #: ../src/editor.c:166 +msgid "Open" +msgstr "" + +#: ../src/editor.c:168 +msgid "Save" +msgstr "" + +#: ../src/editor.c:169 +msgid "Save as" +msgstr "" + +#: ../src/editor.c:172 +msgid "Cut" +msgstr "" + +#: ../src/editor.c:173 msgid "Copy" msgstr "" -#: ../src/editor.c:167 +#: ../src/editor.c:174 msgid "Paste" msgstr "" -#: ../src/editor.c:170 +#: ../src/editor.c:177 msgid "Preferences" msgstr "" -#: ../src/editor.c:182 +#: ../src/editor.c:189 msgid "none" msgstr "" -#: ../src/editor.c:183 +#: ../src/editor.c:190 msgid "characters" msgstr "" -#: ../src/editor.c:184 +#: ../src/editor.c:191 msgid "words" msgstr "" -#: ../src/editor.c:185 +#: ../src/editor.c:192 msgid "words then characters" msgstr "" -#: ../src/editor.c:268 +#: ../src/editor.c:275 msgid "Text editor - " msgstr "" -#: ../src/editor.c:269 +#: ../src/editor.c:276 msgid "(Untitled)" msgstr "" -#: ../src/editor.c:382 +#: ../src/editor.c:389 msgid "translator-credits" msgstr "" -#: ../src/editor.c:418 +#: ../src/editor.c:425 msgid "Could not save configuration" msgstr "" -#: ../src/editor.c:432 ../src/editor.c:437 +#: ../src/editor.c:439 ../src/editor.c:444 msgid "Error" msgstr "" -#: ../src/editor.c:464 ../src/editor.c:474 ../src/editor.c:616 -#: ../src/editor.c:630 ../src/editor.c:779 ../src/editor.c:784 +#: ../src/editor.c:471 ../src/editor.c:481 ../src/editor.c:709 +#: ../src/editor.c:723 ../src/editor.c:876 ../src/editor.c:881 msgid "Warning" msgstr "" -#: ../src/editor.c:468 +#: ../src/editor.c:475 msgid "" "There are unsaved changes.\n" "Discard or save them?" msgstr "" -#: ../src/editor.c:532 +#: ../src/editor.c:539 msgid "Find text" msgstr "" -#: ../src/editor.c:543 +#: ../src/editor.c:550 msgid "Text:" msgstr "" -#: ../src/editor.c:550 +#: ../src/editor.c:557 msgid "Case-sensitive" msgstr "" -#: ../src/editor.c:552 +#: ../src/editor.c:559 msgid "Wrap" msgstr "" -#: ../src/editor.c:575 +#: ../src/editor.c:582 msgid "Text not found" msgstr "" -#: ../src/editor.c:620 +#: ../src/editor.c:661 +msgid "Insert file..." +msgstr "" + +#: ../src/editor.c:667 ../src/editor.c:790 +msgid "Text files" +msgstr "" + +#: ../src/editor.c:671 ../src/editor.c:794 +msgid "All files" +msgstr "" + +#: ../src/editor.c:713 msgid "" "There are unsaved changes.\n" "Are you sure you want to discard them?" msgstr "" -#: ../src/editor.c:627 +#: ../src/editor.c:720 msgid "Discard" msgstr "" -#: ../src/editor.c:687 +#: ../src/editor.c:784 msgid "Open file..." msgstr "" -#: ../src/editor.c:693 -msgid "Text files" -msgstr "" - -#: ../src/editor.c:697 -msgid "All files" -msgstr "" - -#: ../src/editor.c:755 +#: ../src/editor.c:852 msgid "Partial write" msgstr "" -#: ../src/editor.c:783 +#: ../src/editor.c:880 msgid "This file already exists. Overwrite?" msgstr "" -#: ../src/editor.c:792 +#: ../src/editor.c:889 msgid "Allocation error" msgstr "" -#: ../src/editor.c:807 +#: ../src/editor.c:904 msgid "Save as..." msgstr "" -#: ../src/editor.c:864 +#: ../src/editor.c:961 msgid "Text editor preferences" msgstr "" -#: ../src/editor.c:881 +#: ../src/editor.c:978 msgid "Font:" msgstr "" -#: ../src/editor.c:891 +#: ../src/editor.c:988 msgid "Wrap mode:" msgstr "" diff --git a/po/fr.po b/po/fr.po index e50ebb3..7cfabbd 100644 --- a/po/fr.po +++ b/po/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Editor 0.1.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-25 13:16+0200\n" +"POT-Creation-Date: 2011-10-25 15:13+0200\n" "PO-Revision-Date: 2010-04-11 12:32+0200\n" "Last-Translator: Calimero \n" "Language-Team: French\n" @@ -73,125 +73,145 @@ msgid "_Preferences" msgstr "_Préférences" #: ../src/editor.c:138 +msgid "_File..." +msgstr "_Fichier..." + +#: ../src/editor.c:144 msgid "_About" msgstr "À _propos" -#: ../src/editor.c:149 +#: ../src/editor.c:155 msgid "_File" msgstr "_Fichier" -#: ../src/editor.c:150 +#: ../src/editor.c:156 msgid "_Edit" msgstr "É_dition" -#: ../src/editor.c:151 +#: ../src/editor.c:157 +msgid "_Insert" +msgstr "_Insertion" + +#: ../src/editor.c:158 msgid "_Help" msgstr "_Aide" -#: ../src/editor.c:158 +#: ../src/editor.c:165 msgid "New" msgstr "Nouveau" -#: ../src/editor.c:159 +#: ../src/editor.c:166 msgid "Open" msgstr "Ouvrir" -#: ../src/editor.c:161 +#: ../src/editor.c:168 msgid "Save" msgstr "Enregistrer" -#: ../src/editor.c:162 +#: ../src/editor.c:169 msgid "Save as" msgstr "Enregistrer sous" -#: ../src/editor.c:165 +#: ../src/editor.c:172 msgid "Cut" msgstr "Couper" -#: ../src/editor.c:166 +#: ../src/editor.c:173 msgid "Copy" msgstr "Copier" -#: ../src/editor.c:167 +#: ../src/editor.c:174 msgid "Paste" msgstr "Coller" -#: ../src/editor.c:170 +#: ../src/editor.c:177 msgid "Preferences" msgstr "Préférences" -#: ../src/editor.c:182 +#: ../src/editor.c:189 msgid "none" msgstr "aucun" -#: ../src/editor.c:183 +#: ../src/editor.c:190 msgid "characters" msgstr "caractères" -#: ../src/editor.c:184 +#: ../src/editor.c:191 msgid "words" msgstr "mots" -#: ../src/editor.c:185 +#: ../src/editor.c:192 msgid "words then characters" msgstr "mots puis caractères" -#: ../src/editor.c:268 +#: ../src/editor.c:275 msgid "Text editor - " msgstr "Éditeur de texte - " -#: ../src/editor.c:269 +#: ../src/editor.c:276 msgid "(Untitled)" msgstr "(Sans titre)" -#: ../src/editor.c:382 +#: ../src/editor.c:389 msgid "translator-credits" msgstr "" "Calimero \n" "Pierre Pronchery " -#: ../src/editor.c:418 +#: ../src/editor.c:425 msgid "Could not save configuration" msgstr "Erreur lors de la sauvegarde de la configuration" -#: ../src/editor.c:432 ../src/editor.c:437 +#: ../src/editor.c:439 ../src/editor.c:444 msgid "Error" msgstr "Erreur" -#: ../src/editor.c:464 ../src/editor.c:474 ../src/editor.c:616 -#: ../src/editor.c:630 ../src/editor.c:779 ../src/editor.c:784 +#: ../src/editor.c:471 ../src/editor.c:481 ../src/editor.c:709 +#: ../src/editor.c:723 ../src/editor.c:876 ../src/editor.c:881 msgid "Warning" msgstr "Avertissement" -#: ../src/editor.c:468 +#: ../src/editor.c:475 msgid "" "There are unsaved changes.\n" "Discard or save them?" msgstr "" "Il y a des changements non enregistrés.\n" -"Ignorer ou sauvegarder ?" +"Abandonner ou enregistrer ?" -#: ../src/editor.c:532 +#: ../src/editor.c:539 msgid "Find text" msgstr "Rechercher" -#: ../src/editor.c:543 -msgid "Text:" -msgstr "Texte :" - #: ../src/editor.c:550 +msgid "Text:" +msgstr "Texte :" + +#: ../src/editor.c:557 msgid "Case-sensitive" msgstr "Sensible à la casse" -#: ../src/editor.c:552 +#: ../src/editor.c:559 msgid "Wrap" msgstr "Boucler" -#: ../src/editor.c:575 +#: ../src/editor.c:582 msgid "Text not found" msgstr "Texte non trouvé" -#: ../src/editor.c:620 +#: ../src/editor.c:661 +msgid "Insert file..." +msgstr "Insérer un fichier..." + +#: ../src/editor.c:667 ../src/editor.c:790 +msgid "Text files" +msgstr "Fichiers texte" + +#: ../src/editor.c:671 ../src/editor.c:794 +msgid "All files" +msgstr "Tous les fichiers" + +#: ../src/editor.c:713 msgid "" "There are unsaved changes.\n" "Are you sure you want to discard them?" @@ -199,49 +219,41 @@ msgstr "" "Il y a des changements non enregistrés.\n" "Êtes-vous sûr de vouloir les annuler ?" -#: ../src/editor.c:627 +#: ../src/editor.c:720 msgid "Discard" msgstr "Annuler" -#: ../src/editor.c:687 +#: ../src/editor.c:784 msgid "Open file..." msgstr "Ouvrir un fichier..." -#: ../src/editor.c:693 -msgid "Text files" -msgstr "Fichiers texte" - -#: ../src/editor.c:697 -msgid "All files" -msgstr "Tous les fichiers" - -#: ../src/editor.c:755 +#: ../src/editor.c:852 msgid "Partial write" msgstr "Écriture partielle" -#: ../src/editor.c:783 +#: ../src/editor.c:880 msgid "This file already exists. Overwrite?" msgstr "Le fichier existe déjà. L'écraser ?" -#: ../src/editor.c:792 +#: ../src/editor.c:889 msgid "Allocation error" msgstr "Erreur d'allocation" -#: ../src/editor.c:807 +#: ../src/editor.c:904 msgid "Save as..." msgstr "Enregistrer sous..." -#: ../src/editor.c:864 +#: ../src/editor.c:961 msgid "Text editor preferences" msgstr "Préférences de l'éditeur de texte" -#: ../src/editor.c:881 +#: ../src/editor.c:978 msgid "Font:" -msgstr "Police :" +msgstr "Police :" -#: ../src/editor.c:891 +#: ../src/editor.c:988 msgid "Wrap mode:" -msgstr "Retour à la ligne :" +msgstr "Retour à la ligne :" #: ../src/main.c:43 msgid "Usage: editor [file]\n" diff --git a/po/it.po b/po/it.po index 6e0c98d..f96e01b 100644 --- a/po/it.po +++ b/po/it.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Editor 0.1.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-25 13:16+0200\n" +"POT-Creation-Date: 2011-10-25 15:13+0200\n" "PO-Revision-Date: 2010-04-09 16:43+0200\n" "Last-Translator: Pierre Pronchery \n" "Language-Team: Italian\n" @@ -74,167 +74,179 @@ msgid "_Preferences" msgstr "" #: ../src/editor.c:138 +msgid "_File..." +msgstr "" + +#: ../src/editor.c:144 msgid "_About" msgstr "" -#: ../src/editor.c:149 +#: ../src/editor.c:155 msgid "_File" msgstr "" -#: ../src/editor.c:150 +#: ../src/editor.c:156 msgid "_Edit" msgstr "" -#: ../src/editor.c:151 -msgid "_Help" +#: ../src/editor.c:157 +msgid "_Insert" msgstr "" #: ../src/editor.c:158 -msgid "New" -msgstr "" - -#: ../src/editor.c:159 -msgid "Open" -msgstr "" - -#: ../src/editor.c:161 -msgid "Save" -msgstr "" - -#: ../src/editor.c:162 -msgid "Save as" +msgid "_Help" msgstr "" #: ../src/editor.c:165 -msgid "Cut" +msgid "New" msgstr "" #: ../src/editor.c:166 +msgid "Open" +msgstr "" + +#: ../src/editor.c:168 +msgid "Save" +msgstr "" + +#: ../src/editor.c:169 +msgid "Save as" +msgstr "" + +#: ../src/editor.c:172 +msgid "Cut" +msgstr "" + +#: ../src/editor.c:173 msgid "Copy" msgstr "" -#: ../src/editor.c:167 +#: ../src/editor.c:174 msgid "Paste" msgstr "" -#: ../src/editor.c:170 +#: ../src/editor.c:177 msgid "Preferences" msgstr "" -#: ../src/editor.c:182 +#: ../src/editor.c:189 msgid "none" msgstr "" -#: ../src/editor.c:183 +#: ../src/editor.c:190 msgid "characters" msgstr "" -#: ../src/editor.c:184 +#: ../src/editor.c:191 msgid "words" msgstr "" -#: ../src/editor.c:185 +#: ../src/editor.c:192 msgid "words then characters" msgstr "" -#: ../src/editor.c:268 +#: ../src/editor.c:275 msgid "Text editor - " msgstr "" -#: ../src/editor.c:269 +#: ../src/editor.c:276 msgid "(Untitled)" msgstr "" -#: ../src/editor.c:382 +#: ../src/editor.c:389 msgid "translator-credits" msgstr "" -#: ../src/editor.c:418 +#: ../src/editor.c:425 msgid "Could not save configuration" msgstr "" -#: ../src/editor.c:432 ../src/editor.c:437 +#: ../src/editor.c:439 ../src/editor.c:444 msgid "Error" msgstr "" -#: ../src/editor.c:464 ../src/editor.c:474 ../src/editor.c:616 -#: ../src/editor.c:630 ../src/editor.c:779 ../src/editor.c:784 +#: ../src/editor.c:471 ../src/editor.c:481 ../src/editor.c:709 +#: ../src/editor.c:723 ../src/editor.c:876 ../src/editor.c:881 msgid "Warning" msgstr "" -#: ../src/editor.c:468 +#: ../src/editor.c:475 msgid "" "There are unsaved changes.\n" "Discard or save them?" msgstr "" -#: ../src/editor.c:532 +#: ../src/editor.c:539 msgid "Find text" msgstr "" -#: ../src/editor.c:543 +#: ../src/editor.c:550 msgid "Text:" msgstr "" -#: ../src/editor.c:550 +#: ../src/editor.c:557 msgid "Case-sensitive" msgstr "" -#: ../src/editor.c:552 +#: ../src/editor.c:559 msgid "Wrap" msgstr "" -#: ../src/editor.c:575 +#: ../src/editor.c:582 msgid "Text not found" msgstr "" -#: ../src/editor.c:620 +#: ../src/editor.c:661 +msgid "Insert file..." +msgstr "" + +#: ../src/editor.c:667 ../src/editor.c:790 +msgid "Text files" +msgstr "" + +#: ../src/editor.c:671 ../src/editor.c:794 +msgid "All files" +msgstr "" + +#: ../src/editor.c:713 msgid "" "There are unsaved changes.\n" "Are you sure you want to discard them?" msgstr "" -#: ../src/editor.c:627 +#: ../src/editor.c:720 msgid "Discard" msgstr "" -#: ../src/editor.c:687 +#: ../src/editor.c:784 msgid "Open file..." msgstr "" -#: ../src/editor.c:693 -msgid "Text files" -msgstr "" - -#: ../src/editor.c:697 -msgid "All files" -msgstr "" - -#: ../src/editor.c:755 +#: ../src/editor.c:852 msgid "Partial write" msgstr "" -#: ../src/editor.c:783 +#: ../src/editor.c:880 msgid "This file already exists. Overwrite?" msgstr "" -#: ../src/editor.c:792 +#: ../src/editor.c:889 msgid "Allocation error" msgstr "" -#: ../src/editor.c:807 +#: ../src/editor.c:904 msgid "Save as..." msgstr "" -#: ../src/editor.c:864 +#: ../src/editor.c:961 msgid "Text editor preferences" msgstr "" -#: ../src/editor.c:881 +#: ../src/editor.c:978 msgid "Font:" msgstr "" -#: ../src/editor.c:891 +#: ../src/editor.c:988 msgid "Wrap mode:" msgstr "" diff --git a/src/callbacks.c b/src/callbacks.c index da7c009..6a97ced 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -150,6 +150,15 @@ void on_help_about(gpointer data) } +/* on_insert_file */ +void on_insert_file(gpointer data) +{ + Editor * editor = data; + + editor_insert_file_dialog(editor); +} + + /* toolbar */ /* on_close */ void on_close(gpointer data) diff --git a/src/callbacks.h b/src/callbacks.h index b111efd..d819ada 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -36,6 +36,7 @@ void on_file_open(gpointer data); void on_file_save(gpointer data); void on_file_save_as(gpointer data); void on_help_about(gpointer data); +void on_insert_file(gpointer data); /* toolbar */ void on_close(gpointer data); diff --git a/src/editor.c b/src/editor.c index 111c2b8..6f75505 100644 --- a/src/editor.c +++ b/src/editor.c @@ -133,6 +133,12 @@ static DesktopMenu _editor_menu_edit[] = { NULL, NULL, NULL, 0, 0 } }; +static DesktopMenu _editor_menu_insert[] = +{ + { N_("_File..."), G_CALLBACK(on_insert_file), 0, 0, 0 }, + { NULL, NULL, NULL, 0, 0 } +}; + static DesktopMenu _editor_menu_help[] = { { N_("_About"), G_CALLBACK(on_help_about), @@ -148,6 +154,7 @@ static DesktopMenubar _editor_menubar[] = { { N_("_File"), _editor_menu_file }, { N_("_Edit"), _editor_menu_edit }, + { N_("_Insert"), _editor_menu_insert }, { N_("_Help"), _editor_menu_help }, { NULL, NULL } }; @@ -590,6 +597,92 @@ static void _on_find_response(GtkWidget * widget, gint response, gpointer data) } +/* editor_insert_file */ +int editor_insert_file(Editor * editor, char const * filename) +{ + int ret = 0; + FILE * fp; + GtkTextBuffer * tbuf; + char buf[BUFSIZ]; + size_t len; + char * p; + size_t rlen; + size_t wlen; + GError * error = NULL; + + if((fp = fopen(filename, "r")) == NULL) + { + snprintf(buf, sizeof(buf), "%s: %s", filename, strerror(errno)); + return -editor_error(editor, buf, 1); + } + tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(editor->view)); + while((len = fread(buf, sizeof(char), sizeof(buf), fp)) > 0) + { + /* FIXME code duplicated from editor_open() */ +#if 0 + if((p = g_convert(buf, len, "UTF-8", "ISO-8859-15", &rlen, &wlen, NULL)) != NULL) + { + gtk_text_buffer_insert_at_cursor(tbuf, p, wlen); + g_free(p); + } + else + gtk_text_buffer_insert(tbuf, &iter, buf, len); +#else + if((p = g_locale_to_utf8(buf, len, &rlen, &wlen, &error)) + != NULL) + /* FIXME may lose characters */ + gtk_text_buffer_insert_at_cursor(tbuf, p, wlen); + else + { + editor_error(editor, error->message, 1); + g_error_free(error); + gtk_text_buffer_insert_at_cursor(tbuf, buf, len); + } +#endif + } + if(ferror(fp)) + { + snprintf(buf, sizeof(buf), "%s: %s", filename, strerror(errno)); + ret = -editor_error(editor, buf, 1); + } + fclose(fp); + return ret; +} + + +/* editor_insert_file_dialog */ +int editor_insert_file_dialog(Editor * editor) +{ + int ret; + GtkWidget * dialog; + GtkFileFilter * filter; + char * filename = NULL; + + dialog = gtk_file_chooser_dialog_new(_("Insert file..."), + GTK_WINDOW(editor->window), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, _("Text files")); + gtk_file_filter_add_mime_type(filter, "text/plain"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, _("All files")); + gtk_file_filter_add_pattern(filter, "*"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); + if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER( + dialog)); + gtk_widget_destroy(dialog); + if(filename == NULL) + return 0; + ret = editor_insert_file(editor, filename); + g_free(filename); + return ret; +} + + /* editor_open */ void editor_open(Editor * editor, char const * filename) { @@ -666,7 +759,11 @@ void editor_open(Editor * editor, char const * filename) /* FIXME may lose characters */ gtk_text_buffer_insert(tbuf, &iter, p, wlen); else + { + editor_error(editor, error->message, 1); + g_error_free(error); gtk_text_buffer_insert(tbuf, &iter, buf, len); + } #endif } fclose(fp); diff --git a/src/editor.h b/src/editor.h index 11bc362..721a9ca 100644 --- a/src/editor.h +++ b/src/editor.h @@ -53,6 +53,9 @@ void editor_copy(Editor * editor); void editor_cut(Editor * editor); void editor_paste(Editor * editor); +int editor_insert_file(Editor * editor, char const * filename); +int editor_insert_file_dialog(Editor * editor); + gboolean editor_save(Editor * editor); gboolean editor_save_as(Editor * editor, char const * filename); gboolean editor_save_as_dialog(Editor * editor);