Commit e162b401 authored by Lucian Langa's avatar Lucian Langa
Browse files

fix saving folder properties; correctly update status bar

parent 6a7a9ee0
......@@ -5,13 +5,16 @@ Lucian Langa <cooly@gnome.eu.org>
A few people I would like to thank:
Srinivasa Ragavan <sragavan@novell.com>
Sankar P <psankar@novell.com>
Andre Klapper <a9016009@gmx.de>
Michael Monreal <michael.monreal@gmx.net>
Sebastian Keller <sebastian-keller@gmx.de>
Daniel Nylander <po@danielnylander.se>
Black Penguin <gnomecn@gmail.com>
Ryan Pavlik <abiryan@ryand.net>
Daniel Nylander <po@danielnylander.se>
David Richards <flbeachlf@yahoo.com>
Fridrich Strba
Josselin Mouette
Michael Monreal <michael.monreal@gmx.net>
Pedro Fragoso
Ryan Pavlik <abiryan@ryand.net>
Srinivasa Ragavan <sragavan@novell.com>
Sankar P <psankar@novell.com>
Sebastian Keller <sebastian-keller@gmx.de>
Tobias Strauß
2009-05-18 Lucian Langa <lucilanga@gnome.org>
* src/rss-config-factory.c (feeds_dialog_disable),
(feeds_dialog_delete), (process_dialog_edit), (feeds_dialog_edit),
(rss_folder_factory_commit), (rss_folder_factory): fix save of folder
properties
* src/rss.c (compare_enabled), (rss_find_enabled), (statuscb),
(browsercb), (network_timeout), (generic_finish_feed): correctly
update progress bar
2009-05-16 Lucian Langa <lucilanga@gnome.org>
* src/parser.c (layer_find_all): fix for Debian Bug #528827
......
......@@ -59,3 +59,5 @@
* store feed in an alternate file to serve images from
* migrate fetch_blocking -> fetch_unblocking
* grey stop button on complete load
* display links from content in status bar
* grey out disabled folders (feeds)
......@@ -860,8 +860,7 @@ feeds_dialog_disable(GtkDialog *d, gpointer data)
gchar *name;
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rf->treeview));
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_tree_model_get (model, &iter, 3, &name, -1);
gpointer key = lookup_key(name);
g_free(name);
......@@ -923,8 +922,7 @@ feeds_dialog_delete(GtkDialog *d, gpointer data)
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
if (gtk_tree_selection_get_selected(selection, &model, &iter)
&& !rf->import)
{
&& !rf->import) {
rf->import = 1;
gtk_tree_model_get (model, &iter, 3, &name, -1);
GtkWidget *rfd = remove_feed_dialog(name);
......@@ -935,76 +933,56 @@ feeds_dialog_delete(GtkDialog *d, gpointer data)
}
}
static void
feeds_dialog_edit(GtkDialog *d, gpointer data)
void
process_dialog_edit(add_feed *feed, gchar *url, gchar *feed_name)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
gchar *name, *feed_name;
gchar *text;
gchar *url;
gchar *text = NULL;
gpointer key = lookup_key(feed_name);
/* This will only work in single or browse selection mode! */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_tree_model_get (model, &iter, 3, &feed_name, -1);
name = g_hash_table_lookup(rf->hr, lookup_key(feed_name));
if (name) {
add_feed *feed = create_dialog_add(name, feed_name);
if (feed->dialog)
gtk_widget_destroy(feed->dialog);
GtkWidget *msg_feeds = e_error_new(NULL, "org-gnome-evolution-rss:rssmsg", "", NULL);
GtkWidget *progress = gtk_progress_bar_new();
gtk_box_pack_start(GTK_BOX(((GtkDialog *)msg_feeds)->vbox), progress, FALSE, FALSE, 0);
gtk_progress_bar_set_fraction((GtkProgressBar *)progress, 0);
/* xgettext:no-c-format */
gtk_progress_bar_set_text((GtkProgressBar *)progress, _("0% done"));
feed->progress=progress;
gtk_window_set_keep_above(GTK_WINDOW(msg_feeds), TRUE);
g_signal_connect(msg_feeds, "response", G_CALLBACK(msg_feeds_response), NULL);
gtk_widget_show_all(msg_feeds);
while (gtk_events_pending ())
gtk_main_iteration ();
if (!feed->add)
goto out;
text = feed->feed_url;
feed->feed_url = sanitize_url(feed->feed_url);
g_free(text);
url = name;
if (feed->feed_url) {
gtk_tree_model_get (model, &iter, 3, &name, -1);
gpointer key = lookup_key(name);
if (strcmp(url, feed->feed_url)) {
//prevent adding of an existing feed (url)
//which might screw things
if (g_hash_table_find(rf->hr,
GtkWidget *msg_feeds = e_error_new(NULL, "org-gnome-evolution-rss:rssmsg", "", NULL);
GtkWidget *progress = gtk_progress_bar_new();
gtk_box_pack_start(GTK_BOX(((GtkDialog *)msg_feeds)->vbox), progress, FALSE, FALSE, 0);
gtk_progress_bar_set_fraction((GtkProgressBar *)progress, 0);
/* xgettext:no-c-format */
gtk_progress_bar_set_text((GtkProgressBar *)progress, _("0% done"));
feed->progress=progress;
gtk_window_set_keep_above(GTK_WINDOW(msg_feeds), TRUE);
g_signal_connect(msg_feeds, "response", G_CALLBACK(msg_feeds_response), NULL);
gtk_widget_show_all(msg_feeds);
while (gtk_events_pending ())
gtk_main_iteration ();
if (!feed->add)
goto out;
text = feed->feed_url;
feed->feed_url = sanitize_url(feed->feed_url);
g_free(text);
if (feed->feed_url) {
if (strcmp(url, feed->feed_url)) {
//prevent adding of an existing feed (url)
//which might screw things
if (g_hash_table_find(rf->hr,
check_if_match,
feed->feed_url))
{
rss_error(NULL, NULL, _("Error adding feed."),
feed->feed_url)) {
rss_error(NULL, NULL, _("Error adding feed."),
_("Feed already exists!"));
goto out;
}
hrfeed *saved_feed = save_feed_hash(name);
remove_feed_hash(name);
gpointer md5 = gen_md5(feed->feed_url);
if (!setup_feed(feed)) {
//editing might loose a corectly setup feed
//so re-add previous deleted feed
restore_feed_hash(key, saved_feed);
} else
destroy_feed_hash_content(saved_feed);
gtk_list_store_clear(GTK_LIST_STORE(model));
g_hash_table_foreach(rf->hrname, construct_list, model);
save_gconf_feed();
g_free(md5);
} else {
key = gen_md5(url);
g_hash_table_replace(rf->hrh,
}
hrfeed *saved_feed = save_feed_hash(feed_name);
remove_feed_hash(feed_name);
gpointer md5 = gen_md5(feed->feed_url);
if (!setup_feed(feed)) {
//editing might loose a corectly setup feed
//so re-add previous deleted feed
restore_feed_hash(key, saved_feed);
} else
destroy_feed_hash_content(saved_feed);
g_free(md5);
} else {
key = gen_md5(url);
g_hash_table_replace(rf->hrh,
g_strdup(key),
GINT_TO_POINTER(feed->fetch_html));
if (feed->update == 2) {
if (feed->update == 2) {
g_hash_table_replace(rf->hrttl,
g_strdup(key),
GINT_TO_POINTER(feed->ttl));
......@@ -1012,13 +990,13 @@ feeds_dialog_edit(GtkDialog *d, gpointer data)
g_strdup(key),
GINT_TO_POINTER(feed->ttl_multiply));
custom_feed_timeout();
}
if (feed->update == 3)
g_hash_table_replace(rf->hre,
g_strdup(key),
0);
else
g_hash_table_replace(rf->hre,
}
if (feed->update == 3)
g_hash_table_replace(rf->hre,
g_strdup(key),
0);
else
g_hash_table_replace(rf->hre,
g_strdup(key),
GINT_TO_POINTER(feed->enabled));
g_hash_table_replace(rf->hrdel_feed,
......@@ -1037,15 +1015,41 @@ feeds_dialog_edit(GtkDialog *d, gpointer data)
g_strdup(key),
GINT_TO_POINTER(feed->del_unread));
g_free(key);
gtk_list_store_clear(GTK_LIST_STORE(model));
g_hash_table_foreach(rf->hrname, construct_list, model);
save_gconf_feed();
}
}
out: gtk_widget_destroy(msg_feeds);
g_free(feed);
}
}
save_gconf_feed();
}
out: gtk_widget_destroy(msg_feeds);
g_free(feed);
}
static void
feeds_dialog_edit(GtkDialog *d, gpointer data)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
gchar *name, *feed_name;
gchar *text;
gpointer key;
add_feed *feed = NULL;
/* This will only work in single or browse selection mode! */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_tree_model_get (model, &iter, 3, &feed_name, -1);
key = lookup_key(feed_name);
name = g_hash_table_lookup(rf->hr, key);
if (name) {
feed = create_dialog_add(name, feed_name);
if (feed->dialog)
gtk_widget_destroy(feed->dialog);
process_dialog_edit(feed, name, feed_name);
}
if (feed->feed_url) {
gtk_list_store_clear(GTK_LIST_STORE(model));
g_hash_table_foreach(rf->hrname, construct_list, model);
}
}
}
void
......@@ -1775,6 +1779,12 @@ e_plugin_lib_get_configure_widget (EPlugin *epl)
return hbox;
}
typedef struct _EConfigTargetRSS EConfigTargetRSS;
struct _EConfigTargetRSS
{
gchar *label;
} ER;
void rss_folder_factory_abort (EPlugin *epl, EConfigTarget *target)
{
g_print("abort");
......@@ -1783,6 +1793,74 @@ void rss_folder_factory_abort (EPlugin *epl, EConfigTarget *target)
void rss_folder_factory_commit (EPlugin *epl, EConfigTarget *target)
{
g_print("commit");
add_feed *feed = (add_feed *)g_object_get_data((GObject *)epl, "add-feed");
gchar *url = (gchar *)g_object_get_data((GObject *)epl, "url");
gchar *ofolder = (gchar *)g_object_get_data((GObject *)epl, "ofolder");
GtkWidget *entry1 = (GtkWidget *)glade_xml_get_widget (feed->gui, "url_entry");
GtkWidget *checkbutton1 = (GtkWidget *)glade_xml_get_widget (feed->gui, "html_check");
GtkWidget *checkbutton2 = (GtkWidget *)glade_xml_get_widget (feed->gui, "enabled_check");
GtkWidget *checkbutton3 = (GtkWidget *)glade_xml_get_widget (feed->gui, "validate_check");
GtkWidget *checkbutton4 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_unread");
GtkWidget *radiobutton1 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb1");
GtkWidget *radiobutton2 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb2");
GtkWidget *radiobutton3 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb3");
GtkWidget *radiobutton4 = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl_global");
GtkWidget *radiobutton5 = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl");
GtkWidget *radiobutton6 = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl_disabled");
GtkWidget *spinbutton1 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_sb1");
GtkWidget *spinbutton2 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_sb2");
GtkWidget *ttl_value = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl_value");
gboolean fhtml = feed->fetch_html;
feed->feed_url = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry1)));
fhtml = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (checkbutton1));
fhtml ^= 1;
feed->fetch_html = fhtml;
feed->enabled = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(checkbutton2));
feed->validate = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(checkbutton3));
guint i=0;
while (i<3) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton1)))
break;
i++;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton2)))
break;
i++;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton3)))
break;
}
feed->del_feed=i;
feed->del_unread = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(checkbutton4));
gtk_spin_button_update((GtkSpinButton *)spinbutton1);
feed->del_messages = gtk_spin_button_get_value((GtkSpinButton *)spinbutton1);
gtk_spin_button_update((GtkSpinButton *)spinbutton2);
feed->del_days = gtk_spin_button_get_value((GtkSpinButton *)spinbutton2);
i=1;
while (i<3) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton4)))
break;
i++;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton5)))
break;
i++;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton6)))
break;
}
feed->update=i;
feed->ttl = gtk_spin_button_get_value((GtkSpinButton *)ttl_value);
feed->add = 1;
// there's no reason to feetch feed if url isn't changed
if (url && !strncmp(url, feed->feed_url, strlen(url)))
feed->changed = 0;
else
feed->changed = 1;
process_dialog_edit(feed, url, ofolder);
}
GtkWidget *
......@@ -1801,7 +1879,6 @@ rss_folder_factory (EPlugin *epl, EConfigHookItemFactoryData *data)
ofolder = lookup_original_folder(folder);
gpointer key = lookup_key(ofolder);
g_print("key:%s\n", key);
if (!key) {
g_free(ofolder);
goto out;
......@@ -1817,9 +1894,13 @@ rss_folder_factory (EPlugin *epl, EConfigHookItemFactoryData *data)
gtk_container_remove (GTK_CONTAINER (feed->child->parent), feed->child);
gtk_notebook_remove_page((GtkNotebook *) data->parent, 0);
gtk_notebook_insert_page((GtkNotebook *) data->parent, (GtkWidget *) feed->child, NULL, 0);
g_object_set_data_full (G_OBJECT (epl), "add-feed", feed, NULL);
g_object_set_data_full (G_OBJECT (epl), "url", url, NULL);
g_object_set_data_full (G_OBJECT (epl), "ofolder", ofolder, NULL);
g_free(ofolder);
return feed->child;
}
g_free(ofolder);
out: return NULL;
}
......
......@@ -241,6 +241,21 @@ lookup_key(gpointer key)
return g_hash_table_lookup(rf->hrname, key);
}
void
compare_enabled(gpointer key, gpointer value, guint *data)
{
if (value == 1)
*data = *data+1;
}
guint
rss_find_enabled(void)
{
guint enabled=0;
g_hash_table_foreach (rf->hre, compare_enabled, &enabled);
return enabled;
}
/* hash table of ops->dialogue of active errors */
static GHashTable *active_errors = NULL;
......@@ -423,8 +438,9 @@ statuscb(NetStatusType status, gpointer statusdata, gpointer data)
g_free(what);
}
#else
if (rf->progress_bar && 0 <= fraction && 1 >= fraction)
if (rf->progress_bar && 0 <= fraction && 1 >= fraction) {
gtk_progress_bar_set_fraction((GtkProgressBar *)rf->progress_bar, fraction);
}
if (rf->sr_feed) {
gchar *furl = g_strdup_printf("<b>%s</b>: %s", _("Feed"), (char *)data);
gtk_label_set_markup (GTK_LABEL (rf->sr_feed), furl);
......@@ -433,9 +449,10 @@ statuscb(NetStatusType status, gpointer statusdata, gpointer data)
#endif
}
//update individual progress if previous percetage has not changed
if (rf->progress_bar && rf->feed_queue)
gtk_progress_bar_set_fraction((GtkProgressBar *)rf->progress_bar,
((gfloat)((100-(rf->feed_queue*100/g_hash_table_size(rf->hrname))))/100));
if (rf->progress_bar && rf->feed_queue) {
gtk_progress_bar_set_fraction((GtkProgressBar *)rf->progress_bar,
(double)(100-rf->feed_queue*100/rss_find_enabled())/100);
}
break;
case NET_STATUS_DONE:
//progress_window_set_cancel_cb(pw, NULL, NULL);
......@@ -488,7 +505,7 @@ browsercb(NetStatusType status, gpointer statusdata, gpointer data)
// g_print("chunk:%s\n", progress->chunk);
g_print("total:%d\n", progress->total);
g_print("curent:%d\n", progress->current);
g_print("--------------\n chunk: %d \n=============\n", GPOINTER_TO_INT(progress->chunksize));
g_print("-------------- chunk: %d =============\n", GPOINTER_TO_INT(progress->chunksize));
//browser_write(progress->chunk, progress->chunksize, data);
// browser_fill+=progress->chunksize;
break;
......@@ -741,11 +758,12 @@ network_timeout(void)
g_source_remove(nettime_id);
float timeout = gconf_client_get_float(rss_gconf, GCONF_KEY_NETWORK_TIMEOUT, NULL);
if (!timeout)
timeout = NETWORK_MIN_TIMEOUT;
nettime_id = g_timeout_add (
timeout*1000,
(guint)(timeout)*1000,
(GtkFunction) timeout_soup,
0);
}
......@@ -2435,8 +2453,8 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
if (rf->feed_queue) {
rf->feed_queue--;
gchar *tmsg = g_strdup_printf(_("Fetching Feeds (%d enabled)"), g_hash_table_size(rf->hrname));
taskbar_op_set_progress("main", tmsg, rf->feed_queue ? ((gfloat)((100-(rf->feed_queue*100/g_hash_table_size(rf->hrname))))/100): 1);
gchar *tmsg = g_strdup_printf(_("Fetching Feeds (%d enabled)"), rss_find_enabled());
taskbar_op_set_progress("main", tmsg, rf->feed_queue ? 1-(gdouble)((rf->feed_queue*100/rss_find_enabled()))/100: 1);
g_free(tmsg);
}
......@@ -2456,6 +2474,7 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
gtk_label_set_markup (GTK_LABEL (rf->label), _("Complete."));
if (rf->info->cancel_button)
gtk_widget_set_sensitive(rf->info->cancel_button, FALSE);
gtk_progress_bar_set_fraction((GtkProgressBar *)rf->progress_bar, 1);
g_hash_table_steal(rf->info->data->active, rf->info->uri);
rf->info->data->infos = g_list_remove(rf->info->data->infos, rf->info);
......@@ -4254,7 +4273,7 @@ finish_create_image (SoupMessage *msg, gchar *user_data)
finish_create_image (SoupSession *soup_sess, SoupMessage *msg, gchar *user_data)
#endif
{
g_print("finish_image(): status:%d, user_data:%s\n", msg->status_code, user_data);
d(g_print("finish_image(): status:%d, user_data:%s\n", msg->status_code, user_data));
if (404 != msg->status_code) {
CamelStream *feed_fs = camel_stream_fs_new_with_name(user_data,
O_RDWR|O_CREAT, 0666);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment