diff options
author | Rob Kendrick <rjek@netsurf-browser.org> | 2006-08-18 11:44:24 +0000 |
---|---|---|
committer | Rob Kendrick <rjek@netsurf-browser.org> | 2006-08-18 11:44:24 +0000 |
commit | 43bb5b652d0a5c2efda484195a3ef55f17b9cc8b (patch) | |
tree | 3c44b46ce13e23f55cf9e06f15ca45ddd9428b20 | |
parent | a1292c7935dcf0e78e92a37fe3dc6b39a1782c8e (diff) | |
download | netsurf-43bb5b652d0a5c2efda484195a3ef55f17b9cc8b.tar.gz netsurf-43bb5b652d0a5c2efda484195a3ef55f17b9cc8b.tar.bz2 |
Very simple global history implementation for nsgtk, misc fixes
svn path=/trunk/netsurf/; revision=2867
-rw-r--r-- | gtk/gtk_gui.c | 5 | ||||
-rw-r--r-- | gtk/gtk_history.c | 149 | ||||
-rw-r--r-- | gtk/gtk_history.h | 20 | ||||
-rw-r--r-- | gtk/gtk_window.c | 11 | ||||
-rw-r--r-- | gtk/netsurf.glade | 303 | ||||
-rw-r--r-- | makefile | 5 |
6 files changed, 487 insertions, 6 deletions
diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c index 1abdba87f..eb756b8fb 100644 --- a/gtk/gtk_gui.c +++ b/gtk/gtk_gui.c @@ -31,6 +31,7 @@ #include "netsurf/gtk/gtk_completion.h" #include "netsurf/gtk/options.h" #include "netsurf/gtk/gtk_throbber.h" +#include "netsurf/gtk/gtk_history.h" #include "netsurf/render/box.h" #include "netsurf/render/form.h" #include "netsurf/render/html.h" @@ -157,6 +158,8 @@ void gui_init(int argc, char** argv) urldb_load(option_url_file); urldb_load_cookies(option_cookie_file); + + nsgtk_history_init(); } @@ -309,8 +312,6 @@ void hotlist_visited(struct content *content) void gui_cert_verify(struct browser_window *bw, struct content *c, const struct ssl_cert_info *certs, unsigned long num) {} -void global_history_add(const char *url) {} - utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len, char **result) { diff --git a/gtk/gtk_history.c b/gtk/gtk_history.c new file mode 100644 index 000000000..a93192408 --- /dev/null +++ b/gtk/gtk_history.c @@ -0,0 +1,149 @@ +/* + * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * Licensed under the GNU General Public License, + * http://www.opensource.org/licenses/gpl-license + * Copyright 2006 Rob Kendrick <rjek@rjek.com> + */ + +#include <gtk/gtk.h> +#include <glade/glade.h> +#include "netsurf/utils/log.h" +#include "netsurf/content/urldb.h" +#include "netsurf/gtk/gtk_history.h" +#include "netsurf/gtk/gtk_gui.h" + +enum +{ + COL_TITLE = 0, + COL_ADDRESS, + COL_LASTVISIT, + COL_TOTALVISITS, + COL_THUMBNAIL, + COL_NCOLS +}; + +GtkWindow *wndHistory; +static GtkTreeView *treeview; +static GtkTreeStore *history_tree; +static GtkTreeSelection *selection; + +static bool nsgtk_history_add_internal(const char *, const struct url_data *); +static void nsgtk_history_selection_changed(GtkTreeSelection *, gpointer); + +void nsgtk_history_init(void) +{ + GtkCellRenderer *renderer; + + wndHistory = GTK_WINDOW(glade_xml_get_widget(gladeWindows, + "wndHistory")); + treeview = GTK_TREE_VIEW(glade_xml_get_widget(gladeWindows, + "treeHistory")); + history_tree = gtk_tree_store_new(COL_NCOLS, + G_TYPE_STRING, /* title */ + G_TYPE_STRING, /* address */ + G_TYPE_STRING, /* last visit */ + G_TYPE_INT, /* nr. visits */ + GDK_TYPE_PIXBUF); /* thumbnail */ + + selection = gtk_tree_view_get_selection(treeview); + gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); + g_signal_connect(G_OBJECT(selection), "changed", + G_CALLBACK(nsgtk_history_selection_changed), NULL); + + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_insert_column_with_attributes(treeview, -1, "Title", + renderer, + "text", + COL_TITLE, + NULL); + + gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(history_tree)); + + nsgtk_history_update(); +} + +void nsgtk_history_update(void) +{ + gtk_tree_store_clear(history_tree); + urldb_iterate_entries(nsgtk_history_add_internal); +} + +bool nsgtk_history_add_internal(const char *url, const struct url_data *data) +{ + GtkTreeIter iter; + + if (data->visits > 0) + { + gtk_tree_store_append(history_tree, &iter, NULL); + gtk_tree_store_set(history_tree, &iter, + COL_TITLE, data->title, + COL_ADDRESS, url, + COL_LASTVISIT, "Unknown", + COL_TOTALVISITS, data->visits, + -1); + } + + return true; +} + +void nsgtk_history_selection_changed(GtkTreeSelection *treesel, gpointer g) +{ + GtkTreeIter iter; + + if (gtk_tree_selection_get_selected(treesel, &history_tree, &iter)) + { + gchar *b; + gint i; + char buf[20]; + + gtk_tree_model_get(history_tree, &iter, COL_ADDRESS, &b, -1); + gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(gladeWindows, + "labelHistoryAddress")), b); + + gtk_tree_model_get(history_tree, &iter, COL_LASTVISIT, &b, -1); + gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(gladeWindows, + "labelHistoryLastVisit")), b); + + gtk_tree_model_get(history_tree, &iter, COL_TOTALVISITS, + &i, -1); + snprintf(buf, 20, "%d", i); + gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(gladeWindows, + "labelHistoryVisits")), buf); + + + + } + else + { + + } +} + +void nsgtk_history_row_activated(GtkTreeView *tv, GtkTreePath *path, + GtkTreeViewColumn *column, gpointer g) +{ + GtkTreeModel *model; + GtkTreeIter iter; + + model = gtk_tree_view_get_model(tv); + if (gtk_tree_model_get_iter(model, &iter, path)) + { + gchar *b; + + gtk_tree_model_get(model, &iter, COL_ADDRESS, &b, -1); + + browser_window_create((const char *)b, NULL, NULL, true); + } +} + +void global_history_add(const char *url) +{ + const struct url_data *data; + + data = urldb_get_url_data(url); + if (!data) + return; + + nsgtk_history_add_internal(url, data); + +} diff --git a/gtk/gtk_history.h b/gtk/gtk_history.h new file mode 100644 index 000000000..230279b0b --- /dev/null +++ b/gtk/gtk_history.h @@ -0,0 +1,20 @@ +/* + * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * Licensed under the GNU General Public License, + * http://www.opensource.org/licenses/gpl-license + * Copyright 2006 Rob Kendrick <rjek@rjek.com> + */ + +#ifndef __NSGTK_HISTORY_H__ +#define __NSGTK_HISTORY_H__ + +#include <gtk/gtk.h> + +extern GtkWindow *wndHistory; + +void nsgtk_history_init(void); +void nsgtk_history_update(void); +void nsgtk_history_row_activated(GtkTreeView *, GtkTreePath *, + GtkTreeViewColumn *, gpointer); + +#endif /* __NSGTK_HISTORY_H__ */ diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c index 6fe604c38..183497bd7 100644 --- a/gtk/gtk_window.c +++ b/gtk/gtk_window.c @@ -27,6 +27,7 @@ #include "netsurf/gtk/gtk_options.h" #include "netsurf/gtk/gtk_completion.h" #include "netsurf/gtk/gtk_throbber.h" +#include "netsurf/gtk/gtk_history.h" #include "netsurf/render/box.h" #include "netsurf/render/font.h" #include "netsurf/render/form.h" @@ -151,6 +152,7 @@ MENUPROTO(back); MENUPROTO(forward); MENUPROTO(home); MENUPROTO(local_history); +MENUPROTO(global_history); /* help menu */ MENUPROTO(about); @@ -179,6 +181,7 @@ static struct menu_events menu_events[] = { MENUEVENT(forward), MENUEVENT(home), MENUEVENT(local_history), + MENUEVENT(global_history), /* help menu */ MENUEVENT(about), @@ -609,6 +612,14 @@ MENUHANDLER(local_history) return TRUE; } +MENUHANDLER(global_history) +{ + gtk_widget_show(GTK_WIDGET(wndHistory)); + gdk_window_raise(GDK_WINDOW(wndHistory)); + + return TRUE; +} + MENUHANDLER(about) { return TRUE; diff --git a/gtk/netsurf.glade b/gtk/netsurf.glade index 9509cbfc0..ae414d478 100644 --- a/gtk/netsurf.glade +++ b/gtk/netsurf.glade @@ -707,9 +707,8 @@ </child> <child> - <widget class="GtkMenuItem" id="global_history1"> + <widget class="GtkMenuItem" id="global_history"> <property name="visible">True</property> - <property name="sensitive">False</property> <property name="tooltip" translatable="yes">Show the history tree for all windows.</property> <property name="label" translatable="yes">_Global history...</property> <property name="use_underline">True</property> @@ -4374,4 +4373,304 @@ Fantasy</property> </child> </widget> +<widget class="GtkWindow" id="wndHistory"> + <property name="width_request">400</property> + <property name="height_request">500</property> + <property name="title" translatable="yes">NetSurf Global History</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_CENTER</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_UTILITY</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <signal name="delete_event" handler="gtk_widget_hide" last_modification_time="Fri, 18 Aug 2006 10:17:39 GMT"/> + + <child> + <widget class="GtkVBox" id="vbox28"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="treeHistory"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">False</property> + <property name="rules_hint">True</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + <signal name="row_activated" handler="nsgtk_history_row_activated" last_modification_time="Fri, 18 Aug 2006 11:33:42 GMT"/> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkExpander" id="expander1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="expanded">True</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkHBox" id="hbox25"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkImage" id="image400"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0</property> + <property name="xpad">5</property> + <property name="ypad">5</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkTable" id="table11"> + <property name="border_width">2</property> + <property name="visible">True</property> + <property name="n_rows">3</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">0</property> + <property name="column_spacing">4</property> + + <child> + <widget class="GtkLabel" id="label117"> + <property name="visible">True</property> + <property name="label" translatable="yes">Address</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label118"> + <property name="visible">True</property> + <property name="label" translatable="yes">Last visited</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label119"> + <property name="visible">True</property> + <property name="label" translatable="yes">Number of visits</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="labelHistoryVisits"> + <property name="visible">True</property> + <property name="label" translatable="yes">2</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_END</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="labelHistoryLastVisit"> + <property name="visible">True</property> + <property name="label" translatable="yes">Fri Aug 09 00:00:00 2006</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_END</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="labelHistoryAddress"> + <property name="visible">True</property> + <property name="label" translatable="yes">http://netsurf.sf.net/</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_MIDDLE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label116"> + <property name="visible">True</property> + <property name="label" translatable="yes">Details</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + </glade-interface> @@ -69,7 +69,8 @@ OBJECTS_GTK += browser.o history_core.o netsurf.o selection.o textinput.o \ OBJECTS_GTK += font_pango.o gtk_bitmap.o gtk_gui.o \ gtk_schedule.o gtk_thumbnail.o gtk_options.o \ gtk_plotters.o gtk_treeview.o gtk_window.o \ - gtk_completion.o gtk_login.o gtk_throbber.o # gtk/ + gtk_completion.o gtk_login.o gtk_throbber.o \ + gtk_history.o # gtk/ OBJDIR_RISCOS = arm-riscos-aof @@ -122,7 +123,7 @@ CFLAGS_NCOS = $(CFLAGS_RISCOS) -Dncos CFLAGS_DEBUG = -std=c9x -D_BSD_SOURCE -DDEBUG_BUILD $(WARNFLAGS) -I.. \ $(PLATFORM_CFLAGS_DEBUG) -g CFLAGS_GTK = -Dnsgtk -std=c9x -D_BSD_SOURCE -D_POSIX_C_SOURCE -Dgtk \ - $(WARNFLAGS) -I.. -g -O2 -Wformat=2 \ + $(WARNFLAGS) -I.. -g -O0 -Wformat=2 \ `pkg-config --cflags libglade-2.0 gtk+-2.0` `xml2-config --cflags` # Stop GCC under Cygwin throwing a fit |