-
Notifications
You must be signed in to change notification settings - Fork 49
Feature: Save as dialog #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,11 @@ | |
| <property name="can_focus">False</property> | ||
| <property name="icon_name">document-properties-symbolic</property> | ||
| </object> | ||
| <object class="GtkImage" id="img-save-as-surface"> | ||
| <property name="visible">True</property> | ||
| <property name="can-focus">False</property> | ||
| <property name="icon-name">document-save-as</property> | ||
| </object> | ||
| <object class="GtkImage" id="zoom-in"> | ||
| <property name="visible">True</property> | ||
| <property name="can_focus">False</property> | ||
|
|
@@ -781,6 +786,22 @@ | |
| <property name="always_show_image">True</property> | ||
| <signal name="clicked" handler="save_clicked_handler" swapped="no"/> | ||
| </object> | ||
| <packing> | ||
| <property name="expand">False</property> | ||
| <property name="fill">True</property> | ||
| <property name="position">1</property> | ||
| </packing> | ||
| </child> | ||
| <child> | ||
| <object class="GtkButton" id="save-as"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove the UI part please There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And re-run the .po files so that there is no more diff |
||
| <property name="visible">True</property> | ||
| <property name="can-focus">False</property> | ||
| <property name="receives-default">True</property> | ||
| <property name="tooltip-text" translatable="yes">Save Surface As</property> | ||
Maaxxs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <property name="image">img-save-as-surface</property> | ||
| <property name="always-show-image">True</property> | ||
| <signal name="clicked" handler="save_as_clicked_handler" swapped="no"/> | ||
| </object> | ||
| <packing> | ||
| <property name="expand">False</property> | ||
| <property name="fill">True</property> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,22 @@ | ||
| #define _POSIX_C_SOURCE 200809L | ||
|
|
||
| #include <libintl.h> | ||
| #include <locale.h> | ||
|
|
||
| #include "application.h" | ||
| #include "config.h" | ||
|
|
||
| int main(int argc, char *argv[]) { | ||
| struct swappy_state state = {0}; | ||
| int status; | ||
|
|
||
| // set locales according to environment variables | ||
| setlocale(LC_ALL, ""); | ||
| // set base directory for translated messages | ||
| bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); | ||
| // explicitly set encoding of message translations to UTF-8 | ||
| bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this part fix? |
||
|
|
||
| state.argc = argc; | ||
| state.argv = argv; | ||
| state.mode = SWAPPY_PAINT_MODE_BRUSH; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,26 +22,35 @@ static void write_file(GdkPixbuf *pixbuf, char *path) { | |
| } | ||
| } | ||
|
|
||
| void pixbuf_save_state_to_folder(GdkPixbuf *pixbuf, char *folder, | ||
| char *filename_format) { | ||
| char *format_filename(char *filename_format) { | ||
| time_t current_time = time(NULL); | ||
| char *c_time_string; | ||
| char filename[255]; | ||
| char path[MAX_PATH]; | ||
| size_t bytes_formated; | ||
| size_t bytes_formatted; | ||
|
|
||
| c_time_string = ctime(¤t_time); | ||
| c_time_string[strlen(c_time_string) - 1] = '\0'; | ||
| bytes_formated = strftime(filename, sizeof(filename), filename_format, | ||
| localtime(¤t_time)); | ||
| if (!bytes_formated) { | ||
| bytes_formatted = strftime(filename, sizeof(filename), filename_format, | ||
| localtime(¤t_time)); | ||
| if (!bytes_formatted) { | ||
| g_warning( | ||
| "filename_format: %s overflows filename limit - file cannot be saved", | ||
| filename_format); | ||
| return; | ||
| return NULL; | ||
| } | ||
|
|
||
| return g_strdup(filename); | ||
| } | ||
|
|
||
| void pixbuf_save_state_to_folder(GdkPixbuf *pixbuf, char *folder, | ||
| char *filename_format) { | ||
| char path[MAX_PATH]; | ||
| char *filename; | ||
| filename = format_filename(filename_format); | ||
| if (filename == NULL) return; | ||
|
|
||
| g_snprintf(path, MAX_PATH, "%s/%s", folder, filename); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in this case we actually should abort if this fails. We do not want to write to a truncated filename as this could potentially overwrite some file the user did not intend to overwrite. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for taking a look at the code! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes good catch @kadamski |
||
| g_free(filename); | ||
| g_info("saving surface to path: %s", path); | ||
| write_file(pixbuf, path); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| res/swappy.glade | ||
| src/application.c |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ msgid "" | |
| msgstr "" | ||
| "Project-Id-Version: swappy\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2022-11-18 16:07-0500\n" | ||
| "POT-Creation-Date: 2022-12-04 22:52+0100\n" | ||
| "PO-Revision-Date: 2020-11-19 18:03+0300\n" | ||
| "Last-Translator: Brodi <[email protected]>\n" | ||
| "Language-Team: none\n" | ||
|
|
@@ -17,42 +17,54 @@ msgstr "" | |
| "Content-Transfer-Encoding: 8bit\n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
|
||
| #: res/swappy.glade:456 | ||
| #: res/swappy.glade:461 | ||
| msgid "Line Width" | ||
| msgstr "Linienstärke" | ||
|
|
||
| #: res/swappy.glade:526 | ||
| #: res/swappy.glade:531 | ||
| msgid "Text Size" | ||
| msgstr "Textgröße" | ||
|
|
||
| #: res/swappy.glade:592 | ||
| #: res/swappy.glade:597 | ||
| msgid "Fill shape" | ||
| msgstr "" | ||
|
|
||
| #: res/swappy.glade:597 | ||
| #: res/swappy.glade:602 | ||
| msgid "Toggle shape filling" | ||
| msgstr "" | ||
|
|
||
| #: res/swappy.glade:671 | ||
| #: res/swappy.glade:676 | ||
| msgid "Toggle Paint Panel" | ||
| msgstr "Farbtafel umschalten" | ||
|
|
||
| #: res/swappy.glade:697 | ||
| #: res/swappy.glade:702 | ||
| msgid "Undo Last Paint" | ||
| msgstr "Letzte Bemalung rückgängig machen" | ||
|
|
||
| #: res/swappy.glade:716 | ||
| #: res/swappy.glade:721 | ||
| msgid "Redo Previous Paint" | ||
| msgstr "Vorherige Bemalung wiederherstellen" | ||
|
|
||
| #: res/swappy.glade:735 | ||
| #: res/swappy.glade:740 | ||
| msgid "Clear Paints" | ||
| msgstr "Bemalung löschen" | ||
|
|
||
| #: res/swappy.glade:763 | ||
| #: res/swappy.glade:768 | ||
| msgid "Copy Surface" | ||
| msgstr "Fläche kopieren" | ||
|
|
||
| #: res/swappy.glade:779 | ||
| #: res/swappy.glade:784 | ||
| msgid "Save Surface" | ||
| msgstr "Fläche speichern" | ||
|
|
||
| #: res/swappy.glade:800 | ||
| msgid "Save Surface As" | ||
| msgstr "Fläche speichern unter" | ||
|
|
||
| #: src/application.c:327 | ||
| msgid "_Cancel" | ||
| msgstr "_Abbrechen" | ||
|
|
||
| #: src/application.c:328 | ||
| msgid "_Save" | ||
| msgstr "_Speichern" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ msgid "" | |
| msgstr "" | ||
| "Project-Id-Version: swappy\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2022-11-18 16:07-0500\n" | ||
| "POT-Creation-Date: 2022-12-04 22:52+0100\n" | ||
| "PO-Revision-Date: 2021-02-20 21:00-0500\n" | ||
| "Last-Translator: Jeremy Attali <[email protected]>\n" | ||
| "Language-Team: none\n" | ||
|
|
@@ -17,42 +17,55 @@ msgstr "" | |
| "Content-Transfer-Encoding: 8bit\n" | ||
| "Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
|
|
||
| #: res/swappy.glade:456 | ||
| #: res/swappy.glade:461 | ||
| msgid "Line Width" | ||
| msgstr "Epaisseur de ligne" | ||
|
|
||
| #: res/swappy.glade:526 | ||
| #: res/swappy.glade:531 | ||
| msgid "Text Size" | ||
| msgstr "Taille du texte" | ||
|
|
||
| #: res/swappy.glade:592 | ||
| #: res/swappy.glade:597 | ||
| msgid "Fill shape" | ||
| msgstr "Remplir la forme" | ||
|
|
||
| #: res/swappy.glade:597 | ||
| #: res/swappy.glade:602 | ||
| msgid "Toggle shape filling" | ||
| msgstr "Activer/Désactiver le remplissage de forme" | ||
|
|
||
| #: res/swappy.glade:671 | ||
| #: res/swappy.glade:676 | ||
| msgid "Toggle Paint Panel" | ||
| msgstr "Afficher/Cacher le panneau de peinture" | ||
|
|
||
| #: res/swappy.glade:697 | ||
| #: res/swappy.glade:702 | ||
| msgid "Undo Last Paint" | ||
| msgstr "Annuler la dernière peinture" | ||
|
|
||
| #: res/swappy.glade:716 | ||
| #: res/swappy.glade:721 | ||
| msgid "Redo Previous Paint" | ||
| msgstr "Rétablir la dernière peinture" | ||
|
|
||
| #: res/swappy.glade:735 | ||
| #: res/swappy.glade:740 | ||
| msgid "Clear Paints" | ||
| msgstr "Supprimer les peintures" | ||
|
|
||
| #: res/swappy.glade:763 | ||
| #: res/swappy.glade:768 | ||
| msgid "Copy Surface" | ||
| msgstr "Copier la surface" | ||
|
|
||
| #: res/swappy.glade:779 | ||
| #: res/swappy.glade:784 | ||
| msgid "Save Surface" | ||
| msgstr "Sauvegarder la surface" | ||
|
|
||
| #: res/swappy.glade:800 | ||
| #, fuzzy | ||
| msgid "Save Surface As" | ||
| msgstr "Sauvegarder la surface" | ||
|
|
||
| #: src/application.c:327 | ||
| msgid "_Cancel" | ||
| msgstr "" | ||
|
|
||
| #: src/application.c:328 | ||
| msgid "_Save" | ||
| msgstr "" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the man page file too