aboutsummaryrefslogtreecommitdiffstats
path: root/executive-summary/component/e-summary-url.c
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2000-11-02 08:42:35 +0800
committerIain Holmes <iain@src.gnome.org>2000-11-02 08:42:35 +0800
commit4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c (patch)
tree6f9b76cee8d456070ca9c849c697f621ff833694 /executive-summary/component/e-summary-url.c
parent35162bcd8728297bff435a5592328051fd1df211 (diff)
downloadgsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.gz
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.bz2
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.lz
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.xz
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.zst
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.zip
Moving the executive summarys now :)
mail-summary now has clickable names to change to that view executive summary remembers what components are running when you close. selection now blocks ES updating so it won't be cleared. svn path=/trunk/; revision=6330
Diffstat (limited to 'executive-summary/component/e-summary-url.c')
-rw-r--r--executive-summary/component/e-summary-url.c306
1 files changed, 287 insertions, 19 deletions
diff --git a/executive-summary/component/e-summary-url.c b/executive-summary/component/e-summary-url.c
index 856297bb68..c07a3efc99 100644
--- a/executive-summary/component/e-summary-url.c
+++ b/executive-summary/component/e-summary-url.c
@@ -39,6 +39,7 @@
#include "e-summary-url.h"
#include "e-summary-util.h"
+#include <evolution-services/executive-summary-component-view.h>
#include "Composer.h"
typedef enum _ESummaryProtocol {
@@ -48,11 +49,37 @@ typedef enum _ESummaryProtocol {
PROTOCOL_VIEW,
PROTOCOL_EXEC,
PROTOCOL_FILE,
+ PROTOCOL_CLOSE,
+ PROTOCOL_LEFT,
+ PROTOCOL_RIGHT,
+ PROTOCOL_UP,
+ PROTOCOL_DOWN,
+ PROTOCOL_CONFIGURE,
PROTOCOL_OTHER
} ESummaryProtocol;
+static char *descriptions[] = {
+ N_("Open %s with the default GNOME application"),
+ N_("Open %s with the default GNOME web browser"),
+ N_("Send an email to %s"),
+ N_("Change the view to %s"),
+ N_("Run %s"),
+ N_("Open %s with the default GNOME application"),
+ N_("Close %s"),
+ N_("Move %s to the left"),
+ N_("Move %s to the right"),
+ N_("Move %s into the previous row"),
+ N_("Move %s into the next row"),
+ N_("Configure %s"),
+ N_("Open %s with the default GNOME application")
+};
+
#define COMPOSER_IID "OAFIID:evolution-composer:evolution-mail:cd8618ea-53e1-4b9e-88cf-ec578bdb903b"
+gboolean e_summary_url_mail_compose (ESummary *esummary,
+ const char *url);
+gboolean e_summary_url_exec (const char *exec);
+
void
e_summary_url_request (GtkHTML *html,
const gchar *url,
@@ -111,6 +138,98 @@ e_summary_url_request (GtkHTML *html,
gnome_vfs_close (handle);
}
+static char *
+parse_uri (const char *uri,
+ ESummaryProtocol protocol,
+ ESummary *esummary)
+{
+ ExecutiveSummaryComponentView *view;
+ char *parsed;
+ char *p;
+ int id;
+
+ switch (protocol) {
+
+ case PROTOCOL_HTTP:
+ /* "http://" == 7 */
+ parsed = g_strdup (uri + 7);
+ break;
+
+ case PROTOCOL_EXEC:
+ /* "exec://" == 7 */
+ parsed = g_strdup (uri + 7);
+ break;
+
+ case PROTOCOL_VIEW:
+ /* "view://" == 7 */
+ parsed = g_strdup (uri + 7);
+ break;
+
+ case PROTOCOL_MAILTO:
+ /* Fun. Mailto's might be "mailto:" or "mailto://" */
+ if (strstr (uri, "mailto://") == NULL) {
+ parsed = (char *) (uri + 7);
+ } else {
+ parsed = (char *) (uri + 9);
+ }
+
+ /* Now strip anything after a question mark,
+ as it is a parameter (that we ignore for the time being) */
+ if ( (p = strchr (parsed, '?')) != NULL) {
+ parsed = g_strndup (parsed, p - parsed);
+ } else {
+ parsed = g_strdup (parsed);
+ }
+
+ break;
+
+ case PROTOCOL_CLOSE:
+ id = atoi (uri + 8);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_LEFT:
+ id = atoi (uri + 7);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_RIGHT:
+ id = atoi (uri + 8);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_UP:
+ id = atoi (uri + 5);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_DOWN:
+ id = atoi (uri + 7);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_CONFIGURE:
+ id = atoi (uri + 12);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_NONE:
+ case PROTOCOL_OTHER:
+ default:
+ /* Just return the uneditted uri. */
+ parsed = g_strdup (uri);
+ break;
+ }
+
+ return parsed;
+}
+
static ESummaryProtocol
get_protocol (const char *url)
{
@@ -134,29 +253,61 @@ get_protocol (const char *url)
}
switch (lowerurl[0]) {
+ case 'c':
+ switch (lowerurl[1]) {
+ case 'l':
+ if (strncmp (lowerurl + 2, "ose", 3) == 0)
+ protocol = PROTOCOL_CLOSE;
+ break;
+ case 'o':
+ if (strncmp (lowerurl + 2, "nfigure", 7) == 0)
+ protocol = PROTOCOL_CONFIGURE;
+ break;
+ }
+
+ case 'd':
+ if (strncmp (lowerurl + 1, "own", 3) == 0)
+ protocol = PROTOCOL_DOWN;
+ break;
+
+ case 'e':
+ if (strncmp (lowerurl + 1, "xec", 3) == 0)
+ protocol = PROTOCOL_EXEC;
+ break;
+
+ case 'f':
+ if (strncmp (lowerurl + 1, "ile", 3) == 0)
+ protocol = PROTOCOL_FILE;
+ break;
+
case 'h':
if (strncmp (lowerurl + 1, "ttp", 3) == 0)
protocol = PROTOCOL_HTTP;
break;
+ case 'l':
+ if (strncmp (lowerurl + 1, "eft", 3) == 0)
+ protocol = PROTOCOL_LEFT;
+ break;
+
case 'm':
if (strncmp (lowerurl + 1, "ailto", 5) == 0)
protocol = PROTOCOL_MAILTO;
break;
- case 'v':
- if (strncmp (lowerurl + 1, "iew", 3) == 0)
- protocol = PROTOCOL_VIEW;
+ case 'r':
+ if (strncmp (lowerurl + 1, "ight", 4) == 0)
+ protocol = PROTOCOL_RIGHT;
break;
-
- case 'e':
- if (strncmp (lowerurl + 1, "xec", 3) == 0)
- protocol = PROTOCOL_EXEC;
+
+ case 'u':
+ if (lowerurl[1] == 'p')
+ protocol = PROTOCOL_UP;
break;
- case 'f':
- if (strncmp (lowerurl + 1, "ile", 3) == 0)
- protocol = PROTOCOL_FILE;
+ case 'v':
+ if (strncmp (lowerurl + 1, "iew", 3) == 0)
+ protocol = PROTOCOL_VIEW;
break;
default:
@@ -174,25 +325,104 @@ e_summary_url_click (GtkWidget *widget,
ESummary *esummary)
{
ESummaryProtocol protocol;
- g_print ("URL: %s\n", url);
-
+ ExecutiveSummaryComponentView *view;
+ gpointer window; /* FIXME */
+ char *parsed;
+ int id;
+
protocol = get_protocol (url);
-
+
+ parsed = parse_uri (url, protocol, esummary);
+
switch (protocol) {
case PROTOCOL_MAILTO:
/* Open a composer window */
- e_summary_url_mail_compose (esummary, url);
+ e_summary_url_mail_compose (esummary, parsed);
break;
case PROTOCOL_VIEW:
/* Change the EShellView's current uri */
+ e_summary_change_current_view (esummary, parsed);
break;
case PROTOCOL_EXEC:
/* Execute the rest of the url */
- e_summary_url_exec (url + 7);
+ e_summary_url_exec (parsed);
break;
-
+
+ case PROTOCOL_CLOSE:
+ /* Close the window. */
+ id = atoi (url + 8);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+ e_summary_window_remove_from_ht (window, esummary);
+ e_summary_window_free (window, esummary);
+ e_summary_rebuild_page (esummary);
+ break;
+
+ case PROTOCOL_CONFIGURE:
+ /* Configure the window. . . */
+ id = atoi (url + 12);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ /* Issue the configure command some how :) */
+ break;
+
+ case PROTOCOL_LEFT:
+ /* Window left */
+ id = atoi (url + 7);
+ view = e_summary_view_from_id (esummary, id);
+
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+
+ e_summary_window_move_left (esummary, window);
+ e_summary_rebuild_page (esummary);
+ break;
+
+ case PROTOCOL_RIGHT:
+ id = atoi (url + 8);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+
+ e_summary_window_move_right (esummary, window);
+ e_summary_rebuild_page (esummary);
+ break;
+
+ case PROTOCOL_UP:
+ id = atoi (url + 5);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+
+ e_summary_window_move_up (esummary, window);
+ e_summary_rebuild_page (esummary);
+ break;
+
+ case PROTOCOL_DOWN:
+ id = atoi (url + 7);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+
+ e_summary_window_move_down (esummary, window);
+ e_summary_rebuild_page (esummary);
+ break;
+
case PROTOCOL_NONE:
case PROTOCOL_OTHER:
case PROTOCOL_HTTP:
@@ -203,6 +433,8 @@ e_summary_url_click (GtkWidget *widget,
break;
}
+
+ g_free (parsed);
}
gboolean
@@ -225,13 +457,16 @@ e_summary_url_mail_compose (ESummary *esummary,
g_warning ("Unable to start composer component!");
return FALSE;
}
-
+
if ( (proto = strstr (url, "://")) != NULL){
address = proto + 3;
} else {
- address = url + 7;
+ if (strncmp (url, "mailto:", 7) == 0)
+ address = (char *) (url + 7);
+ else
+ address = (char *) url;
}
-
+
to = Evolution_Composer_RecipientList__alloc ();
to->_length = 1;
to->_maximum = 1;
@@ -296,4 +531,37 @@ e_summary_url_exec (const char *exec)
gnome_execute_async (NULL, argc, exec_array);
g_strfreev (exec_array);
+ return TRUE;
+}
+
+static char *
+e_summary_url_describe (const char *uri,
+ ESummary *esummary)
+{
+ ESummaryProtocol protocol;
+ char *contents, *description;
+
+ protocol = get_protocol (uri);
+ contents = parse_uri (uri, protocol, esummary);
+
+ description = g_strdup_printf (_(descriptions[protocol]), contents);
+ g_free (contents);
+
+ return description;
+}
+
+void
+e_summary_url_over (GtkHTML *html,
+ const char *uri,
+ ESummary *esummary)
+{
+ char *description;
+
+ if (uri != NULL) {
+ description = e_summary_url_describe (uri, esummary);
+ e_summary_set_message (esummary, description, FALSE);
+ g_free (description);
+ } else {
+ e_summary_unset_message (esummary);
+ }
}