[pan2/testing: 118/279] togo
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 118/279] togo
- Date: Sat, 3 Dec 2011 22:32:06 +0000 (UTC)
commit b4ec641b39e5764d11cbfd2ee83a0523adf67cb6
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Mon Jun 27 12:31:48 2011 +0200
togo
pan/gui/post-ui.cc | 61 +++++++++++++++++++++++++++++++++++++++++++++++++-
pan/gui/post-ui.h | 17 +++++++++++++-
pan/gui/prefs-ui.cc | 12 ++++++++-
3 files changed, 85 insertions(+), 5 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index b744910..4bcf9dc 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -2015,6 +2015,28 @@ PostUI :: group_entry_changed_cb (GtkEditable*, gpointer ui_gpointer)
tag = g_timeout_add (2000, group_entry_changed_idle, ui);
}
+gboolean
+PostUI :: body_changed_idle (gpointer ui_gpointer)
+{
+ std::cerr<<"body changed idle\n";
+ PostUI * ui (static_cast<PostUI*>(ui_gpointer));
+
+ ui->_body_changed_idle_tag = 0;
+ ui->_draft_autosave_id = g_timeout_add_seconds( ui->_draft_autosave_timeout * 60, draft_save_cb, ui);
+
+ return false;
+}
+
+void
+PostUI :: body_changed_cb (GtkEditable*, gpointer ui_gpointer)
+{
+ std::cerr<<"body changed cb\n";
+ PostUI * ui (static_cast<PostUI*>(ui_gpointer));
+ unsigned int& tag (ui->_body_changed_idle_tag);
+ if (!tag)
+ tag = g_timeout_add (2000, body_changed_idle, ui);
+}
+
/***
****
***/
@@ -2122,7 +2144,7 @@ PostUI :: create_main_tab ()
w = create_body_widget (_body_buf, _body_view, _prefs);
set_spellcheck_enabled (_prefs.get_flag ("spellcheck-enabled", DEFAULT_SPELLCHECK_FLAG));
-
+ _body_changed_id = g_signal_connect (_body_buf, "changed", G_CALLBACK(body_changed_cb), this);
GtkWidget * v = gtk_vbox_new (false, PAD);
gtk_container_set_border_width (GTK_CONTAINER(v), PAD);
@@ -2637,6 +2659,33 @@ PostUI :: update_parts_tab()
}
}
+gboolean
+PostUI::draft_save_cb(gpointer ptr)
+{
+
+ std::cerr<<"auto-saving draft\n";
+
+ PostUI *data = static_cast<PostUI*>(ptr);
+// data->in_newsrc_cb = true;
+ GMimeMessage * msg = data->new_message_from_ui (DRAFTING);
+ std::string& draft_filename (get_draft_filename ());
+ const char* filename = draft_filename.c_str();
+
+ errno = 0;
+ std::ofstream o (filename);
+ char * pch = g_mime_object_to_string ((GMimeObject *) msg);
+ o << pch;
+ o.close ();
+
+ g_free (pch);
+ g_object_unref (msg);
+// data->in_newsrc_cb = false;
+
+ data->_unchanged_body = data->get_body ();
+ g_source_remove( data->_draft_autosave_id );
+ return FALSE;
+}
+
PostUI :: PostUI (GtkWindow * parent,
Data & data,
Queue & queue,
@@ -2669,11 +2718,19 @@ PostUI :: PostUI (GtkWindow * parent,
_file_queue_empty(true),
_upload_ptr(0),
_total_parts(0),
- _running_uploads(0)
+ _running_uploads(0),
+ _draft_autosave_id(0),
+ _draft_autosave_timeout(0),
+ _body_changed_id(0),
+ _body_changed_idle_tag(0)
{
_upload_queue.add_listener (this);
+ /* init timer for autosave */
+ set_draft_autosave_timeout( prefs.get_int("draft-autosave-timeout-min", 10 ));
+ _draft_autosave_id = g_timeout_add_seconds( _draft_autosave_timeout * 60, draft_save_cb, this);
+
g_assert (profiles.has_profiles());
g_return_if_fail (message != 0);
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index 3bee1ae..5da4abe 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -190,8 +190,14 @@ namespace pan
static void body_widget_resized_cb (GtkWidget*, GtkAllocation*, gpointer);
private:
- unsigned long _group_entry_changed_id;
+
+ unsigned long _body_changed_id;
+ unsigned int _body_changed_idle_tag;
+ static gboolean body_changed_idle (gpointer);
+ static void body_changed_cb (GtkEditable*, gpointer);
+
unsigned int _group_entry_changed_idle_tag;
+ unsigned long _group_entry_changed_id;
static gboolean group_entry_changed_idle (gpointer);
static void group_entry_changed_cb (GtkEditable*, gpointer);
@@ -226,6 +232,15 @@ namespace pan
std::string get_domain(const StringView& mid);
bool update_queue_mids (bool enable=true);
bool update_queue_save_file ();
+
+ private:
+ guint _draft_autosave_id;
+ guint _draft_autosave_timeout;
+ static gboolean draft_save_cb(gpointer ptr);
+
+ public:
+ void set_draft_autosave_timeout(guint seconds)
+ { _draft_autosave_timeout = seconds;}
};
}
diff --git a/pan/gui/prefs-ui.cc b/pan/gui/prefs-ui.cc
index 7af0252..b0b7b89 100644
--- a/pan/gui/prefs-ui.cc
+++ b/pan/gui/prefs-ui.cc
@@ -464,8 +464,8 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
HIG :: workarea_add_wide_control (t, &row, w);
w = new_check_button (_("E_xpand all threads when entering group"), "expand-threads-when-entering-group", false, prefs);
HIG :: workarea_add_wide_control (t, &row, w);
- HIG::workarea_add_section_divider (t, &row);
- HIG :: workarea_add_section_title (t, &row, _("Articles"));
+ HIG::workarea_add_section_divider (t, &row);
+ HIG :: workarea_add_section_title (t, &row, _("Articles"));
HIG :: workarea_add_section_spacer (t, row, 4);
w = new_check_button (_("Space selects next article rather than next unread"), "space-selects-next-article", true, prefs);
HIG :: workarea_add_wide_control (t, &row, w);
@@ -473,11 +473,19 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
HIG :: workarea_add_wide_control (t, &row, w);
w = new_check_button (_("Clear article cache on shutdown"), "clear-article-cache-on-shutdown", false, prefs);
HIG :: workarea_add_wide_control (t, &row, w);
+ HIG::workarea_add_section_divider (t, &row);
w = new_spin_button ("newsrc-autosave-timeout-min", 0, 60, prefs);
l = gtk_label_new(_("Minutes to autosave newsrc files."));
gtk_misc_set_alignment (GTK_MISC(l), 0.0, 0.5);
gtk_label_set_mnemonic_widget(GTK_LABEL(l), w);
HIG::workarea_add_row (t, &row, w, l);
+ HIG::workarea_add_section_divider (t, &row);
+ HIG :: workarea_add_section_title (t, &row, _("Article Drafts"));
+ w = new_spin_button ("draft-autosave-timeout-min", 0, 60, prefs);
+ l = gtk_label_new(_("Minutes to autosave the current Article Draft."));
+ gtk_misc_set_alignment (GTK_MISC(l), 0.0, 0.5);
+ gtk_label_set_mnemonic_widget(GTK_LABEL(l), w);
+ HIG::workarea_add_row (t, &row, w, l);
HIG :: workarea_finish (t, &row);
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), t, gtk_label_new_with_mnemonic(_("_Behavior")));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]