From 2622adaa1fd3a6f24ed3ba527ee132148fd25beb Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 16 May 2012 19:57:43 +0000 Subject: allow netsurf to build with gtk3 svn path=/trunk/netsurf/; revision=13926 --- Makefile.defaults | 3 + gtk/Makefile.target | 35 +- gtk/compat.c | 132 ++ gtk/compat.h | 25 + gtk/cookies.c | 33 +- gtk/dialogs/about.c | 14 +- gtk/dialogs/options.c | 36 +- gtk/dialogs/source.c | 281 ++--- gtk/download.c | 1241 ++++++++++--------- gtk/gui.c | 146 +-- gtk/gui.h | 3 +- gtk/history.c | 43 +- gtk/hotlist.c | 32 +- gtk/login.c | 31 +- gtk/menu.c | 1 - gtk/plotters.h | 1 - gtk/print.c | 6 +- gtk/res/cookies.glade | 174 --- gtk/res/cookies.gtk2.ui | 174 +++ gtk/res/cookies.gtk3.ui | 205 ++++ gtk/res/downloads.glade | 175 --- gtk/res/downloads.gtk2.ui | 175 +++ gtk/res/downloads.gtk3.ui | 175 +++ gtk/res/history.glade | 199 ---- gtk/res/history.gtk2.ui | 242 ++++ gtk/res/history.gtk3.ui | 238 ++++ gtk/res/hotlist.glade | 218 ---- gtk/res/hotlist.gtk2.ui | 217 ++++ gtk/res/hotlist.gtk3.ui | 254 ++++ gtk/res/login.glade | 222 ---- gtk/res/login.gtk2.ui | 223 ++++ gtk/res/login.gtk3.ui | 223 ++++ gtk/res/menu_cursor.png | Bin 0 -> 255 bytes gtk/res/menu_cursor.xbm | 6 + gtk/res/menu_cursor_mask.xbm | 6 + gtk/res/menu_cursor_mask.xpm | 22 + gtk/res/netsurf.glade | 287 ----- gtk/res/netsurf.gtk2.ui | 212 ++++ gtk/res/netsurf.gtk3.ui | 207 ++++ gtk/res/options.glade | 2544 --------------------------------------- gtk/res/options.gtk2.ui | 2417 +++++++++++++++++++++++++++++++++++++ gtk/res/options.gtk3.ui | 2709 ++++++++++++++++++++++++++++++++++++++++++ gtk/res/password.glade | 443 ------- gtk/res/password.gtk2.ui | 415 +++++++ gtk/res/password.gtk3.ui | 415 +++++++ gtk/res/source.glade | 202 ---- gtk/res/source.gtk2.ui | 204 ++++ gtk/res/source.gtk3.ui | 179 +++ gtk/res/ssl.glade | 204 ---- gtk/res/ssl.gtk2.ui | 202 ++++ gtk/res/ssl.gtk3.ui | 202 ++++ gtk/res/tabcontents.gtk2.ui | 75 ++ gtk/res/tabcontents.gtk3.ui | 87 ++ gtk/res/toolbar.glade | 206 ---- gtk/res/toolbar.gtk2.ui | 189 +++ gtk/res/toolbar.gtk3.ui | 189 +++ gtk/res/warning.glade | 79 -- gtk/res/warning.gtk2.ui | 77 ++ gtk/res/warning.gtk3.ui | 77 ++ gtk/scaffolding.c | 98 +- gtk/scaffolding.h | 2 +- gtk/search.c | 5 +- gtk/tabs.c | 20 +- gtk/theme.c | 2 +- gtk/toolbar.c | 48 +- gtk/treeview.c | 138 ++- gtk/window.c | 479 +++++--- image/rsvg.c | 2 +- 68 files changed, 11660 insertions(+), 6166 deletions(-) delete mode 100644 gtk/res/cookies.glade create mode 100644 gtk/res/cookies.gtk2.ui create mode 100644 gtk/res/cookies.gtk3.ui delete mode 100644 gtk/res/downloads.glade create mode 100644 gtk/res/downloads.gtk2.ui create mode 100644 gtk/res/downloads.gtk3.ui delete mode 100644 gtk/res/history.glade create mode 100644 gtk/res/history.gtk2.ui create mode 100644 gtk/res/history.gtk3.ui delete mode 100644 gtk/res/hotlist.glade create mode 100644 gtk/res/hotlist.gtk2.ui create mode 100644 gtk/res/hotlist.gtk3.ui delete mode 100644 gtk/res/login.glade create mode 100644 gtk/res/login.gtk2.ui create mode 100644 gtk/res/login.gtk3.ui create mode 100644 gtk/res/menu_cursor.png create mode 100644 gtk/res/menu_cursor.xbm create mode 100644 gtk/res/menu_cursor_mask.xbm create mode 100644 gtk/res/menu_cursor_mask.xpm delete mode 100644 gtk/res/netsurf.glade create mode 100644 gtk/res/netsurf.gtk2.ui create mode 100644 gtk/res/netsurf.gtk3.ui delete mode 100644 gtk/res/options.glade create mode 100644 gtk/res/options.gtk2.ui create mode 100644 gtk/res/options.gtk3.ui delete mode 100644 gtk/res/password.glade create mode 100644 gtk/res/password.gtk2.ui create mode 100644 gtk/res/password.gtk3.ui delete mode 100644 gtk/res/source.glade create mode 100644 gtk/res/source.gtk2.ui create mode 100644 gtk/res/source.gtk3.ui delete mode 100644 gtk/res/ssl.glade create mode 100644 gtk/res/ssl.gtk2.ui create mode 100644 gtk/res/ssl.gtk3.ui create mode 100644 gtk/res/tabcontents.gtk2.ui create mode 100644 gtk/res/tabcontents.gtk3.ui delete mode 100644 gtk/res/toolbar.glade create mode 100644 gtk/res/toolbar.gtk2.ui create mode 100644 gtk/res/toolbar.gtk3.ui delete mode 100644 gtk/res/warning.glade create mode 100644 gtk/res/warning.gtk2.ui create mode 100644 gtk/res/warning.gtk3.ui diff --git a/Makefile.defaults b/Makefile.defaults index 0ebe04a4c..eda59beac 100644 --- a/Makefile.defaults +++ b/Makefile.defaults @@ -160,6 +160,9 @@ ifeq ($(TARGET),gtk) NETSURF_USE_HARU_PDF := NO endif + # Set default GTK version to build for (2 or 3) + NETSURF_GTK_MAJOR := 2 + # Optimisation levels CFLAGS += -O2 -Wuninitialized diff --git a/gtk/Makefile.target b/gtk/Makefile.target index 71edb64a0..778093837 100644 --- a/gtk/Makefile.target +++ b/gtk/Makefile.target @@ -49,12 +49,12 @@ GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \ -D_NETBSD_SOURCE \ -DGTK_RESPATH=\"$(NETSURF_GTK_RESOURCES)\" \ $(WARNFLAGS) -I. -g \ - $(shell $(PKG_CONFIG) --cflags libglade-2.0 gtk+-2.0) \ + $(shell $(PKG_CONFIG) --cflags gtk+-$(NETSURF_GTK_MAJOR).0) \ $(shell $(PKG_CONFIG) --cflags libhubbub libcurl) \ $(shell $(PKG_CONFIG) --cflags openssl) \ $(shell xml2-config --cflags) -GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 lcms) +GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs gtk+-$(NETSURF_GTK_MAJOR).0 gthread-2.0 gmodule-2.0 lcms) CFLAGS += $(GTKCFLAGS) LDFLAGS += $(GTKLDFLAGS) @@ -67,22 +67,49 @@ ifeq ($(HOST),Windows_NT) CFLAGS += -U__STRICT_ANSI__ endif + +# ---------------------------------------------------------------------------- +# Pixbuf +# ---------------------------------------------------------------------------- + +GTK_IMAGE_menu_cursor := gtk/res/menu_cursor.png + +# 1: input file +# 2: output file +# 3: bitmap name +define convert_image + +S_PIXBUF += $(2) + +$(2): $(1) + $(Q)echo "#include " > $(2) + $(Q)gdk-pixbuf-csource --extern --struct --name=$(3) $(1) >> $(2) || \ + ( rm -f $(2) && false ) + +endef + # ---------------------------------------------------------------------------- # Source file setup # ---------------------------------------------------------------------------- +#converted pixbuf sources +S_PIXBUF := + +$(eval $(foreach V,$(filter GTK_IMAGE_%,$(.VARIABLES)),$(call convert_image,$($(V)),$(OBJROOT)/$(patsubst GTK_IMAGE_%,%,$(V)).c,$(patsubst GTK_IMAGE_%,%,$(V))_pixdata))) + # S_GTK are sources purely for the GTK build S_GTK := font_pango.c bitmap.c gui.c schedule.c thumbnail.c plotters.c \ treeview.c scaffolding.c gdk.c completion.c login.c throbber.c \ selection.c history.c window.c filetype.c download.c menu.c \ print.c save.c search.c tabs.c theme.c toolbar.c \ - sexy_icon_entry.c compat.c cookies.c hotlist.c system_colour.c \ + compat.c cookies.c hotlist.c system_colour.c \ $(addprefix dialogs/,options.c about.c source.c) + S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c) # code in utils/container.ch is non-universal it seems # This is the final source build list # Note this is deliberately *not* expanded here as common and image # are not yet available -SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_GTK) +SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_PIXBUF) $(S_GTK) EXETARGET := nsgtk diff --git a/gtk/compat.c b/gtk/compat.c index 8d8ac698b..191351408 100644 --- a/gtk/compat.c +++ b/gtk/compat.c @@ -20,6 +20,8 @@ * Compatibility functions for older GTK versions (implementation) */ +#include + #include "gtk/compat.h" void nsgtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus) @@ -169,3 +171,133 @@ void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon #endif } + +void nsgtk_widget_override_background_color(GtkWidget *widget, GtkStateFlags state, uint16_t a, uint16_t r, uint16_t g, uint16_t b) +{ +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA colour; + colour.alpha = (double)a / 0xffff; + colour.red = (double)r / 0xffff; + colour.green = (double)g / 0xffff; + colour.blue = (double)b / 0xffff; + gtk_widget_override_background_color(widget, state, &colour); +#else + GdkColor colour; + colour.pixel = a; + colour.red = r; + colour.green = g; + colour.blue = b; + gtk_widget_modify_bg(widget, state, &colour ); +#endif +} + +GtkAdjustment *nsgtk_layout_get_vadjustment(GtkLayout *layout) +{ +#if GTK_CHECK_VERSION(3,0,0) + return gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(layout)); +#else + return gtk_layout_get_vadjustment(layout); +#endif +} + +GtkAdjustment *nsgtk_layout_get_hadjustment(GtkLayout *layout) +{ +#if GTK_CHECK_VERSION(3,0,0) + return gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(layout)); +#else + return gtk_layout_get_hadjustment(layout); +#endif +} + +void nsgtk_layout_set_hadjustment(GtkLayout *layout, GtkAdjustment *adj) +{ +#if GTK_CHECK_VERSION(3,0,0) + gtk_scrollable_set_hadjustment(GTK_SCROLLABLE(layout), adj); +#else + gtk_layout_set_hadjustment(layout, adj); +#endif +} + +void nsgtk_layout_set_vadjustment(GtkLayout *layout, GtkAdjustment *adj) +{ +#if GTK_CHECK_VERSION(3,0,0) + gtk_scrollable_set_vadjustment(GTK_SCROLLABLE(layout), adj); +#else + gtk_layout_set_vadjustment(layout, adj); +#endif +} + +GtkWidget *nsgtk_hbox_new(gboolean homogeneous, gint spacing) +{ +#if GTK_CHECK_VERSION(3,0,0) + return gtk_box_new(GTK_ORIENTATION_HORIZONTAL, spacing); +#else + return gtk_hbox_new(homogeneous, spacing); +#endif +} + +GtkWidget *nsgtk_vbox_new(gboolean homogeneous, gint spacing) +{ +#if GTK_CHECK_VERSION(3,0,0) + return gtk_box_new(GTK_ORIENTATION_VERTICAL, spacing); +#else + return gtk_vbox_new(homogeneous, spacing); +#endif +} + +GtkStateFlags nsgtk_widget_get_state_flags(GtkWidget *widget) +{ +#if GTK_CHECK_VERSION(3,0,0) + return gtk_widget_get_state_flags(widget); +#else + return gtk_widget_get_state(widget); +#endif +} + +GtkStyleContext *nsgtk_widget_get_style_context(GtkWidget *widget) +{ +#if GTK_CHECK_VERSION(3,0,0) + return gtk_widget_get_style_context(widget); +#else + return widget->style; +#endif +} + +const PangoFontDescription* nsgtk_style_context_get_font(GtkStyleContext *style, GtkStateFlags state) +{ +#if GTK_CHECK_VERSION(3,0,0) + return gtk_style_context_get_font(style, state); +#else + return style->font_desc; +#endif +} + +gulong nsgtk_connect_draw_event(GtkWidget *widget, GCallback callback, gpointer g) +{ +#if GTK_CHECK_VERSION(3,0,0) + return g_signal_connect(G_OBJECT(widget), "draw", callback, g); +#else + return g_signal_connect(G_OBJECT(widget), "expose_event", callback, g); +#endif +} + +void nsgdk_cursor_unref(GdkCursor *cursor) +{ +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cursor); +#else + gdk_cursor_unref(cursor); +#endif +} + +void nsgtk_widget_modify_font(GtkWidget *widget, PangoFontDescription *font_desc) +{ +#if GTK_CHECK_VERSION(3,0,0) +/* FIXME */ + return; +#else + gtk_widget_modify_font(widget, font_desc); +#endif +} + + diff --git a/gtk/compat.h b/gtk/compat.h index b8f90e5e4..dea23e1db 100644 --- a/gtk/compat.h +++ b/gtk/compat.h @@ -46,8 +46,33 @@ typedef enum { } GtkEntryIconPosition; #endif +#if GTK_CHECK_VERSION (2, 90, 7) +#define GDK_KEY(symbol) GDK_KEY_##symbol +#else +#include +#define GDK_KEY(symbol) GDK_##symbol +#endif + +#if !GTK_CHECK_VERSION(3,0,0) +typedef GtkStateType GtkStateFlags; +typedef GtkStyle GtkStyleContext; +#endif + GtkWidget *nsgtk_entry_new(void); void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry, GtkEntryIconPosition icon_pos, GdkPixbuf *pixbuf); void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id); +void nsgtk_widget_override_background_color(GtkWidget *widget, GtkStateFlags state, uint16_t a, uint16_t r, uint16_t g, uint16_t b); +GtkAdjustment *nsgtk_layout_get_vadjustment(GtkLayout *layout); +GtkAdjustment *nsgtk_layout_get_hadjustment(GtkLayout *layout); +void nsgtk_layout_set_hadjustment(GtkLayout *layout, GtkAdjustment *adj); +void nsgtk_layout_set_vadjustment(GtkLayout *layout, GtkAdjustment *adj); +GtkWidget* nsgtk_hbox_new(gboolean homogeneous, gint spacing); +GtkWidget* nsgtk_vbox_new(gboolean homogeneous, gint spacing); +GtkStateFlags nsgtk_widget_get_state_flags(GtkWidget *widget); +GtkStyleContext* nsgtk_widget_get_style_context(GtkWidget *widget); +const PangoFontDescription* nsgtk_style_context_get_font(GtkStyleContext *style, GtkStateFlags state); +gulong nsgtk_connect_draw_event(GtkWidget *widget, GCallback callback, gpointer g); +void nsgdk_cursor_unref(GdkCursor *cursor); +void nsgtk_widget_modify_font(GtkWidget *widget, PangoFontDescription *font_desc); #endif /* NETSURF_GTK_COMPAT_H */ diff --git a/gtk/cookies.c b/gtk/cookies.c index 6427a1b06..dd62d568e 100644 --- a/gtk/cookies.c +++ b/gtk/cookies.c @@ -24,6 +24,7 @@ #include "desktop/cookies.h" #include "desktop/plotters.h" #include "desktop/tree.h" +#include "utils/log.h" #include "gtk/gui.h" #include "gtk/cookies.h" #include "gtk/plotters.h" @@ -80,7 +81,7 @@ static struct menu_events menu_events[] = { }; static struct nsgtk_treeview *cookies_window; -static GladeXML *gladeFile; +static GtkBuilder *gladeFile; GtkWindow *wndCookies; /** @@ -92,19 +93,23 @@ bool nsgtk_cookies_init(const char *glade_file_location) GtkScrolledWindow *scrolled; GtkDrawingArea *drawing_area; - gladeFile = glade_xml_new(glade_file_location, NULL, NULL); - if (gladeFile == NULL) + GError* error = NULL; + gladeFile = gtk_builder_new (); + if (!gtk_builder_add_from_file(gladeFile, glade_file_location, &error)) { + g_warning ("Couldn't load builder file: %s", error->message); + g_error_free (error); return false; + } - glade_xml_signal_autoconnect(gladeFile); + gtk_builder_connect_signals(gladeFile, NULL); - wndCookies = GTK_WINDOW(glade_xml_get_widget(gladeFile, "wndCookies")); + wndCookies = GTK_WINDOW(gtk_builder_get_object(gladeFile, "wndCookies")); window = wndCookies; - scrolled = GTK_SCROLLED_WINDOW(glade_xml_get_widget(gladeFile, + scrolled = GTK_SCROLLED_WINDOW(gtk_builder_get_object(gladeFile, "cookiesScrolled")); - drawing_area = GTK_DRAWING_AREA(glade_xml_get_widget(gladeFile, + drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(gladeFile, "cookiesDrawingArea")); cookies_window = nsgtk_treeview_create(cookies_get_tree_flags(), window, @@ -134,12 +139,14 @@ bool nsgtk_cookies_init(const char *glade_file_location) void nsgtk_cookies_init_menu() { struct menu_events *event = menu_events; - - while (event->widget != NULL) - { - GtkWidget *w = glade_xml_get_widget(gladeFile, event->widget); - g_signal_connect(G_OBJECT(w), "activate", event->handler, - cookies_window); + GtkWidget *w; + + while (event->widget != NULL) { + w = GTK_WIDGET(gtk_builder_get_object(gladeFile, event->widget)); + if (w == NULL) { + LOG(("Unable to connect menu widget ""%s""", event->widget)); } else { + g_signal_connect(G_OBJECT(w), "activate", event->handler, cookies_window); + } event++; } } diff --git a/gtk/dialogs/about.c b/gtk/dialogs/about.c index 1f29103ad..c75a9787b 100644 --- a/gtk/dialogs/about.c +++ b/gtk/dialogs/about.c @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +#include + #include "gtk/compat.h" #include "gtk/gui.h" #include "gtk/dialogs/about.h" @@ -55,9 +57,9 @@ void nsgtk_about_dialog_init(GtkWindow *parent, GTK_DIALOG_DESTROY_WITH_PARENT, NULL); - vbox = gtk_vbox_new (FALSE, 8); + vbox = nsgtk_vbox_new(FALSE, 8); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox, TRUE, TRUE, 0); if (pixbufs != NULL) { GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(GDK_PIXBUF(g_list_nth_data(pixbufs, 0))); @@ -101,16 +103,16 @@ void nsgtk_about_dialog_init(GtkWindow *parent, /* Add the credits button */ button = gtk_button_new_from_stock ("Credits"); - gtk_box_pack_end(GTK_BOX (GTK_DIALOG (dialog)->action_area), + gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), button, FALSE, TRUE, 0); - gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE); + gtk_button_box_set_child_secondary (GTK_BUTTON_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), button, TRUE); g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_credits), (gpointer)bw); /* Add the Licence button */ button = gtk_button_new_from_stock ("Licence"); - gtk_box_pack_end(GTK_BOX (GTK_DIALOG (dialog)->action_area), + gtk_box_pack_end(GTK_BOX (GTK_DIALOG(gtk_dialog_get_action_area(GTK_DIALOG(dialog)))), button, FALSE, TRUE, 0); - gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE); + gtk_button_box_set_child_secondary (GTK_BUTTON_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), button, TRUE); g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_licence), (gpointer)bw); diff --git a/gtk/dialogs/options.c b/gtk/dialogs/options.c index 8cf949b31..1d095af97 100644 --- a/gtk/dialogs/options.c +++ b/gtk/dialogs/options.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "desktop/options.h" #include "desktop/print.h" @@ -42,7 +41,7 @@ #include "utils/messages.h" GtkDialog *wndPreferences = NULL; -static GladeXML *gladeFile; +static GtkBuilder *gladeFile; static struct browser_window *current_browser; @@ -128,7 +127,7 @@ DECLARE(setDefaultExportOptions); /* Used when the feature is not implemented yet */ #define FIND_WIDGET(wname) \ do { \ - (wname) = glade_xml_get_widget(gladeFile, #wname); \ + (wname) = GTK_WIDGET(gtk_builder_get_object(gladeFile, #wname)); \ if ((wname) == NULL) \ LOG(("Unable to find widget '%s'!", #wname)); \ } while (0) @@ -140,14 +139,17 @@ DECLARE(setDefaultExportOptions); GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent) { - gladeFile = glade_xml_new(glade_file_location->options, NULL, NULL); - if (gladeFile == NULL) + GError* error = NULL; + gladeFile = gtk_builder_new(); + if (!gtk_builder_add_from_file(gladeFile, glade_file_location->options, &error)) { + g_warning("Couldn't load builder file: %s", error->message); + g_error_free(error); return NULL; + } current_browser = bw; - wndPreferences = GTK_DIALOG(glade_xml_get_widget(gladeFile, - "dlgPreferences")); - gtk_window_set_transient_for (GTK_WINDOW(wndPreferences), parent); + wndPreferences = GTK_DIALOG(gtk_builder_get_object(gladeFile, "dlgPreferences")); + gtk_window_set_transient_for(GTK_WINDOW(wndPreferences), parent); FIND_WIDGET(sourceButtonTab); FIND_WIDGET(sourceButtonWindow); @@ -246,46 +248,46 @@ GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent) #define SET_ENTRY(widget, value) \ do { \ - (widget) = glade_xml_get_widget(gladeFile, #widget); \ + (widget) = GTK_WIDGET(gtk_builder_get_object(gladeFile, #widget)); \ gtk_entry_set_text(GTK_ENTRY((widget)), (value)); \ } while (0) #define SET_SPIN(widget, value) \ do { \ - (widget) = glade_xml_get_widget(gladeFile, #widget); \ + (widget) = GTK_WIDGET(gtk_builder_get_object(gladeFile, #widget)); \ gtk_spin_button_set_value(GTK_SPIN_BUTTON((widget)), (value)); \ } while (0) #define SET_CHECK(widget, value) \ do { \ - (widget) = glade_xml_get_widget(gladeFile, #widget); \ + (widget) = GTK_WIDGET(gtk_builder_get_object(gladeFile, #widget)); \ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((widget)), \ (value)); \ } while (0) #define SET_COMBO(widget, value) \ do { \ - (widget) = glade_xml_get_widget(gladeFile, #widget); \ + (widget) = GTK_WIDGET(gtk_builder_get_object(gladeFile, #widget)); \ gtk_combo_box_set_active(GTK_COMBO_BOX((widget)), (value)); \ } while (0) #define SET_FONT(widget, value) \ do { \ - (widget) = glade_xml_get_widget(gladeFile, #widget); \ + (widget) = GTK_WIDGET(gtk_builder_get_object(gladeFile, #widget)); \ gtk_font_button_set_font_name(GTK_FONT_BUTTON((widget)), \ (value)); \ } while (0) #define SET_FILE_CHOOSER(widget, value) \ do { \ - (widget) = glade_xml_get_widget(gladeFile, #widget); \ + (widget) = GTK_WIDGET(gtk_builder_get_object(gladeFile, #widget)); \ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(\ (widget)), (value)); \ } while (0) #define SET_BUTTON(widget) \ do { \ - (widget) = glade_xml_get_widget(gladeFile, #widget); \ + (widget) = GTK_WIDGET(gtk_builder_get_object(gladeFile, #widget)); \ } while (0) @@ -329,7 +331,7 @@ void nsgtk_options_load(void) } /* Create combobox */ - box = GTK_BOX(glade_xml_get_widget(gladeFile, "combolanguagevbox")); + box = GTK_BOX(gtk_builder_get_object(gladeFile, "combolanguagevbox")); comboLanguage = nsgtk_combo_box_text_new(); /* Populate combobox from languages file */ @@ -477,7 +479,7 @@ static gboolean on_dialog_close (GtkDialog *dlg, gboolean stay_alive) static void nsgtk_options_theme_combo(void) { /* populate theme combo from themelist file */ - GtkBox *box = GTK_BOX(glade_xml_get_widget(gladeFile, "themehbox")); + GtkBox *box = GTK_BOX(gtk_builder_get_object(gladeFile, "themehbox")); char buf[50]; size_t len = SLEN("themelist") + strlen(res_dir_location) + 1; char themefile[len]; diff --git a/gtk/dialogs/source.c b/gtk/dialogs/source.c index 5fbd9bcd5..a364b3804 100644 --- a/gtk/dialogs/source.c +++ b/gtk/dialogs/source.c @@ -16,13 +16,14 @@ * along with this program. If not, see . */ +#include #include #include #include #include #include -#include +#include "gtk/compat.h" #include "gtk/dialogs/source.h" #include "gtk/dialogs/about.h" #include "gtk/window.h" @@ -36,6 +37,7 @@ #include "utils/url.h" #include "utils/utils.h" #include "utils/utf8.h" +#include "render/html.h" #include "render/font.h" #include "content/content.h" #include "content/content_type.h" @@ -58,17 +60,11 @@ struct menu_events { GCallback handler; }; -static GladeXML *glade_File; +static GtkBuilder *glade_File; static struct nsgtk_source_window *nsgtk_source_list = 0; static char source_zoomlevel = 10; void nsgtk_source_tab_init(GtkWindow *parent, struct browser_window *bw); -static void nsgtk_attach_source_menu_handlers(GladeXML *xml, gpointer g); -static gboolean nsgtk_source_delete_event(GtkWindow *window, gpointer g); -static gboolean nsgtk_source_destroy_event(GtkWindow *window, gpointer g); -static void nsgtk_source_update_zoomlevel(gpointer g); -static void nsgtk_source_file_save(GtkWindow *parent, const char *filename, - const char *data); #define MENUEVENT(x) { #x, G_CALLBACK(nsgtk_on_##x##_activate) } #define MENUPROTO(x) static gboolean nsgtk_on_##x##_activate( \ @@ -103,9 +99,45 @@ MENUEVENT(source_about), {NULL, NULL} }; +static void nsgtk_attach_source_menu_handlers(GtkBuilder *xml, gpointer g) +{ + struct menu_events *event = source_menu_events; + + while (event->widget != NULL) + { + GtkWidget *w = GTK_WIDGET(gtk_builder_get_object(xml, event->widget)); + g_signal_connect(G_OBJECT(w), "activate", event->handler, g); + event++; + } +} + +static gboolean nsgtk_source_destroy_event(GtkBuilder *window, gpointer g) +{ + struct nsgtk_source_window *nsg = (struct nsgtk_source_window *) g; + + if (nsg->next != NULL) + nsg->next->prev = nsg->prev; + + if (nsg->prev != NULL) + nsg->prev->next = nsg->next; + else + nsgtk_source_list = nsg->next; + + free(nsg->data); + free(nsg->url); + free(g); + + return FALSE; +} + +static gboolean nsgtk_source_delete_event(GtkWindow * window, gpointer g) +{ + return FALSE; +} + void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw) { - char glade_Location[strlen(res_dir_location) + SLEN("source.glade") + char glade_Location[strlen(res_dir_location) + SLEN("source.gtk2.ui") + 1]; if (content_get_type(bw->current_content) != CONTENT_HTML) return; @@ -115,12 +147,18 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw) return; } - sprintf(glade_Location, "%ssource.glade", res_dir_location); - glade_File = glade_xml_new(glade_Location, NULL, NULL); - if (glade_File == NULL) { + sprintf(glade_Location, "%ssource.gtk2.ui", res_dir_location); + + GError* error = NULL; + glade_File = gtk_builder_new(); + if (!gtk_builder_add_from_file(glade_File, glade_Location, &error)) { + g_warning ("Couldn't load builder file: %s", error->message); + g_error_free (error); LOG(("error loading glade tree")); + return; } + const char *source_data; unsigned long source_size; char *data = NULL; @@ -141,16 +179,16 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw) return; } - GtkWindow *wndSource = GTK_WINDOW(glade_xml_get_widget( + GtkWindow *wndSource = GTK_WINDOW(gtk_builder_get_object( glade_File, "wndSource")); - GtkWidget *cutbutton = glade_xml_get_widget( - glade_File, "source_cut"); - GtkWidget *pastebutton = glade_xml_get_widget( - glade_File, "source_paste"); - GtkWidget *deletebutton = glade_xml_get_widget( - glade_File, "source_delete"); - GtkWidget *printbutton = glade_xml_get_widget( - glade_File, "source_print"); + GtkWidget *cutbutton = GTK_WIDGET(gtk_builder_get_object( + glade_File, "source_cut")); + GtkWidget *pastebutton = GTK_WIDGET(gtk_builder_get_object( + glade_File, "source_paste")); + GtkWidget *deletebutton = GTK_WIDGET(gtk_builder_get_object( + glade_File, "source_delete")); + GtkWidget *printbutton = GTK_WIDGET(gtk_builder_get_object( + glade_File, "source_print")); gtk_widget_set_sensitive(cutbutton, FALSE); gtk_widget_set_sensitive(pastebutton, FALSE); gtk_widget_set_sensitive(deletebutton, FALSE); @@ -200,13 +238,15 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw) thiswindow); GtkTextView *sourceview = GTK_TEXT_VIEW( - glade_xml_get_widget(glade_File, + gtk_builder_get_object(glade_File, "source_view")); + PangoFontDescription *fontdesc = pango_font_description_from_string("Monospace 8"); thiswindow->gv = sourceview; - gtk_widget_modify_font(GTK_WIDGET(sourceview), fontdesc); + nsgtk_widget_modify_font(GTK_WIDGET(sourceview), fontdesc); + GtkTextBuffer *tb = gtk_text_view_get_buffer(sourceview); gtk_text_buffer_set_text(tb, thiswindow->data, -1); @@ -262,59 +302,7 @@ void nsgtk_source_tab_init(GtkWindow *parent, struct browser_window *bw) free(fileurl); } - -void nsgtk_attach_source_menu_handlers(GladeXML *xml, gpointer g) -{ - struct menu_events *event = source_menu_events; - - while (event->widget != NULL) - { - GtkWidget *w = glade_xml_get_widget(xml, event->widget); - g_signal_connect(G_OBJECT(w), "activate", event->handler, g); - event++; - } -} - -gboolean nsgtk_on_source_save_as_activate(GtkMenuItem *widget, gpointer g) -{ - struct nsgtk_source_window *nsg = (struct nsgtk_source_window *) g; - GtkWidget *fc = gtk_file_chooser_dialog_new( - messages_get("gtkSourceSave"), - nsg->sourcewindow, - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, - GTK_RESPONSE_ACCEPT, - NULL); - char *filename; - url_func_result res; - - res = url_nice(nsg->url, &filename, false); - if (res != URL_FUNC_OK) { - filename = strdup(messages_get("SaveSource")); - if (filename == NULL) { - warn_user("NoMemory", 0); - return FALSE; - } - } - - gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), filename); - - free(filename); - - if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT) { - filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc)); - nsgtk_source_file_save(nsg->sourcewindow, filename, nsg->data); - g_free(filename); - } - - gtk_widget_destroy(fc); - - return TRUE; -} - -void nsgtk_source_file_save(GtkWindow *parent, const char *filename, +static void nsgtk_source_file_save(GtkWindow *parent, const char *filename, const char *data) { FILE *f; @@ -344,7 +332,7 @@ void nsgtk_source_file_save(GtkWindow *parent, const char *filename, warn[len] = '\0'; label = gtk_label_new(warn); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(confd)->vbox), + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(confd))), label); gtk_widget_show(label); if (gtk_dialog_run(GTK_DIALOG(confd)) == GTK_RESPONSE_ACCEPT) { @@ -372,10 +360,51 @@ void nsgtk_source_file_save(GtkWindow *parent, const char *filename, g_signal_connect_swapped(notif, "response", G_CALLBACK(gtk_widget_destroy), notif); label = gtk_label_new(temp); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(notif)->vbox), label); + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(notif))), label); gtk_widget_show_all(notif); } + +gboolean nsgtk_on_source_save_as_activate(GtkMenuItem *widget, gpointer g) +{ + struct nsgtk_source_window *nsg = (struct nsgtk_source_window *) g; + GtkWidget *fc = gtk_file_chooser_dialog_new( + messages_get("gtkSourceSave"), + nsg->sourcewindow, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, + GTK_RESPONSE_ACCEPT, + NULL); + char *filename; + url_func_result res; + + res = url_nice(nsg->url, &filename, false); + if (res != URL_FUNC_OK) { + filename = strdup(messages_get("SaveSource")); + if (filename == NULL) { + warn_user("NoMemory", 0); + return FALSE; + } + } + + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), filename); + + free(filename); + + if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT) { + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc)); + nsgtk_source_file_save(nsg->sourcewindow, filename, nsg->data); + g_free(filename); + } + + gtk_widget_destroy(fc); + + return TRUE; +} + + gboolean nsgtk_on_source_print_activate( GtkMenuItem *widget, gpointer g) { /* correct printing */ @@ -392,29 +421,7 @@ gboolean nsgtk_on_source_close_activate( GtkMenuItem *widget, gpointer g) return TRUE; } -gboolean nsgtk_source_delete_event(GtkWindow * window, gpointer g) -{ - return FALSE; -} - -gboolean nsgtk_source_destroy_event(GtkWindow * window, gpointer g) -{ - struct nsgtk_source_window *nsg = (struct nsgtk_source_window *) g; - - if (nsg->next != NULL) - nsg->next->prev = nsg->prev; - - if (nsg->prev != NULL) - nsg->prev->next = nsg->next; - else - nsgtk_source_list = nsg->next; - - free(nsg->data); - free(nsg->url); - free(g); - return FALSE; -} gboolean nsgtk_on_source_select_all_activate (GtkMenuItem *widget, gpointer g) { @@ -455,42 +462,7 @@ gboolean nsgtk_on_source_delete_activate(GtkMenuItem *widget, gpointer g) return TRUE; } -gboolean nsgtk_on_source_zoom_in_activate(GtkMenuItem *widget, gpointer g) -{ - source_zoomlevel++; - nsgtk_source_update_zoomlevel(g); - - return TRUE; -} - -gboolean nsgtk_on_source_zoom_out_activate(GtkMenuItem *widget, gpointer g) -{ - if (source_zoomlevel > 1) { - source_zoomlevel--; - nsgtk_source_update_zoomlevel(g); - } - - return TRUE; -} - -gboolean nsgtk_on_source_zoom_normal_activate(GtkMenuItem *widget, gpointer g) -{ - source_zoomlevel = 10; - nsgtk_source_update_zoomlevel(g); - - return TRUE; -} - -gboolean nsgtk_on_source_about_activate(GtkMenuItem *widget, gpointer g) -{ - struct nsgtk_source_window *nsg = (struct nsgtk_source_window *) g; - - nsgtk_about_dialog_init(nsg->sourcewindow, nsg->bw, netsurf_version); - - return TRUE; -} - -void nsgtk_source_update_zoomlevel(gpointer g) +static void nsgtk_source_update_zoomlevel(gpointer g) { struct nsgtk_source_window *nsg; GtkTextBuffer *buf; @@ -527,3 +499,40 @@ void nsgtk_source_update_zoomlevel(gpointer g) nsg = nsg->next; } } + +gboolean nsgtk_on_source_zoom_in_activate(GtkMenuItem *widget, gpointer g) +{ + source_zoomlevel++; + nsgtk_source_update_zoomlevel(g); + + return TRUE; +} + +gboolean nsgtk_on_source_zoom_out_activate(GtkMenuItem *widget, gpointer g) +{ + if (source_zoomlevel > 1) { + source_zoomlevel--; + nsgtk_source_update_zoomlevel(g); + } + + return TRUE; +} + + +gboolean nsgtk_on_source_zoom_normal_activate(GtkMenuItem *widget, gpointer g) +{ + source_zoomlevel = 10; + nsgtk_source_update_zoomlevel(g); + + return TRUE; +} + +gboolean nsgtk_on_source_about_activate(GtkMenuItem *widget, gpointer g) +{ + struct nsgtk_source_window *nsg = (struct nsgtk_source_window *) g; + + nsgtk_about_dialog_init(nsg->sourcewindow, nsg->bw, netsurf_version); + + return TRUE; +} + diff --git a/gtk/download.c b/gtk/download.c index 5e22352b4..71b1aa633 100644 --- a/gtk/download.c +++ b/gtk/download.c @@ -70,7 +70,7 @@ struct gui_download_window { struct download_context *ctx; nsgtk_download_actions sensitivity; nsgtk_download_status status; - + GString *name; GString *time_left; gint size_total; @@ -79,7 +79,7 @@ struct gui_download_window { gfloat time_remaining; gfloat start_time; gfloat speed; - + GtkTreeRowReference *row; GIOChannel *write; GError *error; @@ -96,176 +96,641 @@ static GtkTreeSelection *nsgtk_download_selection; static GtkTreeIter nsgtk_download_iter; static GTimer *nsgtk_downloads_timer; -static GList *nsgtk_downloads_list, *nsgtk_download_buttons; +static GList *nsgtk_downloads_list; +static GtkButton *nsgtk_download_button_pause; +static GtkButton *nsgtk_download_button_clear; +static GtkButton *nsgtk_download_button_cancel; +static GtkButton *nsgtk_download_button_resume; static gint nsgtk_downloads_num_active; -static const gchar* status_messages[] = { NULL, "gtkWorking", "gtkError", - "gtkComplete", "gtkCanceled" }; +static const gchar* status_messages[] = { NULL, "gtkWorking", "gtkError", + "gtkComplete", "gtkCanceled" }; + + + +static GtkTreeView* nsgtk_download_tree_view_new(GtkBuilder *gladeFile) +{ + GtkTreeView *treeview; + GtkCellRenderer *renderer; + + treeview = GTK_TREE_VIEW(gtk_builder_get_object(gladeFile, "treeDownloads")); + + /* Progress column */ + renderer = gtk_cell_renderer_progress_new(); + gtk_tree_view_insert_column_with_attributes (treeview, -1, + messages_get("gtkProgress"), renderer, "value", + NSGTK_DOWNLOAD_PROGRESS, "pulse", NSGTK_DOWNLOAD_PULSE, + "text", NSGTK_DOWNLOAD_STATUS, NULL); + + /* Information column */ + renderer = gtk_cell_renderer_text_new(); + g_object_set(G_OBJECT(renderer), "wrap-mode", PANGO_WRAP_WORD_CHAR, + "wrap-width", 300, NULL); + gtk_tree_view_insert_column_with_attributes (treeview, -1, + messages_get("gtkDetails"), renderer, "text", + NSGTK_DOWNLOAD_INFO, NULL); + gtk_tree_view_column_set_expand(gtk_tree_view_get_column(treeview, + NSGTK_DOWNLOAD_INFO), TRUE); + + /* Time remaining column */ + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_insert_column_with_attributes (treeview, -1, + messages_get("gtkRemaining"), renderer, "text", + NSGTK_DOWNLOAD_REMAINING, NULL); + + /* Speed column */ + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_insert_column_with_attributes (treeview, -1, + messages_get("gtkSpeed"), renderer, "text", + NSGTK_DOWNLOAD_SPEED, NULL); + + return treeview; +} + +static gint +nsgtk_download_sort(GtkTreeModel *model, + GtkTreeIter *a, + GtkTreeIter *b, + gpointer userdata) +{ + struct gui_download_window *dl1, *dl2; + + gtk_tree_model_get(model, a, NSGTK_DOWNLOAD, &dl1, -1); + gtk_tree_model_get(model, b, NSGTK_DOWNLOAD, &dl2, -1); + + return dl1->status - dl2->status; +} + +static void +nsgtk_download_sensitivity_update_buttons(nsgtk_download_actions sensitivity) +{ + /* Glade seems to pack the buttons in an arbitrary order */ + enum { PAUSE_BUTTON, CLEAR_BUTTON, CANCEL_BUTTON, RESUME_BUTTON }; + + gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_download_button_pause), + sensitivity & NSGTK_DOWNLOAD_PAUSE); + gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_download_button_clear), + sensitivity & NSGTK_DOWNLOAD_CLEAR); + gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_download_button_cancel), + sensitivity & NSGTK_DOWNLOAD_CANCEL); + gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_download_button_resume), + sensitivity & NSGTK_DOWNLOAD_RESUME); +} + +static void nsgtk_download_sensitivity_evaluate(GtkTreeSelection *selection) +{ + GtkTreeIter iter; + GList *rows; + gboolean selected = gtk_tree_selection_count_selected_rows(selection); + GtkTreeModel *model = GTK_TREE_MODEL(nsgtk_download_store); + nsgtk_download_actions sensitivity = 0; + struct gui_download_window *dl; + + if (selected) { + rows = gtk_tree_selection_get_selected_rows(selection, &model); + while (rows != NULL) { + gtk_tree_model_get_iter(model, &iter, + (GtkTreePath*)rows->data); + gtk_tree_model_get(model, &iter, NSGTK_DOWNLOAD, + &dl, -1); + sensitivity |= dl->sensitivity; + rows = rows->next; + } + } else { + rows = nsgtk_downloads_list; + while (rows != NULL) { + dl = rows->data; + sensitivity |= (dl->sensitivity & NSGTK_DOWNLOAD_CLEAR); + rows = rows->next; + } + } + + + nsgtk_download_sensitivity_update_buttons(sensitivity); +} + +static void nsgtk_download_do(nsgtk_download_selection_action action) +{ + GList *rows, *dls = NULL; + GtkTreeModel *model = GTK_TREE_MODEL(nsgtk_download_store); + gboolean selection_exists = gtk_tree_selection_count_selected_rows( + nsgtk_download_selection); + + if (selection_exists) { + rows = gtk_tree_selection_get_selected_rows( + nsgtk_download_selection, &model); + while (rows != NULL) { + struct gui_download_window *dl; + gtk_tree_model_get_iter(GTK_TREE_MODEL( + nsgtk_download_store), + &nsgtk_download_iter, + (GtkTreePath*)rows->data); + gtk_tree_model_get(GTK_TREE_MODEL(nsgtk_download_store), + &nsgtk_download_iter, NSGTK_DOWNLOAD, + &dl, -1); + dls = g_list_prepend(dls, dl); + + rows = rows->next; + } + g_list_foreach(rows, (GFunc)gtk_tree_path_free, NULL); + g_list_foreach(rows, (GFunc)g_free, NULL); + g_list_free(rows); + } else + dls = g_list_copy(nsgtk_downloads_list); + + g_list_foreach(dls, (GFunc)action, NULL); + g_list_free(dls); +} + +static gchar* nsgtk_download_info_to_string(struct gui_download_window *dl) +{ + gchar *size_info = g_strdup_printf(messages_get("gtkSizeInfo"), + human_friendly_bytesize(dl->size_downloaded), + dl->size_total == 0 ? messages_get("gtkUnknownSize") : + human_friendly_bytesize(dl->size_total)); + + gchar *r; + + if (dl->status != NSGTK_DOWNLOAD_ERROR) + r = g_strdup_printf("%s\n%s", dl->name->str, size_info); + else + r = g_strdup_printf("%s\n%s", dl->name->str, + dl->error->message); + + g_free(size_info); + + return r; +} + +static gchar* nsgtk_download_time_to_string(gint seconds) +{ + gint hours, minutes; + + if (seconds < 0) + return g_strdup("-"); + + hours = seconds / 3600; + seconds -= hours * 3600; + minutes = seconds / 60; + seconds -= minutes * 60; -static gboolean nsgtk_download_hide(GtkWidget *window); + if (hours > 0) + return g_strdup_printf("%u:%02u:%02u", hours, minutes, + seconds); + else + return g_strdup_printf("%u:%02u", minutes, seconds); +} + +static void nsgtk_download_store_update_item (struct gui_download_window *dl) +{ + gchar *info = nsgtk_download_info_to_string(dl); + char *human = human_friendly_bytesize(dl->speed); + char speed[strlen(human) + SLEN("/s") + 1]; + sprintf(speed, "%s/s", human); + gchar *time = nsgtk_download_time_to_string(dl->time_remaining); + gboolean pulse = dl->status == NSGTK_DOWNLOAD_WORKING; + + /* Updates iter (which is needed to set and get data) with the dl row */ + gtk_tree_model_get_iter(GTK_TREE_MODEL(nsgtk_download_store), + &nsgtk_download_iter, + gtk_tree_row_reference_get_path(dl->row)); + + gtk_list_store_set(nsgtk_download_store, &nsgtk_download_iter, + NSGTK_DOWNLOAD_PULSE, pulse ? dl->progress : -1, + NSGTK_DOWNLOAD_PROGRESS, pulse ? 0 : dl->progress, + NSGTK_DOWNLOAD_INFO, info, + NSGTK_DOWNLOAD_SPEED, dl->speed == 0 ? "-" : speed, + NSGTK_DOWNLOAD_REMAINING, time, + NSGTK_DOWNLOAD, dl, + -1); + + g_free(info); + g_free(time); +} + +static gboolean nsgtk_download_update(gboolean force_update) +{ + /* Be sure we need to update */ + if (!nsgtk_widget_get_visible(GTK_WIDGET(nsgtk_download_window))) + return TRUE; + + GList *list; + gchar *text; + gboolean update, pulse_mode = FALSE; + gint downloaded = 0, total = 0, dls = 0; + gfloat percent, elapsed = g_timer_elapsed(nsgtk_downloads_timer, NULL); + nsgtk_downloads_num_active = 0; + + for (list = nsgtk_downloads_list; list != NULL; list = list->next) { + struct gui_download_window *dl = list->data; + update = force_update; + + switch (dl->status) { + case NSGTK_DOWNLOAD_WORKING: + pulse_mode = TRUE; + + case NSGTK_DOWNLOAD_NONE: + dl->speed = dl->size_downloaded / + (elapsed - dl->start_time); + if (dl->status == NSGTK_DOWNLOAD_NONE) { + dl->time_remaining = (dl->size_total - + dl->size_downloaded)/ + dl->speed; + dl->progress = (gfloat) + dl->size_downloaded / + dl->size_total * 100; + } else + dl->progress++; + + nsgtk_downloads_num_active++; + update = TRUE; + + case NSGTK_DOWNLOAD_COMPLETE: + downloaded += dl->size_downloaded; + total += dl->size_total; + dls++; + + default: + ;//Do nothing + + } + if (update) + nsgtk_download_store_update_item(dl); + } + + if (pulse_mode) { + text = g_strdup_printf( + messages_get(nsgtk_downloads_num_active > 1 ? + "gtkProgressBarPulse" : + "gtkProgressBarPulseSingle"), + nsgtk_downloads_num_active); + gtk_progress_bar_pulse(nsgtk_download_progress_bar); + gtk_progress_bar_set_text(nsgtk_download_progress_bar, text); + } else { + percent = total != 0 ? (gfloat)downloaded / total : 0; + text = g_strdup_printf(messages_get("gtkProgressBar"), + floor(percent*100), dls); + gtk_progress_bar_set_fraction(nsgtk_download_progress_bar, + percent); + gtk_progress_bar_set_text(nsgtk_download_progress_bar, text); + } + + g_free(text); + + if (nsgtk_downloads_num_active == 0) + return FALSE; /* Returning FALSE here cancels the g_timeout */ + else + return TRUE; +} + +static void nsgtk_download_store_clear_item(struct gui_download_window *dl) +{ + if (dl->sensitivity & NSGTK_DOWNLOAD_CLEAR) { + nsgtk_downloads_list = g_list_remove(nsgtk_downloads_list, dl); + + gtk_tree_model_get_iter(GTK_TREE_MODEL(nsgtk_download_store), + &nsgtk_download_iter, + gtk_tree_row_reference_get_path(dl->row)); + gtk_list_store_remove(nsgtk_download_store, + &nsgtk_download_iter); + + download_context_destroy(dl->ctx); + g_string_free(dl->name, TRUE); + g_string_free(dl->time_left, TRUE); + g_free(dl); + + nsgtk_download_sensitivity_evaluate(nsgtk_download_selection); + nsgtk_download_update(FALSE); + } +} -static GtkTreeView *nsgtk_download_tree_view_new(GladeXML *gladeFile); static void nsgtk_download_tree_view_row_activated(GtkTreeView *tree, - GtkTreePath *path, GtkTreeViewColumn *column, gpointer data); - -static gint nsgtk_download_sort(GtkTreeModel *model, GtkTreeIter *a, - GtkTreeIter *b, gpointer userdata); -static gboolean nsgtk_download_update(gboolean force_update); -static void nsgtk_download_do(nsgtk_download_selection_action action); - -static void nsgtk_download_store_update_item(struct gui_download_window *dl); -static void nsgtk_download_store_create_item (struct gui_download_window *dl); -static void nsgtk_download_store_clear_item (struct gui_download_window *dl); -static void nsgtk_download_store_cancel_item (struct gui_download_window *dl); - -static void nsgtk_download_sensitivity_evaluate(GtkTreeSelection *selection); -static void nsgtk_download_sensitivity_update_buttons( - nsgtk_download_actions sensitivity); - -static void nsgtk_download_change_sensitivity( - struct gui_download_window *dl, nsgtk_download_actions sens); + GtkTreePath *path, GtkTreeViewColumn *column, gpointer data) +{ + GtkTreeModel *model; + GtkTreeIter iter; + + model = gtk_tree_view_get_model(tree); + + if (gtk_tree_model_get_iter(model, &iter, path)) { + /* TODO: This will be a context action (pause, start, clear) */ + nsgtk_download_do(nsgtk_download_store_clear_item); + } +} + +static void nsgtk_download_change_sensitivity(struct gui_download_window *dl, + nsgtk_download_actions sensitivity) +{ + dl->sensitivity = sensitivity; + nsgtk_download_sensitivity_evaluate(nsgtk_download_selection); +} + static void nsgtk_download_change_status ( - struct gui_download_window *dl, nsgtk_download_status status); + struct gui_download_window *dl, nsgtk_download_status status) +{ + dl->status = status; + if (status != NSGTK_DOWNLOAD_NONE) { + gtk_tree_model_get_iter(GTK_TREE_MODEL(nsgtk_download_store), + &nsgtk_download_iter, + gtk_tree_row_reference_get_path(dl->row)); -static gchar* nsgtk_download_dialog_show (const gchar *filename, - const gchar *domain, const gchar *size); -static gchar* nsgtk_download_info_to_string (struct gui_download_window *dl); -static gchar* nsgtk_download_time_to_string (gint seconds); -static gboolean nsgtk_download_handle_error (GError *error); + gtk_list_store_set(nsgtk_download_store, &nsgtk_download_iter, + NSGTK_DOWNLOAD_STATUS, + messages_get(status_messages[status]), -1); + } +} - +static void nsgtk_download_store_cancel_item (struct gui_download_window *dl) +{ + if (dl->sensitivity & NSGTK_DOWNLOAD_CANCEL) { + dl->speed = 0; + dl->size_downloaded = 0; + dl->progress = 0; + dl->time_remaining = -1; + nsgtk_download_change_sensitivity(dl, NSGTK_DOWNLOAD_CLEAR); + nsgtk_download_change_status(dl, NSGTK_DOWNLOAD_CANCELED); + + download_context_abort(dl->ctx); + + g_unlink(download_context_get_filename(dl->ctx)); + + nsgtk_download_update(TRUE); + } +} + +static gboolean nsgtk_download_hide (GtkWidget *window) +{ + gtk_widget_hide(window); + return TRUE; +} bool nsgtk_download_init(const char *glade_file_location) { - GladeXML *gladeFile; + GError* error = NULL; + GtkBuilder* builder = gtk_builder_new(); - gladeFile = glade_xml_new(glade_file_location, NULL, NULL); - if (gladeFile == NULL) + if (!gtk_builder_add_from_file(builder, glade_file_location, &error)) + { + g_warning("Couldn't load builder file: %s", error->message); + g_error_free(error); return false; + } - nsgtk_download_buttons = - glade_xml_get_widget_prefix(gladeFile, "button"); - nsgtk_download_progress_bar = GTK_PROGRESS_BAR(glade_xml_get_widget( - gladeFile, "progressBar")); - nsgtk_download_window = GTK_WINDOW(glade_xml_get_widget(gladeFile, - "wndDownloads")); + nsgtk_download_button_pause = GTK_BUTTON(gtk_builder_get_object(builder, "buttonPause")); + nsgtk_download_button_clear = GTK_BUTTON(gtk_builder_get_object(builder, "buttonClear")); + nsgtk_download_button_cancel = GTK_BUTTON(gtk_builder_get_object(builder, "buttonCancel")); + nsgtk_download_button_resume = GTK_BUTTON(gtk_builder_get_object(builder, "buttonPlay")); + + nsgtk_download_progress_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "progressBar")); + nsgtk_download_window = GTK_WINDOW(gtk_builder_get_object(builder, "wndDownloads")); nsgtk_download_parent = NULL; - + gtk_window_set_transient_for(GTK_WINDOW(nsgtk_download_window), - nsgtk_download_parent); + nsgtk_download_parent); gtk_window_set_destroy_with_parent(GTK_WINDOW(nsgtk_download_window), - FALSE); - + FALSE); + nsgtk_downloads_timer = g_timer_new(); - - nsgtk_download_tree = nsgtk_download_tree_view_new(gladeFile); - + + nsgtk_download_tree = nsgtk_download_tree_view_new(builder); + nsgtk_download_store = gtk_list_store_new(NSGTK_DOWNLOAD_N_COLUMNS, - G_TYPE_INT, /* % complete */ - G_TYPE_STRING, /* Description */ - G_TYPE_STRING, /* Time remaining */ - G_TYPE_STRING, /* Speed */ - G_TYPE_INT, /* Pulse */ - G_TYPE_STRING, /* Status */ - G_TYPE_POINTER /* Download structure */ - ); - - + G_TYPE_INT, /* % complete */ + G_TYPE_STRING, /* Description */ + G_TYPE_STRING, /* Time remaining */ + G_TYPE_STRING, /* Speed */ + G_TYPE_INT, /* Pulse */ + G_TYPE_STRING, /* Status */ + G_TYPE_POINTER /* Download structure */ + ); + + gtk_tree_view_set_model(nsgtk_download_tree, - GTK_TREE_MODEL(nsgtk_download_store)); - + GTK_TREE_MODEL(nsgtk_download_store)); + gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(nsgtk_download_store), - NSGTK_DOWNLOAD_STATUS, - (GtkTreeIterCompareFunc) nsgtk_download_sort, NULL, NULL); + NSGTK_DOWNLOAD_STATUS, + (GtkTreeIterCompareFunc) nsgtk_download_sort, NULL, NULL); gtk_tree_sortable_set_sort_column_id( - GTK_TREE_SORTABLE(nsgtk_download_store), - NSGTK_DOWNLOAD_STATUS, GTK_SORT_ASCENDING); - + GTK_TREE_SORTABLE(nsgtk_download_store), + NSGTK_DOWNLOAD_STATUS, GTK_SORT_ASCENDING); + g_object_unref(nsgtk_download_store); - - nsgtk_download_selection = - gtk_tree_view_get_selection(nsgtk_download_tree); + + nsgtk_download_selection = + gtk_tree_view_get_selection(nsgtk_download_tree); gtk_tree_selection_set_mode(nsgtk_download_selection, - GTK_SELECTION_MULTIPLE); - - g_signal_connect(G_OBJECT(nsgtk_download_selection), "changed", - G_CALLBACK(nsgtk_download_sensitivity_evaluate), NULL); - g_signal_connect(nsgtk_download_tree, "row-activated", - G_CALLBACK(nsgtk_download_tree_view_row_activated), - NULL); - g_signal_connect_swapped(glade_xml_get_widget(gladeFile, "buttonClear"), - "clicked", G_CALLBACK(nsgtk_download_do), - nsgtk_download_store_clear_item); - g_signal_connect_swapped(glade_xml_get_widget(gladeFile, - "buttonCancel"), "clicked", - G_CALLBACK(nsgtk_download_do), - nsgtk_download_store_cancel_item); - g_signal_connect(G_OBJECT(nsgtk_download_window), "delete-event", - G_CALLBACK(nsgtk_download_hide), NULL); - - return true; + GTK_SELECTION_MULTIPLE); + + g_signal_connect(G_OBJECT(nsgtk_download_selection), "changed", + G_CALLBACK(nsgtk_download_sensitivity_evaluate), NULL); + g_signal_connect(nsgtk_download_tree, "row-activated", + G_CALLBACK(nsgtk_download_tree_view_row_activated), + NULL); + g_signal_connect_swapped(gtk_builder_get_object(builder, "buttonClear"), + "clicked", + G_CALLBACK(nsgtk_download_do), + nsgtk_download_store_clear_item); + g_signal_connect_swapped(gtk_builder_get_object(builder, "buttonCancel"), + "clicked", + G_CALLBACK(nsgtk_download_do), + nsgtk_download_store_cancel_item); + g_signal_connect(G_OBJECT(nsgtk_download_window), "delete-event", + G_CALLBACK(nsgtk_download_hide), NULL); + + return true; +} + +void nsgtk_download_destroy () +{ + nsgtk_download_do(nsgtk_download_store_cancel_item); +} + +bool nsgtk_check_for_downloads (GtkWindow *parent) +{ + if (nsgtk_downloads_num_active != 0) { + GtkWidget *dialog; + dialog = gtk_message_dialog_new_with_markup(parent, + GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, + GTK_BUTTONS_NONE, + "%s\n\n" + "%s", messages_get("gtkQuit"), + messages_get("gtkDownloadsRunning")); + gtk_dialog_add_buttons(GTK_DIALOG(dialog), "gtk-cancel", + GTK_RESPONSE_CANCEL, "gtk-quit", + GTK_RESPONSE_CLOSE, NULL); + + gint response = gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + + if (response == GTK_RESPONSE_CANCEL) + return true; + } + + return false; +} + +void nsgtk_download_show(GtkWindow *parent) +{ + gtk_window_set_transient_for(nsgtk_download_window, + nsgtk_download_parent); + gtk_window_present(nsgtk_download_window); +} + +static gchar* nsgtk_download_dialog_show (const gchar *filename, const gchar *domain, + const gchar *size) +{ + enum { GTK_RESPONSE_DOWNLOAD, GTK_RESPONSE_SAVE_AS }; + GtkWidget *dialog; + char *destination = NULL; + gchar *message = g_strdup(messages_get("gtkStartDownload")); + gchar *info = g_strdup_printf(messages_get("gtkInfo"), filename, + domain, size); + + dialog = gtk_message_dialog_new_with_markup(nsgtk_download_parent, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, + "%s" + "\n\n%s", + message, info); + + gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_SAVE, + GTK_RESPONSE_DOWNLOAD, GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE_AS, + GTK_RESPONSE_SAVE_AS, NULL); + + gint result = gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + g_free(message); + g_free(info); + + switch (result) { + case GTK_RESPONSE_SAVE_AS: { + dialog = gtk_file_chooser_dialog_new + (messages_get("gtkSave"), + nsgtk_download_parent, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + NULL); + gtk_file_chooser_set_current_name + (GTK_FILE_CHOOSER(dialog), filename); + gtk_file_chooser_set_current_folder + (GTK_FILE_CHOOSER(dialog), + nsoption_charp(downloads_directory)); + gtk_file_chooser_set_do_overwrite_confirmation + (GTK_FILE_CHOOSER(dialog), + nsoption_bool(request_overwrite)); + + gint result = gtk_dialog_run(GTK_DIALOG(dialog)); + if (result == GTK_RESPONSE_ACCEPT) + destination = gtk_file_chooser_get_filename + (GTK_FILE_CHOOSER(dialog)); + gtk_widget_destroy(dialog); + break; + } + case GTK_RESPONSE_DOWNLOAD: { + destination = malloc(strlen(nsoption_charp(downloads_directory)) + + strlen(filename) + SLEN("/") + 1); + if (destination == NULL) { + warn_user(messages_get("NoMemory"), 0); + break; + } + sprintf(destination, "%s/%s", + nsoption_charp(downloads_directory), filename); + /* Test if file already exists and display overwrite + * confirmation if needed */ + if (g_file_test(destination, G_FILE_TEST_EXISTS) && + nsoption_bool(request_overwrite)) { + message = g_strdup_printf(messages_get( + "gtkOverwrite"), filename); + info = g_strdup_printf(messages_get( + "gtkOverwriteInfo"), + nsoption_charp(downloads_directory)); + + dialog = gtk_message_dialog_new_with_markup( + nsgtk_download_parent, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_CANCEL, + "%s",message); + gtk_message_dialog_format_secondary_markup( + GTK_MESSAGE_DIALOG(dialog), + "%s", info); + + GtkWidget *button = gtk_dialog_add_button( + GTK_DIALOG(dialog), + "_Replace", + GTK_RESPONSE_DOWNLOAD); + gtk_button_set_image(GTK_BUTTON(button), + gtk_image_new_from_stock( + "gtk-save", + GTK_ICON_SIZE_BUTTON)); + + gint result = gtk_dialog_run(GTK_DIALOG( + dialog)); + if (result == GTK_RESPONSE_CANCEL) + destination = NULL; + + gtk_widget_destroy(dialog); + g_free(message); + g_free(info); + } + break; + } + } + return destination; } -void nsgtk_download_destroy () -{ - nsgtk_download_do(nsgtk_download_store_cancel_item); -} -bool nsgtk_check_for_downloads (GtkWindow *parent) +static gboolean nsgtk_download_handle_error (GError *error) { - if (nsgtk_downloads_num_active != 0) { - GtkWidget *dialog; - dialog = gtk_message_dialog_new_with_markup(parent, - GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, - GTK_BUTTONS_NONE, - "%s\n\n" - "%s", messages_get("gtkQuit"), - messages_get("gtkDownloadsRunning")); - gtk_dialog_add_buttons(GTK_DIALOG(dialog), "gtk-cancel", - GTK_RESPONSE_CANCEL, "gtk-quit", - GTK_RESPONSE_CLOSE, NULL); - - gint response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (error != NULL) { + GtkWidget*dialog; + gchar *message = g_strdup_printf(messages_get("gtkFileError"), + error->message); + + dialog = gtk_message_dialog_new_with_markup + (nsgtk_download_parent, + GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + "%s\n\n" + "%s", messages_get("gtkFailed"), + message); + + gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); - - if (response == GTK_RESPONSE_CANCEL) - return true; - } - - return false; + return TRUE; + } + return FALSE; } -void nsgtk_download_show(GtkWindow *parent) +static void nsgtk_download_store_create_item (struct gui_download_window *dl) { - gtk_window_set_transient_for(nsgtk_download_window, - nsgtk_download_parent); - gtk_window_present(nsgtk_download_window); -} - -gboolean nsgtk_download_hide (GtkWidget *window) -{ - gtk_widget_hide(window); - return TRUE; + nsgtk_download_store_update_item(dl); + /* The iter has already been updated to this row */ + gtk_list_store_set(nsgtk_download_store, &nsgtk_download_iter, + NSGTK_DOWNLOAD, dl, -1); } struct gui_download_window *gui_download_window_create(download_context *ctx, - struct gui_window *gui) + struct gui_window *gui) { const char *url = download_context_get_url(ctx); unsigned long total_size = download_context_get_total_length(ctx); gchar *domain; gchar *destination; gboolean unknown_size = total_size == 0; - const char *size = (total_size == 0 ? - messages_get("gtkUnknownSize") : - human_friendly_bytesize(total_size)); - - nsgtk_download_parent = - nsgtk_scaffolding_window(nsgtk_get_scaffold(gui)); + const char *size = (total_size == 0 ? + messages_get("gtkUnknownSize") : + human_friendly_bytesize(total_size)); + + nsgtk_download_parent = + nsgtk_scaffolding_window(nsgtk_get_scaffold(gui)); struct gui_download_window *download = malloc(sizeof *download); if (download == NULL) return NULL; - + if (url_host(url, &domain) != URL_FUNC_OK) { domain = g_strdup(messages_get("gtkUnknownHost")); if (domain == NULL) { @@ -273,24 +738,24 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, return NULL; } } - + destination = nsgtk_download_dialog_show( - download_context_get_filename(ctx), domain, size); + download_context_get_filename(ctx), domain, size); if (destination == NULL) { g_free(domain); free(download); return NULL; } - - /* Add the new row and store the reference to it (which keeps track of + + /* Add the new row and store the reference to it (which keeps track of * the tree changes) */ gtk_list_store_prepend(nsgtk_download_store, &nsgtk_download_iter); download->row = gtk_tree_row_reference_new( + GTK_TREE_MODEL(nsgtk_download_store), + gtk_tree_model_get_path( GTK_TREE_MODEL(nsgtk_download_store), - gtk_tree_model_get_path( - GTK_TREE_MODEL(nsgtk_download_store), - &nsgtk_download_iter)); - + &nsgtk_download_iter)); + download->ctx = ctx; download->name = g_string_new(download_context_get_filename(ctx)); download->time_left = g_string_new(""); @@ -311,44 +776,44 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, free(download); return NULL; } - g_io_channel_set_encoding(download->write, NULL, &download->error); + g_io_channel_set_encoding(download->write, NULL, &download->error); nsgtk_download_change_sensitivity(download, NSGTK_DOWNLOAD_CANCEL); - + nsgtk_download_store_create_item(download); nsgtk_download_show(nsgtk_download_parent); - - if (unknown_size) + + if (unknown_size) nsgtk_download_change_status(download, NSGTK_DOWNLOAD_WORKING); - + if (nsgtk_downloads_num_active == 0) { - g_timeout_add(UPDATE_RATE, - (GSourceFunc) nsgtk_download_update, FALSE); + g_timeout_add(UPDATE_RATE, + (GSourceFunc) nsgtk_download_update, FALSE); } nsgtk_downloads_list = g_list_prepend(nsgtk_downloads_list, download); - - return download; + + return download; } -nserror gui_download_window_data(struct gui_download_window *dw, - const char *data, unsigned int size) +nserror gui_download_window_data(struct gui_download_window *dw, + const char *data, unsigned int size) { g_io_channel_write_chars(dw->write, data, size, NULL, &dw->error); if (dw->error != NULL) { dw->speed = 0; dw->time_remaining = -1; - + nsgtk_download_change_sensitivity(dw, NSGTK_DOWNLOAD_CLEAR); nsgtk_download_change_status(dw, NSGTK_DOWNLOAD_ERROR); - + nsgtk_download_update(TRUE); - + gtk_window_present(nsgtk_download_window); return NSERROR_SAVE_FAILED; - } + } dw->size_downloaded += size; return NSERROR_OK; @@ -356,7 +821,7 @@ nserror gui_download_window_data(struct gui_download_window *dw, void gui_download_window_error(struct gui_download_window *dw, - const char *error_msg) + const char *error_msg) { } @@ -365,14 +830,14 @@ void gui_download_window_done(struct gui_download_window *dw) { g_io_channel_shutdown(dw->write, TRUE, &dw->error); g_io_channel_unref(dw->write); - + dw->speed = 0; dw->time_remaining = -1; dw->progress = 100; dw->size_total = dw->size_downloaded; nsgtk_download_change_sensitivity(dw, NSGTK_DOWNLOAD_CLEAR); nsgtk_download_change_status(dw, NSGTK_DOWNLOAD_COMPLETE); - + if (nsoption_bool(downloads_clear)) nsgtk_download_store_clear_item(dw); else @@ -380,485 +845,17 @@ void gui_download_window_done(struct gui_download_window *dw) } -GtkTreeView* nsgtk_download_tree_view_new(GladeXML *gladeFile) -{ - GtkTreeView *treeview = GTK_TREE_VIEW(glade_xml_get_widget(gladeFile, - "treeDownloads")); - GtkCellRenderer *renderer; - - /* Progress column */ - renderer = gtk_cell_renderer_progress_new(); - gtk_tree_view_insert_column_with_attributes (treeview, -1, - messages_get("gtkProgress"), renderer, "value", - NSGTK_DOWNLOAD_PROGRESS, "pulse", NSGTK_DOWNLOAD_PULSE, - "text", NSGTK_DOWNLOAD_STATUS, NULL); - - /* Information column */ - renderer = gtk_cell_renderer_text_new(); - g_object_set(G_OBJECT(renderer), "wrap-mode", PANGO_WRAP_WORD_CHAR, - "wrap-width", 300, NULL); - gtk_tree_view_insert_column_with_attributes (treeview, -1, - messages_get("gtkDetails"), renderer, "text", - NSGTK_DOWNLOAD_INFO, NULL); - gtk_tree_view_column_set_expand(gtk_tree_view_get_column(treeview, - NSGTK_DOWNLOAD_INFO), TRUE); - - /* Time remaining column */ - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes (treeview, -1, - messages_get("gtkRemaining"), renderer, "text", - NSGTK_DOWNLOAD_REMAINING, NULL); - - /* Speed column */ - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes (treeview, -1, - messages_get("gtkSpeed"), renderer, "text", - NSGTK_DOWNLOAD_SPEED, NULL); - - return treeview; -} - -void nsgtk_download_tree_view_row_activated(GtkTreeView *tree, - GtkTreePath *path, GtkTreeViewColumn *column, gpointer data) -{ - GtkTreeModel *model; - GtkTreeIter iter; - - model = gtk_tree_view_get_model(tree); - - if (gtk_tree_model_get_iter(model, &iter, path)) { - /* TODO: This will be a context action (pause, start, clear) */ - nsgtk_download_do(nsgtk_download_store_clear_item); - } -} - -gint nsgtk_download_sort (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, - gpointer userdata) -{ - struct gui_download_window *dl1, *dl2; - - gtk_tree_model_get(model, a, NSGTK_DOWNLOAD, &dl1, -1); - gtk_tree_model_get(model, b, NSGTK_DOWNLOAD, &dl2, -1); - - return dl1->status - dl2->status; -} - -void nsgtk_download_do(nsgtk_download_selection_action action) -{ - GList *rows, *dls = NULL; - GtkTreeModel *model = GTK_TREE_MODEL(nsgtk_download_store); - gboolean selection_exists = gtk_tree_selection_count_selected_rows( - nsgtk_download_selection); - - if (selection_exists) { - rows = gtk_tree_selection_get_selected_rows( - nsgtk_download_selection, &model); - while (rows != NULL) { - struct gui_download_window *dl; - gtk_tree_model_get_iter(GTK_TREE_MODEL( - nsgtk_download_store), - &nsgtk_download_iter, - (GtkTreePath*)rows->data); - gtk_tree_model_get(GTK_TREE_MODEL(nsgtk_download_store), - &nsgtk_download_iter, NSGTK_DOWNLOAD, - &dl, -1); - dls = g_list_prepend(dls, dl); - - rows = rows->next; - } - g_list_foreach(rows, (GFunc)gtk_tree_path_free, NULL); - g_list_foreach(rows, (GFunc)g_free, NULL); - g_list_free(rows); - } else - dls = g_list_copy(nsgtk_downloads_list); - - g_list_foreach(dls, (GFunc)action, NULL); - g_list_free(dls); -} - -gboolean nsgtk_download_update(gboolean force_update) -{ - /* Be sure we need to update */ - if (!nsgtk_widget_get_visible(GTK_WIDGET(nsgtk_download_window))) - return TRUE; - - GList *list; - gchar *text; - gboolean update, pulse_mode = FALSE; - gint downloaded = 0, total = 0, dls = 0; - gfloat percent, elapsed = g_timer_elapsed(nsgtk_downloads_timer, NULL); - nsgtk_downloads_num_active = 0; - - for (list = nsgtk_downloads_list; list != NULL; list = list->next) { - struct gui_download_window *dl = list->data; - update = force_update; - - switch (dl->status) { - case NSGTK_DOWNLOAD_WORKING: - pulse_mode = TRUE; - - case NSGTK_DOWNLOAD_NONE: - dl->speed = dl->size_downloaded / - (elapsed - dl->start_time); - if (dl->status == NSGTK_DOWNLOAD_NONE) { - dl->time_remaining = (dl->size_total - - dl->size_downloaded)/ - dl->speed; - dl->progress = (gfloat) - dl->size_downloaded / - dl->size_total * 100; - } else - dl->progress++; - - nsgtk_downloads_num_active++; - update = TRUE; - - case NSGTK_DOWNLOAD_COMPLETE: - downloaded += dl->size_downloaded; - total += dl->size_total; - dls++; - - default: - ;//Do nothing - - } - if (update) - nsgtk_download_store_update_item(dl); - } - - if (pulse_mode) { - text = g_strdup_printf( - messages_get(nsgtk_downloads_num_active > 1 ? - "gtkProgressBarPulse" : - "gtkProgressBarPulseSingle"), - nsgtk_downloads_num_active); - gtk_progress_bar_pulse(nsgtk_download_progress_bar); - gtk_progress_bar_set_text(nsgtk_download_progress_bar, text); - } else { - percent = total != 0 ? (gfloat)downloaded / total : 0; - text = g_strdup_printf(messages_get("gtkProgressBar"), - floor(percent*100), dls); - gtk_progress_bar_set_fraction(nsgtk_download_progress_bar, - percent); - gtk_progress_bar_set_text(nsgtk_download_progress_bar, text); - } - - g_free(text); - - if (nsgtk_downloads_num_active == 0) - return FALSE; /* Returning FALSE here cancels the g_timeout */ - else - return TRUE; -} - -void nsgtk_download_store_update_item (struct gui_download_window *dl) -{ - gchar *info = nsgtk_download_info_to_string(dl); - char *human = human_friendly_bytesize(dl->speed); - char speed[strlen(human) + SLEN("/s") + 1]; - sprintf(speed, "%s/s", human); - gchar *time = nsgtk_download_time_to_string(dl->time_remaining); - gboolean pulse = dl->status == NSGTK_DOWNLOAD_WORKING; - - /* Updates iter (which is needed to set and get data) with the dl row */ - gtk_tree_model_get_iter(GTK_TREE_MODEL(nsgtk_download_store), - &nsgtk_download_iter, - gtk_tree_row_reference_get_path(dl->row)); - - gtk_list_store_set(nsgtk_download_store, &nsgtk_download_iter, - NSGTK_DOWNLOAD_PULSE, pulse ? dl->progress : -1, - NSGTK_DOWNLOAD_PROGRESS, pulse ? 0 : dl->progress, - NSGTK_DOWNLOAD_INFO, info, - NSGTK_DOWNLOAD_SPEED, dl->speed == 0 ? "-" : speed, - NSGTK_DOWNLOAD_REMAINING, time, - NSGTK_DOWNLOAD, dl, - -1); - - g_free(info); - g_free(time); -} - -void nsgtk_download_store_create_item (struct gui_download_window *dl) -{ - nsgtk_download_store_update_item(dl); - /* The iter has already been updated to this row */ - gtk_list_store_set(nsgtk_download_store, &nsgtk_download_iter, - NSGTK_DOWNLOAD, dl, -1); -} -void nsgtk_download_store_clear_item (struct gui_download_window *dl) -{ - if (dl->sensitivity & NSGTK_DOWNLOAD_CLEAR) { - nsgtk_downloads_list = g_list_remove(nsgtk_downloads_list, dl); - - gtk_tree_model_get_iter(GTK_TREE_MODEL(nsgtk_download_store), - &nsgtk_download_iter, - gtk_tree_row_reference_get_path(dl->row)); - gtk_list_store_remove(nsgtk_download_store, - &nsgtk_download_iter); - download_context_destroy(dl->ctx); - g_string_free(dl->name, TRUE); - g_string_free(dl->time_left, TRUE); - g_free(dl); - - nsgtk_download_sensitivity_evaluate(nsgtk_download_selection); - nsgtk_download_update(FALSE); - } -} -void nsgtk_download_store_cancel_item (struct gui_download_window *dl) -{ - if (dl->sensitivity & NSGTK_DOWNLOAD_CANCEL) { - dl->speed = 0; - dl->size_downloaded = 0; - dl->progress = 0; - dl->time_remaining = -1; - nsgtk_download_change_sensitivity(dl, NSGTK_DOWNLOAD_CLEAR); - nsgtk_download_change_status(dl, NSGTK_DOWNLOAD_CANCELED); - - download_context_abort(dl->ctx); - - g_unlink(download_context_get_filename(dl->ctx)); - - nsgtk_download_update(TRUE); - } -} -void nsgtk_download_sensitivity_evaluate (GtkTreeSelection *selection) -{ - GtkTreeIter iter; - GList *rows; - gboolean selected = gtk_tree_selection_count_selected_rows(selection); - GtkTreeModel *model = GTK_TREE_MODEL(nsgtk_download_store); - nsgtk_download_actions sensitivity = 0; - struct gui_download_window *dl; - - if (selected) { - rows = gtk_tree_selection_get_selected_rows(selection, &model); - while (rows != NULL) { - gtk_tree_model_get_iter(model, &iter, - (GtkTreePath*)rows->data); - gtk_tree_model_get(model, &iter, NSGTK_DOWNLOAD, - &dl, -1); - sensitivity |= dl->sensitivity; - rows = rows->next; - } - } else { - rows = nsgtk_downloads_list; - while (rows != NULL) { - dl = rows->data; - sensitivity |= (dl->sensitivity & NSGTK_DOWNLOAD_CLEAR); - rows = rows->next; - } - } - - - nsgtk_download_sensitivity_update_buttons(sensitivity); -} -void nsgtk_download_sensitivity_update_buttons( - nsgtk_download_actions sensitivity) -{ - /* Glade seems to pack the buttons in an arbitrary order */ - enum { PAUSE_BUTTON, CLEAR_BUTTON, CANCEL_BUTTON, RESUME_BUTTON }; - - gtk_widget_set_sensitive(g_list_nth_data(nsgtk_download_buttons, - PAUSE_BUTTON), sensitivity & NSGTK_DOWNLOAD_PAUSE); - gtk_widget_set_sensitive(g_list_nth_data(nsgtk_download_buttons, - CLEAR_BUTTON), sensitivity & NSGTK_DOWNLOAD_CLEAR); - gtk_widget_set_sensitive(g_list_nth_data(nsgtk_download_buttons, - CANCEL_BUTTON), sensitivity & NSGTK_DOWNLOAD_CANCEL); - gtk_widget_set_sensitive(g_list_nth_data(nsgtk_download_buttons, - RESUME_BUTTON), sensitivity & NSGTK_DOWNLOAD_RESUME); -} -void nsgtk_download_change_sensitivity(struct gui_download_window *dl, - nsgtk_download_actions sensitivity) -{ - dl->sensitivity = sensitivity; - nsgtk_download_sensitivity_evaluate(nsgtk_download_selection); -} -void nsgtk_download_change_status ( - struct gui_download_window *dl, nsgtk_download_status status) -{ - dl->status = status; - if (status != NSGTK_DOWNLOAD_NONE) { - gtk_tree_model_get_iter(GTK_TREE_MODEL(nsgtk_download_store), - &nsgtk_download_iter, - gtk_tree_row_reference_get_path(dl->row)); - - gtk_list_store_set(nsgtk_download_store, &nsgtk_download_iter, - NSGTK_DOWNLOAD_STATUS, - messages_get(status_messages[status]), -1); - } -} - -gchar* nsgtk_download_dialog_show (const gchar *filename, const gchar *domain, - const gchar *size) -{ - enum { GTK_RESPONSE_DOWNLOAD, GTK_RESPONSE_SAVE_AS }; - GtkWidget *dialog; - char *destination = NULL; - gchar *message = g_strdup(messages_get("gtkStartDownload")); - gchar *info = g_strdup_printf(messages_get("gtkInfo"), filename, - domain, size); - - dialog = gtk_message_dialog_new_with_markup(nsgtk_download_parent, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, - "%s" - "\n\n%s", - message, info); - - gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_SAVE, - GTK_RESPONSE_DOWNLOAD, GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE_AS, - GTK_RESPONSE_SAVE_AS, NULL); - - gint result = gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - g_free(message); - g_free(info); - - switch (result) { - case GTK_RESPONSE_SAVE_AS: { - dialog = gtk_file_chooser_dialog_new - (messages_get("gtkSave"), - nsgtk_download_parent, - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL); - gtk_file_chooser_set_current_name - (GTK_FILE_CHOOSER(dialog), filename); - gtk_file_chooser_set_current_folder - (GTK_FILE_CHOOSER(dialog), - nsoption_charp(downloads_directory)); - gtk_file_chooser_set_do_overwrite_confirmation - (GTK_FILE_CHOOSER(dialog), - nsoption_bool(request_overwrite)); - - gint result = gtk_dialog_run(GTK_DIALOG(dialog)); - if (result == GTK_RESPONSE_ACCEPT) - destination = gtk_file_chooser_get_filename - (GTK_FILE_CHOOSER(dialog)); - gtk_widget_destroy(dialog); - break; - } - case GTK_RESPONSE_DOWNLOAD: { - destination = malloc(strlen(nsoption_charp(downloads_directory)) - + strlen(filename) + SLEN("/") + 1); - if (destination == NULL) { - warn_user(messages_get("NoMemory"), 0); - break; - } - sprintf(destination, "%s/%s", - nsoption_charp(downloads_directory), filename); - /* Test if file already exists and display overwrite - * confirmation if needed */ - if (g_file_test(destination, G_FILE_TEST_EXISTS) && - nsoption_bool(request_overwrite)) { - message = g_strdup_printf(messages_get( - "gtkOverwrite"), filename); - info = g_strdup_printf(messages_get( - "gtkOverwriteInfo"), - nsoption_charp(downloads_directory)); - - dialog = gtk_message_dialog_new_with_markup( - nsgtk_download_parent, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_CANCEL, - "%s",message); - gtk_message_dialog_format_secondary_markup( - GTK_MESSAGE_DIALOG(dialog), - "%s", info); - - GtkWidget *button = gtk_dialog_add_button( - GTK_DIALOG(dialog), - "_Replace", - GTK_RESPONSE_DOWNLOAD); - gtk_button_set_image(GTK_BUTTON(button), - gtk_image_new_from_stock( - "gtk-save", - GTK_ICON_SIZE_BUTTON)); - - gint result = gtk_dialog_run(GTK_DIALOG( - dialog)); - if (result == GTK_RESPONSE_CANCEL) - destination = NULL; - - gtk_widget_destroy(dialog); - g_free(message); - g_free(info); - } - break; - } - } - return destination; -} -gchar* nsgtk_download_info_to_string (struct gui_download_window *dl) -{ - gchar *size_info = g_strdup_printf(messages_get("gtkSizeInfo"), - human_friendly_bytesize(dl->size_downloaded), - dl->size_total == 0 ? messages_get("gtkUnknownSize") : - human_friendly_bytesize(dl->size_total)); - - gchar *r; - if (dl->status != NSGTK_DOWNLOAD_ERROR) - r = g_strdup_printf("%s\n%s", dl->name->str, size_info); - else - r = g_strdup_printf("%s\n%s", dl->name->str, - dl->error->message); - - g_free(size_info); - return r; -} -gchar* nsgtk_download_time_to_string (gint seconds) -{ - gint hours, minutes; - - if (seconds < 0) - return g_strdup("-"); - - hours = seconds / 3600; - seconds -= hours * 3600; - minutes = seconds / 60; - seconds -= minutes * 60; - - if (hours > 0) - return g_strdup_printf("%u:%02u:%02u", hours, minutes, - seconds); - else - return g_strdup_printf("%u:%02u", minutes, seconds); -} -gboolean nsgtk_download_handle_error (GError *error) -{ - if (error != NULL) { - GtkWidget*dialog; - gchar *message = g_strdup_printf(messages_get("gtkFileError"), - error->message); - - dialog = gtk_message_dialog_new_with_markup - (nsgtk_download_parent, - GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - "%s\n\n" - "%s", messages_get("gtkFailed"), - message); - - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - return TRUE; - } - return FALSE; -} diff --git a/gtk/gui.c b/gtk/gui.c index 36a3de888..c7e90aeb1 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -58,6 +57,7 @@ #include "desktop/textinput.h" #include "desktop/tree.h" #include "css/utils.h" +#include "gtk/compat.h" #include "gtk/dialogs/options.h" #include "gtk/completion.h" #include "gtk/cookies.h" @@ -169,14 +169,20 @@ static bool nsgtk_throbber_init(char **respath, int framec) #define NEW_GLADE_ERROR_SIZE 128 static char * -nsgtk_new_glade(char **respath, const char *name, GladeXML **pglade) +nsgtk_new_ui(char **respath, const char *name, GtkBuilder **pglade) { - GladeXML *newglade; + GtkBuilder *builder; + GError* error = NULL; char *filepath; char errorstr[NEW_GLADE_ERROR_SIZE]; char resname[PATH_MAX]; +#if GTK_CHECK_VERSION(3,0,0) + int gtkv = 3; +#else + int gtkv = 2; +#endif - snprintf(resname, PATH_MAX, "%s.glade", name); + snprintf(resname, PATH_MAX, "%s.gtk%d.ui", name, gtkv); filepath = filepath_find(respath, resname); if (filepath == NULL) { @@ -185,19 +191,22 @@ nsgtk_new_glade(char **respath, const char *name, GladeXML **pglade) die(errorstr); } - newglade = glade_xml_new(filepath, NULL, NULL); - if (newglade == NULL) { + builder = gtk_builder_new(); + if (!gtk_builder_add_from_file(builder, filepath, &error)) { + g_warning ("Couldn't load builder file: %s", error->message); + g_error_free (error); snprintf(errorstr, NEW_GLADE_ERROR_SIZE, "Unable to load glade %s window definitions.\n", name); die(errorstr); } - glade_xml_signal_autoconnect(newglade); - LOG(("Using '%s' as %s glade template file", filepath, name)); + gtk_builder_connect_signals(builder, NULL); + + LOG(("Using '%s' as %s ui template file", filepath, name)); if (pglade != NULL) { - *pglade = newglade; + *pglade = builder; } return filepath; @@ -209,29 +218,28 @@ nsgtk_new_glade(char **respath, const char *name, GladeXML **pglade) static void nsgtk_init_glade(char **respath) { - GladeXML *gladeWarning; - - glade_init(); + GtkBuilder *gladeWarning; glade_file_location = calloc(1, sizeof(struct glade_file_location_s)); if (glade_file_location == NULL) { die("Unable to allocate glade file locations"); } - glade_file_location->netsurf = nsgtk_new_glade(respath, "netsurf", NULL); - glade_file_location->password = nsgtk_new_glade(respath, "password", NULL); - glade_file_location->login = nsgtk_new_glade(respath, "login", NULL); - glade_file_location->ssl = nsgtk_new_glade(respath, "ssl", NULL); - glade_file_location->toolbar = nsgtk_new_glade(respath, "toolbar", NULL); - glade_file_location->downloads = nsgtk_new_glade(respath, "downloads", NULL); - glade_file_location->history = nsgtk_new_glade(respath, "history", NULL); - glade_file_location->options = nsgtk_new_glade(respath, "options", NULL); - glade_file_location->hotlist = nsgtk_new_glade(respath, "hotlist", NULL); - glade_file_location->cookies = nsgtk_new_glade(respath, "cookies", NULL); - - glade_file_location->warning = nsgtk_new_glade(respath, "warning", &gladeWarning); - nsgtk_warning_window = GTK_WINDOW(glade_xml_get_widget(gladeWarning, "wndWarning")); - widWarning = glade_xml_get_widget(gladeWarning, "labelWarning"); + glade_file_location->netsurf = nsgtk_new_ui(respath, "netsurf", NULL); + glade_file_location->tabcontents = nsgtk_new_ui(respath, "tabcontents", NULL); + glade_file_location->password = nsgtk_new_ui(respath, "password", NULL); + glade_file_location->login = nsgtk_new_ui(respath, "login", NULL); + glade_file_location->ssl = nsgtk_new_ui(respath, "ssl", NULL); + glade_file_location->toolbar = nsgtk_new_ui(respath, "toolbar", NULL); + glade_file_location->downloads = nsgtk_new_ui(respath, "downloads", NULL); + glade_file_location->history = nsgtk_new_ui(respath, "history", NULL); + glade_file_location->options = nsgtk_new_ui(respath, "options", NULL); + glade_file_location->hotlist = nsgtk_new_ui(respath, "hotlist", NULL); + glade_file_location->cookies = nsgtk_new_ui(respath, "cookies", NULL); + + glade_file_location->warning = nsgtk_new_ui(respath, "warning", &gladeWarning); + nsgtk_warning_window = GTK_WINDOW(gtk_builder_get_object(gladeWarning, "wndWarning")); + widWarning = GTK_WIDGET(gtk_builder_get_object(gladeWarning, "labelWarning")); } static void check_options(char **respath) @@ -701,22 +709,26 @@ void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, { static struct nsgtk_treeview *ssl_window; struct sslcert_session_data *data; - GladeXML *x = glade_xml_new(glade_file_location->ssl, NULL, NULL); GtkButton *accept, *reject; void **session = calloc(sizeof(void *), 3); GtkWindow *window; GtkScrolledWindow *scrolled; GtkDrawingArea *drawing_area; + GError* error = NULL; + GtkBuilder* builder; + + builder = gtk_builder_new (); + if (!gtk_builder_add_from_file(builder, glade_file_location->ssl, &error)) { + g_warning("Couldn't load builder file: %s", error->message); + g_error_free(error); + return; + } data = sslcert_create_session_data(num, url, cb, cbpw); - window = GTK_WINDOW( - glade_xml_get_widget(x,"wndSSLProblem")); - scrolled = GTK_SCROLLED_WINDOW( - glade_xml_get_widget(x,"SSLScrolled")); - drawing_area = GTK_DRAWING_AREA( - glade_xml_get_widget(x,"SSLDrawingArea")); - + window = GTK_WINDOW(gtk_builder_get_object(builder, "wndSSLProblem")); + scrolled = GTK_SCROLLED_WINDOW(gtk_builder_get_object(builder, "SSLScrolled")); + drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(builder, "SSLDrawingArea")); ssl_window = nsgtk_treeview_create(sslcert_get_tree_flags(), window, scrolled, drawing_area); @@ -726,10 +738,10 @@ void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, sslcert_load_tree(nsgtk_treeview_get_tree(ssl_window), certs, data); - accept = GTK_BUTTON(glade_xml_get_widget(x, "sslaccept")); - reject = GTK_BUTTON(glade_xml_get_widget(x, "sslreject")); + accept = GTK_BUTTON(gtk_builder_get_object(builder, "sslaccept")); + reject = GTK_BUTTON(gtk_builder_get_object(builder, "sslreject")); - session[0] = x; + session[0] = builder; session[1] = ssl_window; session[2] = data; @@ -747,7 +759,7 @@ void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, void nsgtk_ssl_accept(GtkButton *w, gpointer data) { void **session = data; - GladeXML *x = session[0]; + GtkBuilder *x = session[0]; struct nsgtk_treeview *wnd = session[1]; struct sslcert_session_data *ssl_data = session[2]; @@ -761,7 +773,7 @@ void nsgtk_ssl_accept(GtkButton *w, gpointer data) void nsgtk_ssl_reject(GtkWidget *w, gpointer data) { void **session = data; - GladeXML *x = session[0]; + GtkBuilder *x = session[0]; struct nsgtk_treeview *wnd = session[1]; struct sslcert_session_data *ssl_data = session[2]; @@ -970,38 +982,38 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key) */ switch (key->keyval) { - case GDK_Tab: + case GDK_KEY(Tab): return KEY_TAB; - case GDK_BackSpace: + case GDK_KEY(BackSpace): if (key->state & GDK_SHIFT_MASK) return KEY_DELETE_LINE_START; else return KEY_DELETE_LEFT; - case GDK_Delete: + case GDK_KEY(Delete): if (key->state & GDK_SHIFT_MASK) return KEY_DELETE_LINE_END; else return KEY_DELETE_RIGHT; - case GDK_Linefeed: return 13; - case GDK_Return: return 10; - case GDK_Left: return KEY_LEFT; - case GDK_Right: return KEY_RIGHT; - case GDK_Up: return KEY_UP; - case GDK_Down: return KEY_DOWN; - case GDK_Home: + case GDK_KEY(Linefeed): return 13; + case GDK_KEY(Return): return 10; + case GDK_KEY(Left): return KEY_LEFT; + case GDK_KEY(Right): return KEY_RIGHT; + case GDK_KEY(Up): return KEY_UP; + case GDK_KEY(Down): return KEY_DOWN; + case GDK_KEY(Home): if (key->state & GDK_CONTROL_MASK) return KEY_TEXT_START; else return KEY_LINE_START; - case GDK_End: + case GDK_KEY(End): if (key->state & GDK_CONTROL_MASK) return KEY_TEXT_END; else return KEY_LINE_END; - case GDK_Page_Up: + case GDK_KEY(Page_Up): return KEY_PAGE_UP; - case GDK_Page_Down: + case GDK_KEY(Page_Down): return KEY_PAGE_DOWN; case 'a': if (key->state & GDK_CONTROL_MASK) @@ -1011,24 +1023,24 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key) if (key->state & GDK_CONTROL_MASK) return KEY_CLEAR_SELECTION; return gdk_keyval_to_unicode(key->keyval); - case GDK_Escape: + case GDK_KEY(Escape): return KEY_ESCAPE; /* Modifiers - do nothing for now */ - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Caps_Lock: - case GDK_Shift_Lock: - case GDK_Meta_L: - case GDK_Meta_R: - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Super_L: - case GDK_Super_R: - case GDK_Hyper_L: - case GDK_Hyper_R: + case GDK_KEY(Shift_L): + case GDK_KEY(Shift_R): + case GDK_KEY(Control_L): + case GDK_KEY(Control_R): + case GDK_KEY(Caps_Lock): + case GDK_KEY(Shift_Lock): + case GDK_KEY(Meta_L): + case GDK_KEY(Meta_R): + case GDK_KEY(Alt_L): + case GDK_KEY(Alt_R): + case GDK_KEY(Super_L): + case GDK_KEY(Super_R): + case GDK_KEY(Hyper_L): + case GDK_KEY(Hyper_R): return 0; default: diff --git a/gtk/gui.h b/gtk/gui.h index c7333d55d..b53de256a 100644 --- a/gtk/gui.h +++ b/gtk/gui.h @@ -29,10 +29,11 @@ #include #include #include -#include +//#include struct glade_file_location_s { char *netsurf; + char *tabcontents; char *password; char *warning; char *login; diff --git a/gtk/history.c b/gtk/history.c index 34c76cd7d..e7b083671 100644 --- a/gtk/history.c +++ b/gtk/history.c @@ -85,7 +85,7 @@ static struct menu_events menu_events[] = { }; static struct nsgtk_treeview *global_history_window; -static GladeXML *gladeFile; +static GtkBuilder *gladeFile; GtkWindow *wndHistory; @@ -95,31 +95,33 @@ bool nsgtk_history_init(const char *glade_file_location) GtkWindow *window; GtkScrolledWindow *scrolled; GtkDrawingArea *drawing_area; - - gladeFile = glade_xml_new(glade_file_location, NULL, NULL); - if (gladeFile == NULL) + GError* error = NULL; + + gladeFile = gtk_builder_new(); + if (!gtk_builder_add_from_file(gladeFile, glade_file_location, &error)) { + g_warning ("Couldn't load builder file: %s", error->message); + g_error_free (error); return false; + } - glade_xml_signal_autoconnect(gladeFile); + gtk_builder_connect_signals(gladeFile, NULL); - wndHistory = GTK_WINDOW(glade_xml_get_widget(gladeFile, "wndHistory")); + wndHistory = GTK_WINDOW(gtk_builder_get_object(gladeFile, "wndHistory")); window = wndHistory; - scrolled = GTK_SCROLLED_WINDOW(glade_xml_get_widget(gladeFile, - "globalHistoryScrolled")); + scrolled = GTK_SCROLLED_WINDOW(gtk_builder_get_object(gladeFile, "globalHistoryScrolled")); - drawing_area = GTK_DRAWING_AREA(glade_xml_get_widget(gladeFile, - "globalHistoryDrawingArea")); + drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(gladeFile, "globalHistoryDrawingArea")); global_history_window = nsgtk_treeview_create( - history_global_get_tree_flags(), window, scrolled, - drawing_area); + history_global_get_tree_flags(), window, scrolled, + drawing_area); if (global_history_window == NULL) return false; -#define CONNECT(obj, sig, callback, ptr) \ +#define CONNECT(obj, sig, callback, ptr) \ g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr)) CONNECT(window, "delete_event", gtk_widget_hide_on_delete, NULL); @@ -141,12 +143,15 @@ bool nsgtk_history_init(const char *glade_file_location) void nsgtk_history_init_menu(void) { struct menu_events *event = menu_events; - - while (event->widget != NULL) - { - GtkWidget *w = glade_xml_get_widget(gladeFile, event->widget); - g_signal_connect(G_OBJECT(w), "activate", event->handler, - global_history_window); + GtkWidget *w; + + while (event->widget != NULL) { + w = GTK_WIDGET(gtk_builder_get_object(gladeFile, event->widget)); + if (w == NULL) { + LOG(("Unable to connect menu widget ""%s""", event->widget)); + } else { + g_signal_connect(G_OBJECT(w), "activate", event->handler, global_history_window); + } event++; } } diff --git a/gtk/hotlist.c b/gtk/hotlist.c index dc95866db..d7b5b9e8f 100644 --- a/gtk/hotlist.c +++ b/gtk/hotlist.c @@ -90,7 +90,7 @@ static struct menu_events menu_events[] = { }; static struct nsgtk_treeview *hotlist_window; -static GladeXML *gladeFile; +static GtkBuilder *gladeFile; GtkWindow *wndHotlist; @@ -101,19 +101,23 @@ bool nsgtk_hotlist_init(const char *glade_file_location) GtkScrolledWindow *scrolled; GtkDrawingArea *drawing_area; - gladeFile = glade_xml_new(glade_file_location, NULL, NULL); - if (gladeFile == NULL) + GError* error = NULL; + gladeFile = gtk_builder_new(); + if (!gtk_builder_add_from_file(gladeFile, glade_file_location, &error)) { + g_warning("Couldn't load builder file: %s", error->message); + g_error_free(error); return false; + } - glade_xml_signal_autoconnect(gladeFile); + gtk_builder_connect_signals(gladeFile, NULL); - wndHotlist = GTK_WINDOW(glade_xml_get_widget(gladeFile, "wndHotlist")); + wndHotlist = GTK_WINDOW(gtk_builder_get_object(gladeFile, "wndHotlist")); window = wndHotlist; - scrolled = GTK_SCROLLED_WINDOW(glade_xml_get_widget(gladeFile, + scrolled = GTK_SCROLLED_WINDOW(gtk_builder_get_object(gladeFile, "hotlistScrolled")); - drawing_area = GTK_DRAWING_AREA(glade_xml_get_widget(gladeFile, + drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(gladeFile, "hotlistDrawingArea")); @@ -145,12 +149,14 @@ bool nsgtk_hotlist_init(const char *glade_file_location) void nsgtk_hotlist_init_menu(void) { struct menu_events *event = menu_events; - - while (event->widget != NULL) - { - GtkWidget *w = glade_xml_get_widget(gladeFile, event->widget); - g_signal_connect(G_OBJECT(w), "activate", event->handler, - hotlist_window); + GtkWidget *w; + + while (event->widget != NULL) { + w = GTK_WIDGET(gtk_builder_get_object(gladeFile, event->widget)); + if (w == NULL) { + LOG(("Unable to connect menu widget ""%s""", event->widget)); } else { + g_signal_connect(G_OBJECT(w), "activate", event->handler, hotlist_window); + } event++; } } diff --git a/gtk/login.c b/gtk/login.c index daf9e9644..41f66de20 100644 --- a/gtk/login.c +++ b/gtk/login.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "utils/log.h" #include "gtk/gui.h" @@ -41,7 +40,7 @@ struct session_401 { char *realm; /**< Authentication realm */ nserror (*cb)(bool proceed, void *pw); /**< Continuation callback */ void *cbpw; /**< Continuation data */ - GladeXML *x; /**< Our glade windows */ + GtkBuilder *x; /**< Our glade windows */ GtkWindow *wnd; /**< The login window itself */ GtkEntry *user; /**< Widget with username */ GtkEntry *pass; /**< Widget with password */ @@ -78,18 +77,26 @@ void create_login_window(const char *url, const char *host, const char *realm, * the widgets we're interested in. */ - GladeXML *x = glade_xml_new(glade_file_location->login, NULL, NULL); - GtkWindow *wnd = GTK_WINDOW(glade_xml_get_widget(x, "wndLogin")); + GtkWindow *wnd; GtkLabel *lhost, *lrealm; GtkEntry *euser, *epass; GtkButton *bok, *bcan; - - lhost = GTK_LABEL(glade_xml_get_widget(x, "labelLoginHost")); - lrealm = GTK_LABEL(glade_xml_get_widget(x, "labelLoginRealm")); - euser = GTK_ENTRY(glade_xml_get_widget(x, "entryLoginUser")); - epass = GTK_ENTRY(glade_xml_get_widget(x, "entryLoginPass")); - bok = GTK_BUTTON(glade_xml_get_widget(x, "buttonLoginOK")); - bcan = GTK_BUTTON(glade_xml_get_widget(x, "buttonLoginCan")); + GError* error = NULL; + GtkBuilder* builder; + + builder = gtk_builder_new (); + if (!gtk_builder_add_from_file(builder, glade_file_location->login, &error)) { + g_warning ("Couldn't load builder file: %s", error->message); + g_error_free (error); + } + + wnd = GTK_WINDOW(gtk_builder_get_object(builder, "wndLogin")); + lhost = GTK_LABEL(gtk_builder_get_object(builder, "labelLoginHost")); + lrealm = GTK_LABEL(gtk_builder_get_object(builder, "labelLoginRealm")); + euser = GTK_ENTRY(gtk_builder_get_object(builder, "entryLoginUser")); + epass = GTK_ENTRY(gtk_builder_get_object(builder, "entryLoginPass")); + bok = GTK_BUTTON(gtk_builder_get_object(builder, "buttonLoginOK")); + bcan = GTK_BUTTON(gtk_builder_get_object(builder, "buttonLoginCan")); /* create and fill in our session structure */ @@ -99,7 +106,7 @@ void create_login_window(const char *url, const char *host, const char *realm, session->realm = strdup(realm ? realm : "Secure Area"); session->cb = cb; session->cbpw = cbpw; - session->x = x; + session->x = builder; session->wnd = wnd; session->user = euser; session->pass = epass; diff --git a/gtk/menu.c b/gtk/menu.c index f16cfee40..7c55a9fd6 100644 --- a/gtk/menu.c +++ b/gtk/menu.c @@ -20,7 +20,6 @@ #include #include -#include #include "gtk/menu.h" #include "utils/messages.h" diff --git a/gtk/plotters.h b/gtk/plotters.h index 55ad71b5a..c88a8da0c 100644 --- a/gtk/plotters.h +++ b/gtk/plotters.h @@ -31,7 +31,6 @@ extern const struct plotter_table nsgtk_plotters; /* make sure this is NULL if no redraw is in progress */ extern GtkWidget *current_widget; -extern GdkDrawable *current_drawable; extern cairo_t *current_cr; void nsgtk_set_colour(colour c); diff --git a/gtk/print.c b/gtk/print.c index 73bf3b397..02d89bbdb 100644 --- a/gtk/print.c +++ b/gtk/print.c @@ -54,19 +54,19 @@ static GdkRectangle cliprect; static inline void nsgtk_print_set_colour(colour c) { int r, g, b; - GdkColor colour; r = c & 0xff; g = (c & 0xff00) >> 8; b = (c & 0xff0000) >> 16; +#ifdef FIXME + GdkColor colour; colour.red = r | (r << 8); colour.green = g | (g << 8); colour.blue = b | (b << 8); colour.pixel = (r << 16) | (g << 8) | b; - gdk_colormap_alloc_color(gdk_colormap_get_system(), &colour, true, true); - +#endif cairo_set_source_rgba(gtk_print_current_cr, r / 255.0, g / 255.0, b / 255.0, 1.0); } diff --git a/gtk/res/cookies.glade b/gtk/res/cookies.glade deleted file mode 100644 index 9fc5de148..000000000 --- a/gtk/res/cookies.glade +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - Cookies - NetSurf - mouse - 600 - 500 - - - True - 2 - 2 - - - True - - - True - _Edit - True - - - True - - - True - Deletes selected nodes - _Delete - True - - - - - - True - D_elete all - True - - - - - True - _Select all - True - - - - - - True - _Clear selection - True - - - - - - - - - - True - _View - True - - - True - - - True - _Expand - True - - - True - - - True - _All - True - - - - - True - _Domains - True - - - - - True - _Cookies - True - - - - - - - - - True - Collapse - True - - - True - - - True - _All - True - - - - - True - _Domains - True - - - - - True - _Cookies - True - - - - - - - - - - - - - False - 0 - - - - - True - True - automatic - automatic - - - True - queue - - - True - True - True - GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK - - - - - - - 1 - - - - - - diff --git a/gtk/res/cookies.gtk2.ui b/gtk/res/cookies.gtk2.ui new file mode 100644 index 000000000..86f15c765 --- /dev/null +++ b/gtk/res/cookies.gtk2.ui @@ -0,0 +1,174 @@ + + + + + + Cookies - NetSurf + mouse + 600 + 500 + + + True + 2 + vertical + 2 + + + True + + + True + _Edit + True + + + True + + + True + _Delete + True + + + + + + True + D_elete all + True + + + + + True + _Select all + True + + + + + + True + _Clear selection + True + + + + + + + + + + True + _View + True + + + True + + + True + _Expand + True + + + True + + + True + _All + True + + + + + True + _Domains + True + + + + + True + _Cookies + True + + + + + + + + + True + Collapse + True + + + True + + + True + _All + True + + + + + True + _Domains + True + + + + + True + _Cookies + True + + + + + + + + + + + + + False + 0 + + + + + True + True + automatic + automatic + + + True + queue + + + True + True + True + GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK + + + + + + + 1 + + + + + + diff --git a/gtk/res/cookies.gtk3.ui b/gtk/res/cookies.gtk3.ui new file mode 100644 index 000000000..3ccc04bce --- /dev/null +++ b/gtk/res/cookies.gtk3.ui @@ -0,0 +1,205 @@ + + + + + False + NetSurf Cookies + mouse + 600 + 500 + + + True + False + vertical + + + True + False + + + False + True + False + _Edit + True + + + True + False + + + False + True + False + _Delete + True + + + + + False + True + False + D_elete all + True + + + + + False + True + False + _Select all + True + + + + + False + True + False + _Clear selection + True + + + + + + + + + False + True + False + _View + True + + + True + False + + + False + True + False + _Expand + True + + + True + False + + + False + True + False + _All + True + + + + + False + True + False + _Domains + True + + + + + False + True + False + _Cookies + True + + + + + + + + + False + True + False + Collapse + True + + + True + False + + + False + True + False + _All + True + + + + + False + True + False + _Domains + True + + + + + False + True + False + _Cookies + True + + + + + + + + + + + + + False + True + 0 + + + + + True + True + never + in + + + True + False + + + True + True + False + + + + + + + True + True + 1 + + + + + + diff --git a/gtk/res/downloads.glade b/gtk/res/downloads.glade deleted file mode 100644 index 706bfe19a..000000000 --- a/gtk/res/downloads.glade +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Downloads - NetSurf - mouse - 500 - 300 - True - - - True - - - True - True - never - automatic - - - True - True - 2 - False - True - - - - - 0 - - - - - True - - - False - 1 - - - - - True - - - True - 2 - 2 - 2 - 2 - - - True - True - 0% of 0 files - - - - - 0 - - - - - True - True - end - - - gtk-media-pause - True - False - True - True - none - True - - - False - False - 0 - - - - - True - False - True - True - none - - - True - - - True - gtk-media-play - 2 - - - 0 - - - - - True - Resume - - - 1 - - - - - - - False - False - 1 - - - - - gtk-cancel - True - False - True - True - none - True - - - False - False - 2 - - - - - gtk-clear - True - False - True - True - none - True - - - False - False - 3 - - - - - False - False - end - 1 - - - - - False - False - 2 - - - - - - diff --git a/gtk/res/downloads.gtk2.ui b/gtk/res/downloads.gtk2.ui new file mode 100644 index 000000000..1e71328a4 --- /dev/null +++ b/gtk/res/downloads.gtk2.ui @@ -0,0 +1,175 @@ + + + + + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Downloads - NetSurf + mouse + 500 + 300 + True + + + True + + + True + True + never + automatic + + + True + True + 2 + False + True + + + + + 0 + + + + + True + + + False + 1 + + + + + True + + + True + 2 + 2 + 2 + 2 + + + True + True + 0% of 0 files + + + + + 0 + + + + + True + True + end + + + gtk-media-pause + True + False + True + True + none + True + + + False + False + 0 + + + + + True + False + True + True + none + + + True + + + True + gtk-media-play + 2 + + + 0 + + + + + True + Resume + + + 1 + + + + + + + False + False + 1 + + + + + gtk-cancel + True + False + True + True + none + True + + + False + False + 2 + + + + + gtk-clear + True + False + True + True + none + True + + + False + False + 3 + + + + + False + False + end + 1 + + + + + False + False + 2 + + + + + + diff --git a/gtk/res/downloads.gtk3.ui b/gtk/res/downloads.gtk3.ui new file mode 100644 index 000000000..1e71328a4 --- /dev/null +++ b/gtk/res/downloads.gtk3.ui @@ -0,0 +1,175 @@ + + + + + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Downloads - NetSurf + mouse + 500 + 300 + True + + + True + + + True + True + never + automatic + + + True + True + 2 + False + True + + + + + 0 + + + + + True + + + False + 1 + + + + + True + + + True + 2 + 2 + 2 + 2 + + + True + True + 0% of 0 files + + + + + 0 + + + + + True + True + end + + + gtk-media-pause + True + False + True + True + none + True + + + False + False + 0 + + + + + True + False + True + True + none + + + True + + + True + gtk-media-play + 2 + + + 0 + + + + + True + Resume + + + 1 + + + + + + + False + False + 1 + + + + + gtk-cancel + True + False + True + True + none + True + + + False + False + 2 + + + + + gtk-clear + True + False + True + True + none + True + + + False + False + 3 + + + + + False + False + end + 1 + + + + + False + False + 2 + + + + + + diff --git a/gtk/res/history.glade b/gtk/res/history.glade deleted file mode 100644 index 5c6e06424..000000000 --- a/gtk/res/history.glade +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - NetSurf Global History - center - 600 - 500 - utility - - - True - 2 - 2 - - - True - - - True - _File - True - - - True - - - True - _Export - True - - - - - - - - - - True - _Edit - True - - - True - - - True - Deletes selected nodes - _Delete - True - - - - - - True - D_elete all - True - - - - - True - _Select all - True - - - - - - True - _Clear selection - True - - - - - - - - - - True - _View - True - - - True - - - True - _Expand - True - - - True - - - True - _All - True - - - - - True - _Directories - True - - - - - True - Add_resses - True - - - - - - - - - True - _Collapse - True - - - True - - - True - _All - True - - - - - True - _Directories - True - - - - - True - Add_resses - True - - - - - - - - - - - - - True - Launches the selected addresses - _Launch - True - - - - - False - - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - True - GTK_RESIZE_QUEUE - - - True - True - True - GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK - - - - - - - - - - diff --git a/gtk/res/history.gtk2.ui b/gtk/res/history.gtk2.ui new file mode 100644 index 000000000..2b89ecb4b --- /dev/null +++ b/gtk/res/history.gtk2.ui @@ -0,0 +1,242 @@ + + + + + False + NetSurf Global History + center + 600 + 500 + utility + + + True + False + + + True + False + + + False + True + False + _File + True + + + True + False + + + False + True + False + _Export + True + + + + + + + + + + False + True + False + _Edit + True + + + True + False + + + False + True + False + _Delete + True + + + + + + False + True + False + D_elete all + True + + + + + False + True + False + _Select all + True + + + + + + False + True + False + _Clear selection + True + + + + + + + + + + False + True + False + _View + True + + + True + False + + + False + True + False + _Expand + True + + + True + False + + + False + True + False + _All + True + + + + + False + True + False + _Directories + True + + + + + False + True + False + Add_resses + True + + + + + + + + + False + True + False + _Collapse + True + + + True + False + + + False + True + False + _All + True + + + + + False + True + False + _Directories + True + + + + + False + True + False + Add_resses + True + + + + + + + + + + + + + False + True + False + _Launch + True + + + + + False + True + 0 + + + + + True + True + + + True + False + queue + + + True + True + True + GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK + + + + + + + True + True + 1 + + + + + + diff --git a/gtk/res/history.gtk3.ui b/gtk/res/history.gtk3.ui new file mode 100644 index 000000000..7fa598f1e --- /dev/null +++ b/gtk/res/history.gtk3.ui @@ -0,0 +1,238 @@ + + + + + False + NetSurf Global History + center + 600 + 500 + utility + + + True + False + vertical + + + True + False + + + False + True + False + _File + True + + + True + False + + + False + True + False + _Export + True + + + + + + + + + False + True + False + _Edit + True + + + True + False + + + False + True + False + _Delete + True + + + + + False + True + False + D_elete all + True + + + + + False + True + False + _Select all + True + + + + + False + True + False + _Clear selection + True + + + + + + + + + False + True + False + _View + True + + + True + False + + + False + True + False + _Expand + True + + + True + False + + + False + True + False + _All + True + + + + + False + True + False + _Directories + True + + + + + False + True + False + Add_resses + True + + + + + + + + + False + True + False + _Collapse + True + + + True + False + + + False + True + False + _All + True + + + + + False + True + False + _Directories + True + + + + + False + True + False + Add_resses + True + + + + + + + + + + + + + False + True + False + _Launch + True + + + + + False + True + 0 + + + + + True + True + in + + + True + False + + + True + False + GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK + + + + + + + True + True + 1 + + + + + + diff --git a/gtk/res/hotlist.glade b/gtk/res/hotlist.glade deleted file mode 100644 index 8f0a6ecc7..000000000 --- a/gtk/res/hotlist.glade +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - Bookmarks - NetSurf - mouse - 600 - 500 - - - True - 2 - 2 - - - True - - - True - _File - True - - - True - - - True - _Export - True - - - - - - True - New _folder - True - - - - - - True - New _entry - True - - - - - - - - - - True - _Edit - True - - - True - - - True - _Edit - True - - - - - True - Deletes selected nodes - _Delete - True - - - - - - True - _Select all - True - - - - - - True - _Clear selection - True - - - - - - - - - - True - _View - True - - - True - - - True - _Expand - True - - - True - - - True - _All - True - - - - - True - _Directories - True - - - - - True - Add_resses - True - - - - - - - - - True - _Collapse - True - - - True - - - True - _All - True - - - - - True - _Directories - True - - - - - True - Add_resses - True - - - - - - - - - - - - - True - Launches the selected addresses - _Launch - True - - - - - False - 0 - - - - - True - True - automatic - automatic - - - True - queue - - - True - True - True - GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK - - - - - - - 1 - - - - - - diff --git a/gtk/res/hotlist.gtk2.ui b/gtk/res/hotlist.gtk2.ui new file mode 100644 index 000000000..af0fd5696 --- /dev/null +++ b/gtk/res/hotlist.gtk2.ui @@ -0,0 +1,217 @@ + + + + + + Bookmarks - NetSurf + mouse + 600 + 500 + + + True + 2 + vertical + 2 + + + True + + + True + _File + True + + + True + + + True + _Export + True + + + + + + True + New _folder + True + + + + + + True + New _entry + True + + + + + + + + + + True + _Edit + True + + + True + + + True + _Edit + True + + + + + True + _Delete + True + + + + + + True + _Select all + True + + + + + + True + _Clear selection + True + + + + + + + + + + True + _View + True + + + True + + + True + _Expand + True + + + True + + + True + _All + True + + + + + True + _Directories + True + + + + + True + Add_resses + True + + + + + + + + + True + _Collapse + True + + + True + + + True + _All + True + + + + + True + _Directories + True + + + + + True + Add_resses + True + + + + + + + + + + + + + True + _Launch + True + + + + + False + 0 + + + + + True + True + automatic + automatic + + + True + queue + + + True + True + True + GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK + + + + + + + 1 + + + + + + diff --git a/gtk/res/hotlist.gtk3.ui b/gtk/res/hotlist.gtk3.ui new file mode 100644 index 000000000..78a81672b --- /dev/null +++ b/gtk/res/hotlist.gtk3.ui @@ -0,0 +1,254 @@ + + + + + False + NetSurf Bookmarks + mouse + 600 + 500 + + + True + False + vertical + + + True + False + + + False + True + False + _File + True + + + True + False + + + False + True + False + _Export + True + + + + + False + True + False + New _folder + True + + + + + False + True + False + New _entry + True + + + + + + + + + False + True + False + _Edit + True + + + True + False + + + False + True + False + _Edit + True + + + + + False + True + False + _Delete + True + + + + + False + True + False + _Select all + True + + + + + False + True + False + _Clear selection + True + + + + + + + + + False + True + False + _View + True + + + True + False + + + False + True + False + _Expand + True + + + True + False + + + False + True + False + _All + True + + + + + False + True + False + _Directories + True + + + + + False + True + False + Add_resses + True + + + + + + + + + False + True + False + _Collapse + True + + + True + False + + + False + True + False + _All + True + + + + + False + True + False + _Directories + True + + + + + False + True + False + Add_resses + True + + + + + + + + + + + + + False + True + False + _Launch + True + + + + + False + True + 0 + + + + + True + True + in + + + True + False + + + True + False + + + + + + + True + True + 1 + + + + + + diff --git a/gtk/res/login.glade b/gtk/res/login.glade deleted file mode 100644 index c46740591..000000000 --- a/gtk/res/login.glade +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - Site Authentication - GTK_WIN_POS_CENTER_ALWAYS - GDK_WINDOW_TYPE_HINT_DIALOG - - - True - - - True - 3 - - - True - 0.10000000149011612 - 12 - 6 - gtk-dialog-authentication - - - False - False - - - - - True - 1 - 4 - 2 - 11 - 10 - - - True - 0 - moo.yoo.com - - - 1 - 2 - - - - - - True - 0 - Password - - - 3 - 4 - - - - - - True - 0 - Username - - - 2 - 3 - - - - - - True - 0 - Host - - - - - - - - True - 0 - Realm - - - 1 - 2 - - - - - - True - 0 - my sekr3t area - - - 1 - 2 - 1 - 2 - - - - - - True - True - False - True - opensesame - - - 1 - 2 - 3 - 4 - - - - - - True - True - True - sesame - - - 1 - 2 - 2 - 3 - - - - - - 1 - 1 - - - - - 2 - - - - - True - GTK_BUTTONBOX_END - - - True - True - gtk-cancel - True - -6 - - - - - True - True - True - True - -5 - - - True - True - True - 0 - 0 - - - True - 2 - - - True - gtk-ok - - - False - False - - - - - True - Login - True - - - False - False - 1 - - - - - - - - - 1 - - - - - False - GTK_PACK_END - - - - - - diff --git a/gtk/res/login.gtk2.ui b/gtk/res/login.gtk2.ui new file mode 100644 index 000000000..552b173ed --- /dev/null +++ b/gtk/res/login.gtk2.ui @@ -0,0 +1,223 @@ + + + + + Site Authentication + GTK_WIN_POS_CENTER_ALWAYS + GDK_WINDOW_TYPE_HINT_DIALOG + + + True + + + True + 3 + + + True + 0.10000000149011612 + 12 + 6 + gtk-dialog-authentication + + + False + False + + + + + True + 1 + 4 + 2 + 11 + 10 + + + True + 0 + moo.yoo.com + + + 1 + 2 + + + + + + True + 0 + Password + + + 3 + 4 + + + + + + True + 0 + Username + + + 2 + 3 + + + + + + True + 0 + Host + + + + + + + + True + 0 + Realm + + + 1 + 2 + + + + + + True + 0 + my sekr3t area + + + 1 + 2 + 1 + 2 + + + + + + True + True + False + True + opensesame + + + 1 + 2 + 3 + 4 + + + + + + True + True + True + sesame + + + 1 + 2 + 2 + 3 + + + + + + 1 + 1 + + + + + 2 + + + + + True + GTK_BUTTONBOX_END + + + True + True + gtk-cancel + True + + + + + True + True + True + True + + + True + True + True + 0 + 0 + + + True + 2 + + + True + gtk-ok + + + False + False + + + + + True + Login + True + + + False + False + 1 + + + + + + + + + 1 + + + + + False + GTK_PACK_END + + + + + + buttonLoginCan + buttonLoginOK + + + diff --git a/gtk/res/login.gtk3.ui b/gtk/res/login.gtk3.ui new file mode 100644 index 000000000..552b173ed --- /dev/null +++ b/gtk/res/login.gtk3.ui @@ -0,0 +1,223 @@ + + + + + Site Authentication + GTK_WIN_POS_CENTER_ALWAYS + GDK_WINDOW_TYPE_HINT_DIALOG + + + True + + + True + 3 + + + True + 0.10000000149011612 + 12 + 6 + gtk-dialog-authentication + + + False + False + + + + + True + 1 + 4 + 2 + 11 + 10 + + + True + 0 + moo.yoo.com + + + 1 + 2 + + + + + + True + 0 + Password + + + 3 + 4 + + + + + + True + 0 + Username + + + 2 + 3 + + + + + + True + 0 + Host + + + + + + + + True + 0 + Realm + + + 1 + 2 + + + + + + True + 0 + my sekr3t area + + + 1 + 2 + 1 + 2 + + + + + + True + True + False + True + opensesame + + + 1 + 2 + 3 + 4 + + + + + + True + True + True + sesame + + + 1 + 2 + 2 + 3 + + + + + + 1 + 1 + + + + + 2 + + + + + True + GTK_BUTTONBOX_END + + + True + True + gtk-cancel + True + + + + + True + True + True + True + + + True + True + True + 0 + 0 + + + True + 2 + + + True + gtk-ok + + + False + False + + + + + True + Login + True + + + False + False + 1 + + + + + + + + + 1 + + + + + False + GTK_PACK_END + + + + + + buttonLoginCan + buttonLoginOK + + + diff --git a/gtk/res/menu_cursor.png b/gtk/res/menu_cursor.png new file mode 100644 index 000000000..ccbbbd2d4 Binary files /dev/null and b/gtk/res/menu_cursor.png differ diff --git a/gtk/res/menu_cursor.xbm b/gtk/res/menu_cursor.xbm new file mode 100644 index 000000000..1257ac1f4 --- /dev/null +++ b/gtk/res/menu_cursor.xbm @@ -0,0 +1,6 @@ +#define menu_cursor_width 16 +#define menu_cursor_height 16 +static char menu_cursor_bits[] = { + 0x00, 0x00, 0x80, 0x7F, 0x88, 0x40, 0x9E, 0x5E, 0x88, 0x40, 0x80, 0x56, + 0x80, 0x40, 0x80, 0x5A, 0x80, 0x40, 0x80, 0x5E, 0x80, 0x40, 0x80, 0x56, + 0x80, 0x40, 0x80, 0x7F, 0x00, 0x00, 0x00, 0x00 }; diff --git a/gtk/res/menu_cursor_mask.xbm b/gtk/res/menu_cursor_mask.xbm new file mode 100644 index 000000000..09789d51b --- /dev/null +++ b/gtk/res/menu_cursor_mask.xbm @@ -0,0 +1,6 @@ +#define menu_cursor_mask_width 16 +#define menu_cursor_mask_height 16 +static char menu_cursor_mask_bits[] = { + 0xC0, 0xFF, 0xC8, 0xFF, 0xDF, 0xFF, 0xFF, 0xFF, 0xDF, 0xFF, 0xC8, 0xFF, + 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, + 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0x00, 0x00 }; diff --git a/gtk/res/menu_cursor_mask.xpm b/gtk/res/menu_cursor_mask.xpm new file mode 100644 index 000000000..985d46cc6 --- /dev/null +++ b/gtk/res/menu_cursor_mask.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * menu_cursor_mask_xpm[] = { +"16 16 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ..........", +" . .++++++++.", +"...+. .+......+.", +".++++..+.++++.+.", +"...+. .+......+.", +" . .+.++.+.+.", +" .+......+.", +" .+.+.++.+.", +" .+......+.", +" .+.++++.+.", +" .+......+.", +" .+.++.+.+.", +" .+......+.", +" .++++++++.", +" ..........", +" "}; diff --git a/gtk/res/netsurf.glade b/gtk/res/netsurf.glade deleted file mode 100644 index abd981e41..000000000 --- a/gtk/res/netsurf.glade +++ /dev/null @@ -1,287 +0,0 @@ - - - - - - NetSurf - GTK_WIN_POS_CENTER - - - True - - - True - - - False - False - - - - - True - GTK_TOOLBAR_BOTH_HORIZ - - - False - False - 1 - - - - - GTK_TOOLBAR_BOTH - - - True - gtk-close - - - False - - - - - True - - - True - 4 - Match - - - - - False - False - - - - - True - - - True - True - - - - - False - False - - - - - True - Search _Back - True - gtk-go-back - - - False - - - - - True - Search _Forward - True - gtk-go-forward - - - False - - - - - True - - - True - True - show all matches - All - True - 0 - True - - - - - False - False - - - - - True - - - True - True - Match case when searching - Case - GTK_RELIEF_NONE - True - 0 - True - - - - - False - False - - - - - False - False - 2 - - - - - True - False - False - True - - - - - - - tab - - - - - - - - - tab - - - - - - - - - tab - - - - - - - - - tab - - - - - - - - - tab - - - - - - - - - tab - - - - - 3 - - - - - - - - - True - 2 - 2 - - - True - True - - - - - 1 - True - 2 - - - 1 - 2 - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - True - - - 1 - True - 0 - 4 - Status - - - False - False - - - - - True - 0.5357142857142857 0 100 26 10 10 - - - True - True - - - - - 1 - 2 - GTK_FILL - - - - - True - 0 0 100 26 10 10 - - - 1 - 2 - - - - - - - diff --git a/gtk/res/netsurf.gtk2.ui b/gtk/res/netsurf.gtk2.ui new file mode 100644 index 000000000..68812b364 --- /dev/null +++ b/gtk/res/netsurf.gtk2.ui @@ -0,0 +1,212 @@ + + + + + 100 + 0 + 10 + 26 + 10 + 0.5357142857142857 + + + 100 + 0 + 10 + 26 + 10 + 0 + + + + + + + + NetSurf + GTK_WIN_POS_CENTER + + + True + + + True + + + False + False + + + + + True + GTK_TOOLBAR_BOTH_HORIZ + + + False + False + 1 + + + + + GTK_TOOLBAR_BOTH + + + True + gtk-close + + + False + + + + + True + + + True + 4 + Match + + + + + False + False + + + + + True + + + True + True + + + + + False + False + + + + + True + Search _Back + True + gtk-go-back + + + False + + + + + True + Search _Forward + True + gtk-go-forward + + + False + + + + + True + + + True + True + show all matches + All + True + True + + + + + False + False + + + + + True + + + True + True + Match case when searching + Case + GTK_RELIEF_NONE + True + True + + + + + False + False + + + + + False + False + 2 + + + + + True + False + False + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + + diff --git a/gtk/res/netsurf.gtk3.ui b/gtk/res/netsurf.gtk3.ui new file mode 100644 index 000000000..ce47c6370 --- /dev/null +++ b/gtk/res/netsurf.gtk3.ui @@ -0,0 +1,207 @@ + + + + + False + + + True + False + vertical + + + True + False + + + False + True + 0 + + + + + True + False + both + + + False + False + 1 + + + + + False + both + + + False + True + False + False + gtk-close + gtk-close + + + False + True + + + + + False + True + False + False + + + True + False + 4 + Match + + + + + False + + + + + False + True + False + False + + + True + True + + + + + + False + + + + + False + True + False + False + Search _Back + True + gtk-go-back + + + False + True + + + + + False + True + False + False + Search _Forward + True + gtk-go-forward + + + False + True + + + + + False + True + False + False + + + All + False + True + True + False + False + 0 + True + + + + + False + + + + + False + True + False + False + + + Case + False + True + True + False + False + 0 + True + + + + + False + + + + + False + False + 2 + + + + + True + True + False + False + True + + + + + + + + + + + + + + + + + + + + + True + True + 3 + + + + + + diff --git a/gtk/res/options.glade b/gtk/res/options.glade deleted file mode 100644 index 75313e38e..000000000 --- a/gtk/res/options.glade +++ /dev/null @@ -1,2544 +0,0 @@ - - - - - - 5 - Netsurf Preferences - center-on-parent - True - dialog - False - - - True - 2 - - - True - True - 4 - - - True - - - True - 5 - 0 - none - - - True - 12 - - - True - - - True - 5 - 5 - - - True - URL - - - False - False - 0 - - - - - True - True - The page to visit when the Home button is pressed, or a new window is opened. - - - - 1 - - - - - 0 - - - - - True - 5 - - - Current Page - True - True - False - True - - - 5 - 0 - - - - - Default Page - True - True - False - True - - - 5 - end - 1 - - - - - 1 - - - - - - - - - True - <b>Home page</b> - True - - - label_item - - - - - False - 0 - - - - - True - - - True - 5 - 0 - none - - - True - 12 - - - True - True - - - Hide advertisements - True - True - False - Attempt to hide images from known advertisement servers. - True - True - - - False - False - 0 - - - - - Disable pop-up windows - True - True - False - Stop pop-up windows normally containing adverts appearing. - True - True - - - False - False - 1 - - - - - Disable plug-ins - True - False - Do not allow embedded applets or plugins. - True - True - - - False - False - 2 - - - - - - - - - True - <b>Content blocking</b> - True - - - label_item - - - - - False - 0 - - - - - True - 0 - none - - - True - 12 - - - True - - - - - - True - - - - - - - - - - - - False - False - 1 - - - - - - - - - - - - True - <b>Content Language</b> - True - - - label_item - - - - - 1 - - - - - False - 1 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - 1 - 2 - - - True - 4 - 4 - - - True - Keep history for - - - False - False - 0 - - - - - True - True - Visited pages are kept in memory for this many days - 14 0 100 1 10 0 - 1 - - - False - False - 1 - - - - - True - days - - - False - False - 2 - - - - - 0 - - - - - Hover URLs by pointer in local history - True - True - False - Show a tooltip showing the URL of a page in the local history tree. - True - True - - - False - False - 1 - - - - - - - - - True - <b>History</b> - True - - - label_item - - - - - False - False - 2 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - True - - - Display recently visited URLs as you type - True - True - False - Show a drop-down list of recent addresses when typing into the address bar. - True - True - - - False - False - 0 - - - - - Send site referral information - True - True - False - When requesting items or pages, tell the server what linked to them. - True - True - True - - - False - False - 1 - - - - - - - - - - - - True - <b>Misc</b> - True - - - label_item - - - - - False - 3 - - - - - - - True - General - - - False - tab - - - - - True - - - True - 5 - 0 - none - - - True - 12 - - - True - 4 - 2 - 3 - 3 - - - True - True - If your proxy server requires authentication, enter your username here. - - - - 1 - 2 - 2 - 3 - - - - - - True - No proxy -Simple proxy -Basic authentication -NTLM authentication - - - 1 - 2 - - - - - - True - - - True - True - Host name of your proxy server. - - - - 0 - - - - - True - : - - - False - False - 1 - - - - - 64 - True - True - Port number to connect to on proxy server. - - - - False - 2 - - - - - 1 - 2 - 1 - 2 - - - - - - True - True - If your proxy server requires authentication, enter your password here. - False - - - - 1 - 2 - 3 - 4 - - - - - - True - 0.89999997615814209 - Host - - - 1 - 2 - GTK_FILL - - - - - - True - 0.89999997615814209 - Proxy type - - - GTK_FILL - - - - - - True - 0.89999997615814209 - Username - - - 2 - 3 - GTK_FILL - - - - - - True - 0.89999997615814209 - Password - - - 3 - 4 - GTK_FILL - - - - - - - - - - True - <b>HTTP Proxy</b> - True - - - label_item - - - - - False - 0 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - 3 - 3 - 3 - 3 - 3 - - - True - True - Maximum number of concurrent items to fetch at once. - 1 0 100 1 10 0 - 1 - - - 1 - 2 - - - - - - True - True - Maximum number of item fetches per web server. - 1 0 100 1 10 0 - 1 - - - 1 - 2 - 1 - 2 - - - - - - True - True - Number of connections to keep incase they are needed again. - 1 0 100 1 10 0 - 1 - - - 1 - 2 - 2 - 3 - - - - - - True - 0.89999997615814209 - Maximum fetchers - - - - - - - - True - 0.89999997615814209 - Fetches per host - - - 1 - 2 - - - - - - True - 0.89999997615814209 - Cached connections - - - 2 - 3 - - - - - - - - - - - - - - - - - - - True - <b>Fetching</b> - True - - - label_item - - - - - False - 1 - - - - - 1 - - - - - True - Network - - - 1 - False - tab - - - - - True - - - True - 5 - 0 - none - - - True - 12 - - - True - - - Resample images when not at natural size - True - True - False - Resample images when not at natural size - True - True - True - - - 0 - - - - - - - - - True - <b>Quality</b> - True - - - label_item - - - - - False - 0 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - - - True - - - True - 0.89999997615814209 - Limit speed to - - - 0 - - - - - True - True - Do not update animations any more often than this. - 0 0 100 0.10000000149 1 0 - 1 - 1 - True - if-valid - - - False - 1 - - - - - True - 0 - seconds between frames - - - 2 - - - - - 0 - - - - - Disable animations - True - True - False - Display only the first frame of animated images. - True - True - - - False - False - 1 - - - - - - - - - True - <b>Animations</b> - True - - - label_item - - - - - False - False - 1 - - - - - 2 - - - - - True - Rendering - - - 2 - False - tab - - - - - True - - - True - 5 - 0 - none - - - True - 12 - - - True - 2 - 6 - 2 - 3 - 3 - - - True - True - False - False - False - - - 1 - 2 - - - - - - True - 0.89999997615814209 - Sans-serif - - - GTK_FILL - - - - - - True - 0.89999997615814209 - Serif - - - 1 - 2 - GTK_FILL - - - - - - True - 0.89999997615814209 - Monospace - - - 2 - 3 - GTK_FILL - - - - - - True - 0.89999997615814209 - Cursive - - - 3 - 4 - GTK_FILL - - - - - - True - 0.89999997615814209 - Fantasy - - - 4 - 5 - GTK_FILL - - - - - - True - 0.89999997615814209 - Default - - - 5 - 6 - GTK_FILL - - - - - - True - True - False - False - False - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - - True - True - False - False - False - - - 1 - 2 - 2 - 3 - GTK_FILL - - - - - - True - True - False - False - False - - - 1 - 2 - 3 - 4 - GTK_FILL - - - - - - True - True - False - False - False - - - 1 - 2 - 4 - 5 - GTK_FILL - - - - - - True - Sans-serif -Serif -Monospace -Cursive -Fantasy - - - 1 - 2 - 5 - 6 - GTK_FILL - - - - - - - - - - True - <b>Font faces</b> - True - - - label_item - - - - - False - 0 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - 2 - 4 - 3 - 3 - - - True - True - False - View the changes in the browser window immediately. - - - True - 2 - - - True - gtk-apply - - - 0 - - - - - True - _Preview - True - - - 1 - - - - - - - 3 - 4 - 2 - - - 2 - - - - - True - True - The base-line font size to use. - 1 0 100 1 10 0 - 1 - - - 1 - 2 - - - - - - - True - True - Do not allow text to be displayed any smaller than this. - 1 0 100 1 10 0 - 1 - - - 1 - 2 - 1 - 2 - - - - - - - True - 0 - pt - - - 2 - 3 - - - - - - True - 0 - pt - - - 2 - 3 - 1 - 2 - - - - - - True - 0.89999997615814209 - Minimum - - - 1 - 2 - GTK_FILL - - - - - - True - 0.89999997615814209 - Default - - - GTK_FILL - - - - - - - - - - True - <b>Font size</b> - True - - - label_item - - - - - False - 1 - - - - - True - 0 - none - - - True - 12 - - - True - 2 - 10 - 3 - - - True - Small icons -Large icons -Large icons and text -Text only - - - 1 - 2 - - - - - - - True - Toolbar buttons - right - - - - GTK_FILL - - - - - - - - - True - 5 - <b>Icons</b> - True - - - label_item - - - - - 2 - - - - - 3 - - - - - True - Style - - - 3 - False - tab - - - - - True - - - True - 5 - 0 - none - - - True - 12 - - - True - 2 - 6 - - - True - Size - - - False - False - 0 - - - - - True - True - How much memory to use for caching recently viewed objects in memory. - 1 0 100 1 10 0 - 1 - - - False - False - 1 - - - - - True - MB - - - False - False - 2 - - - - - - - - - True - <b>Memory cache</b> - True - - - label_item - - - - - False - False - 0 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - 5 - - - True - 3 - - - True - Duration - - - False - False - 0 - - - - - True - True - How long to keep cached items around on disc. - 1 0 100 1 10 0 - 1 - - - False - False - 1 - - - - - True - days - - - False - False - 2 - - - - - 0 - - - - - True - 4 - 4 - - - - - - True - True - False - Flush cached items that are older than the maximum permitted age. - - - True - 0 - 0 - - - True - 2 - - - True - gtk-delete - - - False - False - 0 - - - - - True - False - Perform maintainance - True - - - False - False - 1 - - - - - - - - - False - False - 1 - - - - - - - - False - False - 1 - - - - - - - - - True - <b>Disc cache</b> - True - - - label_item - - - - - False - 1 - - - - - 4 - - - - - True - Cache - - - 4 - False - tab - - - - - True - - - True - 5 - 0 - none - - - True - 12 - - - True - - - Automatically clear downloads when completed - True - True - False - Erase the download from the list as soon as it completes. - True - True - True - - - 0 - - - - - Request confirmation before overwriting files - True - True - False - Ask before overwriting files when downloading. - True - True - - - False - False - 1 - - - - - True - - - True - 2 - Download directory - - - False - False - 2 - 0 - - - - - True - True - select-folder - 25 - - - 1 - - - - - 2 - - - - - - - - - True - <b>Downloads</b> - True - - - label_item - - - - - False - 0 - - - - - True - 0 - none - - - True - 12 - - - True - - - Show tab bar with only one tab - True - True - False - True - True - - - False - False - 0 - - - - - Shift focus to new tab - True - True - False - True - True - - - 1 - - - - - Open blank window - True - True - False - True - True - - - 2 - - - - - True - - - True - 0.4699999988079071 - 2 - Tabs position - - - False - False - 2 - 0 - - - - - True - Top -Left -Right -Bottom - - - 1 - - - - - 3 - - - - - - - - - True - <b>Tabs</b> - True - - - label_item - - - - - False - 1 - - - - - True - 0 - none - - - True - 12 - - - True - - - in own window - True - True - False - True - True - True - - - False - False - 0 - - - - - in new tab - True - True - False - True - True - - - False - False - 1 - - - - - - - - - True - <b>View Source</b> - True - - - label_item - - - - - False - False - 2 - - - - - True - 0 - none - - - True - 12 - - - True - - - Search from URL bar - True - True - False - True - True - - - False - 0 - - - - - True - Default provider - right - - - False - 1 - - - - - True - Google -Yahoo! -Microsoft live -Business.com -Omgili -BBC News -Ubuntu packages -Creative commons -Ask -Answers -Dictionary.com -Youtube -AeroMp3 -AOL -Baidu -Amazon -Ebay -IMDB -Espn -Wikipedia -DuckDuckGo - - - 2 - - - - - - - - - True - <b>Search</b> - True - - - label_item - - - - - False - False - 3 - - - - - True - 0 - none - - - True - 12 - - - True - - - - - - Add theme… - True - True - False - True - - - False - False - end - 1 - - - - - - - - - True - <b>Select themes</b> - True - - - label_item - - - - - False - 4 - - - - - 5 - - - - - True - Advanced - - - 5 - False - tab - - - - - True - - - True - 5 - 0 - none - - - True - 12 - - - True - True - - - True - 2 - 3 - 4 - 5 - - - True - mm - - - 2 - 3 - 1 - 2 - - - - - True - mm - - - 2 - 3 - - - - - True - True - Set the bottom margin - 0 0 100 1 10 0 - 1 - - - 1 - 2 - 1 - 2 - - - - - True - True - Set the top margin - 0 0 100 1 10 0 - 1 - - - 1 - 2 - - - - - True - 0.89999997615814209 - Bottom - - - 1 - 2 - - - - - True - 0.89999997615814209 - Top - - - - - False - False - 0 - - - - - True - 2 - 3 - 4 - 5 - - - True - mm - - - 2 - 3 - 1 - 2 - - - - - True - mm - - - 2 - 3 - - - - - True - True - Set the right margin - 0 0 100 1 10 0 - 1 - - - 1 - 2 - 1 - 2 - - - - - True - True - Set the left margin - 0 0 100 1 10 0 - 1 - - - 1 - 2 - - - - - True - 0.89999997615814209 - Right - - - 1 - 2 - - - - - True - 0.89999997615814209 - Left - - - - - False - False - 1 - - - - - - - - - True - <b>Margins</b> - True - - - label_item - - - - - False - 0 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - 4 - - - True - Scale - - - False - 0 - - - - - True - True - Set the scaling for the document - this way more content can fit in a page - 0 0 1000 1 10 0 - 1 - - - False - False - 1 - - - - - True - % - - - False - 2 - - - - - - - - - True - <b>Scaling</b> - True - - - label_item - - - - - False - False - 1 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - - - Suppress images - True - True - False - True - True - - - 0 - - - - - Remove backgrounds - True - True - False - True - True - - - 1 - - - - - Fit page - True - True - False - True - True - - - 2 - - - - - - - - - True - <b>Appearance</b> - True - - - label_item - - - - - False - 2 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - - - Compress PDF - True - True - False - True - True - - - 0 - - - - - Set a password for PDF - True - True - False - True - True - - - 1 - - - - - - - - - True - <b>Advanced</b> - True - - - label_item - - - - - False - False - 3 - - - - - True - 10 - - - Default - True - True - False - Reset export settings to defaults - True - - - False - False - 0 - - - - - False - 4 - - - - - 6 - - - - - True - Export - - - 6 - False - tab - - - - - 1 - - - - - True - edge - - - gtk-help - True - False - True - False - True - - - False - False - 0 - - - - - gtk-close - -7 - True - True - False - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - diff --git a/gtk/res/options.gtk2.ui b/gtk/res/options.gtk2.ui new file mode 100644 index 000000000..0f50ecce6 --- /dev/null +++ b/gtk/res/options.gtk2.ui @@ -0,0 +1,2417 @@ + + + + + + 5 + Netsurf Preferences + center-on-parent + True + dialog + False + + + True + vertical + 2 + + + True + True + 4 + + + True + vertical + + + True + 5 + 0 + none + + + True + 12 + + + True + vertical + + + True + 5 + 5 + + + True + URL + + + False + False + 0 + + + + + True + True + + + + 1 + + + + + 0 + + + + + True + 5 + + + Current Page + True + True + False + True + + + 5 + 0 + + + + + Default Page + True + True + False + True + + + 5 + end + 1 + + + + + 1 + + + + + + + + + True + <b>Home page</b> + True + + + + + False + 0 + + + + + True + + + True + 5 + 0 + none + + + True + 12 + + + True + vertical + True + + + Hide advertisements + True + True + False + True + True + + + False + False + 0 + + + + + Disable pop-up windows + True + True + False + True + True + + + False + False + 1 + + + + + Disable plug-ins + True + False + True + True + + + False + False + 2 + + + + + + + + + True + <b>Content blocking</b> + True + + + + + False + 0 + + + + + True + 0 + none + + + True + 12 + + + True + vertical + + + + + + True + vertical + + + + + + + + + + + + False + False + 1 + + + + + + + + + + + + True + <b>Content Language</b> + True + + + + + 1 + + + + + False + 1 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + 1 + vertical + 2 + + + True + 4 + 4 + + + True + Keep history for + + + False + False + 0 + + + + + True + True + + 1 + + + False + False + 1 + + + + + True + days + + + False + False + 2 + + + + + 0 + + + + + Hover URLs by pointer in local history + True + True + False + True + True + + + False + False + 1 + + + + + + + + + True + <b>History</b> + True + + + + + False + False + 2 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + vertical + True + + + Display recently visited URLs as you type + True + True + False + True + True + + + False + False + 0 + + + + + Send site referral information + True + True + False + True + True + True + + + False + False + 1 + + + + + + + + + True + <b>Misc</b> + True + + + + + False + 3 + + + + + + + True + General + + + False + + + + + True + vertical + + + True + 5 + 0 + none + + + True + 12 + + + True + 4 + 2 + 3 + 3 + + + True + True + + + + 1 + 2 + 2 + 3 + + + + + + True + + + 1 + 2 + + + + + + True + + + True + True + + + + 0 + + + + + True + : + + + False + False + 1 + + + + + 64 + True + True + + + + False + 2 + + + + + 1 + 2 + 1 + 2 + + + + + + True + True + False + + + + 1 + 2 + 3 + 4 + + + + + + True + 0.89999997615814209 + Host + + + 1 + 2 + GTK_FILL + + + + + + True + 0.89999997615814209 + Proxy type + + + GTK_FILL + + + + + + True + 0.89999997615814209 + Username + + + 2 + 3 + GTK_FILL + + + + + + True + 0.89999997615814209 + Password + + + 3 + 4 + GTK_FILL + + + + + + + + + + True + <b>HTTP Proxy</b> + True + + + + + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + 3 + 3 + 3 + 3 + 3 + + + True + True + + 1 + + + 1 + 2 + + + + + + True + True + + 1 + + + 1 + 2 + 1 + 2 + + + + + + True + True + + 1 + + + 1 + 2 + 2 + 3 + + + + + + True + 0.89999997615814209 + Maximum fetchers + + + + + + + + True + 0.89999997615814209 + Fetches per host + + + 1 + 2 + + + + + + True + 0.89999997615814209 + Cached connections + + + 2 + 3 + + + + + + + + + + + + + + + + + + + True + <b>Fetching</b> + True + + + + + False + 1 + + + + + 1 + + + + + True + Network + + + 1 + False + + + + + True + vertical + + + True + 5 + 0 + none + + + True + 12 + + + True + + + Resample images when not at natural size + True + True + False + True + True + True + + + 0 + + + + + + + + + True + <b>Quality</b> + True + + + + + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + + + True + + + True + 0.89999997615814209 + Limit speed to + + + 0 + + + + + True + True + + 1 + 1 + True + if-valid + + + False + 1 + + + + + True + 0 + seconds between frames + + + 2 + + + + + 0 + + + + + Disable animations + True + True + False + True + True + + + False + False + 1 + + + + + + + + + True + <b>Animations</b> + True + + + + + False + False + 1 + + + + + 2 + + + + + True + Rendering + + + 2 + False + + + + + True + vertical + + + True + 5 + 0 + none + + + True + 12 + + + True + 2 + 6 + 2 + 3 + 3 + + + True + True + False + False + False + + + 1 + 2 + + + + + + True + 0.89999997615814209 + Sans-serif + + + GTK_FILL + + + + + + True + 0.89999997615814209 + Serif + + + 1 + 2 + GTK_FILL + + + + + + True + 0.89999997615814209 + Monospace + + + 2 + 3 + GTK_FILL + + + + + + True + 0.89999997615814209 + Cursive + + + 3 + 4 + GTK_FILL + + + + + + True + 0.89999997615814209 + Fantasy + + + 4 + 5 + GTK_FILL + + + + + + True + 0.89999997615814209 + Default + + + 5 + 6 + GTK_FILL + + + + + + True + True + False + False + False + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + True + True + False + False + False + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + + True + True + False + False + False + + + 1 + 2 + 3 + 4 + GTK_FILL + + + + + + True + True + False + False + False + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + + True + + + 1 + 2 + 5 + 6 + GTK_FILL + + + + + + + + + + True + <b>Font faces</b> + True + + + + + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + 2 + 4 + 3 + 3 + + + True + True + False + + + True + 2 + + + True + gtk-apply + + + 0 + + + + + True + _Preview + True + + + 1 + + + + + + + 3 + 4 + 2 + + + 2 + + + + + True + True + + 1 + + + 1 + 2 + + + + + + + True + True + + 1 + + + 1 + 2 + 1 + 2 + + + + + + + True + 0 + pt + + + 2 + 3 + + + + + + True + 0 + pt + + + 2 + 3 + 1 + 2 + + + + + + True + 0.89999997615814209 + Minimum + + + 1 + 2 + GTK_FILL + + + + + + True + 0.89999997615814209 + Default + + + GTK_FILL + + + + + + + + + + True + <b>Font size</b> + True + + + + + False + 1 + + + + + True + 0 + none + + + True + 12 + + + True + 2 + 10 + 3 + + + True + + + 1 + 2 + + + + + + + True + Toolbar buttons + right + + + + GTK_FILL + + + + + + + + + True + 5 + <b>Icons</b> + True + + + + + 2 + + + + + 3 + + + + + True + Style + + + 3 + False + + + + + True + vertical + + + True + 5 + 0 + none + + + True + 12 + + + True + 2 + 6 + + + True + Size + + + False + False + 0 + + + + + True + True + + 1 + + + False + False + 1 + + + + + True + MB + + + False + False + 2 + + + + + + + + + True + <b>Memory cache</b> + True + + + + + False + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + vertical + 5 + + + True + 3 + + + True + Duration + + + False + False + 0 + + + + + True + True + + 1 + + + False + False + 1 + + + + + True + days + + + False + False + 2 + + + + + 0 + + + + + True + 4 + 4 + + + + + + True + True + False + + + True + 0 + 0 + + + True + 2 + + + True + gtk-delete + + + False + False + 0 + + + + + True + False + Perform maintainance + True + + + False + False + 1 + + + + + + + + + False + False + 1 + + + + + + + + False + False + 1 + + + + + + + + + True + <b>Disc cache</b> + True + + + + + False + 1 + + + + + 4 + + + + + True + Cache + + + 4 + False + + + + + True + vertical + + + True + 5 + 0 + none + + + True + 12 + + + True + vertical + + + Automatically clear downloads when completed + True + True + False + True + True + True + + + 0 + + + + + Request confirmation before overwriting files + True + True + False + True + True + + + False + False + 1 + + + + + True + + + True + 2 + Download directory + + + False + False + 2 + 0 + + + + + True + select-folder + True + 25 + + + 1 + + + + + 2 + + + + + + + + + True + <b>Downloads</b> + True + + + + + False + 0 + + + + + True + 0 + none + + + True + 12 + + + True + vertical + + + Show tab bar with only one tab + True + True + False + True + True + + + False + False + 0 + + + + + Shift focus to new tab + True + True + False + True + True + + + 1 + + + + + Open blank window + True + True + False + True + True + + + 2 + + + + + True + + + True + 0.4699999988079071 + 2 + Tabs position + + + False + False + 2 + 0 + + + + + True + + + 1 + + + + + 3 + + + + + + + + + True + <b>Tabs</b> + True + + + + + False + 1 + + + + + True + 0 + none + + + True + 12 + + + True + + + in own window + True + True + False + True + True + True + + + False + False + 0 + + + + + in new tab + True + True + False + True + True + + + False + False + 1 + + + + + + + + + True + <b>View Source</b> + True + + + + + False + False + 2 + + + + + True + 0 + none + + + True + 12 + + + True + + + Search from URL bar + True + True + False + True + True + + + False + 0 + + + + + True + Default provider + right + + + False + 1 + + + + + True + + + 2 + + + + + + + + + True + <b>Search</b> + True + + + + + False + False + 3 + + + + + True + 0 + none + + + True + 12 + + + True + + + + + + Add theme… + True + True + False + True + + + False + False + end + 1 + + + + + + + + + True + <b>Select themes</b> + True + + + + + False + 4 + + + + + 5 + + + + + True + Advanced + + + 5 + False + + + + + True + vertical + + + True + 5 + 0 + none + + + True + 12 + + + True + True + + + True + 2 + 3 + 4 + 5 + + + True + mm + + + 2 + 3 + 1 + 2 + + + + + True + mm + + + 2 + 3 + + + + + True + True + + 1 + + + 1 + 2 + 1 + 2 + + + + + True + True + + 1 + + + 1 + 2 + + + + + True + 0.89999997615814209 + Bottom + + + 1 + 2 + + + + + True + 0.89999997615814209 + Top + + + + + False + False + 0 + + + + + True + 2 + 3 + 4 + 5 + + + True + mm + + + 2 + 3 + 1 + 2 + + + + + True + mm + + + 2 + 3 + + + + + True + True + + 1 + + + 1 + 2 + 1 + 2 + + + + + True + True + + 1 + + + 1 + 2 + + + + + True + 0.89999997615814209 + Right + + + 1 + 2 + + + + + True + 0.89999997615814209 + Left + + + + + False + False + 1 + + + + + + + + + True + <b>Margins</b> + True + + + + + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + 4 + + + True + Scale + + + False + 0 + + + + + True + True + + 1 + + + False + False + 1 + + + + + True + % + + + False + 2 + + + + + + + + + True + <b>Scaling</b> + True + + + + + False + False + 1 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + vertical + + + Suppress images + True + True + False + True + True + + + 0 + + + + + Remove backgrounds + True + True + False + True + True + + + 1 + + + + + Fit page + True + True + False + True + True + + + 2 + + + + + + + + + True + <b>Appearance</b> + True + + + + + False + 2 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + vertical + + + Compress PDF + True + True + False + True + True + + + 0 + + + + + Set a password for PDF + True + True + False + True + True + + + 1 + + + + + + + + + True + <b>Advanced</b> + True + + + + + False + False + 3 + + + + + True + 10 + + + Default + True + True + False + True + + + False + False + 0 + + + + + False + 4 + + + + + 6 + + + + + True + Export + + + 6 + False + + + + + 1 + + + + + True + edge + + + gtk-help + True + False + True + False + True + + + False + False + 0 + + + + + gtk-close + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + help + close + + + diff --git a/gtk/res/options.gtk3.ui b/gtk/res/options.gtk3.ui new file mode 100644 index 000000000..b6254a34d --- /dev/null +++ b/gtk/res/options.gtk3.ui @@ -0,0 +1,2709 @@ + + + + 100 + 0 + 10 + 1 + 0 + 14 + + + 100 + 0 + 10 + 1 + 0 + 0 + + + 100 + 0 + 10 + 1 + 0 + 0 + + + 100 + 0 + 10 + 1 + 0 + 0 + + + 100 + 0 + 10 + 1 + 0 + 0 + + + 1000 + 0 + 10 + 1 + 0 + 0 + + + 100 + 0 + 10 + 1 + 0 + 1 + + + 100 + 0 + 10 + 1 + 0 + 1 + + + 100 + 0 + 10 + 1 + 0 + 1 + + + 100 + 0 + 1 + 0.10000000149 + 0 + 0 + + + 100 + 0 + 10 + 1 + 0 + 1 + + + 100 + 0 + 10 + 1 + 0 + 1 + + + 100 + 0 + 10 + 1 + 0 + 1 + + + 100 + 0 + 10 + 1 + 0 + 1 + + + + + + + + No proxy + + + Simple proxy + + + Basic authentication + + + NTLM authentication + + + + + + + + + + Sans-serif + + + Serif + + + Monospace + + + Cursive + + + Fantasy + + + + + + + + + + Small icons + + + Large icons + + + Large icons and text + + + Text only + + + + + + + + + + Top + + + Left + + + Right + + + Bottom + + + + + + + + + + Google + + + Yahoo! + + + Microsoft live + + + Business.com + + + Omgili + + + BBC News + + + Ubuntu packages + + + Creative commons + + + Ask + + + Answers + + + Dictionary.com + + + Youtube + + + AeroMp3 + + + AOL + + + Baidu + + + Amazon + + + Ebay + + + IMDB + + + Espn + + + Wikipedia + + + DuckDuckGo + + + + + + + 5 + Netsurf Preferences + center-on-parent + True + dialog + + + True + 2 + + + True + True + 4 + + + True + + + True + 5 + 0 + none + + + True + 12 + + + True + + + True + 5 + 5 + + + True + URL + + + False + False + 0 + + + + + True + True + The page to visit when the Home button is pressed, or a new window is opened. + + + + 1 + + + + + 0 + + + + + True + 5 + + + Current Page + True + True + False + True + + + 5 + 0 + + + + + Default Page + True + True + False + True + + + 5 + end + 1 + + + + + 1 + + + + + + + + + True + <b>Home page</b> + True + + + + + False + 0 + + + + + True + + + True + 5 + 0 + none + + + True + 12 + + + True + True + + + Hide advertisements + True + True + False + Attempt to hide images from known advertisement servers. + True + True + + + False + False + 0 + + + + + Disable pop-up windows + True + True + False + Stop pop-up windows normally containing adverts appearing. + True + True + + + False + False + 1 + + + + + Disable plug-ins + True + False + Do not allow embedded applets or plugins. + True + True + + + False + False + 2 + + + + + + + + + True + <b>Content blocking</b> + True + + + + + False + 0 + + + + + True + 0 + none + + + True + 12 + + + True + + + + + + True + + + + + + + + + + + + False + False + 1 + + + + + + + + + + + + True + <b>Content Language</b> + True + + + + + 1 + + + + + False + 1 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + 1 + 2 + + + True + 4 + 4 + + + True + Keep history for + + + False + False + 0 + + + + + True + True + Visited pages are kept in memory for this many days + adjustment1 + 1 + + + False + False + 1 + + + + + True + days + + + False + False + 2 + + + + + 0 + + + + + Hover URLs by pointer in local history + True + True + False + Show a tooltip showing the URL of a page in the local history tree. + True + True + + + False + False + 1 + + + + + + + + + True + <b>History</b> + True + + + + + False + False + 2 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + True + + + Display recently visited URLs as you type + True + True + False + Show a drop-down list of recent addresses when typing into the address bar. + True + True + + + False + False + 0 + + + + + Send site referral information + True + True + False + When requesting items or pages, tell the server what linked to them. + True + True + True + + + False + False + 1 + + + + + + + + + + + + True + <b>Misc</b> + True + + + + + False + 3 + + + + + + + True + General + + + False + + + + + True + + + True + 5 + 0 + none + + + True + 12 + + + True + 4 + 2 + 3 + 3 + + + True + True + If your proxy server requires authentication, enter your username here. + + + + 1 + 2 + 2 + 3 + + + + + + True + model1 + + + + 0 + + + + + 1 + 2 + + + + + + True + + + True + True + Host name of your proxy server. + + + + 0 + + + + + True + : + + + False + False + 1 + + + + + 64 + True + True + Port number to connect to on proxy server. + + + + False + 2 + + + + + 1 + 2 + 1 + 2 + + + + + + True + True + If your proxy server requires authentication, enter your password here. + False + + + + 1 + 2 + 3 + 4 + + + + + + True + 0.89999997615814209 + Host + + + 1 + 2 + GTK_FILL + + + + + + True + 0.89999997615814209 + Proxy type + + + GTK_FILL + + + + + + True + 0.89999997615814209 + Username + + + 2 + 3 + GTK_FILL + + + + + + True + 0.89999997615814209 + Password + + + 3 + 4 + GTK_FILL + + + + + + + + + + True + <b>HTTP Proxy</b> + True + + + + + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + 3 + 3 + 3 + 3 + 3 + + + True + True + Maximum number of concurrent items to fetch at once. + adjustment2 + 1 + + + 1 + 2 + + + + + + True + True + Maximum number of item fetches per web server. + adjustment3 + 1 + + + 1 + 2 + 1 + 2 + + + + + + True + True + Number of connections to keep incase they are needed again. + adjustment4 + 1 + + + 1 + 2 + 2 + 3 + + + + + + True + 0.89999997615814209 + Maximum fetchers + + + + + + + + True + 0.89999997615814209 + Fetches per host + + + 1 + 2 + + + + + + True + 0.89999997615814209 + Cached connections + + + 2 + 3 + + + + + + + + + + + + + + + + + + + True + <b>Fetching</b> + True + + + + + False + 1 + + + + + + + True + Network + + + 1 + False + + + + + True + + + True + 5 + 0 + none + + + True + 12 + + + True + + + Resample images when not at natural size + True + True + False + Resample images when not at natural size + True + True + True + + + 0 + + + + + + + + + True + <b>Quality</b> + True + + + + + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + + + True + + + True + 0.89999997615814209 + Limit speed to + + + 0 + + + + + True + True + Do not update animations any more often than this. + adjustment5 + 1 + 1 + True + if-valid + + + False + 1 + + + + + True + 0 + seconds between frames + + + 2 + + + + + 0 + + + + + Disable animations + True + True + False + Display only the first frame of animated images. + True + True + + + False + False + 1 + + + + + + + + + True + <b>Animations</b> + True + + + + + False + False + 1 + + + + + + + True + Rendering + + + 2 + False + + + + + True + + + True + 5 + 0 + none + + + True + 12 + + + True + 2 + 6 + 2 + 3 + 3 + + + True + True + False + False + False + + + 1 + 2 + + + + + + True + 0.89999997615814209 + Sans-serif + + + GTK_FILL + + + + + + True + 0.89999997615814209 + Serif + + + 1 + 2 + GTK_FILL + + + + + + True + 0.89999997615814209 + Monospace + + + 2 + 3 + GTK_FILL + + + + + + True + 0.89999997615814209 + Cursive + + + 3 + 4 + GTK_FILL + + + + + + True + 0.89999997615814209 + Fantasy + + + 4 + 5 + GTK_FILL + + + + + + True + 0.89999997615814209 + Default + + + 5 + 6 + GTK_FILL + + + + + + True + True + False + False + False + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + True + True + False + False + False + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + + True + True + False + False + False + + + 1 + 2 + 3 + 4 + GTK_FILL + + + + + + True + True + False + False + False + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + + True + model2 + + + + 0 + + + + + 1 + 2 + 5 + 6 + GTK_FILL + + + + + + + + + + True + <b>Font faces</b> + True + + + + + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + 2 + 4 + 3 + 3 + + + True + True + False + View the changes in the browser window immediately. + + + True + 2 + + + True + gtk-apply + + + 0 + + + + + True + _Preview + True + + + 1 + + + + + + + 3 + 4 + 2 + + + 2 + + + + + True + True + The base-line font size to use. + adjustment6 + 1 + + + 1 + 2 + + + + + + + True + True + Do not allow text to be displayed any smaller than this. + adjustment7 + 1 + + + 1 + 2 + 1 + 2 + + + + + + + True + 0 + pt + + + 2 + 3 + + + + + + True + 0 + pt + + + 2 + 3 + 1 + 2 + + + + + + True + 0.89999997615814209 + Minimum + + + 1 + 2 + GTK_FILL + + + + + + True + 0.89999997615814209 + Default + + + GTK_FILL + + + + + + + + + + True + <b>Font size</b> + True + + + + + False + 1 + + + + + True + 0 + none + + + True + 12 + + + True + 2 + 10 + 3 + + + True + model3 + + + + 0 + + + + + 1 + 2 + + + + + + + True + Toolbar buttons + right + + + + GTK_FILL + + + + + + + + + True + 5 + <b>Icons</b> + True + + + + + 2 + + + + + + + True + Style + + + 3 + False + + + + + True + + + True + 5 + 0 + none + + + True + 12 + + + True + 2 + 6 + + + True + Size + + + False + False + 0 + + + + + True + True + How much memory to use for caching recently viewed objects in memory. + adjustment8 + 1 + + + False + False + 1 + + + + + True + MB + + + False + False + 2 + + + + + + + + + True + <b>Memory cache</b> + True + + + + + False + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + 5 + + + True + 3 + + + True + Duration + + + False + False + 0 + + + + + True + True + How long to keep cached items around on disc. + adjustment9 + 1 + + + False + False + 1 + + + + + True + days + + + False + False + 2 + + + + + 0 + + + + + True + 4 + 4 + + + + + + True + True + False + Flush cached items that are older than the maximum permitted age. + + + True + 0 + 0 + + + True + 2 + + + True + gtk-delete + + + False + False + 0 + + + + + True + False + Perform maintainance + True + + + False + False + 1 + + + + + + + + + False + False + 1 + + + + + + + + False + False + 1 + + + + + + + + + True + <b>Disc cache</b> + True + + + + + False + 1 + + + + + + + True + Cache + + + 4 + False + + + + + True + + + True + 5 + 0 + none + + + True + 12 + + + True + + + Automatically clear downloads when completed + True + True + False + Erase the download from the list as soon as it completes. + True + True + True + + + 0 + + + + + Request confirmation before overwriting files + True + True + False + Ask before overwriting files when downloading. + True + True + + + False + False + 1 + + + + + True + + + True + 2 + Download directory + + + False + False + 2 + 0 + + + + + True + True + select-folder + 25 + + + 1 + + + + + 2 + + + + + + + + + True + <b>Downloads</b> + True + + + + + False + 0 + + + + + True + 0 + none + + + True + 12 + + + True + + + Show tab bar with only one tab + True + True + False + True + True + + + False + False + 0 + + + + + Shift focus to new tab + True + True + False + True + True + + + 1 + + + + + Open blank window + True + True + False + True + True + + + 2 + + + + + True + + + True + 0.4699999988079071 + 2 + Tabs position + + + False + False + 2 + 0 + + + + + True + model4 + + + + 0 + + + + + 1 + + + + + 3 + + + + + + + + + True + <b>Tabs</b> + True + + + + + False + 1 + + + + + True + 0 + none + + + True + 12 + + + True + + + in own window + True + True + False + True + True + True + + + False + False + 0 + + + + + in new tab + True + True + False + True + True + + + False + False + 1 + + + + + + + + + True + <b>View Source</b> + True + + + + + False + False + 2 + + + + + True + 0 + none + + + True + 12 + + + True + + + Search from URL bar + True + True + False + True + True + + + False + 0 + + + + + True + Default provider + right + + + False + 1 + + + + + True + model5 + + + + 0 + + + + + 2 + + + + + + + + + True + <b>Search</b> + True + + + + + False + False + 3 + + + + + True + 0 + none + + + True + 12 + + + True + + + + + + Add theme… + True + True + False + True + + + False + False + end + 1 + + + + + + + + + True + <b>Select themes</b> + True + + + + + False + 4 + + + + + + + True + Advanced + + + 5 + False + + + + + True + + + True + 5 + 0 + none + + + True + 12 + + + True + True + + + True + 2 + 3 + 4 + 5 + + + True + mm + + + 2 + 3 + 1 + 2 + + + + + True + mm + + + 2 + 3 + + + + + True + True + Set the bottom margin + adjustment10 + 1 + + + 1 + 2 + 1 + 2 + + + + + True + True + Set the top margin + adjustment11 + 1 + + + 1 + 2 + + + + + True + 0.89999997615814209 + Bottom + + + 1 + 2 + + + + + True + 0.89999997615814209 + Top + + + + + False + False + 0 + + + + + True + 2 + 3 + 4 + 5 + + + True + mm + + + 2 + 3 + 1 + 2 + + + + + True + mm + + + 2 + 3 + + + + + True + True + Set the right margin + adjustment12 + 1 + + + 1 + 2 + 1 + 2 + + + + + True + True + Set the left margin + adjustment13 + 1 + + + 1 + 2 + + + + + True + 0.89999997615814209 + Right + + + 1 + 2 + + + + + True + 0.89999997615814209 + Left + + + + + False + False + 1 + + + + + + + + + True + <b>Margins</b> + True + + + + + False + 0 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + 4 + + + True + Scale + + + False + 0 + + + + + True + True + Set the scaling for the document - this way more content can fit in a page + adjustment14 + 1 + + + False + False + 1 + + + + + True + % + + + False + 2 + + + + + + + + + True + <b>Scaling</b> + True + + + + + False + False + 1 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + + + Suppress images + True + True + False + True + True + + + 0 + + + + + Remove backgrounds + True + True + False + True + True + + + 1 + + + + + Fit page + True + True + False + True + True + + + 2 + + + + + + + + + True + <b>Appearance</b> + True + + + + + False + 2 + + + + + True + 5 + 0 + none + + + True + 12 + + + True + + + Compress PDF + True + True + False + True + True + + + 0 + + + + + Set a password for PDF + True + True + False + True + True + + + 1 + + + + + + + + + True + <b>Advanced</b> + True + + + + + False + False + 3 + + + + + True + 10 + + + Default + True + True + False + Reset export settings to defaults + True + + + False + False + 0 + + + + + False + 4 + + + + + + + True + Export + + + 6 + False + + + + + 1 + + + + + True + edge + + + gtk-help + True + False + True + False + True + + + False + False + 0 + + + + + gtk-close + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + close + + + diff --git a/gtk/res/password.glade b/gtk/res/password.glade deleted file mode 100644 index 27a16a085..000000000 --- a/gtk/res/password.glade +++ /dev/null @@ -1,443 +0,0 @@ - - - - - - - PDF Password - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - True - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - True - False - - - - True - False - 0 - - - - True - 6 - gtk-dialog-authentication - 0.5 - 0.10000000149 - 12 - 0 - - - 0 - False - False - - - - - - 5 - True - False - 0 - - - - 5 - True - True - 0 - - - - True - Owner password - False - False - GTK_JUSTIFY_LEFT - False - False - 0.899999976158 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - 15 - False - 0 - - - 0 - False - True - - - - - - True - True - True - False - 20 - - True - - False - 20 - - - 0 - False - False - - - - - 0 - False - False - - - - - - 5 - True - True - 0 - - - - True - Repeat password - False - False - GTK_JUSTIFY_LEFT - False - False - 0.899999976158 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - 15 - False - 0 - - - 0 - False - True - - - - - - True - True - True - False - 20 - - True - - False - 20 - - - 0 - False - False - - - - - 0 - False - False - - - - - - 5 - True - True - 0 - - - - True - User password - False - False - GTK_JUSTIFY_LEFT - False - False - 0.899999976158 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - 15 - False - 0 - - - 0 - False - True - - - - - - True - True - True - False - 20 - - True - - False - 20 - - - 0 - False - False - - - - - 0 - False - False - - - - - - 5 - True - True - 0 - - - - True - Repeat password - False - False - GTK_JUSTIFY_LEFT - False - False - 0.899999976158 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - 15 - False - 0 - - - 0 - False - True - - - - - - True - True - True - False - 20 - - True - - False - 20 - - - 0 - False - False - - - - - 0 - False - False - - - - - - 5 - True - GTK_BUTTONBOX_END - 10 - - - - True - True - GTK_RELIEF_NORMAL - True - - - - True - False - 0 - - - - True - gtk-dialog-authentication - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Use these as passwords - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - True - True - - - - - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 1 - 1 - 0 - 0 - 0 - 0 - - - - True - False - 0 - - - - True - gtk-cancel - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Do not set any passwords - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - True - True - - - - - - - - - - - 0 - False - False - - - - - 0 - True - True - - - - - - - diff --git a/gtk/res/password.gtk2.ui b/gtk/res/password.gtk2.ui new file mode 100644 index 000000000..eb51e4f8f --- /dev/null +++ b/gtk/res/password.gtk2.ui @@ -0,0 +1,415 @@ + + + + + PDF Password + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + True + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + True + False + 0 + + + True + 6 + gtk-dialog-authentication + 0.5 + 0.10000000149 + 12 + 0 + + + 0 + False + False + + + + + 5 + True + False + 0 + + + 5 + True + True + 0 + + + True + Owner password + False + False + GTK_JUSTIFY_LEFT + False + False + 0.899999976158 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 15 + False + 0 + + + 0 + False + True + + + + + True + True + True + False + 20 + + True + + False + 20 + + + 0 + False + False + + + + + 0 + False + False + + + + + 5 + True + True + 0 + + + True + Repeat password + False + False + GTK_JUSTIFY_LEFT + False + False + 0.899999976158 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 15 + False + 0 + + + 0 + False + True + + + + + True + True + True + False + 20 + + True + + False + 20 + + + 0 + False + False + + + + + 0 + False + False + + + + + 5 + True + True + 0 + + + True + User password + False + False + GTK_JUSTIFY_LEFT + False + False + 0.899999976158 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 15 + False + 0 + + + 0 + False + True + + + + + True + True + True + False + 20 + + True + + False + 20 + + + 0 + False + False + + + + + 0 + False + False + + + + + 5 + True + True + 0 + + + True + Repeat password + False + False + GTK_JUSTIFY_LEFT + False + False + 0.899999976158 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 15 + False + 0 + + + 0 + False + True + + + + + True + True + True + False + 20 + + True + + False + 20 + + + 0 + False + False + + + + + 0 + False + False + + + + + 5 + True + GTK_BUTTONBOX_END + 10 + + + True + True + GTK_RELIEF_NORMAL + True + + + True + False + 0 + + + True + gtk-dialog-authentication + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + True + Use these as passwords + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 0 + 0 + + + True + False + 0 + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + True + Do not set any passwords + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + + + + + 0 + False + False + + + + + 0 + True + True + + + + + + diff --git a/gtk/res/password.gtk3.ui b/gtk/res/password.gtk3.ui new file mode 100644 index 000000000..eb51e4f8f --- /dev/null +++ b/gtk/res/password.gtk3.ui @@ -0,0 +1,415 @@ + + + + + PDF Password + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + True + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + True + False + 0 + + + True + 6 + gtk-dialog-authentication + 0.5 + 0.10000000149 + 12 + 0 + + + 0 + False + False + + + + + 5 + True + False + 0 + + + 5 + True + True + 0 + + + True + Owner password + False + False + GTK_JUSTIFY_LEFT + False + False + 0.899999976158 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 15 + False + 0 + + + 0 + False + True + + + + + True + True + True + False + 20 + + True + + False + 20 + + + 0 + False + False + + + + + 0 + False + False + + + + + 5 + True + True + 0 + + + True + Repeat password + False + False + GTK_JUSTIFY_LEFT + False + False + 0.899999976158 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 15 + False + 0 + + + 0 + False + True + + + + + True + True + True + False + 20 + + True + + False + 20 + + + 0 + False + False + + + + + 0 + False + False + + + + + 5 + True + True + 0 + + + True + User password + False + False + GTK_JUSTIFY_LEFT + False + False + 0.899999976158 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 15 + False + 0 + + + 0 + False + True + + + + + True + True + True + False + 20 + + True + + False + 20 + + + 0 + False + False + + + + + 0 + False + False + + + + + 5 + True + True + 0 + + + True + Repeat password + False + False + GTK_JUSTIFY_LEFT + False + False + 0.899999976158 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 15 + False + 0 + + + 0 + False + True + + + + + True + True + True + False + 20 + + True + + False + 20 + + + 0 + False + False + + + + + 0 + False + False + + + + + 5 + True + GTK_BUTTONBOX_END + 10 + + + True + True + GTK_RELIEF_NORMAL + True + + + True + False + 0 + + + True + gtk-dialog-authentication + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + True + Use these as passwords + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 0 + 0 + + + True + False + 0 + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + True + Do not set any passwords + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + + + + + 0 + False + False + + + + + 0 + True + True + + + + + + diff --git a/gtk/res/source.glade b/gtk/res/source.glade deleted file mode 100644 index 144179bb1..000000000 --- a/gtk/res/source.glade +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - True - - - True - - - True - _File - True - - - True - - - True - gtk-save-as - True - True - - - - - - True - gtk-print - True - True - - - - - - True - - - - - True - gtk-close - True - True - - - - - - - - - True - _Edit - True - - - True - - - True - gtk-select-all - True - True - - - - - - True - gtk-cut - True - True - - - - - True - gtk-copy - True - True - - - - - True - gtk-paste - True - True - - - - - True - gtk-delete - True - True - - - - - - - - - - True - _View - True - - - True - - - True - gtk-zoom-in - True - True - - - - - - True - gtk-zoom-out - True - True - - - - - - True - gtk-zoom-100 - True - True - - - - - - - - - - True - _Help - True - - - True - - - True - gtk-about - True - True - - - - - - - - - False - - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - 600 - 400 - True - True - 1 - 1 - False - GTK_WRAP_WORD - 3 - 3 - False - - - - - 1 - - - - - - diff --git a/gtk/res/source.gtk2.ui b/gtk/res/source.gtk2.ui new file mode 100644 index 000000000..84c3e0cf5 --- /dev/null +++ b/gtk/res/source.gtk2.ui @@ -0,0 +1,204 @@ + + + + + + + + True + vertical + + + True + + + True + _File + True + + + True + + + gtk-save-as + True + True + True + + + + + + gtk-print + True + True + True + + + + + + True + + + + + gtk-close + True + True + True + + + + + + + + + True + _Edit + True + + + True + + + gtk-select-all + True + True + True + + + + + + gtk-cut + True + True + True + + + + + gtk-copy + True + True + True + + + + + gtk-paste + True + True + True + + + + + gtk-delete + True + True + True + + + + + + + + + + True + _View + True + + + True + + + gtk-zoom-in + True + True + True + + + + + + gtk-zoom-out + True + True + True + + + + + + gtk-zoom-100 + True + True + True + + + + + + + + + + True + _Help + True + + + True + + + gtk-about + True + True + True + + + + + + + + + False + 0 + + + + + True + True + automatic + automatic + + + 600 + 400 + True + True + 1 + 1 + False + word + 3 + 3 + False + + + + + 1 + + + + + + diff --git a/gtk/res/source.gtk3.ui b/gtk/res/source.gtk3.ui new file mode 100644 index 000000000..b972315d3 --- /dev/null +++ b/gtk/res/source.gtk3.ui @@ -0,0 +1,179 @@ + + + + + + + + + menuitem1 + _File + + + + + gtk-save-as + source_save_as + + + + + + gtk-print + source_print + + + + + + gtk-close + source_close + + + + + menuitem2 + _Edit + + + + + gtk-select-all + source_select_all + + + + + + gtk-cut + source_cut + + + + + gtk-copy + source_copy + + + + + gtk-paste + source_paste + + + + + gtk-delete + source_delete + + + + + + menuitem3 + _View + + + + + gtk-zoom-in + source_zoom_in + + + + + + gtk-zoom-out + source_zoom_out + + + + + + gtk-zoom-100 + source_zoom_normal + + + + + + menuitem4 + _Help + + + + + gtk-about + source_about + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + + + True + + + False + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + 600 + 400 + True + True + 1 + 1 + False + GTK_WRAP_WORD + 3 + 3 + False + + + + + 1 + + + + + + diff --git a/gtk/res/ssl.glade b/gtk/res/ssl.glade deleted file mode 100644 index 5d0570987..000000000 --- a/gtk/res/ssl.glade +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - 1 - SSL certificate problem - True - 500 - 250 - GDK_WINDOW_TYPE_HINT_DIALOG - - - True - - - True - - - True - 0 - 6 - gtk-dialog-warning - - - False - False - - - - - True - - - True - NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below. - GTK_JUSTIFY_CENTER - True - - - False - False - - - - - True - 5 - 0 - - - True - 12 - - - True - True - GTK_SHADOW_IN - - - True - GTK_RESIZE_QUEUE - - - True - True - True - GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK - - - - - - - - - - - True - <b>Certificate chain</b> - True - - - label_item - - - - - 1 - - - - - 1 - - - - - 2 - - - - - True - GTK_BUTTONBOX_END - - - True - True - True - -6 - - - True - 0 - 0 - - - True - 2 - - - True - gtk-cancel - - - False - False - - - - - True - Reject - True - - - False - False - 1 - - - - - - - - - - - True - True - True - -5 - - - True - 0 - 0 - - - True - 2 - - - True - gtk-apply - - - False - False - - - - - True - Accept - True - - - False - False - 1 - - - - - - - - - 1 - - - - - False - GTK_PACK_END - - - - - - diff --git a/gtk/res/ssl.gtk2.ui b/gtk/res/ssl.gtk2.ui new file mode 100644 index 000000000..90f449ddd --- /dev/null +++ b/gtk/res/ssl.gtk2.ui @@ -0,0 +1,202 @@ + + + + + 1 + SSL certificate problem + True + 500 + 250 + GDK_WINDOW_TYPE_HINT_DIALOG + + + True + + + True + + + True + 0 + 6 + gtk-dialog-warning + + + False + False + + + + + True + + + True + NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below. + GTK_JUSTIFY_CENTER + True + + + False + False + + + + + True + 5 + 0 + + + True + 12 + + + True + True + GTK_SHADOW_IN + + + True + GTK_RESIZE_QUEUE + + + True + True + True + GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK + + + + + + + + + + + True + <b>Certificate chain</b> + True + + + + + 1 + + + + + 1 + + + + + 2 + + + + + True + GTK_BUTTONBOX_END + + + True + True + True + + + True + 0 + 0 + + + True + 2 + + + True + gtk-cancel + + + False + False + + + + + True + Reject + True + + + False + False + 1 + + + + + + + + + + + True + True + True + + + True + 0 + 0 + + + True + 2 + + + True + gtk-apply + + + False + False + + + + + True + Accept + True + + + False + False + 1 + + + + + + + + + 1 + + + + + False + GTK_PACK_END + + + + + + sslreject + sslaccept + + + diff --git a/gtk/res/ssl.gtk3.ui b/gtk/res/ssl.gtk3.ui new file mode 100644 index 000000000..90f449ddd --- /dev/null +++ b/gtk/res/ssl.gtk3.ui @@ -0,0 +1,202 @@ + + + + + 1 + SSL certificate problem + True + 500 + 250 + GDK_WINDOW_TYPE_HINT_DIALOG + + + True + + + True + + + True + 0 + 6 + gtk-dialog-warning + + + False + False + + + + + True + + + True + NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below. + GTK_JUSTIFY_CENTER + True + + + False + False + + + + + True + 5 + 0 + + + True + 12 + + + True + True + GTK_SHADOW_IN + + + True + GTK_RESIZE_QUEUE + + + True + True + True + GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK + + + + + + + + + + + True + <b>Certificate chain</b> + True + + + + + 1 + + + + + 1 + + + + + 2 + + + + + True + GTK_BUTTONBOX_END + + + True + True + True + + + True + 0 + 0 + + + True + 2 + + + True + gtk-cancel + + + False + False + + + + + True + Reject + True + + + False + False + 1 + + + + + + + + + + + True + True + True + + + True + 0 + 0 + + + True + 2 + + + True + gtk-apply + + + False + False + + + + + True + Accept + True + + + False + False + 1 + + + + + + + + + 1 + + + + + False + GTK_PACK_END + + + + + + sslreject + sslaccept + + + diff --git a/gtk/res/tabcontents.gtk2.ui b/gtk/res/tabcontents.gtk2.ui new file mode 100644 index 000000000..1c7d99bc3 --- /dev/null +++ b/gtk/res/tabcontents.gtk2.ui @@ -0,0 +1,75 @@ + + + + + + True + 2 + 2 + + + True + True + + + + + 1 + True + 2 + + + 1 + 2 + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + True + + + 1 + True + 0 + 4 + Status + + + False + False + + + + + True + + + True + True + + + + + 1 + 2 + GTK_FILL + + + + + True + vertical + + + 1 + 2 + + + + + diff --git a/gtk/res/tabcontents.gtk3.ui b/gtk/res/tabcontents.gtk3.ui new file mode 100644 index 000000000..28d09e074 --- /dev/null +++ b/gtk/res/tabcontents.gtk3.ui @@ -0,0 +1,87 @@ + + + + + True + False + 2 + 2 + + + True + True + False + + + 0 + 0 + 1 + 1 + + + + + True + False + True + vertical + + + 1 + 0 + 1 + 1 + + + + + True + False + 2 + + + 1 + 1 + 1 + 1 + + + + + True + True + True + + + True + False + 0 + 4 + Status + True + + + False + True + + + + + True + False + + + True + True + + + + + 0 + 1 + 1 + 1 + + + + diff --git a/gtk/res/toolbar.glade b/gtk/res/toolbar.glade deleted file mode 100644 index 9e2a338b5..000000000 --- a/gtk/res/toolbar.glade +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - 700 - 450 - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - True - False - - - - True - False - 0 - - - - True - Move items from store to toolbar Rearrange items in toolbar Move items from toolbar to store - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - True - - - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - GTK_SHADOW_IN - - - - True - False - 0 - - - - - - - - - - - 0 - True - True - - - - - - True - True - False - 0 - - - - True - True - GTK_RELIEF_NORMAL - True - - - - True - False - 0 - - - - True - gtk-refresh - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - True - - - - - - True - Reset to defaults - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - True - True - - - - - - - 10 - False - True - - - - - - - - - - True - True - True - gtk-apply - True - GTK_RELIEF_NORMAL - True - - - 10 - False - True - - - - - - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - - - 0 - False - True - - - - - 0 - False - True - - - - - - - diff --git a/gtk/res/toolbar.gtk2.ui b/gtk/res/toolbar.gtk2.ui new file mode 100644 index 000000000..d84db5c8c --- /dev/null +++ b/gtk/res/toolbar.gtk2.ui @@ -0,0 +1,189 @@ + + + + + 700 + 450 + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + True + False + 0 + + + True + Move items from store to toolbar Rearrange items in toolbar Move items from toolbar to store + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + True + + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + True + GTK_SHADOW_IN + + + True + False + 0 + + + + + + + + + + 0 + True + True + + + + + True + True + False + 0 + + + True + True + GTK_RELIEF_NORMAL + True + + + True + False + 0 + + + True + gtk-refresh + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + True + Reset to defaults + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + 10 + False + True + + + + + + + + True + True + True + gtk-apply + True + GTK_RELIEF_NORMAL + True + + + 10 + False + True + + + + + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + + + 0 + False + True + + + + + 0 + False + True + + + + + + diff --git a/gtk/res/toolbar.gtk3.ui b/gtk/res/toolbar.gtk3.ui new file mode 100644 index 000000000..d84db5c8c --- /dev/null +++ b/gtk/res/toolbar.gtk3.ui @@ -0,0 +1,189 @@ + + + + + 700 + 450 + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + True + False + 0 + + + True + Move items from store to toolbar Rearrange items in toolbar Move items from toolbar to store + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + True + + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + True + GTK_SHADOW_IN + + + True + False + 0 + + + + + + + + + + 0 + True + True + + + + + True + True + False + 0 + + + True + True + GTK_RELIEF_NORMAL + True + + + True + False + 0 + + + True + gtk-refresh + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + True + Reset to defaults + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + 10 + False + True + + + + + + + + True + True + True + gtk-apply + True + GTK_RELIEF_NORMAL + True + + + 10 + False + True + + + + + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + + + 0 + False + True + + + + + 0 + False + True + + + + + + diff --git a/gtk/res/warning.glade b/gtk/res/warning.glade deleted file mode 100644 index edfa18076..000000000 --- a/gtk/res/warning.glade +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - Warning from NetSurf - GTK_WIN_POS_CENTER - gtk-dialog-warning - GDK_WINDOW_TYPE_HINT_DIALOG - True - - - True - 2 - - - True - 3 - - - True - 12 - 6 - gtk-dialog-warning - - - False - False - - - - - True - Help help help! I'm being held prisoner by a bunch of RISC OS zealots! - True - - - 1 - 1 - - - - - - - True - - - False - 3 - 1 - - - - - True - GTK_BUTTONBOX_END - - - True - True - True - gtk-ok - True - 0 - - - - - - False - False - 2 - - - - - - diff --git a/gtk/res/warning.gtk2.ui b/gtk/res/warning.gtk2.ui new file mode 100644 index 000000000..e4fb4e662 --- /dev/null +++ b/gtk/res/warning.gtk2.ui @@ -0,0 +1,77 @@ + + + + + Warning from NetSurf + GTK_WIN_POS_CENTER + gtk-dialog-warning + GDK_WINDOW_TYPE_HINT_DIALOG + True + + + True + 2 + + + True + 3 + + + True + 12 + 6 + gtk-dialog-warning + + + False + False + + + + + True + Help help help! I'm being held prisoner by a bunch of RISC OS zealots! + True + + + 1 + 1 + + + + + + + True + + + False + 3 + 1 + + + + + True + GTK_BUTTONBOX_END + + + True + True + True + gtk-ok + True + + + + + + False + False + 2 + + + + + + diff --git a/gtk/res/warning.gtk3.ui b/gtk/res/warning.gtk3.ui new file mode 100644 index 000000000..e4fb4e662 --- /dev/null +++ b/gtk/res/warning.gtk3.ui @@ -0,0 +1,77 @@ + + + + + Warning from NetSurf + GTK_WIN_POS_CENTER + gtk-dialog-warning + GDK_WINDOW_TYPE_HINT_DIALOG + True + + + True + 2 + + + True + 3 + + + True + 12 + 6 + gtk-dialog-warning + + + False + False + + + + + True + Help help help! I'm being held prisoner by a bunch of RISC OS zealots! + True + + + 1 + 1 + + + + + + + True + + + False + 3 + 1 + + + + + True + GTK_BUTTONBOX_END + + + True + True + True + gtk-ok + True + + + + + + False + False + 2 + + + + + + diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index 34e0d514b..f09dc446c 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -88,8 +88,6 @@ #include "utils/log.h" -/** Obtain a GTK widget handle from glade xml object */ -#define GET_WIDGET(x) glade_xml_get_widget(g->xml, (x)) /** Macro to define a handler for menu, button and activate events. */ #define MULTIHANDLER(q)\ @@ -139,7 +137,7 @@ struct gtk_scaffolding { int toolbarbase; int historybase; - GladeXML *xml; + GtkBuilder *xml; struct gtk_history_window *history_window; GtkDialog *preferences_dialog; @@ -565,8 +563,9 @@ MULTIHANDLER(newtab) if (nsoption_bool(new_blank)) { browser_window_create(NULL, bw, NULL, false, true); GtkWidget *window = gtk_notebook_get_nth_page(g->notebook, -1); - gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &((GdkColor) - {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF})); + nsgtk_widget_override_background_color(window, + GTK_STATE_NORMAL, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF); } else { const char *url = nsoption_charp(homepage_url); @@ -1285,8 +1284,10 @@ MULTIHANDLER(savedomtree) if (bw->current_content && content_get_type(bw->current_content) == CONTENT_HTML) { +#ifdef FIXME xmlDebugDumpDocument(fh, html_get_document(bw->current_content)); +#endif } fclose(fh); @@ -1409,7 +1410,7 @@ MULTIHANDLER(localhistory) gtk_widget_show(GTK_WIDGET(g->history_window->window)); gtk_window_move(g->history_window->window, x + g->historybase, y + g->toolbarbase); - gdk_window_raise(GTK_WIDGET(g->history_window->window)->window); + gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(g->history_window->window))); return TRUE; } @@ -1417,7 +1418,7 @@ MULTIHANDLER(localhistory) MULTIHANDLER(globalhistory) { gtk_widget_show(GTK_WIDGET(wndHistory)); - gdk_window_raise(GTK_WIDGET(wndHistory)->window); + gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(wndHistory))); return TRUE; } @@ -1436,7 +1437,7 @@ MULTIHANDLER(addbookmarks) MULTIHANDLER(showbookmarks) { gtk_widget_show(GTK_WIDGET(wndHotlist)); - gdk_window_raise(GTK_WIDGET(wndHotlist)->window); + gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(wndHotlist))); gtk_window_set_focus(wndHotlist, NULL); return TRUE; @@ -1445,7 +1446,7 @@ MULTIHANDLER(showbookmarks) MULTIHANDLER(showcookies) { gtk_widget_show(GTK_WIDGET(wndCookies)); - gdk_window_raise(GTK_WIDGET(wndCookies)->window); + gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(wndCookies))); return TRUE; } @@ -1519,10 +1520,49 @@ BUTTONHANDLER(history) #undef CHECKHANDLER #undef BUTTONHANDLER +#if GTK_CHECK_VERSION(3,0,0) + +static gboolean +nsgtk_history_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) +{ + struct rect clip; + struct gtk_history_window *hw = (struct gtk_history_window *)data; + struct browser_window *bw = + nsgtk_get_browser_window(hw->g->top_level); + + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &nsgtk_plotters + }; + double x1; + double y1; + double x2; + double y2; + + current_widget = widget; + current_cr = cr; + + cairo_clip_extents(cr, &x1, &y1, &x2, &y2); + + clip.x0 = x1; + clip.y0 = y1; + clip.x1 = x2; + clip.y1 = y2; + + ctx.plot->clip(&clip); + + history_redraw(bw->history, &ctx); + + current_widget = NULL; + + return FALSE; +} +#else /* signal handler functions for the local history window */ -static gboolean nsgtk_history_expose_event(GtkWidget *widget, - GdkEventExpose *event, gpointer g) +static gboolean +nsgtk_history_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer g) { struct rect clip; struct gtk_history_window *hw = (struct gtk_history_window *)g; @@ -1537,7 +1577,7 @@ static gboolean nsgtk_history_expose_event(GtkWidget *widget, current_widget = widget; - current_cr = gdk_cairo_create(widget->window); + current_cr = gdk_cairo_create(gtk_widget_get_window(widget)); clip.x0 = event->area.x; clip.y0 = event->area.y; @@ -1547,13 +1587,14 @@ static gboolean nsgtk_history_expose_event(GtkWidget *widget, history_redraw(bw->history, &ctx); - current_widget = NULL; - cairo_destroy(current_cr); + current_widget = NULL; + return FALSE; } +#endif /* GTK_CHECK_VERSION(3,0,0) */ static gboolean nsgtk_history_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer g) @@ -1654,6 +1695,7 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) char *searchname; int i; GtkAccelGroup *group; + GError* error = NULL; if (g == NULL) { warn_user("NoMemory", 0); @@ -1669,9 +1711,18 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) /* load the window template from the glade xml file, and extract * widget references from it for later use. */ - g->xml = glade_xml_new(glade_file_location->netsurf, - "wndBrowser", NULL); - glade_xml_signal_autoconnect(g->xml); + g->xml = gtk_builder_new(); + if (!gtk_builder_add_from_file(g->xml, glade_file_location->netsurf, &error)) { + g_warning("Couldn't load builder file: \"%s\"", error->message); + g_error_free (error); + return NULL; + } + + gtk_builder_connect_signals(g->xml, NULL); + +/** Obtain a GTK widget handle from glade xml object */ +#define GET_WIDGET(x) GTK_WIDGET (gtk_builder_get_object(g->xml, (x))) + g->window = GTK_WINDOW(GET_WIDGET("wndBrowser")); g->notebook = GTK_NOTEBOOK(GET_WIDGET("notebook")); g->tool_bar = GTK_TOOLBAR(GET_WIDGET("toolbar")); @@ -1694,7 +1745,7 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) g->search->checkAll = GTK_CHECK_BUTTON(GET_WIDGET("checkAllSearch")); g->search->caseSens = GTK_CHECK_BUTTON(GET_WIDGET("caseSensButton")); - +#undef GET_WIDGET for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { g->buttons[i] = malloc(sizeof(struct nsgtk_button_connect)); @@ -1724,7 +1775,7 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) group = gtk_accel_group_new(); gtk_window_add_accel_group(g->window, group); - g->menu_bar = nsgtk_menu_bar_create(GTK_MENU_SHELL(glade_xml_get_widget(g->xml, "menubar")), group); + g->menu_bar = nsgtk_menu_bar_create(GTK_MENU_SHELL(gtk_builder_get_object(g->xml, "menubar")), group); g->preferences_dialog = NULL; @@ -1838,9 +1889,9 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK); - gtk_widget_modify_bg(GTK_WIDGET(g->history_window->drawing_area), + nsgtk_widget_override_background_color(GTK_WIDGET(g->history_window->drawing_area), GTK_STATE_NORMAL, - &((GdkColor) { 0, 0xffff, 0xffff, 0xffff } )); + 0, 0xffff, 0xffff, 0xffff); gtk_scrolled_window_add_with_viewport(g->history_window->scrolled, GTK_WIDGET(g->history_window->drawing_area)); gtk_widget_show(GTK_WIDGET(g->history_window->drawing_area)); @@ -1868,8 +1919,9 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr)) /* connect history window signals to their handlers */ - CONNECT(g->history_window->drawing_area, "expose_event", - nsgtk_history_expose_event, g->history_window); + nsgtk_connect_draw_event(GTK_WIDGET(g->history_window->drawing_area), + G_CALLBACK(nsgtk_history_draw_event), + g->history_window); /*CONNECT(g->history_window->drawing_area, "motion_notify_event", nsgtk_history_motion_notify_event, g->history_window);*/ CONNECT(g->history_window->drawing_area, "button_press_event", diff --git a/gtk/scaffolding.h b/gtk/scaffolding.h index 4769ad8df..cf75f0af3 100644 --- a/gtk/scaffolding.h +++ b/gtk/scaffolding.h @@ -20,7 +20,7 @@ #define NETSURF_GTK_SCAFFOLDING_H 1 #include -#include +//#include #include #include "desktop/gui.h" diff --git a/gtk/search.c b/gtk/search.c index fc2f3f2c3..1c002d523 100644 --- a/gtk/search.c +++ b/gtk/search.c @@ -20,10 +20,12 @@ /** \file * Free text search (front component) */ +#include #include #include #include +#include "gtk/compat.h" #include "gtk/search.h" #include "gtk/scaffolding.h" #include "gtk/window.h" @@ -37,7 +39,6 @@ #include "desktop/selection.h" #include "render/box.h" #include "render/html.h" -#include "utils/config.h" #include "utils/log.h" #include "utils/messages.h" #include "utils/utils.h" @@ -171,7 +172,7 @@ gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data) gboolean nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event, gpointer data) { - if (event->keyval == GDK_Escape) { + if (event->keyval == GDK_KEY(Escape)) { struct gtk_scaffolding *g = (struct gtk_scaffolding *)data; nsgtk_scaffolding_toggle_search_bar_visibility(g); } diff --git a/gtk/tabs.c b/gtk/tabs.c index 13f6d393d..b258a20ad 100644 --- a/gtk/tabs.c +++ b/gtk/tabs.c @@ -16,8 +16,10 @@ * along with this program. If not, see . */ -#include +#include #include + +#include "gtk/compat.h" #include "gtk/window.h" #include "gtk/gui.h" #include "desktop/browser.h" @@ -37,10 +39,16 @@ static void nsgtk_tab_update_size(GtkWidget *hbox, GtkStyle *previous_style, PangoFontMetrics *metrics; PangoContext *context; int char_width, h, w; + GtkStyleContext *style; + GtkStateFlags state; + + state = nsgtk_widget_get_state_flags(hbox); + style = nsgtk_widget_get_style_context(hbox); context = gtk_widget_get_pango_context(hbox); - metrics = pango_context_get_metrics(context, hbox->style->font_desc, - pango_context_get_language(context)); + metrics = pango_context_get_metrics(context, + nsgtk_style_context_get_font(style, state), + pango_context_get_language(context)); char_width = pango_font_metrics_get_approximate_digit_width(metrics); pango_font_metrics_unref(metrics); @@ -59,9 +67,8 @@ static void nsgtk_tab_update_size(GtkWidget *hbox, GtkStyle *previous_style, static GtkWidget *nsgtk_tab_label_setup(struct gui_window *window) { GtkWidget *hbox, *label, *button, *close; - GtkRcStyle *rcstyle; - hbox = gtk_hbox_new(FALSE, 2); + hbox = nsgtk_hbox_new(FALSE, 2); if (nsoption_bool(new_blank) == true) label = gtk_label_new("New Tab"); @@ -81,10 +88,13 @@ static GtkWidget *nsgtk_tab_label_setup(struct gui_window *window) gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_widget_set_tooltip_text(button, "Close this tab."); +#ifdef FIXME + GtkRcStyle *rcstyle; rcstyle = gtk_rc_style_new(); rcstyle->xthickness = rcstyle->ythickness = 0; gtk_widget_modify_style(button, rcstyle); g_object_unref(rcstyle); +#endif g_signal_connect_swapped(button, "clicked", G_CALLBACK(nsgtk_window_destroy_browser), window); diff --git a/gtk/theme.c b/gtk/theme.c index 26206110e..a8c33225c 100644 --- a/gtk/theme.c +++ b/gtk/theme.c @@ -254,7 +254,7 @@ void nsgtk_theme_add(const char *themename) } g_signal_connect_swapped(notification, "response", G_CALLBACK(gtk_widget_destroy), notification); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(notification)->vbox), label); + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(notification))), label); gtk_widget_show_all(notification); /* update combo */ diff --git a/gtk/toolbar.c b/gtk/toolbar.c index 7fa2764df..0e5ef4e1d 100644 --- a/gtk/toolbar.c +++ b/gtk/toolbar.c @@ -43,7 +43,7 @@ struct nsgtk_toolbar_custom_store { GtkWidget *widgetvbox; GtkWidget *currentbar; char numberh; /* current horizontal location while adding */ - GladeXML *glade; /* button widgets to store */ + GtkBuilder *glade; /* button widgets to store */ int buttonlocations[PLACEHOLDER_BUTTON]; int currentbutton; bool fromstore; @@ -123,10 +123,10 @@ void nsgtk_toolbar_customization_init(nsgtk_scaffolding *g) nsgtk_window_get_signalhandler( nsgtk_scaffolding_top_level(list), NSGTK_WINDOW_SIGNAL_REDRAW)); - gtk_widget_modify_bg(GTK_WIDGET(nsgtk_window_get_layout( + nsgtk_widget_override_background_color( + GTK_WIDGET(nsgtk_window_get_layout( nsgtk_scaffolding_top_level(list))), - GTK_STATE_NORMAL, &((GdkColor) - {0, 0xEEEE, 0xEEEE, 0xEEEE})); + GTK_STATE_NORMAL, 0, 0xEEEE, 0xEEEE, 0xEEEE); if (list == g) { list = nsgtk_scaffolding_iterate(list); @@ -188,6 +188,7 @@ void nsgtk_toolbar_customization_init(nsgtk_scaffolding *g) void nsgtk_toolbar_window_open(nsgtk_scaffolding *g) { int x = 0, y = 0; + GError* error = NULL; struct nsgtk_theme *theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR); if (theme == NULL) { @@ -195,22 +196,29 @@ void nsgtk_toolbar_window_open(nsgtk_scaffolding *g) nsgtk_toolbar_cancel_clicked(NULL, g); return; } - window->glade = glade_xml_new(glade_file_location->toolbar, - "toolbarwindow", NULL); - if (window->glade == NULL) { + + window->glade = gtk_builder_new(); + if (!gtk_builder_add_from_file(window->glade, + glade_file_location->toolbar, + &error)) { + g_warning ("Couldn't load builder file: %s", error->message); + g_error_free (error); warn_user(messages_get("NoMemory"), 0); nsgtk_toolbar_cancel_clicked(NULL, g); + return; } - glade_xml_signal_autoconnect(window->glade); - window->window = glade_xml_get_widget(window->glade, "toolbarwindow"); + gtk_builder_connect_signals(window->glade, NULL); + + window->window = GTK_WIDGET(gtk_builder_get_object(window->glade, "toolbarwindow")); if (window->window == NULL) { warn_user(messages_get("NoMemory"), 0); nsgtk_toolbar_cancel_clicked(NULL, g); free(theme); return; } - window->widgetvbox = glade_xml_get_widget(window->glade, "widgetvbox"); + + window->widgetvbox = GTK_WIDGET(gtk_builder_get_object(window->glade, "widgetvbox")); if (window->widgetvbox == NULL) { warn_user(messages_get("NoMemory"), 0); nsgtk_toolbar_cancel_clicked(NULL, g); @@ -251,12 +259,14 @@ void nsgtk_toolbar_window_open(nsgtk_scaffolding *g) GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_get_position(nsgtk_scaffolding_window(g), &x, &y); gtk_window_move(GTK_WINDOW(window->window), x, y + 100); - g_signal_connect(glade_xml_get_widget(window->glade, "cancelbutton"), - "clicked", G_CALLBACK( - nsgtk_toolbar_cancel_clicked), g); - g_signal_connect(glade_xml_get_widget(window->glade, "okbutton"), + g_signal_connect(GTK_WIDGET(gtk_builder_get_object(window->glade, "cancelbutton")), + "clicked", + G_CALLBACK(nsgtk_toolbar_cancel_clicked), + g); + + g_signal_connect(GTK_WIDGET(gtk_builder_get_object(window->glade, "okbutton")), "clicked", G_CALLBACK(nsgtk_toolbar_persist), g); - g_signal_connect(glade_xml_get_widget(window->glade, "resetbutton"), + g_signal_connect(GTK_WIDGET(gtk_builder_get_object(window->glade, "resetbutton")), "clicked", G_CALLBACK(nsgtk_toolbar_reset), g); g_signal_connect(window->window, "delete-event", G_CALLBACK(nsgtk_toolbar_delete), g); @@ -396,10 +406,7 @@ void nsgtk_toolbar_close(nsgtk_scaffolding *g) gtk_widget_show_all(GTK_WIDGET(nsgtk_scaffolding_toolbar( list))); nsgtk_scaffolding_set_sensitivity(list); - gtk_widget_modify_bg(GTK_WIDGET(nsgtk_window_get_layout( - nsgtk_scaffolding_top_level(list))), - GTK_STATE_NORMAL, &((GdkColor) - {0, 0xFFFF, 0xFFFF, 0xFFFF})); + nsgtk_widget_override_background_color(GTK_WIDGET(nsgtk_window_get_layout(nsgtk_scaffolding_top_level(list))), GTK_STATE_NORMAL, 0, 0xFFFF, 0xFFFF, 0xFFFF); g_signal_handler_unblock(GTK_WIDGET( nsgtk_window_get_layout( nsgtk_scaffolding_top_level(list))), @@ -1044,8 +1051,9 @@ void nsgtk_toolbar_customization_load(nsgtk_scaffolding *g) return; } val = fgets(buffer, sizeof buffer, f); - if (val == NULL) + if (val == NULL) { LOG(("empty read toolbar settings")); + } fclose(f); i = BACK_BUTTON; ii = BACK_BUTTON; diff --git a/gtk/treeview.c b/gtk/treeview.c index 7e690e7db..ca936ef5f 100644 --- a/gtk/treeview.c +++ b/gtk/treeview.c @@ -22,14 +22,16 @@ */ #include -#include -#include #include #include +#include +#include + #include "desktop/tree.h" #include "desktop/tree_url_node.h" #include "desktop/plotters.h" +#include "gtk/compat.h" #include "gtk/gui.h" #include "gtk/plotters.h" #include "gtk/treeview.h" @@ -164,9 +166,40 @@ static void nsgtk_tree_get_window_dimensions(int *width, int *height, void *data } } +#if GTK_CHECK_VERSION(3,0,0) + +static gboolean +nsgtk_tree_window_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) +{ + struct tree *tree = (struct tree *)data; + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &nsgtk_plotters + }; + double x1; + double y1; + double x2; + double y2; + + current_widget = widget; + current_cr = cr; + + cairo_clip_extents(cr, &x1, &y1, &x2, &y2); + + tree_set_redraw(tree, true); + tree_draw(tree, 0, 0, x1, y1, x2 - x1, y2 - y1, &ctx); + + current_widget = NULL; + + return FALSE; +} + +#else + /* signal handler functions for a tree window */ -gboolean nsgtk_tree_window_expose_event(GtkWidget *widget, - GdkEventExpose *event, gpointer g) +static gboolean +nsgtk_tree_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer g) { struct tree *tree = (struct tree *) g; struct redraw_context ctx = { @@ -182,7 +215,7 @@ gboolean nsgtk_tree_window_expose_event(GtkWidget *widget, height = event->area.height; current_widget = widget; - current_cr = gdk_cairo_create(widget->window); + current_cr = gdk_cairo_create(gtk_widget_get_window(widget)); tree_set_redraw(tree, true); tree_draw(tree, 0, 0, x, y, width, height, &ctx); @@ -193,6 +226,8 @@ gboolean nsgtk_tree_window_expose_event(GtkWidget *widget, return FALSE; } +#endif + void nsgtk_tree_window_hide(GtkWidget *widget, gpointer g) { struct nsgtk_treeview *tw = g; @@ -382,81 +417,85 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event, edited = tree_is_edited(tree); switch (event->keyval) { - case GDK_Home: - case GDK_KP_Home: + case GDK_KEY(Home): + case GDK_KEY(KP_Home): if (edited) break; scroll = vscroll; - value = scroll->lower; + value = gtk_adjustment_get_lower(scroll); break; - case GDK_End: - case GDK_KP_End: + case GDK_KEY(End): + case GDK_KEY(KP_End): if (edited) break; scroll = vscroll; - value = scroll->upper - vpage; - if (value < scroll->lower) - value = scroll->lower; + value = gtk_adjustment_get_upper(scroll) - vpage; + if (value < gtk_adjustment_get_lower(scroll)) + value = gtk_adjustment_get_lower(scroll); break; - case GDK_Left: - case GDK_KP_Left: + case GDK_KEY(Left): + case GDK_KEY(KP_Left): if (edited) break; scroll = hscroll; value = gtk_adjustment_get_value(scroll) - - scroll->step_increment; - if (value < scroll->lower) - value = scroll->lower; + gtk_adjustment_get_step_increment(scroll); + if (value < gtk_adjustment_get_lower(scroll)) + value = gtk_adjustment_get_lower(scroll); break; - case GDK_Up: - case GDK_KP_Up: + case GDK_KEY(Up): + case GDK_KEY(KP_Up): scroll = vscroll; value = gtk_adjustment_get_value(scroll) - - scroll->step_increment; - if (value < scroll->lower) - value = scroll->lower; + gtk_adjustment_get_step_increment(scroll); + if (value < gtk_adjustment_get_lower(scroll)) + value = gtk_adjustment_get_lower(scroll); break; - case GDK_Right: - case GDK_KP_Right: + case GDK_KEY(Right): + case GDK_KEY(KP_Right): if (edited) break; scroll = hscroll; value = gtk_adjustment_get_value(scroll) + - scroll->step_increment; - if (value > scroll->upper - hpage) - value = scroll->upper - hpage; + gtk_adjustment_get_step_increment(scroll); + if (value > gtk_adjustment_get_upper(scroll) - hpage) + value = gtk_adjustment_get_upper(scroll) - hpage; break; - case GDK_Down: - case GDK_KP_Down: + case GDK_KEY(Down): + case GDK_KEY(KP_Down): scroll = vscroll; value = gtk_adjustment_get_value(scroll) + - scroll->step_increment; - if (value > scroll->upper - vpage) - value = scroll->upper - vpage; + gtk_adjustment_get_step_increment(scroll); + if (value > gtk_adjustment_get_upper(scroll) - vpage) + value = gtk_adjustment_get_upper(scroll) - vpage; break; - case GDK_Page_Up: - case GDK_KP_Page_Up: + case GDK_KEY(Page_Up): + case GDK_KEY(KP_Page_Up): scroll = vscroll; value = gtk_adjustment_get_value(scroll) - - scroll->page_increment; - if (value < scroll->lower) - value = scroll->lower; + gtk_adjustment_get_page_increment(scroll); + + if (value < gtk_adjustment_get_lower(scroll)) + value = gtk_adjustment_get_lower(scroll); + break; - case GDK_Page_Down: - case GDK_KP_Page_Down: + case GDK_KEY(Page_Down): + case GDK_KEY(KP_Page_Down): scroll = vscroll; value = gtk_adjustment_get_value(scroll) + - scroll->page_increment; - if (value > scroll->upper - vpage) - value = scroll->upper - vpage; + gtk_adjustment_get_page_increment(scroll); + + if (value > gtk_adjustment_get_upper(scroll) - vpage) + value = gtk_adjustment_get_upper(scroll) - vpage; break; + default: tree_keypress(tree, nskey); return TRUE; @@ -483,6 +522,8 @@ struct nsgtk_treeview *nsgtk_treeview_create(unsigned int flags, { struct nsgtk_treeview *tv; + assert(drawing_area != NULL); + tv = malloc(sizeof(struct nsgtk_treeview)); if (tv == NULL) { LOG(("malloc failed")); @@ -497,15 +538,14 @@ struct nsgtk_treeview *nsgtk_treeview_create(unsigned int flags, tv->mouse_state = 0; tv->mouse_pressed = false; - gtk_widget_modify_bg(GTK_WIDGET(drawing_area), GTK_STATE_NORMAL, - &((GdkColor) { 0, 0xffff, 0xffff, 0xffff } )); + nsgtk_widget_override_background_color(GTK_WIDGET(drawing_area), + GTK_STATE_NORMAL, + 0, 0xffff, 0xffff, 0xffff); + + nsgtk_connect_draw_event(GTK_WIDGET(drawing_area), G_CALLBACK(nsgtk_tree_window_draw_event), tv->tree); #define CONNECT(obj, sig, callback, ptr) \ g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr)) - - CONNECT(drawing_area, "expose_event", - nsgtk_tree_window_expose_event, - tv->tree); CONNECT(drawing_area, "button_press_event", nsgtk_tree_window_button_press_event, tv); diff --git a/gtk/window.c b/gtk/window.c index 14a17df40..bf5f022da 100644 --- a/gtk/window.c +++ b/gtk/window.c @@ -22,7 +22,9 @@ #include #include +#include #include +#include #include "content/hlcache.h" #include "gtk/window.h" @@ -43,6 +45,8 @@ #include "utils/log.h" #include "utils/utils.h" +extern const GdkPixdata menu_cursor_pixdata; + struct gui_window { /** The gtk scaffold object containing menu, buttons, url bar, [tabs], * drawing area, etc that may contain one or more gui_windows. @@ -143,10 +147,12 @@ float nsgtk_get_scale_for_gui(struct gui_window *g) return g->bw->scale; } -static gboolean nsgtk_window_expose_event(GtkWidget *widget, - GdkEventExpose *event, gpointer data) +#if GTK_CHECK_VERSION(3,0,0) + +static gboolean +nsgtk_window_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) { - struct gui_window *g = data; + struct gui_window *gw = data; struct gui_window *z; struct rect clip; struct redraw_context ctx = { @@ -155,34 +161,85 @@ static gboolean nsgtk_window_expose_event(GtkWidget *widget, .plot = &nsgtk_plotters }; - assert(g); - assert(g->bw); + double x1; + double y1; + double x2; + double y2; + + assert(gw); + assert(gw->bw); + + for (z = window_list; z && z != gw; z = z->next) + continue; + assert(z); + assert(GTK_WIDGET(gw->layout) == widget); + + current_widget = (GtkWidget *)gw->layout; + current_cr = cr; + + cairo_clip_extents(cr, &x1, &y1, &x2, &y2); + + clip.x0 = x1; + clip.y0 = y1; + clip.x1 = x2; + clip.y1 = y2; + + browser_window_redraw(gw->bw, 0, 0, &clip, &ctx); + + if (gw->careth != 0) { + nsgtk_plot_caret(gw->caretx, gw->carety, gw->careth); + } + + current_widget = NULL; + + return FALSE; +} + +#else + +static gboolean +nsgtk_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + struct gui_window *gw = data; + struct gui_window *z; + struct rect clip; + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &nsgtk_plotters + }; - for (z = window_list; z && z != g; z = z->next) + assert(gw); + assert(gw->bw); + + for (z = window_list; z && z != gw; z = z->next) continue; assert(z); - assert(GTK_WIDGET(g->layout) == widget); + assert(GTK_WIDGET(gw->layout) == widget); - current_widget = (GtkWidget *)g->layout; - current_cr = gdk_cairo_create(g->layout->bin_window); + current_widget = (GtkWidget *)gw->layout; + current_cr = gdk_cairo_create(gtk_layout_get_bin_window(gw->layout)); clip.x0 = event->area.x; clip.y0 = event->area.y; clip.x1 = event->area.x + event->area.width; clip.y1 = event->area.y + event->area.height; - browser_window_redraw(g->bw, 0, 0, &clip, &ctx); + browser_window_redraw(gw->bw, 0, 0, &clip, &ctx); - if (g->careth != 0) { - nsgtk_plot_caret(g->caretx, g->carety, g->careth); + if (gw->careth != 0) { + nsgtk_plot_caret(gw->caretx, gw->carety, gw->careth); } - current_widget = NULL; cairo_destroy(current_cr); + current_widget = NULL; + return FALSE; } +#endif + static gboolean nsgtk_window_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) { @@ -320,79 +377,102 @@ static gboolean nsgtk_window_scroll_event(GtkWidget *widget, { struct gui_window *g = data; double value; - GtkAdjustment *vscroll = gtk_layout_get_vadjustment(g->layout); - GtkAdjustment *hscroll = gtk_layout_get_hadjustment(g->layout); - GtkAdjustment *scroll; - const GtkAllocation *const alloc = - >K_WIDGET(g->layout)->allocation; + GtkAdjustment *vscroll = nsgtk_layout_get_vadjustment(g->layout); + GtkAdjustment *hscroll = nsgtk_layout_get_hadjustment(g->layout); + GtkAllocation alloc; + LOG(("%d", event->direction)); switch (event->direction) { case GDK_SCROLL_LEFT: if (browser_window_scroll_at_point(g->bw, event->x / g->bw->scale, event->y / g->bw->scale, - -100, 0) == true) - /* Core handled it */ - return TRUE; - - scroll = hscroll; - value = gtk_adjustment_get_value(scroll) - - (scroll->step_increment * 2); - if (value < scroll->lower) - value = scroll->lower; + -100, 0) != true) { + /* core did not handle event do horizontal scroll */ + + value = gtk_adjustment_get_value(hscroll) - + (gtk_adjustment_get_step_increment(hscroll) *2); + + if (value < gtk_adjustment_get_lower(hscroll)) { + value = gtk_adjustment_get_lower(hscroll); + } + + gtk_adjustment_set_value(hscroll, value); + } break; case GDK_SCROLL_UP: if (browser_window_scroll_at_point(g->bw, event->x / g->bw->scale, event->y / g->bw->scale, - 0, -100) == true) - /* Core handled it */ - return TRUE; - - scroll = vscroll; - value = gtk_adjustment_get_value(scroll) - - (scroll->step_increment * 2); - if (value < scroll->lower) - value = scroll->lower; + 0, -100) != true) { + /* core did not handle event change vertical + * adjustment. + */ + + value = gtk_adjustment_get_value(vscroll) - + (gtk_adjustment_get_step_increment(vscroll) * 2); + + if (value < gtk_adjustment_get_lower(vscroll)) { + value = gtk_adjustment_get_lower(vscroll); + } + + gtk_adjustment_set_value(vscroll, value); + } break; case GDK_SCROLL_RIGHT: if (browser_window_scroll_at_point(g->bw, event->x / g->bw->scale, event->y / g->bw->scale, - 100, 0) == true) - /* Core handled it */ - return TRUE; - - scroll = hscroll; - value = gtk_adjustment_get_value(scroll) + - (scroll->step_increment * 2); - if (value > scroll->upper - alloc->width) - value = scroll->upper - alloc->width; + 100, 0) != true) { + + /* core did not handle event change horizontal + * adjustment. + */ + + value = gtk_adjustment_get_value(hscroll) + + (gtk_adjustment_get_step_increment(hscroll) * 2); + + /* @todo consider gtk_widget_get_allocated_width() */ + gtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); + + if (value > gtk_adjustment_get_upper(hscroll) - alloc.width) { + value = gtk_adjustment_get_upper(hscroll) - + alloc.width; + } + + gtk_adjustment_set_value(hscroll, value); + } break; case GDK_SCROLL_DOWN: if (browser_window_scroll_at_point(g->bw, event->x / g->bw->scale, event->y / g->bw->scale, - 0, 100) == true) - /* Core handled it */ - return TRUE; - - scroll = vscroll; - value = gtk_adjustment_get_value(scroll) + - (scroll->step_increment * 2); - if (value > scroll->upper - alloc->height) - value = scroll->upper - alloc->height; + 0, 100) != true) { + /* core did not handle event change vertical + * adjustment. + */ + + value = gtk_adjustment_get_value(vscroll) + + (gtk_adjustment_get_step_increment(vscroll) * 2); + /* @todo consider gtk_widget_get_allocated_height */ + gtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); + + if (value > gtk_adjustment_get_upper(vscroll) - alloc.height) { + value = gtk_adjustment_get_upper(vscroll) - + alloc.height; + } + + gtk_adjustment_set_value(vscroll, value); + } break; default: - return TRUE; + break; } - gtk_adjustment_set_value(scroll, value); - return TRUE; } @@ -405,88 +485,104 @@ static gboolean nsgtk_window_keypress_event(GtkWidget *widget, if (browser_window_key_press(g->bw, nskey)) return TRUE; - if ((event->state & 0x7) == 0) { - double value; - GtkAdjustment *vscroll = gtk_layout_get_vadjustment(g->layout); - GtkAdjustment *hscroll = gtk_layout_get_hadjustment(g->layout); - GtkAdjustment *scroll; - const GtkAllocation *const alloc = - >K_WIDGET(g->layout)->allocation; - - switch (event->keyval) { - default: - return TRUE; - - case GDK_Home: - case GDK_KP_Home: - scroll = vscroll; - value = scroll->lower; - break; - - case GDK_End: - case GDK_KP_End: - scroll = vscroll; - value = scroll->upper - alloc->height; - if (value < scroll->lower) - value = scroll->lower; - break; - - case GDK_Left: - case GDK_KP_Left: - scroll = hscroll; - value = gtk_adjustment_get_value(scroll) - - scroll->step_increment; - if (value < scroll->lower) - value = scroll->lower; - break; - - case GDK_Up: - case GDK_KP_Up: - scroll = vscroll; - value = gtk_adjustment_get_value(scroll) - - scroll->step_increment; - if (value < scroll->lower) - value = scroll->lower; - break; - - case GDK_Right: - case GDK_KP_Right: - scroll = hscroll; - value = gtk_adjustment_get_value(scroll) + - scroll->step_increment; - if (value > scroll->upper - alloc->width) - value = scroll->upper - alloc->width; - break; - - case GDK_Down: - case GDK_KP_Down: - scroll = vscroll; - value = gtk_adjustment_get_value(scroll) + - scroll->step_increment; - if (value > scroll->upper - alloc->height) - value = scroll->upper - alloc->height; - break; - - case GDK_Page_Up: - case GDK_KP_Page_Up: - scroll = vscroll; - value = gtk_adjustment_get_value(scroll) - - scroll->page_increment; - if (value < scroll->lower) - value = scroll->lower; - break; - - case GDK_Page_Down: - case GDK_KP_Page_Down: - scroll = vscroll; - value = gtk_adjustment_get_value(scroll) + - scroll->page_increment; - if (value > scroll->upper - alloc->height) - value = scroll->upper - alloc->height; - break; - } + if ((event->state & 0x7) != 0) + return TRUE; + + double value; + GtkAdjustment *vscroll = nsgtk_layout_get_vadjustment(g->layout); + GtkAdjustment *hscroll = nsgtk_layout_get_hadjustment(g->layout); + GtkAllocation alloc; + + /* @todo consider gtk_widget_get_allocated_width() */ + gtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); + + switch (event->keyval) { + + case GDK_KEY(Home): + case GDK_KEY(KP_Home): + value = gtk_adjustment_get_lower(vscroll); + gtk_adjustment_set_value(vscroll, value); + break; + + case GDK_KEY(End): + case GDK_KEY(KP_End): + value = gtk_adjustment_get_upper(vscroll) - alloc.height; + + if (value < gtk_adjustment_get_lower(vscroll)) + value = gtk_adjustment_get_lower(vscroll); + + gtk_adjustment_set_value(vscroll, value); + break; + + case GDK_KEY(Left): + case GDK_KEY(KP_Left): + value = gtk_adjustment_get_value(hscroll) - + gtk_adjustment_get_step_increment(hscroll); + + if (value < gtk_adjustment_get_lower(hscroll)) + value = gtk_adjustment_get_lower(hscroll); + + gtk_adjustment_set_value(hscroll, value); + break; + + case GDK_KEY(Up): + case GDK_KEY(KP_Up): + value = gtk_adjustment_get_value(vscroll) - + gtk_adjustment_get_step_increment(vscroll); + + if (value < gtk_adjustment_get_lower(vscroll)) + value = gtk_adjustment_get_lower(vscroll); + + gtk_adjustment_set_value(vscroll, value); + break; + + case GDK_KEY(Right): + case GDK_KEY(KP_Right): + value = gtk_adjustment_get_value(hscroll) + + gtk_adjustment_get_step_increment(hscroll); + + if (value > gtk_adjustment_get_upper(hscroll) - alloc.width) + value = gtk_adjustment_get_upper(hscroll) - alloc.width; + + gtk_adjustment_set_value(hscroll, value); + break; + + case GDK_KEY(Down): + case GDK_KEY(KP_Down): + value = gtk_adjustment_get_value(vscroll) + + gtk_adjustment_get_step_increment(vscroll); + + if (value > gtk_adjustment_get_upper(vscroll) - alloc.height) + value = gtk_adjustment_get_upper(vscroll) - alloc.height; + + gtk_adjustment_set_value(vscroll, value); + break; + + case GDK_KEY(Page_Up): + case GDK_KEY(KP_Page_Up): + value = gtk_adjustment_get_value(vscroll) - + gtk_adjustment_get_page_increment(vscroll); + + if (value < gtk_adjustment_get_lower(vscroll)) + value = gtk_adjustment_get_lower(vscroll); + + gtk_adjustment_set_value(vscroll, value); + break; + + case GDK_KEY(Page_Down): + case GDK_KEY(KP_Page_Down): + value = gtk_adjustment_get_value(vscroll) + + gtk_adjustment_get_page_increment(vscroll); + + if (value > gtk_adjustment_get_upper(vscroll) - alloc.height) + value = gtk_adjustment_get_upper(vscroll) - alloc.height; + + gtk_adjustment_set_value(vscroll, value); + break; + + default: + break; - gtk_adjustment_set_value(scroll, value); } return TRUE; @@ -558,26 +654,27 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, /* Construct our primary elements */ /* top-level document (not a frame) => create a new tab */ - GladeXML *xml = glade_xml_new(glade_file_location->netsurf, - "tabContents", NULL); - if (!xml) { - warn_user("MiscError", "Failed to create tab contents"); - free(g); + GError* error = NULL; + GtkBuilder* xml = gtk_builder_new(); + if (!gtk_builder_add_from_file(xml, + glade_file_location->tabcontents, + &error)) { + g_warning ("Couldn't load builder file: %s", error->message); + g_error_free(error); return 0; } - GtkWidget *tab_contents = glade_xml_get_widget(xml, "tabContents"); - g->layout = GTK_LAYOUT(glade_xml_get_widget(xml, "layout")); - g->status_bar = GTK_LABEL(glade_xml_get_widget(xml, "status_bar")); - g->paned = GTK_PANED(glade_xml_get_widget(xml, "hpaned1")); + g->layout = GTK_LAYOUT(gtk_builder_get_object(xml, "layout")); + g->status_bar = GTK_LABEL(gtk_builder_get_object(xml, "status_bar")); + g->paned = GTK_PANED(gtk_builder_get_object(xml, "hpaned1")); /* connect the scrollbars to the layout widget */ - gtk_layout_set_hadjustment(g->layout, + nsgtk_layout_set_hadjustment(g->layout, gtk_range_get_adjustment(GTK_RANGE( - glade_xml_get_widget(xml, "hscrollbar")))); - gtk_layout_set_vadjustment(g->layout, + gtk_builder_get_object(xml, "hscrollbar")))); + nsgtk_layout_set_vadjustment(g->layout, gtk_range_get_adjustment(GTK_RANGE( - glade_xml_get_widget(xml, "vscrollbar")))); + gtk_builder_get_object(xml, "vscrollbar")))); /* add the tab to the scaffold */ bool tempback = true; @@ -592,6 +689,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, tempback = true; break; } + + GtkWidget *tab_contents = GTK_WIDGET(gtk_builder_get_object(xml, "tabContents")); g_object_set_data(G_OBJECT(tab_contents), "gui_window", g); nsgtk_tab_add(g, tab_contents, tempback); @@ -620,14 +719,15 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, nsgtk_widget_set_can_focus(GTK_WIDGET(g->layout), TRUE); /* set the default background colour of the drawing area to white. */ - gtk_widget_modify_bg(GTK_WIDGET(g->layout), GTK_STATE_NORMAL, - &((GdkColor) { 0, 0xffff, 0xffff, 0xffff } )); + nsgtk_widget_override_background_color(GTK_WIDGET(g->layout), + GTK_STATE_NORMAL, 0, 0xffff, 0xffff, 0xffff); + + + nsgtk_connect_draw_event(GTK_WIDGET(g->layout), G_CALLBACK(nsgtk_window_draw_event), g); #define CONNECT(obj, sig, callback, ptr) \ g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr)) - g->signalhandler[NSGTK_WINDOW_SIGNAL_REDRAW] = - CONNECT(g->layout, "expose_event", - nsgtk_window_expose_event, g); + CONNECT(g->layout, "motion_notify_event", nsgtk_window_motion_notify_event, g); g->signalhandler[NSGTK_WINDOW_SIGNAL_CLICK] = @@ -665,16 +765,19 @@ void nsgtk_reflow_all_windows(void) void nsgtk_window_process_reformats(void) { struct gui_window *g; + GtkAllocation alloc; browser_reformat_pending = false; for (g = window_list; g; g = g->next) { - GtkWidget *widget = GTK_WIDGET(g->layout); if (!g->bw->reformat_pending) continue; + g->bw->reformat_pending = false; - browser_window_reformat(g->bw, false, - widget->allocation.width, - widget->allocation.height); + + /* @todo consider gtk_widget_get_allocated_width() */ + gtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); + + browser_window_reformat(g->bw, false, alloc.width, alloc.height); } } @@ -797,8 +900,8 @@ void gui_window_set_status(struct gui_window *g, const char *text) bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) { - GtkAdjustment *vadj = gtk_layout_get_vadjustment(g->layout); - GtkAdjustment *hadj = gtk_layout_get_hadjustment(g->layout); + GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout); + GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout); assert(vadj); assert(hadj); @@ -811,8 +914,8 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) void gui_window_set_scroll(struct gui_window *g, int sx, int sy) { - GtkAdjustment *vadj = gtk_layout_get_vadjustment(g->layout); - GtkAdjustment *hadj = gtk_layout_get_hadjustment(g->layout); + GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout); + GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout); gdouble vlower, vpage, vupper, hlower, hpage, hupper, x = (double)sx, y = (double)sy; assert(vadj); @@ -853,35 +956,13 @@ void gui_window_update_extent(struct gui_window *g) static GdkCursor *nsgtk_create_menu_cursor(void) { - static char menu_cursor_bits[] = { - 0x00, 0x00, 0x80, 0x7F, 0x88, 0x40, 0x9E, 0x5E, 0x88, 0x40, 0x80, 0x56, - 0x80, 0x40, 0x80, 0x5A, 0x80, 0x40, 0x80, 0x5E, 0x80, 0x40, 0x80, 0x56, - 0x80, 0x40, 0x80, 0x7F, 0x00, 0x00, 0x00, 0x00, }; - - static char menu_cursor_mask_bits[] = { - 0xC0, 0xFF, 0xC8, 0xFF, 0xDF, 0xFF, 0xFF, 0xFF, 0xDF, 0xFF, 0xC8, 0xFF, - 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, - 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0x00, 0x00, }; - - static GdkCursor *r; - static GdkColor fg = { 0, 0, 0, 0 }; - static GdkColor bg = { 0, 65535, 65535, 65535 }; - - GdkPixmap *source, *mask; - - if (r != NULL) - return r; - - source = gdk_bitmap_create_from_data(NULL, menu_cursor_bits, - 16, 16); - mask = gdk_bitmap_create_from_data (NULL, menu_cursor_mask_bits, - 16, 16); - - r = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, 0, 3); - g_object_unref(source); - g_object_unref(mask); + GdkCursor *cursor = NULL; + GdkPixbuf *pixbuf; + pixbuf = gdk_pixbuf_from_pixdata(&menu_cursor_pixdata, FALSE, NULL); + cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, 0, 3); + g_object_unref (pixbuf); - return r; + return cursor; } void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) @@ -961,10 +1042,11 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) gtk_widget_get_display( GTK_WIDGET(g->layout)), cursortype); - gdk_window_set_cursor(GTK_WIDGET(g->layout)->window, cursor); + gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(g->layout)), + cursor); if (!nullcursor) - gdk_cursor_unref(cursor); + nsgdk_cursor_unref(cursor); } void gui_window_hide_pointer(struct gui_window *g) @@ -1015,8 +1097,13 @@ void gui_drag_save_selection(struct selection *s, struct gui_window *g) void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { - *width = GTK_WIDGET(g->layout)->allocation.width; - *height = GTK_WIDGET(g->layout)->allocation.height; + GtkAllocation alloc; + + /* @todo consider gtk_widget_get_allocated_width() */ + gtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); + + *width = alloc.width; + *height = alloc.height; if (scaled) { *width /= g->bw->scale; diff --git a/image/rsvg.c b/image/rsvg.c index 68d677054..d70364703 100644 --- a/image/rsvg.c +++ b/image/rsvg.c @@ -238,7 +238,7 @@ static void rsvg_destroy(struct content *c) rsvg_content *d = (rsvg_content *) c; if (d->bitmap != NULL) bitmap_destroy(d->bitmap); - if (d->rsvgh != NULL) rsvg_handle_free(d->rsvgh); + if (d->rsvgh != NULL) g_object_unref(d->rsvgh); if (d->ct != NULL) cairo_destroy(d->ct); if (d->cs != NULL) cairo_surface_destroy(d->cs); -- cgit v1.2.3