aboutsummaryrefslogtreecommitdiffstats
path: root/executive-summary
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-02-15 02:37:40 +0800
committerIain Holmes <iain@src.gnome.org>2001-02-15 02:37:40 +0800
commit53659b16caf2b2172c46b261463b589ee12d19b0 (patch)
tree66f7d71f43b0c3a6c0418507bdd6d591a6f95588 /executive-summary
parent59cb3688437bd26c4e2d2e3ea674b6a06d0da4e7 (diff)
downloadgsoc2013-evolution-53659b16caf2b2172c46b261463b589ee12d19b0.tar
gsoc2013-evolution-53659b16caf2b2172c46b261463b589ee12d19b0.tar.gz
gsoc2013-evolution-53659b16caf2b2172c46b261463b589ee12d19b0.tar.bz2
gsoc2013-evolution-53659b16caf2b2172c46b261463b589ee12d19b0.tar.lz
gsoc2013-evolution-53659b16caf2b2172c46b261463b589ee12d19b0.tar.xz
gsoc2013-evolution-53659b16caf2b2172c46b261463b589ee12d19b0.tar.zst
gsoc2013-evolution-53659b16caf2b2172c46b261463b589ee12d19b0.zip
Fix crashes, remove gnome.h includes, add a timer check for the RDF summary, add a new method to the HTMLView so it can handle funny URIs.
svn path=/trunk/; revision=8224
Diffstat (limited to 'executive-summary')
-rw-r--r--executive-summary/ChangeLog26
-rw-r--r--executive-summary/component/component-factory.c6
-rw-r--r--executive-summary/component/e-summary-callbacks.c9
-rw-r--r--executive-summary/component/e-summary-factory.c1
-rw-r--r--executive-summary/component/e-summary-prefs.c4
-rw-r--r--executive-summary/component/e-summary-url.c50
-rw-r--r--executive-summary/component/e-summary-util.c6
-rw-r--r--executive-summary/component/e-summary.c33
-rw-r--r--executive-summary/component/e-summary.h2
-rw-r--r--executive-summary/component/main.c7
-rw-r--r--executive-summary/evolution-services/executive-summary-component-factory-client.h2
-rw-r--r--executive-summary/evolution-services/executive-summary-html-view.c31
-rw-r--r--executive-summary/evolution-services/executive-summary-html-view.h3
-rw-r--r--executive-summary/idl/HtmlView.idl2
-rw-r--r--executive-summary/test-service/rdf-summary.c152
15 files changed, 284 insertions, 50 deletions
diff --git a/executive-summary/ChangeLog b/executive-summary/ChangeLog
index 65142aff28..6e0f51c270 100644
--- a/executive-summary/ChangeLog
+++ b/executive-summary/ChangeLog
@@ -1,3 +1,29 @@
+2001-02-14 Iain Holmes <iain@ximian.com>
+
+ * evolution-services/executive-summary-html-view.c
+ (executive_summary_html_view_destroy): Don't unref the event source.
+ (impl_GNOME_Evolution_Summary_HTMLView_handleURI): Emit the signal.
+ (corba_class_init): Hook up the handleURI method.
+ (executive_summary_html_view_class_init): Create the signal.
+
+ * idl/HTMLView.idl: Add the handleURI method.
+
+2001-02-13 Iain Holmes <iain@ximian.com>
+
+ * test-service/rdf-summary.c (property_control): Add an update now button.
+
+2001-02-12 Iain Holmes <iain@ximian.com>
+
+ * test-service/rdf-summary.c (property_control): Add a "Update" spinner.
+ (property_action): Only download a new RDF if the URL changed. Use a cached
+ version otherwise.
+
+2001-02-08 Iain Holmes <iain@ximian.com>
+
+ * component/e-summary-url.c (e_summary_url_click): Close and remove the
+ window on an idle, so that the whole desktop isn't locked by a
+ GNOME-VFS bug.
+
2001-02-13 Kjartan Maraas <kmaraas@gnome.org>
* Makefile.am: xml-i18n-tools setup for .oaf.in files.
diff --git a/executive-summary/component/component-factory.c b/executive-summary/component/component-factory.c
index 7e1dc17b45..0537275d4e 100644
--- a/executive-summary/component/component-factory.c
+++ b/executive-summary/component/component-factory.c
@@ -26,8 +26,8 @@
#include <config.h>
#endif
-#include <bonobo.h>
-#include <gnome.h>
+#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-generic-factory.h>
#include "Evolution.h"
#include "evolution-storage.h"
@@ -106,7 +106,7 @@ component_destroy_cb (GtkObject *object,
}
static void
-factory_destroy (BonoboEmbeddable *embeddable,
+factory_destroy (BonoboObject *component,
gpointer dummy)
{
running_objects--;
diff --git a/executive-summary/component/e-summary-callbacks.c b/executive-summary/component/e-summary-callbacks.c
index 4d9929fc7e..4ffa7f4d00 100644
--- a/executive-summary/component/e-summary-callbacks.c
+++ b/executive-summary/component/e-summary-callbacks.c
@@ -26,8 +26,13 @@
#include <config.h>
#endif
-#include <gnome.h>
-#include <bonobo.h>
+#include <libgnomeui/gnome-propertybox.h>
+#include <libgnomeui/gnome-file-entry.h>
+#include <libgnome/gnome-i18n.h>
+
+#include <bonobo/bonobo-selector.h>
+
+#include <stdlib.h> /* For atoi */
#include <liboaf/liboaf.h>
#include <glade/glade.h>
diff --git a/executive-summary/component/e-summary-factory.c b/executive-summary/component/e-summary-factory.c
index 4fcd77db48..444c8e8558 100644
--- a/executive-summary/component/e-summary-factory.c
+++ b/executive-summary/component/e-summary-factory.c
@@ -26,7 +26,6 @@
#include <config.h>
#endif
-#include <gnome.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-generic-factory.h>
diff --git a/executive-summary/component/e-summary-prefs.c b/executive-summary/component/e-summary-prefs.c
index 440c3837f4..5ed9876cf4 100644
--- a/executive-summary/component/e-summary-prefs.c
+++ b/executive-summary/component/e-summary-prefs.c
@@ -25,7 +25,9 @@
#include <config.h>
#endif
-#include <gnome.h>
+#include <stdio.h>
+#include <libgnome/gnome-defs.h>
+#include <libgnome/gnome-config.h>
#include "e-summary-prefs.h"
#include "e-summary.h"
diff --git a/executive-summary/component/e-summary-url.c b/executive-summary/component/e-summary-url.c
index 2c405b8664..cdc68091cd 100644
--- a/executive-summary/component/e-summary-url.c
+++ b/executive-summary/component/e-summary-url.c
@@ -25,8 +25,16 @@
#include <config.h>
#endif
-#include <gnome.h>
-#include <bonobo.h>
+#include <bonobo/bonobo-property-control.h>
+#include <bonobo/bonobo-event-source.h>
+#include <bonobo/bonobo-widget.h>
+
+#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-url.h>
+#include <libgnome/gnome-exec.h>
+#include <libgnomeui/gnome-propertybox.h>
+
+#include <stdlib.h>
#include <gtkhtml/gtkhtml.h>
#include <gtkhtml/gtkhtml-stream.h>
@@ -430,6 +438,23 @@ dialog_destroyed (GtkObject *object,
g_free (dialog);
}
+struct _idle_data {
+ ESummary *esummary;
+ ESummaryWindow *window;
+};
+
+static gboolean
+idle_remove_window (gpointer data)
+{
+ struct _idle_data *id = data;
+
+ e_summary_remove_window (id->esummary, id->window);
+ e_summary_queue_rebuild (id->esummary);
+ g_free (id);
+
+ return FALSE;
+}
+
void
e_summary_url_click (GtkWidget *widget,
const char *url,
@@ -439,6 +464,7 @@ e_summary_url_click (GtkWidget *widget,
char *parsed;
int address;
ESummaryWindow *window;
+ struct _idle_data *id;
Bonobo_Control control;
Bonobo_Listener corba_listener;
GtkWidget *prefsbox, *control_widget;
@@ -473,8 +499,15 @@ e_summary_url_click (GtkWidget *widget,
if (window->iid == NULL)
break;
- e_summary_remove_window (esummary, window);
- e_summary_queue_rebuild (esummary);
+ id = g_new (struct _idle_data, 1);
+ id->window = window;
+ id->esummary = esummary;
+
+ /* Close the window on an idle to work around a bug in
+ gnome-vfs which locks the e_summary_remove_window function
+ and as gtkhtml has a pointer grab on, this locks the whole
+ display. GAH! */
+ g_idle_add (idle_remove_window, id);
break;
case PROTOCOL_CONFIGURE:
@@ -565,8 +598,15 @@ e_summary_url_click (GtkWidget *widget,
e_summary_queue_rebuild (esummary);
break;
- case PROTOCOL_NONE:
case PROTOCOL_OTHER:
+ /* Pass it to the parent component */
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_Summary_HTMLView_handleURI (window->html,
+ url, &ev);
+ CORBA_exception_free (&ev);
+ break;
+
+ case PROTOCOL_NONE:
case PROTOCOL_HTTP:
case PROTOCOL_FILE:
default:
diff --git a/executive-summary/component/e-summary-util.c b/executive-summary/component/e-summary-util.c
index 3bd954ce12..a983da39b8 100644
--- a/executive-summary/component/e-summary-util.c
+++ b/executive-summary/component/e-summary-util.c
@@ -23,13 +23,15 @@
#include <e-summary-util.h>
-#include <gnome.h>
-
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
+#include <glib.h>
+#include <libgnome/gnome-defs.h>
+#include <libgnome/gnome-util.h>
+
/**
* e_pixmap_file:
* @filename: Filename of pixmap.
diff --git a/executive-summary/component/e-summary.c b/executive-summary/component/e-summary.c
index ae55f63e53..0e5d613ad8 100644
--- a/executive-summary/component/e-summary.c
+++ b/executive-summary/component/e-summary.c
@@ -25,8 +25,11 @@
#include <config.h>
#endif
-#include <gnome.h>
-#include <bonobo.h>
+#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-event-source.h>
+#include <bonobo/bonobo-listener.h>
+#include <bonobo/bonobo-property-bag.h>
+#include <bonobo/bonobo-property-control.h>
#include <gtkhtml/gtkhtml.h>
#include <gtkhtml/gtkhtml-embedded.h>
@@ -479,7 +482,7 @@ e_summary_rebuild_page (ESummary *esummary)
gtk_layout_freeze (GTK_LAYOUT (priv->html));
e_summary_start_load (esummary);
- if (priv->header == NULL) {
+ if (priv->header == NULL || *priv->header == '\0') {
load_default_header (esummary);
} else {
gtk_html_write (GTK_HTML (priv->html), priv->stream,
@@ -504,7 +507,6 @@ e_summary_rebuild_page (ESummary *esummary)
for (i = 0; i < numrows; i++) {
GList *window = windows;
- g_print ("i: %d/%d\n", i, numrows);
/* Do the same row twice:
Once for the title, once for the contents */
for (j = 0; j < 2; j++) {
@@ -516,7 +518,6 @@ e_summary_rebuild_page (ESummary *esummary)
limit = MIN (columns, (numwindows - (i * columns)));
for (k = 0; k < limit; k++) {
- g_print ("%d of %d\n", k, limit);
if (window == NULL)
break;
@@ -553,7 +554,7 @@ e_summary_rebuild_page (ESummary *esummary)
}
gtk_html_write (GTK_HTML (priv->html), priv->stream, "</tr></table>", 13);
- if (priv->footer == NULL) {
+ if (priv->footer == NULL || *priv->footer == '\0') {
load_default_footer (esummary);
} else {
gtk_html_write (GTK_HTML (priv->html), priv->stream,
@@ -658,7 +659,12 @@ e_summary_add_service (ESummary *esummary,
return NULL;
}
- window->event_source = Bonobo_Unknown_queryInterface(window->component,
+ unknown = Bonobo_Unknown_queryInterface (component,
+ "IDL:Bonobo/PropertyBag:1.0",
+ &ev);
+ window->propertybag = (Bonobo_PropertyBag) unknown;
+
+ window->event_source = Bonobo_Unknown_queryInterface(window->propertybag,
"IDL:Bonobo/EventSource:1.0", &ev);
if (window->event_source == CORBA_OBJECT_NIL) {
g_warning ("There is no Bonobo::EventSource interface");
@@ -675,11 +681,6 @@ e_summary_add_service (ESummary *esummary,
window->listener_id = Bonobo_EventSource_addListener (window->event_source, listener, &ev);
unknown = Bonobo_Unknown_queryInterface (component,
- "IDL:Bonobo/PropertyBag:1.0",
- &ev);
- window->propertybag = (Bonobo_PropertyBag) unknown;
-
- unknown = Bonobo_Unknown_queryInterface (component,
"IDL:Bonobo/PersistStream:1.0",
&ev);
window->persiststream = (Bonobo_PersistStream) unknown;
@@ -693,8 +694,10 @@ e_summary_add_service (ESummary *esummary,
window->title = bonobo_property_bag_client_get_value_string (window->propertybag,
"window_title",
NULL);
+ g_print ("title: %s\n", window->title);
window->icon = bonobo_property_bag_client_get_value_string (window->propertybag,
"window_icon", NULL);
+ g_print ("icon: %s\n", window->icon);
CORBA_exception_free (&ev);
priv->window_list = g_list_append (priv->window_list, window);
@@ -748,7 +751,7 @@ e_summary_window_free (ESummaryWindow *window)
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("CORBA ERROR: %s", CORBA_exception_id (&ev));
}
- bonobo_object_release_unref (window->event_source, &ev);
+ bonobo_object_release_unref (window->event_source, &ev);
}
bonobo_object_release_unref (window->propertybag, &ev);
@@ -756,10 +759,9 @@ e_summary_window_free (ESummaryWindow *window)
bonobo_object_release_unref (window->propertycontrol, &ev);
bonobo_object_unref (BONOBO_OBJECT (window->listener));
bonobo_object_release_unref (window->html, &ev);
-
+
bonobo_object_release_unref (window->component, &ev);
CORBA_exception_free (&ev);
-
g_free (window);
}
@@ -1211,7 +1213,6 @@ e_summary_save_state (ESummary *esummary,
fullpath = g_strdup_printf("%s/Executive-Summary", path);
g_print ("fullpath: %s\n", fullpath);
- /* FIXME: Use RC's rmdir function */
e_summary_rm_dir (fullpath);
storage = bonobo_storage_open (STORAGE_TYPE, fullpath,
diff --git a/executive-summary/component/e-summary.h b/executive-summary/component/e-summary.h
index 470863a9f5..36a9be6ed3 100644
--- a/executive-summary/component/e-summary.h
+++ b/executive-summary/component/e-summary.h
@@ -26,7 +26,7 @@
#include <gtk/gtkvbox.h>
-#include <bonobo.h>
+#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-listener.h>
#include <bonobo/bonobo-event-source.h>
#include <Evolution.h>
diff --git a/executive-summary/component/main.c b/executive-summary/component/main.c
index 3e29b5f337..0834802da1 100644
--- a/executive-summary/component/main.c
+++ b/executive-summary/component/main.c
@@ -21,11 +21,13 @@
* Author: Iain Holmes <iain@helixcode.com>
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include <gnome.h>
+
#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-object-directory.h>
#include <liboaf/liboaf.h>
#include <glade/glade.h>
@@ -35,7 +37,6 @@
#include "gal/widgets/e-gui-utils.h"
#include "gal/widgets/e-cursors.h"
-#include "gal/widgets/e-unicode.h"
#include <libgnomevfs/gnome-vfs.h>
#include "component-factory.h"
@@ -45,7 +46,7 @@ main (int argc,
char **argv)
{
CORBA_ORB orb;
-
+
bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
textdomain (PACKAGE);
diff --git a/executive-summary/evolution-services/executive-summary-component-factory-client.h b/executive-summary/evolution-services/executive-summary-component-factory-client.h
index 7c94afe15c..8ab4a05672 100644
--- a/executive-summary/evolution-services/executive-summary-component-factory-client.h
+++ b/executive-summary/evolution-services/executive-summary-component-factory-client.h
@@ -51,7 +51,7 @@ GtkType executive_summary_component_factory_client_get_type (void);
void executive_summary_component_factory_client_construct (ExecutiveSummaryComponentFactoryClient *client,
CORBA_Object corba_object);
ExecutiveSummaryComponentFactoryClient *executive_summary_component_factory_client_new (const char *id);
-GNOME_Evolution_Summary_Component executive_summary_component_factory_client_create_view (ExecutiveSummaryComponentFactoryClient *client);
+CORBA_Object executive_summary_component_factory_client_create_view (ExecutiveSummaryComponentFactoryClient *client);
#endif
diff --git a/executive-summary/evolution-services/executive-summary-html-view.c b/executive-summary/evolution-services/executive-summary-html-view.c
index 659aad18fd..8a3498cdd8 100644
--- a/executive-summary/evolution-services/executive-summary-html-view.c
+++ b/executive-summary/evolution-services/executive-summary-html-view.c
@@ -42,6 +42,13 @@ static void executive_summary_html_view_class_init (ExecutiveSummaryHtmlViewClas
static BonoboObjectClass *parent_class;
+enum {
+ HANDLE_URI,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
struct _ExecutiveSummaryHtmlViewPrivate {
BonoboEventSource *event_source;
@@ -88,6 +95,18 @@ impl_GNOME_Evolution_Summary_HTMLView_getHtml (PortableServer_Servant servant,
return CORBA_string_dup (priv->html? priv->html: "");
}
+static void
+impl_GNOME_Evolution_Summary_HTMLView_handleURI (PortableServer_Servant servant,
+ CORBA_char *uri,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+
+ gtk_signal_emit (GTK_OBJECT (bonobo_object), signals[HANDLE_URI], uri);
+}
+
/* GtkObject methods */
static void
executive_summary_html_view_destroy (GtkObject *object)
@@ -95,13 +114,13 @@ executive_summary_html_view_destroy (GtkObject *object)
ExecutiveSummaryHtmlView *view;
ExecutiveSummaryHtmlViewPrivate *priv;
+ g_print ("BANG!");
view = EXECUTIVE_SUMMARY_HTML_VIEW (object);
priv = view->private;
if (priv == NULL)
return;
- bonobo_object_unref (BONOBO_OBJECT (priv->event_source));
g_free (priv->html);
g_free (priv);
@@ -124,6 +143,7 @@ corba_class_init (void)
epv = g_new0 (POA_GNOME_Evolution_Summary_HTMLView__epv, 1);
epv->getHtml = impl_GNOME_Evolution_Summary_HTMLView_getHtml;
+ epv->handleURI = impl_GNOME_Evolution_Summary_HTMLView_handleURI;
vepv = &HTMLView_vepv;
vepv->_base_epv = base_epv;
@@ -139,6 +159,15 @@ executive_summary_html_view_class_init (ExecutiveSummaryHtmlViewClass *klass)
object_class = GTK_OBJECT_CLASS (klass);
object_class->destroy = executive_summary_html_view_destroy;
+ signals[HANDLE_URI] = gtk_signal_new ("handle_uri", GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ExecutiveSummaryHtmlViewClass, handle_uri),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_POINTER);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+
parent_class = gtk_type_class (PARENT_TYPE);
corba_class_init ();
diff --git a/executive-summary/evolution-services/executive-summary-html-view.h b/executive-summary/evolution-services/executive-summary-html-view.h
index 3c8895167d..c09962a619 100644
--- a/executive-summary/evolution-services/executive-summary-html-view.h
+++ b/executive-summary/evolution-services/executive-summary-html-view.h
@@ -47,6 +47,9 @@ struct _ExecutiveSummaryHtmlView {
struct _ExecutiveSummaryHtmlViewClass {
BonoboObjectClass parent_class;
+
+ void (* handle_uri) (ExecutiveSummaryHtmlView *view,
+ char *uri);
};
GtkType executive_summary_html_view_get_type (void);
diff --git a/executive-summary/idl/HtmlView.idl b/executive-summary/idl/HtmlView.idl
index 547c3148a5..25ec63de9b 100644
--- a/executive-summary/idl/HtmlView.idl
+++ b/executive-summary/idl/HtmlView.idl
@@ -16,6 +16,8 @@ module Summary {
interface HTMLView : Bonobo::Unknown {
string getHtml ();
+
+ void handleURI (in string uri);
};
};
};
diff --git a/executive-summary/test-service/rdf-summary.c b/executive-summary/test-service/rdf-summary.c
index ad9a826afd..6bc3768335 100644
--- a/executive-summary/test-service/rdf-summary.c
+++ b/executive-summary/test-service/rdf-summary.c
@@ -47,6 +47,9 @@ struct _RdfSummary {
GtkWidget *rdf;
GtkWidget *g_limit;
GtkWidget *g_title;
+ GtkWidget *g_update;
+ GtkWidget *g_update_container;
+ GtkAdjustment *adjustment;
char *title;
char *icon;
@@ -54,10 +57,16 @@ struct _RdfSummary {
int limit;
gboolean showtitle;
+ gboolean usetimer;
+ int time;
+ int timer;
+
GString *str;
char *buffer;
GnomeVFSAsyncHandle *handle;
+
+ xmlDocPtr cache;
};
typedef struct _RdfSummary RdfSummary;
@@ -279,9 +288,15 @@ view_destroyed (GtkObject *object,
{
RdfSummary *summary = (RdfSummary *) data;
+ g_warning ("RDF: Point 1");
if (summary->handle)
gnome_vfs_async_cancel (summary->handle);
+ g_warning ("RDF: Point 2");
+
+ if (summary->cache != NULL)
+ xmlFreeDoc (summary->cache);
+
g_free (summary->title);
g_free (summary->icon);
g_free (summary);
@@ -291,6 +306,7 @@ view_destroyed (GtkObject *object,
if (running_views <= 0) {
gtk_main_quit ();
}
+ g_warning ("RDF: Point 3");
}
/* PersistStream callbacks */
@@ -320,7 +336,6 @@ load_from_stream (BonoboPersistStream *ps,
return;
}
- g_print ("Hydrating with %s\n", str);
doc = xmlParseDoc ((xmlChar *) str);
if (doc == NULL) {
@@ -361,6 +376,24 @@ load_from_stream (BonoboPersistStream *ps,
continue;
}
+ if (strcasecmp (children->name, "usetimer") == 0) {
+ xml_str = xmlNodeListGetString (doc, children->childs, 1);
+ summary->usetimer = atoi (xml_str);
+ xmlFree (xml_str);
+
+ children = children->next;
+ continue;
+ }
+
+ if (strcasecmp (children->name, "timer") == 0) {
+ xml_str = xmlNodeListGetString (doc, children->childs, 1);
+ summary->timer = atoi (xml_str);
+ xmlFree (xml_str);
+
+ children = children->next;
+ continue;
+ }
+
g_print ("Unknown name: %s\n", children->name);
children = children->next;
}
@@ -378,7 +411,7 @@ summary_to_string (RdfSummary *summary)
char *tmp_str;
doc = xmlNewDoc ("1.0");
- ns = xmlNewGlobalNs (doc, "http://www.helixcode.com", "rdf");
+ ns = xmlNewGlobalNs (doc, "http://www.ximian.com", "rdf");
doc->root = xmlNewDocNode (doc, ns, "rdf-summary", NULL);
@@ -391,8 +424,15 @@ summary_to_string (RdfSummary *summary)
xmlNewChild (doc->root, ns, "showtitle", tmp_str);
g_free (tmp_str);
+ tmp_str = g_strdup_printf ("%d", summary->usetimer);
+ xmlNewChild (doc->root, ns, "usetimer", tmp_str);
+ g_free (tmp_str);
+
+ tmp_str = g_strdup_printf ("%d", summary->timer);
+ xmlNewChild (doc->root, ns, "timer", tmp_str);
+ g_free (tmp_str);
+
xmlDocDumpMemory (doc, &out_str, &out_len);
- g_print ("%s\n", out_str);
return out_str;
}
@@ -429,12 +469,23 @@ content_types (BonoboPersistStream *ps,
return bonobo_persist_generate_content_types (1, "application/x-rdf-summary");
}
+static void
+display_doc (RdfSummary *summary)
+{
+ GString *html;
+
+ html = g_string_new ("");
+
+ tree_walk (summary->cache->root, summary, html);
+ executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (summary->view), html->str);
+ g_string_free (html, TRUE);
+}
+
static void
close_callback (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result,
RdfSummary *summary)
{
- GString *html;
xmlDocPtr doc;
char *xml;
@@ -446,6 +497,9 @@ close_callback (GnomeVFSAsyncHandle *handle,
xml = summary->str->str;
g_string_free (summary->str, FALSE);
+ if (summary->cache != NULL)
+ xmlFreeDoc (summary->cache);
+
doc = xmlParseMemory (xml, strlen (xml));
if (doc == NULL) {
char *emsg;
@@ -468,11 +522,12 @@ close_callback (GnomeVFSAsyncHandle *handle,
}
g_free (xml);
- html = g_string_new ("");
- tree_walk (doc->root, summary, html);
- executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (summary->view), html->str);
- g_string_free (html, TRUE);
+ /* Cache it for later */
+ summary->cache = doc;
+
+ /* Draw it */
+ display_doc (summary);
}
static void
@@ -632,9 +687,15 @@ set_prop (BonoboPropertyBag *bag,
}
static void
-item_changed (GtkEntry *entry,
+item_changed (GtkWidget *widget,
RdfSummary *summary)
{
+ if (widget == summary->g_update) {
+ summary->usetimer = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+ gtk_widget_set_sensitive (summary->g_update_container,
+ summary->usetimer);
+ }
+
bonobo_property_control_changed (summary->property_control, NULL);
}
@@ -645,7 +706,7 @@ property_control (BonoboPropertyControl *property_control,
{
BonoboControl *control;
RdfSummary *summary = (RdfSummary *) user_data;
- GtkWidget *container, *label, *hbox;
+ GtkWidget *container, *label, *hbox, *spinner, *button;
char *climit;
container = gtk_vbox_new (FALSE, 2);
@@ -695,8 +756,46 @@ property_control (BonoboPropertyControl *property_control,
GTK_SIGNAL_FUNC (item_changed), summary);
gtk_box_pack_start (GTK_BOX (hbox), summary->g_title, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (container), hbox, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 2);
+
+ /* Update */
+ hbox = gtk_hbox_new (FALSE, 2);
+ label = gtk_label_new (_("Update automatically"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ summary->g_update = gtk_check_button_new ();
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (summary->g_update),
+ summary->usetimer);
+
+ gtk_signal_connect (GTK_OBJECT (summary->g_update), "toggled",
+ GTK_SIGNAL_FUNC (item_changed), summary);
+ gtk_box_pack_start (GTK_BOX (hbox), summary->g_update, TRUE, TRUE, 0);
+
+ button = gtk_button_new_with_label (_("Update now"));
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (download), summary);
+ gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (container), hbox, FALSE, FALSE, 0);
+
+ /* Timer */
+ hbox = gtk_hbox_new (FALSE, 2);
+ summary->g_update_container = hbox;
+
+ label = gtk_label_new (_("Update every "));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ summary->adjustment = gtk_adjustment_new (summary->time / 1000 / 60,
+ 0.0, 1000.0, 1.0, 10.0, 1.0);
+ spinner = gtk_spin_button_new (summary->adjustment, 1.0, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
+
+ label = gtk_label_new (_("minutes"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
gtk_box_pack_start (GTK_BOX (container), hbox, FALSE, FALSE, 0);
+ gtk_widget_set_sensitive (hbox, summary->usetimer);
+
gtk_widget_show_all (container);
control = bonobo_control_new (container);
@@ -709,13 +808,30 @@ property_action (GtkObject *property_control,
Bonobo_PropertyControl_Action action,
RdfSummary *summary)
{
+ gboolean changed = FALSE;
+ char *old_location;
+
switch (action) {
case Bonobo_PropertyControl_APPLY:
- g_free (summary->location);
+ old_location = summary->location;
summary->showtitle = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (summary->g_title));
summary->location = g_strdup (gtk_entry_get_text (GTK_ENTRY (summary->rdf)));
+ if (strcmp (old_location, summary->location) != 0)
+ changed = TRUE;
+
summary->limit = atoi (gtk_entry_get_text (GTK_ENTRY (summary->g_limit)));
- g_idle_add ((GSourceFunc) download, summary);
+ summary->time = summary->adjustment->value * 60 * 1000;
+ if (summary->timer)
+ gtk_timeout_remove (summary->timer);
+ summary->timer = gtk_timeout_add (summary->time,
+ (GSourceFunc)download, summary);
+
+ if (changed)
+ g_idle_add ((GSourceFunc) download, summary);
+ else
+ g_idle_add ((GSourceFunc) display_doc, summary);
+
+ g_free (old_location);
break;
case Bonobo_PropertyControl_HELP:
@@ -745,6 +861,13 @@ create_view (ExecutiveSummaryComponentFactory *_factory,
summary->limit = 10;
summary->showtitle = TRUE;
+ summary->cache = NULL;
+
+ summary->usetimer = TRUE;
+ summary->time = 600000; /* 10 minutes */
+ summary->timer = gtk_timeout_add (summary->time, (GSourceFunc) download,
+ summary);
+
component = executive_summary_component_new ();
gtk_signal_connect (GTK_OBJECT (component), "destroy",
GTK_SIGNAL_FUNC (view_destroyed), summary);
@@ -776,7 +899,8 @@ create_view (ExecutiveSummaryComponentFactory *_factory,
BONOBO_ARG_STRING, NULL,
"The icon for this component's window", 0);
bonobo_object_add_interface (component, BONOBO_OBJECT(bag));
-
+
+ /* Bonobo::PropertyControl */
property = bonobo_property_control_new_full (property_control, 1,
event_source,
summary);
@@ -793,7 +917,7 @@ create_view (ExecutiveSummaryComponentFactory *_factory,
bonobo_object_add_interface (component, BONOBO_OBJECT (stream));
running_views++;
- gtk_timeout_add (5000, (GSourceFunc) download, summary);
+ gtk_idle_add ((GSourceFunc) download, summary);
return component;
}