Remember print dir and reuse when printing again. Bug 713573.
* src/client/conversation-viewer/conversation-email.vala (ConversationEmail): Save config object as a class field, use that to get and set the print directory when printing. Also set the default print filename based on the email's subject.
This commit is contained in:
parent
a20cb240a3
commit
7787af3aac
3 changed files with 42 additions and 1 deletions
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
<schema id="org.gnome.Geary" path="/org/gnome/Geary/">
|
||||
|
||||
<key name="print-directory" type="s">
|
||||
<default>''</default>
|
||||
<summary>Default print output directory</summary>
|
||||
<description>Location used when printing to a file</description>
|
||||
</key>
|
||||
|
||||
<key name="window-maximize" type="b">
|
||||
<default>false</default>
|
||||
<summary>maximize window</summary>
|
||||
|
|
@ -121,6 +127,7 @@
|
|||
<summary>Whether we migrated the old settings</summary>
|
||||
<description>False to check for the old 'org.yorba.geary'-schema and copy its values</description>
|
||||
</key>
|
||||
|
||||
</schema>
|
||||
|
||||
</schemalist>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
public class Configuration {
|
||||
|
||||
public const string PRINT_DIR_KEY = "print-directory";
|
||||
public const string WINDOW_WIDTH_KEY = "window-width";
|
||||
public const string WINDOW_HEIGHT_KEY = "window-height";
|
||||
public const string WINDOW_MAXIMIZE_KEY = "window-maximize";
|
||||
|
|
@ -62,6 +63,11 @@ public class Configuration {
|
|||
}
|
||||
}
|
||||
|
||||
public string? print_dir {
|
||||
owned get { return settings.get_string(PRINT_DIR_KEY); }
|
||||
set { settings.set_string(PRINT_DIR_KEY, value); }
|
||||
}
|
||||
|
||||
public int window_width {
|
||||
get { return settings.get_int(WINDOW_WIDTH_KEY); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,6 +260,8 @@ public class ConversationEmail : Gtk.Box {
|
|||
// Contacts for the email's account
|
||||
private Geary.ContactStore contact_store;
|
||||
|
||||
private Configuration config;
|
||||
|
||||
// Message view with selected text, if any
|
||||
private ConversationMessage? body_selection_message = null;
|
||||
|
||||
|
|
@ -363,6 +365,7 @@ public class ConversationEmail : Gtk.Box {
|
|||
bool is_draft) {
|
||||
this.email = email;
|
||||
this.contact_store = contact_store;
|
||||
this.config = config;
|
||||
|
||||
if (is_sent) {
|
||||
get_style_context().add_class(SENT_CLASS);
|
||||
|
|
@ -736,12 +739,37 @@ public class ConversationEmail : Gtk.Box {
|
|||
private void print() {
|
||||
// XXX This isn't anywhere near good enough - headers aren't
|
||||
// being printed.
|
||||
|
||||
Gtk.Window? window = get_toplevel() as Gtk.Window;
|
||||
WebKit.PrintOperation op = new WebKit.PrintOperation(
|
||||
this.primary_message.web_view
|
||||
);
|
||||
Gtk.Window? window = get_toplevel() as Gtk.Window;
|
||||
Gtk.PrintSettings settings = new Gtk.PrintSettings();
|
||||
|
||||
if (!Geary.String.is_empty(this.config.print_dir)) {
|
||||
settings.set(Gtk.PRINT_SETTINGS_OUTPUT_DIR, this.config.print_dir);
|
||||
}
|
||||
|
||||
if (this.email.subject != null) {
|
||||
string file_name = Geary.String.reduce_whitespace(this.email.subject.value);
|
||||
file_name = file_name.replace("/", "_");
|
||||
if (file_name.char_count() > 128) {
|
||||
file_name = Geary.String.safe_byte_substring(file_name, 128);
|
||||
}
|
||||
|
||||
if (!Geary.String.is_empty(file_name)) {
|
||||
settings.set(Gtk.PRINT_SETTINGS_OUTPUT_BASENAME, file_name);
|
||||
}
|
||||
}
|
||||
|
||||
op.set_print_settings(settings);
|
||||
op.run_dialog(window);
|
||||
|
||||
string? file_uri = op.get_print_settings().get(Gtk.PRINT_SETTINGS_OUTPUT_URI);
|
||||
if (!Geary.String.is_empty(file_uri)) {
|
||||
File print_file = File.new_for_uri(file_uri);
|
||||
this.config.print_dir = print_file.get_parent().get_path();
|
||||
}
|
||||
}
|
||||
|
||||
private void on_flag_remote_images(ConversationMessage view) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue