18 |
*/ |
*/ |
19 |
|
|
20 |
#include "gpxview.h" |
#include "gpxview.h" |
21 |
|
|
22 |
|
// #undef PANNABLE_HTML |
23 |
|
|
24 |
|
#ifdef FREMANTLE |
25 |
#include <hildon/hildon-banner.h> |
#include <hildon/hildon-banner.h> |
26 |
|
#include <hildon/hildon-note.h> |
27 |
|
#endif |
28 |
|
|
29 |
typedef struct load_context { |
typedef struct load_context { |
30 |
int active; |
int active; |
145 |
return NULL; |
return NULL; |
146 |
} |
} |
147 |
|
|
148 |
|
#ifdef ENABLE_BROWSER_INTERFACE |
149 |
|
static void on_link_clicked(GtkHTML *html, const gchar *url, |
150 |
|
gpointer data) { |
151 |
|
|
152 |
|
appdata_t *appdata = (appdata_t*)data; |
153 |
|
|
154 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
155 |
|
GtkWidget *dialog = gtk_message_dialog_new( |
156 |
|
GTK_WINDOW(appdata->window), |
157 |
|
GTK_DIALOG_DESTROY_WITH_PARENT, |
158 |
|
GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, |
159 |
|
_("Open link on external browser?")); |
160 |
|
gboolean yes = (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES); |
161 |
|
#else |
162 |
|
GtkWidget *dialog = |
163 |
|
hildon_note_new_confirmation(GTK_WINDOW(appdata->window), |
164 |
|
_("Open link in external browser?")); |
165 |
|
gboolean yes = (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK); |
166 |
|
#endif |
167 |
|
|
168 |
|
gtk_widget_destroy(dialog); |
169 |
|
|
170 |
|
if(yes) |
171 |
|
browser_url(appdata, (char*)url); |
172 |
|
} |
173 |
|
#endif |
174 |
|
|
175 |
static void on_request_url(GtkHTML *html, const gchar *url, |
static void on_request_url(GtkHTML *html, const gchar *url, |
176 |
GtkHTMLStream *stream, gpointer data) { |
GtkHTMLStream *stream, gpointer data) { |
177 |
char buffer[4096]; |
char buffer[4096]; |
178 |
GnomeVFSFileSize bytes_read; |
GnomeVFSFileSize bytes_read; |
179 |
|
|
180 |
http_context_t *context = (http_context_t*)data; |
http_context_t *context = (http_context_t*)data; |
181 |
|
|
182 |
if(context->cache) { |
if(context->cache) { |
381 |
} |
} |
382 |
#endif |
#endif |
383 |
|
|
384 |
#ifdef PANNABLE_HTML |
#ifdef FREMANTLE |
385 |
static void |
static void |
386 |
tap_and_hold_cb (GtkWidget *widget, gpointer user_data) { |
tap_and_hold_cb (GtkWidget *widget, gpointer user_data) { |
387 |
appdata_t *appdata = (appdata_t*)user_data; |
appdata_t *appdata = (appdata_t*)user_data; |
388 |
|
|
389 |
printf("Tap n hold\n"); |
/* the HildonTextView becomes semi-copy'n pasteable if we enable */ |
390 |
hildon_banner_show_information(GTK_WIDGET(appdata->window), NULL, "Tap n hold"); |
/* the cursor */ |
391 |
|
if(GTK_WIDGET_TYPE(widget) == HILDON_TYPE_TEXT_VIEW) { |
392 |
|
gboolean state = gtk_text_view_get_cursor_visible(GTK_TEXT_VIEW(widget)); |
393 |
|
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(widget), !state); |
394 |
|
|
395 |
|
hildon_banner_show_information(GTK_WIDGET(appdata->window), |
396 |
|
NULL, state?"Cursor disabled":"Cursor enabled"); |
397 |
|
|
398 |
|
return; |
399 |
|
} |
400 |
|
|
401 |
|
GtkWidget *parent = widget->parent; |
402 |
|
|
403 |
|
/* check if the parent actually is a hildonpannablearea */ |
404 |
|
if(GTK_WIDGET_TYPE(parent) != HILDON_TYPE_PANNABLE_AREA) { |
405 |
|
printf("parent is not pannable area, ignoring event\n"); |
406 |
|
return; |
407 |
|
} |
408 |
|
|
409 |
|
/* lets assume parent is a pannable area ... */ |
410 |
|
|
411 |
|
hildon_banner_show_information(GTK_WIDGET(appdata->window), |
412 |
|
NULL, "Copy'n paste is not working in maemo5"); |
413 |
|
|
414 |
|
#if 0 |
415 |
|
gboolean enabled = FALSE; |
416 |
|
g_object_get(parent, "enabled", &enabled, NULL); |
417 |
|
enabled = !enabled; |
418 |
|
g_object_set(parent, "enabled", enabled, NULL); |
419 |
|
|
420 |
|
hildon_banner_show_information(GTK_WIDGET(appdata->window), |
421 |
|
NULL, enabled?"enabled":"disabled"); |
422 |
|
#endif |
423 |
} |
} |
424 |
#endif |
#endif |
425 |
|
|
441 |
|
|
442 |
context->view = view = gtk_html_new(); |
context->view = view = gtk_html_new(); |
443 |
|
|
444 |
|
#ifndef PANNABLE_HTML |
445 |
|
// gtk_html_set_auto_panning(GTK_HTML(view), TRUE); |
446 |
|
#else |
447 |
|
gtk_html_set_auto_panning(GTK_HTML(view), FALSE); |
448 |
|
#endif |
449 |
|
|
450 |
|
#ifdef FREMANTLE |
451 |
|
/* allow selection does not allow anything, but disables auto panning ... */ |
452 |
|
/* even worse: frequently causes the device to reboot */ |
453 |
|
// gtk_html_allow_selection(GTK_HTML(view), TRUE); |
454 |
|
#endif |
455 |
|
|
456 |
/* create a callback to load images only if a cache has been given */ |
/* create a callback to load images only if a cache has been given */ |
457 |
/* so that images can be cached/stored appropriately */ |
/* so that images can be cached/stored appropriately */ |
458 |
g_signal_connect(G_OBJECT(view), "url_requested", |
g_signal_connect(G_OBJECT(view), "url_requested", |
459 |
G_CALLBACK(on_request_url), context); |
G_CALLBACK(on_request_url), context); |
460 |
|
|
461 |
|
#ifdef ENABLE_BROWSER_INTERFACE |
462 |
|
g_signal_connect(G_OBJECT(view), "link_clicked", |
463 |
|
G_CALLBACK(on_link_clicked), context->appdata); |
464 |
|
#endif |
465 |
|
|
466 |
GtkHTMLStream *stream = gtk_html_begin(GTK_HTML(view)); |
GtkHTMLStream *stream = gtk_html_begin(GTK_HTML(view)); |
467 |
|
|
468 |
gtk_html_write(GTK_HTML(view), stream, html_start, strlen(html_start)); |
gtk_html_write(GTK_HTML(view), stream, html_start, strlen(html_start)); |
483 |
*h = g_new0(struct html_view, 1); |
*h = g_new0(struct html_view, 1); |
484 |
(*h)->view = view; |
(*h)->view = view; |
485 |
|
|
486 |
#ifdef PANNABLE_HTML |
#ifdef FREMANTLE |
487 |
gtk_widget_tap_and_hold_setup(GTK_WIDGET(view), NULL, NULL, 0); |
gtk_widget_tap_and_hold_setup(GTK_WIDGET(view), NULL, NULL, 0); |
488 |
g_signal_connect(G_OBJECT(view), "tap-and-hold", G_CALLBACK(tap_and_hold_cb), appdata); |
g_signal_connect(G_OBJECT(view), "tap-and-hold", |
489 |
|
G_CALLBACK(tap_and_hold_cb), appdata); |
490 |
#endif |
#endif |
491 |
|
|
492 |
g_signal_connect(G_OBJECT(view), "destroy", |
g_signal_connect(G_OBJECT(view), "destroy", |
502 |
hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), buffer); |
hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), buffer); |
503 |
|
|
504 |
gtk_widget_tap_and_hold_setup(GTK_WIDGET(view), NULL, NULL, 0); |
gtk_widget_tap_and_hold_setup(GTK_WIDGET(view), NULL, NULL, 0); |
505 |
g_signal_connect(G_OBJECT(view), "tap-and-hold", G_CALLBACK(tap_and_hold_cb), appdata); |
g_signal_connect(G_OBJECT(view), "tap-and-hold", |
506 |
|
G_CALLBACK(tap_and_hold_cb), appdata); |
507 |
#endif |
#endif |
508 |
|
|
509 |
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD); |
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD); |
541 |
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
542 |
gtk_container_add(GTK_CONTAINER(scrolled_window), view); |
gtk_container_add(GTK_CONTAINER(scrolled_window), view); |
543 |
|
|
|
#if 1 |
|
544 |
return scrolled_window; |
return scrolled_window; |
545 |
#else |
#else |
|
GtkWidget *fixed = gtk_fixed_new(); |
|
|
gtk_fixed_put(GTK_FIXED(fixed), scrolled_window, 0, 0); |
|
|
GtkWidget *tbutton = gtk_toggle_button_new_with_label("sel"); |
|
|
gtk_fixed_put(GTK_FIXED(fixed), tbutton, 0, 0); |
|
|
return fixed; |
|
|
#endif |
|
|
#else |
|
546 |
#ifndef PANNABLE_HTML |
#ifndef PANNABLE_HTML |
547 |
if(mode == HTML_HTML) { |
if(mode == HTML_HTML) { |
548 |
GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); |