Beginning of a history implementation

This commit is contained in:
Pierre Pronchery 2010-09-01 01:28:56 +00:00
parent 6603e09fab
commit 1c80bb4942

View File

@ -80,86 +80,86 @@ typedef struct _GHtml
static const GHtmlProperty _ghtml_properties_a[] = static const GHtmlProperty _ghtml_properties_a[] =
{ {
{ "foreground", "blue" }, { "foreground", "blue" },
{ "underline", PANGO_UNDERLINE_SINGLE }, { "underline", (void*)PANGO_UNDERLINE_SINGLE },
{ "underline-set", TRUE }, { "underline-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
static const GHtmlProperty _ghtml_properties_b[] = static const GHtmlProperty _ghtml_properties_b[] =
{ {
{ "weight", PANGO_WEIGHT_BOLD }, { "weight", (void*)PANGO_WEIGHT_BOLD },
{ "weight-set", TRUE }, { "weight-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
/* XXX should use "scale" but gdouble values are not accepted this way */ /* XXX should use "scale" but gdouble values are not accepted this way */
static const GHtmlProperty _ghtml_properties_h1[] = static const GHtmlProperty _ghtml_properties_h1[] =
{ {
{ "font", "Sans 16" }, { "font", "Sans 16" },
{ "weight", PANGO_WEIGHT_BOLD }, { "weight", (void*)PANGO_WEIGHT_BOLD },
{ "weight-set", TRUE }, { "weight-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
static const GHtmlProperty _ghtml_properties_h2[] = static const GHtmlProperty _ghtml_properties_h2[] =
{ {
{ "font", "Sans 14" }, { "font", "Sans 14" },
{ "weight", PANGO_WEIGHT_BOLD }, { "weight", (void*)PANGO_WEIGHT_BOLD },
{ "weight-set", TRUE }, { "weight-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
static const GHtmlProperty _ghtml_properties_h3[] = static const GHtmlProperty _ghtml_properties_h3[] =
{ {
{ "font", "Sans 13" }, { "font", "Sans 13" },
{ "weight", PANGO_WEIGHT_BOLD }, { "weight", (void*)PANGO_WEIGHT_BOLD },
{ "weight-set", TRUE }, { "weight-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
static const GHtmlProperty _ghtml_properties_h4[] = static const GHtmlProperty _ghtml_properties_h4[] =
{ {
{ "font", "Sans 12" }, { "font", "Sans 12" },
{ "weight", PANGO_WEIGHT_BOLD }, { "weight", (void*)PANGO_WEIGHT_BOLD },
{ "weight-set", TRUE }, { "weight-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
static const GHtmlProperty _ghtml_properties_h5[] = static const GHtmlProperty _ghtml_properties_h5[] =
{ {
{ "font", "Sans 11" }, { "font", "Sans 11" },
{ "weight", PANGO_WEIGHT_BOLD }, { "weight", (void*)PANGO_WEIGHT_BOLD },
{ "weight-set", TRUE }, { "weight-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
static const GHtmlProperty _ghtml_properties_h6[] = static const GHtmlProperty _ghtml_properties_h6[] =
{ {
{ "font", "Sans 10" }, { "font", "Sans 10" },
{ "weight", PANGO_WEIGHT_BOLD }, { "weight", (void*)PANGO_WEIGHT_BOLD },
{ "weight-set", TRUE }, { "weight-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
static const GHtmlProperty _ghtml_properties_pre[] = static const GHtmlProperty _ghtml_properties_pre[] =
{ {
{ "family", "Monospace" }, { "family", "Monospace" },
{ "wrap-mode", GTK_WRAP_NONE }, { "wrap-mode", (void*)GTK_WRAP_NONE },
{ "wrap-mode-set", TRUE }, { "wrap-mode-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
static const GHtmlProperty _ghtml_properties_tt[] = static const GHtmlProperty _ghtml_properties_tt[] =
{ {
{ "family", "Monospace" }, { "family", "Monospace" },
{ NULL, 0 } { NULL, NULL }
}; };
static const GHtmlProperty _ghtml_properties_u[] = static const GHtmlProperty _ghtml_properties_u[] =
{ {
{ "underline", PANGO_UNDERLINE_SINGLE }, { "underline", (void*)PANGO_UNDERLINE_SINGLE },
{ "underline-set", TRUE }, { "underline-set", (void*)TRUE },
{ NULL, 0 } { NULL, NULL }
}; };
/* tags */ /* tags */
@ -405,18 +405,30 @@ static gboolean _find_match(GHtml * ghtml, char const * buf, char const * str,
/* ghtml_go_back */ /* ghtml_go_back */
gboolean ghtml_go_back(GtkWidget * ghtml) gboolean ghtml_go_back(GtkWidget * widget)
{ {
/* FIXME implement */ GHtml * ghtml;
return FALSE;
ghtml = g_object_get_data(G_OBJECT(widget), "ghtml");
if(ghtml->current == NULL || ghtml->current->prev == NULL)
return FALSE;
ghtml->current = ghtml->current->prev;
ghtml_load_url(widget, _history_get_location(ghtml->current));
return TRUE;
} }
/* ghtml_go_forward */ /* ghtml_go_forward */
gboolean ghtml_go_forward(GtkWidget * ghtml) gboolean ghtml_go_forward(GtkWidget * widget)
{ {
/* FIXME implement */ GHtml * ghtml;
return FALSE;
ghtml = g_object_get_data(G_OBJECT(widget), "ghtml");
if(ghtml->current == NULL || ghtml->current->next == NULL)
return FALSE;
ghtml->current = ghtml->current->next;
ghtml_load_url(widget, _history_get_location(ghtml->current));
return TRUE;
} }
@ -529,13 +541,18 @@ static void _document_load_write_node_tag_link(GHtml * ghtml,
static int _ghtml_document_load(GHtml * ghtml, char const * url, static int _ghtml_document_load(GHtml * ghtml, char const * url,
char const * post) char const * post)
{ {
char const * q;
History * h; History * h;
_ghtml_stop(ghtml); _ghtml_stop(ghtml);
if((h = _history_new(url, post)) == NULL) if((q = _history_get_location(ghtml->current)) == NULL
return 1; || strcmp(q, url) != 0)
ghtml->history = g_list_append(ghtml->history, h); {
ghtml->current = g_list_last(ghtml->history); if((h = _history_new(url, post)) == NULL)
return 1;
ghtml->current = _history_append(h, ghtml->current);
ghtml->history = g_list_first(ghtml->current);
}
gtk_text_buffer_set_text(ghtml->tbuffer, "", 0); gtk_text_buffer_set_text(ghtml->tbuffer, "", 0);
free(ghtml->buffer); free(ghtml->buffer);
ghtml->buffer = NULL; ghtml->buffer = NULL;