[evolution-rss] try to support even older evolutions and webkit Basic support for evolution feeds are fairly readabl
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-rss] try to support even older evolutions and webkit Basic support for evolution feeds are fairly readabl
- Date: Mon, 7 Jun 2010 20:46:03 +0000 (UTC)
commit 46a27a3ec68fc64df65f8fbfac5b039df0653011
Author: Lucian Langa <lucilanga gnome org>
Date: Mon Jun 7 23:06:32 2010 +0300
try to support even older evolutions and webkit
Basic support for evolution feeds are fairly readable, however older webkit
basically suports nothing.
src/notification.c | 40 ++++++++++-------
src/rss-cache.c | 31 +++++++++++++
src/rss-config-factory.c | 105 +++++++++++++++++++++++++++++++++++++++++++++-
src/rss-config.c | 1 +
src/rss.c | 30 +++++++++++++
5 files changed, 189 insertions(+), 18 deletions(-)
---
diff --git a/src/notification.c b/src/notification.c
index 9f50162..9a2a543 100644
--- a/src/notification.c
+++ b/src/notification.c
@@ -29,9 +29,16 @@
#include <e-util/e-error.h>
#endif
-#include "notification.h"
+#if EVOLUTION_VERSION <= 22203
+#include <misc/e-activity-handler.h>
+#include <e-util/e-icon-factory.h>
+#endif
+
+extern int rss_verbose_debug;
+
#include "rss.h"
#include "network-soup.h"
+#include "notification.h"
#if (EVOLUTION_VERSION >= 22900) //kb//
extern EShellView *rss_shell_view;
@@ -183,7 +190,7 @@ void
taskbar_pop_message(void)
{
#if EVOLUTION_VERSION < 22900 //kb//
- EActivityHandler *activity_handler =
+ EActivityHandler *activity_handler =
mail_component_peek_activity_handler (mail_component_peek ());
e_activity_handler_unset_message(activity_handler);
#else
@@ -198,9 +205,9 @@ void
taskbar_op_abort(gpointer key)
{
#if EVOLUTION_VERSION < 22900 //kb//
- EActivityHandler *activity_handler =
+ EActivityHandler *activity_handler =
mail_component_peek_activity_handler (mail_component_peek ());
- guint activity_key =
+ guint activity_key =
GPOINTER_TO_INT(g_hash_table_lookup(rf->activity, key));
if (activity_key)
e_activity_handler_operation_finished(
@@ -262,11 +269,11 @@ taskbar_op_new(gchar *message)
key);
return activity;
#else
- activity_handler =
+ activity_handler =
mail_component_peek_activity_handler (mail_component_peek ());
mcp = g_strdup_printf("%p", mail_component_peek());
#if (EVOLUTION_VERSION >= 22306)
- activity_id =
+ activity_id =
e_activity_handler_cancelable_operation_started(
activity_handler,
"evolution-mail",
@@ -275,12 +282,12 @@ taskbar_op_new(gchar *message)
(void (*) (gpointer))taskbar_op_abort,
key);
#else
- progress_icon =
+ progress_icon =
e_icon_factory_get_icon (
"mail-unread",
E_ICON_SIZE_MENU);
#if (EVOLUTION_VERSION >= 22200)
- activity_id =
+ activity_id =
e_activity_handler_cancelable_operation_started(
activity_handler,
"evolution-mail",
@@ -343,9 +350,10 @@ taskbar_op_finish(gchar *key)
EActivity *aid = NULL;
EActivity *activity_key;
#else
- guint aid = NULL;
+ guint aid = 0;
guint activity_key;
- EActivityHandler *activity_handler;
+ EActivityHandler *activity_handler = mail_component_peek_activity_handler (
+ mail_component_peek ());
#endif
if (key) {
#if (EVOLUTION_VERSION >= 22900) //kb//
@@ -358,10 +366,10 @@ taskbar_op_finish(gchar *key)
#if (EVOLUTION_VERSION >= 22900) //kb//
activity_key = g_hash_table_lookup(rf->activity, "main");
#else
- activity_key = g_hash_table_lookup(rf->activity, "main");
+ activity_key = GPOINTER_TO_INT(g_hash_table_lookup(rf->activity, "main"));
#endif
if (activity_key) {
- dp("activity_key:%p\n", activity_key);
+ d("activity_key:%p\n", (gpointer)activity_key);
#if (EVOLUTION_VERSION >= 22900) //kb//
e_activity_complete (activity_key);
#else
@@ -373,8 +381,6 @@ taskbar_op_finish(gchar *key)
#if (EVOLUTION_VERSION >= 22900) //kb//
e_activity_complete (aid);
#else
- activity_handler = mail_component_peek_activity_handler (
- mail_component_peek ());
e_activity_handler_operation_finished(activity_handler, aid);
#endif
g_hash_table_remove(rf->activity, key);
@@ -405,12 +411,12 @@ taskbar_op_message(gchar *msg, gchar *unikey)
#if (EVOLUTION_VERSION >= 22900) //kb//
if (!msg)
- activity_id =
+ activity_id =
(EActivity *)taskbar_op_new(
- tmsg,
+ tmsg,
(gchar *)"main");
else
- activity_id =
+ activity_id =
(EActivity *)taskbar_op_new(tmsg, msg);
#else
#if (EVOLUTION_VERSION >= 22200)
diff --git a/src/rss-cache.c b/src/rss-cache.c
index 90692bf..28a0796 100644
--- a/src/rss-cache.c
+++ b/src/rss-cache.c
@@ -99,10 +99,41 @@ rss_cache_get(gchar *url)
return camel_data_cache_get(cache, HTTP_CACHE_PATH, url, NULL);
}
+#if DATASERVER_VERSION <= 2025004
+#define CAMEL_DATA_CACHE_BITS (6)
+#define CAMEL_DATA_CACHE_MASK ((1<<CAMEL_DATA_CACHE_BITS)-1)
+
+static char *
+data_cache_path(
+ CamelDataCache *cdc, int create, const char *path, const char *key)
+{
+ char *dir, *real;
+ char *tmp = NULL;
+ guint32 hash;
+
+ hash = g_str_hash(key);
+ hash = (hash>>5)&CAMEL_DATA_CACHE_MASK;
+ dir = alloca(strlen(cdc->path) + strlen(path) + 8);
+ sprintf(dir, "%s/%s/%02x", cdc->path, path, hash);
+ tmp = camel_file_util_safe_filename(key);
+ if (!tmp)
+ return NULL;
+ real = g_strdup_printf("%s/%s", dir, tmp);
+ g_free(tmp);
+
+ return real;
+}
+#endif
+
+
gchar*
rss_cache_get_filename(gchar *url)
{
+#if DATASERVER_VERSION <= 2025004
+ return data_cache_path(cache, FALSE, HTTP_CACHE_PATH, url);
+#else
return camel_data_cache_get_filename(cache, HTTP_CACHE_PATH, url, NULL);
+#endif
}
CamelStream*
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index 18b8a7a..f648426 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -708,7 +708,13 @@ build_dialog_add(gchar *url, gchar *feed_text)
ok = GTK_WIDGET (
gtk_builder_get_object(gui, "ok_button"));
+#if GTK_VERSION < 2018000
+ GTK_WIDGET_SET_FLAGS (
+ ok,
+ GTK_CAN_DEFAULT);
+#else
gtk_widget_set_can_default (ok, TRUE);
+#endif
d("/*Gtk-CRITICAL **: gtk_box_pack: assertion `child->parent == NULL' failed*/");
gtk_dialog_add_action_widget (
(GtkDialog *)dialog1,
@@ -721,7 +727,13 @@ build_dialog_add(gchar *url, gchar *feed_text)
GTK_DIALOG (dialog1),
cancel,
GTK_RESPONSE_CANCEL);
+#if GTK_VERSION < 2018000
+ GTK_WIDGET_SET_FLAGS (
+ cancel,
+ GTK_CAN_DEFAULT);
+#else
gtk_widget_set_can_default (cancel, TRUE);
+#endif
gtk_widget_add_accelerator (
ok,
@@ -902,12 +914,21 @@ feeds_dialog_add(GtkDialog *d, gpointer data)
NULL);
#endif
progress = gtk_progress_bar_new();
+#if GTK_VERSION >= 2014000
gtk_box_pack_start(
GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(msg_feeds))),
progress,
FALSE,
FALSE,
0);
+#else
+ gtk_box_pack_start(
+ GTK_BOX(GTK_DIALOG(msg_feeds)->vbox),
+ progress,
+ FALSE,
+ FALSE,
+ 0);
+#endif
gtk_progress_bar_set_fraction(
(GtkProgressBar *)progress,
0);
@@ -1295,7 +1316,11 @@ remove_feed_dialog(gchar *msg)
#endif
gtk_window_set_keep_above(GTK_WINDOW(dialog1), TRUE);
+#if GTK_VERSION >= 2014000
dialog_vbox1 = gtk_dialog_get_content_area(GTK_DIALOG (dialog1));
+#else
+ dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+#endif
gtk_widget_show (dialog_vbox1);
vbox1 = gtk_vbox_new (FALSE, 10);
@@ -1330,7 +1355,11 @@ remove_feed_dialog(gchar *msg)
FALSE,
0);
+#if GTK_VERSION >= 2014000
dialog_action_area1 = gtk_dialog_get_action_area(GTK_DIALOG (dialog1));
+#else
+ dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
+#endif
gtk_widget_show (dialog_action_area1);
gtk_button_box_set_layout (
GTK_BUTTON_BOX (dialog_action_area1),
@@ -1399,12 +1428,21 @@ process_dialog_edit(add_feed *feed, gchar *url, gchar *feed_name)
NULL);
#endif
progress = gtk_progress_bar_new();
+#if GTK_VERSION >= 2014000
gtk_box_pack_start(
GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(msg_feeds))),
progress,
FALSE,
FALSE,
0);
+#else
+ gtk_box_pack_start(
+ GTK_BOX(GTK_DIALOG(msg_feeds)->vbox),
+ progress,
+ FALSE,
+ FALSE,
+ 0);
+#endif
gtk_progress_bar_set_fraction((GtkProgressBar *)progress, 0);
/* xgettext:no-c-format */
gtk_progress_bar_set_text((GtkProgressBar *)progress, _("0% done"));
@@ -1693,6 +1731,7 @@ error: rss_error(NULL,
NULL);
import_label = gtk_label_new(_("Please wait"));
import_progress = gtk_progress_bar_new();
+#if GTK_VERSION >= 2014000
gtk_box_pack_start(
GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(import_dialog))),
import_label,
@@ -1705,6 +1744,20 @@ error: rss_error(NULL,
FALSE,
FALSE,
0);
+#else
+ gtk_box_pack_start(
+ GTK_BOX(GTK_DIALOG(import_dialog)->vbox),
+ import_label,
+ FALSE,
+ FALSE,
+ 0);
+ gtk_box_pack_start(
+ GTK_BOX(GTK_DIALOG(import_dialog)->vbox),
+ import_progress,
+ FALSE,
+ FALSE,
+ 0);
+#endif
gtk_widget_show_all(import_dialog);
g_free(msg);
if ((src = src->children)) {
@@ -2119,11 +2172,20 @@ create_import_dialog (void)
GTK_WINDOW (import_file_select),
GDK_WINDOW_TYPE_HINT_DIALOG);
+#if GTK_VERSION >= 2014000
dialog_vbox5 = gtk_dialog_get_content_area(GTK_DIALOG (import_file_select));
+#else
+ dialog_vbox5 = GTK_DIALOG (import_file_select)->vbox;
+#endif
gtk_widget_show (dialog_vbox5);
+#if GTK_VERSION >= 2014000
dialog_action_area5 = gtk_dialog_get_action_area(
GTK_DIALOG (import_file_select));
+#else
+ dialog_action_area5 = GTK_DIALOG (import_file_select)->action_area;
+#endif
+
gtk_widget_show (dialog_action_area5);
gtk_button_box_set_layout (
GTK_BUTTON_BOX (dialog_action_area5),
@@ -2135,9 +2197,15 @@ create_import_dialog (void)
GTK_DIALOG (import_file_select),
button1,
GTK_RESPONSE_CANCEL);
+#if GTK_VERSION < 2018000
+ GTK_WIDGET_SET_FLAGS (
+ button1,
+ GTK_CAN_DEFAULT);
+#else
gtk_widget_set_can_default (
button1,
TRUE);
+#endif
button2 = gtk_button_new_from_stock ("gtk-open");
gtk_widget_show (button2);
@@ -2145,7 +2213,13 @@ create_import_dialog (void)
GTK_DIALOG (import_file_select),
button2,
GTK_RESPONSE_OK);
+#if GTK_VERSION < 2018000
+ GTK_WIDGET_SET_FLAGS (
+ button2,
+ GTK_CAN_DEFAULT);
+#else
gtk_widget_set_can_default(button2, TRUE);
+#endif
gtk_widget_grab_default (button2);
return import_file_select;
@@ -2188,11 +2262,19 @@ create_export_dialog (void)
GTK_WINDOW (export_file_select),
GDK_WINDOW_TYPE_HINT_DIALOG);
+#if GTK_VERSION >= 2014000
vbox26 = gtk_dialog_get_content_area(GTK_DIALOG (export_file_select));
+#else
+ vbox26 = GTK_DIALOG (export_file_select)->vbox;
+#endif
gtk_widget_show (vbox26);
+#if GTK_VERSION >= 2014000
hbuttonbox1 = gtk_dialog_get_action_area(
GTK_DIALOG (export_file_select));
+#else
+ hbuttonbox1 = GTK_DIALOG (export_file_select)->action_area;
+#endif
gtk_widget_show (hbuttonbox1);
gtk_button_box_set_layout (
GTK_BUTTON_BOX (hbuttonbox1),
@@ -2204,14 +2286,25 @@ create_export_dialog (void)
GTK_DIALOG (export_file_select),
button3,
GTK_RESPONSE_CANCEL);
+#if GTK_VERSION < 2018000
+ GTK_WIDGET_SET_FLAGS (
+ button3,
+ GTK_CAN_DEFAULT);
+#else
gtk_widget_set_can_default(button3, TRUE);
-
+#endif
button4 = gtk_button_new_from_stock ("gtk-save");
gtk_widget_show (button4);
gtk_dialog_add_action_widget (
GTK_DIALOG (export_file_select),
button4, GTK_RESPONSE_OK);
+#if GTK_VERSION < 2018000
+ GTK_WIDGET_SET_FLAGS (
+ button4,
+ GTK_CAN_DEFAULT);
+#else
gtk_widget_set_can_default(button4, TRUE);
+#endif
gtk_widget_grab_default (button4);
return export_file_select;
@@ -2496,7 +2589,11 @@ export_opml(gchar *file)
// g_signal_connect(import_dialog, "response", G_CALLBACK(import_dialog_response), NULL);
import_label = gtk_label_new(_("Please wait"));
import_progress = gtk_progress_bar_new();
+#if GTK_VERSION >= 2014000
content_area = gtk_dialog_get_content_area(GTK_DIALOG(import_dialog));
+#else
+ content_area = GTK_DIALOG(import_dialog)->vbox;
+#endif
gtk_box_pack_start(
GTK_BOX(content_area),
import_label,
@@ -2953,10 +3050,16 @@ e_plugin_lib_get_configure_widget (EPlugin *epl)
"rss-html-rendering.ui",
NULL);
ui->xml = gtk_builder_new ();
+#if GTK_VERSION >= 2014000
if (!gtk_builder_add_objects_from_file (ui->xml, uifile, toplevel, &error)) {
g_warning ("Couldn't load builder file: %s", error->message);
g_error_free (error);
}
+#else
+ g_warning("gtk too old! cannot create ui file. need >= 2.14\n");
+ // and not very interesed to back port this
+ return NULL;
+#endif
g_free (uifile);
ui->combobox = GTK_WIDGET (gtk_builder_get_object(ui->xml, "hbox1"));
diff --git a/src/rss-config.c b/src/rss-config.c
index 1080f63..9ab1225 100644
--- a/src/rss-config.c
+++ b/src/rss-config.c
@@ -17,6 +17,7 @@
*/
#include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdio.h>
diff --git a/src/rss.c b/src/rss.c
index 4bfd195..6122108 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -1008,7 +1008,11 @@ reload_cb (GtkWidget *button, gpointer data)
break;
case 1:
#ifdef HAVE_WEBKIT
+#if (WEBKIT_VERSION >= 1000003)
webkit_web_view_reload_bypass_cache(WEBKIT_WEB_VIEW(rf->mozembed));
+#else
+ webkit_web_view_reload(WEBKIT_WEB_VIEW(rf->mozembed));
+#endif
#endif
break;
}
@@ -1026,7 +1030,11 @@ rss_browser_set_hsize (GtkAdjustment *adj, gpointer data);
void
rss_browser_set_hsize (GtkAdjustment *adj, gpointer data)
{
+#if GTK_VERSION >= 2014000
resize_pane_hsize = gtk_adjustment_get_page_size(adj);
+#else
+ resize_pane_hsize = (adj->page_size);
+#endif
}
void rss_browser_update_content (
@@ -1327,9 +1335,12 @@ webkit_set_history(gchar *base)
webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW(rf->mozembed));
WebKitWebHistoryItem *item =
webkit_web_history_item_new_with_data(base, "Untitled");
+#if (WEBKIT_VERSION >= 1001001)
webkit_web_back_forward_list_add_item(back_forward_list, item);
+#endif
}
+#if (WEBKIT_VERSION >= 1001007)
static void
webkit_history_status (WebKitWebView *view,
GParamSpec *spec,
@@ -1352,6 +1363,7 @@ webkit_history_status (WebKitWebView *view,
break;
}
}
+#endif
gboolean
webkit_over_link(WebKitWebView *web_view,
@@ -1658,12 +1670,14 @@ org_gnome_rss_browser (EMFormatHTML *efh, void *eb, EMFormatHTMLPObject *pobject
po->stopbut);
#endif
}
+#if (WEBKIT_VERSION >= 1001007)
g_signal_connect (
rf->mozembed,
"notify::load-status",
G_CALLBACK(webkit_history_status),
po);
#endif
+#endif
#ifdef HAVE_GECKO
if (engine == 2) {
@@ -1752,10 +1766,18 @@ org_gnome_rss_browser (EMFormatHTML *efh, void *eb, EMFormatHTMLPObject *pobject
adj = gtk_scrolled_window_get_vadjustment(
(GtkScrolledWindow *)gtk_widget_get_parent(po->html));
+#if GTK_VERSION >= 2014000
height = (int)gtk_adjustment_get_page_size(adj);
+#else
+ height = (int)(adj->page_size);
+#endif
adj = gtk_scrolled_window_get_hadjustment(
(GtkScrolledWindow *)gtk_widget_get_parent(po->html));
+#if GTK_VERSION >= 2014000
width = (int)gtk_adjustment_get_page_size(adj);
+#else
+ width = (int)(adj->page_size);
+#endif
gtk_widget_set_size_request(rf->mozembed, width-32, height);
po->sh_handler = g_signal_connect(adj,
"changed",
@@ -2261,7 +2283,11 @@ void org_gnome_cooly_format_rss(void *ep, EMFormatHookTarget *t) //camelmimepart
} else
tmp = g_strdup((gchar *)(buffer->data));
+#if GTK_VERSION >= 2018000
gtk_widget_get_allocation(obj, &alloc);
+#else
+ alloc.width = obj->allocation.width;;
+#endif
width = alloc.width - 56;
wids = g_strdup_printf("%d", width);
src = (xmlDoc *)parse_html_sux(
@@ -4285,7 +4311,11 @@ custom_fetch_feed(gpointer key, gpointer value, gpointer user_data)
void evo_window_popup(GtkWidget *win)
{
gint x, y, sx, sy, new_x, new_y;
+#if GTK_VERSION >= 2014000
GdkWindow *window = gtk_widget_get_window(win);
+#else
+ GdkWindow *window = win->window;
+#endif
g_return_if_fail(win != NULL);
g_return_if_fail(window != NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]