From 16fe2e5d0525422ba6ca5db9e92a93d17caae302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 27 Sep 2015 15:05:13 +0200 Subject: Imported Upstream version 0.6.6 --- src/gui/preferencesWindow.vala | 134 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 131 insertions(+), 3 deletions(-) (limited to 'src/gui/preferencesWindow.vala') diff --git a/src/gui/preferencesWindow.vala b/src/gui/preferencesWindow.vala index 5d22d6b..d671501 100644 --- a/src/gui/preferencesWindow.vala +++ b/src/gui/preferencesWindow.vala @@ -154,6 +154,17 @@ public class PreferencesWindow : GLib.Object { scroll_area = builder.get_object("theme-scrolledwindow") as Gtk.ScrolledWindow; scroll_area.add(this.theme_list); + (builder.get_object("theme-help-button") as Gtk.Button).clicked.connect(() => { + try{ + GLib.AppInfo.launch_default_for_uri("http://simmesimme.github.io/lessons/2015/04/26/themes-for-gnome-pie/", null); + } catch (Error e) { + warning(e.message); + } + }); + + (builder.get_object("theme-export-button") as Gtk.Button).clicked.connect(on_export_theme_button_clicked); + (builder.get_object("theme-import-button") as Gtk.Button).clicked.connect(on_import_theme_button_clicked); + this.autostart = (builder.get_object("autostart-checkbox") as Gtk.ToggleButton); this.autostart.toggled.connect(on_autostart_toggled); @@ -209,6 +220,33 @@ public class PreferencesWindow : GLib.Object { Config.global.max_visible_slices = (int)range_slices.get_value(); }); + var info_box = (builder.get_object("info-box") as Gtk.Box); + + // info label + var info_label = new TipViewer({ + _("Pies can be opened with the terminal command \"gnome-pie --open=ID\"."), + _("Feel free to visit Gnome-Pie's homepage at %s!").printf("gnome-pie.simonschneegans.de"), + _("If you want to give some feedback, please write an e-mail to %s!").printf("code@simonschneegans.de"), + _("You can support the development of Gnome-Pie by donating via %s.").printf("Paypal"), + _("Translating Gnome-Pie to your language is easy. Translations are managed at %s.").printf("Zanata"), + _("It's easy to create new themes for Gnome-Pie. Read the Tutorial online.").printf("http://simmesimme.github.io/lessons/2015/04/26/themes-for-gnome-pie/"), + _("It's usually a good practive to have at most twelve slices per pie."), + _("You can export themes you created and share them with the community!"), + _("The source code of Gnome-Pie is available on %s.").printf("Github"), + _("Bugs can be reported at %s!").printf("Github"), + _("Suggestions can be posted on %s!").printf("Github"), + _("An awesome companion of Gnome-Pie is %s. It will make using your computer feel like magic!").printf("Easystroke"), + _("You can drag'n'drop applications from your main menu to the pie above."), + _("You may drag'n'drop URLs and bookmarks from your internet browser to the pie above."), + _("You can drag'n'drop files and folders from your file browser to the pie above."), + _("You can drag'n'drop pies from the list on the left into other pies in order to create sub-pies."), + _("You can drag'n'drop pies from the list on the left to your desktop or dock to create a launcher for this pie.") + }); + this.window.show.connect(info_label.start_slide_show); + this.window.hide.connect(info_label.stop_slide_show); + + info_box.pack_end(info_label); + this.window.hide.connect(() => { // save settings on close Config.global.save(); @@ -290,14 +328,104 @@ public class PreferencesWindow : GLib.Object { FileUtils.set_contents(Paths.autostart, autostart_entry); FileUtils.chmod(Paths.autostart, 0755); } catch (Error e) { - var d = new Gtk.MessageDialog (this.window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, + var d = new Gtk.MessageDialog(this.window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, "%s", e.message); - d.run (); - d.destroy (); + d.run(); + d.destroy(); } } } + ///////////////////////////////////////////////////////////////////// + /// Saves the current theme to an archive. + ///////////////////////////////////////////////////////////////////// + + private void on_export_theme_button_clicked(Gtk.Button button) { + var dialog = new Gtk.FileChooserDialog("Pick a file", this.window, + Gtk.FileChooserAction.SAVE, + "_Cancel", + Gtk.ResponseType.CANCEL, + "_Save", + Gtk.ResponseType.ACCEPT); + + dialog.set_do_overwrite_confirmation(true); + dialog.set_modal(true); + dialog.filter = new Gtk.FileFilter(); + dialog.filter.add_pattern ("*.tar.gz"); + dialog.set_current_name(Config.global.theme.name + ".tar.gz"); + + dialog.response.connect((d, result) => { + if (result == Gtk.ResponseType.ACCEPT) { + var file = dialog.get_filename(); + if (!file.has_suffix(".tar.gz")) { + file = file + ".tar.gz"; + } + Config.global.theme.export(file); + } + dialog.destroy(); + }); + dialog.show(); + } + + ///////////////////////////////////////////////////////////////////// + /// Imports a new theme from an archive. + ///////////////////////////////////////////////////////////////////// + + private void on_import_theme_button_clicked(Gtk.Button button) { + var dialog = new Gtk.FileChooserDialog("Pick a file", this.window, + Gtk.FileChooserAction.OPEN, + "_Cancel", + Gtk.ResponseType.CANCEL, + "_Open", + Gtk.ResponseType.ACCEPT); + + dialog.set_modal(true); + dialog.filter = new Gtk.FileFilter(); + dialog.filter.add_pattern ("*.tar.gz"); + + var result = Gtk.MessageType.INFO; + var message = _("Sucessfully imported new theme!"); + + dialog.response.connect((d, r) => { + if (r == Gtk.ResponseType.ACCEPT) { + var file = dialog.get_filename(); + + var a = new ThemeImporter(); + if (a.open(file)) { + if (a.is_valid_theme) { + if (!Config.global.has_theme(a.theme_name)) { + if (a.extract_to(Paths.local_themes + "/" + a.theme_name)) { + Config.global.load_themes(a.theme_name); + this.theme_list.reload(); + } else { + message = _("An error occured while importing the theme: Failed to extract theme!"); + result = Gtk.MessageType.ERROR; + } + } else { + message = _("An error occured while importing the theme: A theme with this name does already exist!"); + result = Gtk.MessageType.ERROR; + } + } else { + message = _("An error occured while importing the theme: Theme archive does not contain a valid theme!"); + result = Gtk.MessageType.ERROR; + } + } else { + message = _("An error occured while importing the theme: Failed to open theme archive!"); + result = Gtk.MessageType.ERROR; + } + a.close(); + + var result_dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.MODAL, + result, Gtk.ButtonsType.CLOSE, message); + result_dialog.run(); + result_dialog.destroy(); + } + dialog.destroy(); + + }); + dialog.show(); + } + ///////////////////////////////////////////////////////////////////// /// Shows or hides the indicator. ///////////////////////////////////////////////////////////////////// -- cgit v1.2.3