mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-03 17:54:33 +03:00
update gtk frontend to use corewindow local history
This commit is contained in:
parent
c60cb335f2
commit
8ddb9df377
@ -166,10 +166,10 @@ endif
|
||||
# S_FRONTEND are sources purely for the GTK frontend
|
||||
S_FRONTEND := gui.c schedule.c layout_pango.c bitmap.c plotters.c \
|
||||
scaffolding.c gdk.c completion.c login.c throbber.c \
|
||||
selection.c global_history.c window.c fetch.c download.c menu.c \
|
||||
print.c search.c tabs.c toolbar.c gettext.c \
|
||||
compat.c cookies.c hotlist.c viewdata.c viewsource.c \
|
||||
preferences.c about.c ssl_cert.c resources.c corewindow.c
|
||||
selection.c window.c fetch.c download.c menu.c print.c \
|
||||
search.c tabs.c toolbar.c gettext.c compat.c viewdata.c \
|
||||
viewsource.c preferences.c about.c resources.c corewindow.c \
|
||||
local_history.c global_history.c cookies.c hotlist.c ssl_cert.c
|
||||
|
||||
# This is the final source build list
|
||||
# Note this is deliberately *not* expanded here as common and image
|
||||
|
@ -228,7 +228,7 @@ nsgtk_global_history_init_menu(struct nsgtk_global_history_window *ghwin)
|
||||
|
||||
|
||||
/**
|
||||
* callback for mouse action on cookie window
|
||||
* callback for mouse action on global history window
|
||||
*
|
||||
* \param nsgtk_cw The nsgtk core window structure.
|
||||
* \param mouse_state netsurf mouse state on event
|
||||
@ -248,7 +248,7 @@ nsgtk_global_history_mouse(struct nsgtk_corewindow *nsgtk_cw,
|
||||
|
||||
|
||||
/**
|
||||
* callback for keypress on cookie window
|
||||
* callback for keypress on global history window
|
||||
*
|
||||
* \param nsgtk_cw The nsgtk core window structure.
|
||||
* \param nskey The netsurf key code
|
||||
@ -265,7 +265,7 @@ nsgtk_global_history_key(struct nsgtk_corewindow *nsgtk_cw, uint32_t nskey)
|
||||
|
||||
|
||||
/**
|
||||
* callback on draw event for cookie window
|
||||
* callback on draw event for global history window
|
||||
*
|
||||
* \param nsgtk_cw The nsgtk core window structure.
|
||||
* \param r The rectangle of the window that needs updating.
|
||||
@ -304,7 +304,7 @@ static nserror nsgtk_global_history_init(void)
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
res = nsgtk_builder_new_from_resname("history", &ncwin->builder);
|
||||
res = nsgtk_builder_new_from_resname("globalhistory", &ncwin->builder);
|
||||
if (res != NSERROR_OK) {
|
||||
LOG("History UI builder init failed");
|
||||
free(ncwin);
|
||||
|
284
frontends/gtk/local_history.c
Normal file
284
frontends/gtk/local_history.c
Normal file
@ -0,0 +1,284 @@
|
||||
/*
|
||||
* Copyright 2017 Vincent Sanders <vince@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of GTK local history manager.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "netsurf/keypress.h"
|
||||
#include "netsurf/plotters.h"
|
||||
#include "desktop/local_history.h"
|
||||
|
||||
#include "gtk/compat.h"
|
||||
#include "gtk/plotters.h"
|
||||
#include "gtk/resources.h"
|
||||
#include "gtk/corewindow.h"
|
||||
#include "gtk/local_history.h"
|
||||
|
||||
struct nsgtk_local_history_window {
|
||||
struct nsgtk_corewindow core;
|
||||
|
||||
GtkBuilder *builder;
|
||||
|
||||
GtkWindow *wnd;
|
||||
|
||||
struct local_history_session *session;
|
||||
};
|
||||
|
||||
static struct nsgtk_local_history_window *local_history_window = NULL;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* callback for mouse action on local history window
|
||||
*
|
||||
* \param nsgtk_cw The nsgtk core window structure.
|
||||
* \param mouse_state netsurf mouse state on event
|
||||
* \param x location of event
|
||||
* \param y location of event
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
nsgtk_local_history_mouse(struct nsgtk_corewindow *nsgtk_cw,
|
||||
browser_mouse_state mouse_state,
|
||||
int x, int y)
|
||||
{
|
||||
struct nsgtk_local_history_window *lhw;
|
||||
/* technically degenerate container of */
|
||||
lhw = (struct nsgtk_local_history_window *)nsgtk_cw;
|
||||
|
||||
local_history_mouse_action(lhw->session, mouse_state, x, y);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* callback for keypress on local history window
|
||||
*
|
||||
* \param nsgtk_cw The nsgtk core window structure.
|
||||
* \param nskey The netsurf key code
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
nsgtk_local_history_key(struct nsgtk_corewindow *nsgtk_cw, uint32_t nskey)
|
||||
{
|
||||
struct nsgtk_local_history_window *lhw;
|
||||
/* technically degenerate container of */
|
||||
lhw = (struct nsgtk_local_history_window *)nsgtk_cw;
|
||||
|
||||
if (local_history_keypress(lhw->session, nskey)) {
|
||||
return NSERROR_OK;
|
||||
}
|
||||
return NSERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* callback on draw event for local history window
|
||||
*
|
||||
* \param nsgtk_cw The nsgtk core window structure.
|
||||
* \param r The rectangle of the window that needs updating.
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
nsgtk_local_history_draw(struct nsgtk_corewindow *nsgtk_cw, struct rect *r)
|
||||
{
|
||||
struct redraw_context ctx = {
|
||||
.interactive = true,
|
||||
.background_images = true,
|
||||
.plot = &nsgtk_plotters
|
||||
};
|
||||
struct nsgtk_local_history_window *lhw;
|
||||
GtkAdjustment *vscroll;
|
||||
GtkAdjustment *hscroll;
|
||||
struct rect c;
|
||||
int vscroll_val;
|
||||
int hscroll_val;
|
||||
|
||||
vscroll = gtk_scrolled_window_get_vadjustment(nsgtk_cw->scrolled);
|
||||
hscroll = gtk_scrolled_window_get_hadjustment(nsgtk_cw->scrolled);
|
||||
vscroll_val = gtk_adjustment_get_value(vscroll);
|
||||
hscroll_val = gtk_adjustment_get_value(hscroll);
|
||||
|
||||
|
||||
/* technically degenerate container of */
|
||||
lhw = (struct nsgtk_local_history_window *)nsgtk_cw;
|
||||
c.x0 = r->x0 + hscroll_val;
|
||||
c.y0 = r->y0 + vscroll_val;
|
||||
c.x1 = r->x1 + hscroll_val;
|
||||
c.y1 = r->y1 + vscroll_val;
|
||||
|
||||
ctx.plot->clip(&ctx, r);
|
||||
local_history_redraw(lhw->session, r->x0, r->y0, r, &ctx);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the window for the local history view.
|
||||
*
|
||||
* \return NSERROR_OK on success else appropriate error code on faliure.
|
||||
*/
|
||||
static nserror
|
||||
nsgtk_local_history_init(struct browser_window *bw,
|
||||
struct nsgtk_local_history_window **win_out)
|
||||
{
|
||||
struct nsgtk_local_history_window *ncwin;
|
||||
nserror res;
|
||||
|
||||
/* memoise window so it can be represented when necessary
|
||||
* instead of recreating every time.
|
||||
*/
|
||||
if ((*win_out) != NULL) {
|
||||
res = local_history_set((*win_out)->session, bw);
|
||||
return res;
|
||||
}
|
||||
|
||||
ncwin = malloc(sizeof(struct nsgtk_local_history_window));
|
||||
if (ncwin == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
res = nsgtk_builder_new_from_resname("localhistory", &ncwin->builder);
|
||||
if (res != NSERROR_OK) {
|
||||
LOG("Local history UI builder init failed");
|
||||
free(ncwin);
|
||||
return res;
|
||||
}
|
||||
|
||||
gtk_builder_connect_signals(ncwin->builder, NULL);
|
||||
|
||||
ncwin->wnd = GTK_WINDOW(gtk_builder_get_object(ncwin->builder,
|
||||
"wndHistory"));
|
||||
|
||||
ncwin->core.scrolled = GTK_SCROLLED_WINDOW(
|
||||
gtk_builder_get_object(ncwin->builder,
|
||||
"HistoryScrolled"));
|
||||
|
||||
ncwin->core.drawing_area = GTK_DRAWING_AREA(
|
||||
gtk_builder_get_object(ncwin->builder,
|
||||
"HistoryDrawingArea"));
|
||||
|
||||
/* make the delete event hide the window */
|
||||
g_signal_connect(G_OBJECT(ncwin->wnd),
|
||||
"delete_event",
|
||||
G_CALLBACK(gtk_widget_hide_on_delete),
|
||||
NULL);
|
||||
|
||||
ncwin->core.draw = nsgtk_local_history_draw;
|
||||
ncwin->core.key = nsgtk_local_history_key;
|
||||
ncwin->core.mouse = nsgtk_local_history_mouse;
|
||||
|
||||
res = nsgtk_corewindow_init(&ncwin->core);
|
||||
if (res != NSERROR_OK) {
|
||||
free(ncwin);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = local_history_init(ncwin->core.cb_table,
|
||||
(struct core_window *)ncwin,
|
||||
bw,
|
||||
&ncwin->session);
|
||||
if (res != NSERROR_OK) {
|
||||
free(ncwin);
|
||||
return res;
|
||||
}
|
||||
|
||||
*win_out = ncwin;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/* exported function documented gtk/history.h */
|
||||
nserror nsgtk_local_history_present(GtkWindow *parent,
|
||||
struct browser_window *bw)
|
||||
{
|
||||
nserror res;
|
||||
int prnt_width, prnt_height;
|
||||
int width, height;
|
||||
res = nsgtk_local_history_init(bw, &local_history_window);
|
||||
if (res == NSERROR_OK) {
|
||||
gtk_window_set_transient_for(local_history_window->wnd, parent);
|
||||
|
||||
gtk_window_get_size(parent, &prnt_width, &prnt_height);
|
||||
|
||||
/* resize history widget ensureing the drawing area is
|
||||
* no larger than parent window
|
||||
*/
|
||||
res = local_history_get_size(local_history_window->session,
|
||||
&width,
|
||||
&height);
|
||||
if (width > prnt_width) {
|
||||
width = prnt_width;
|
||||
}
|
||||
if (height > prnt_height) {
|
||||
height = prnt_height;
|
||||
}
|
||||
gtk_window_resize(local_history_window->wnd, width, height);
|
||||
|
||||
gtk_window_present(local_history_window->wnd);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* exported function documented gtk/history.h */
|
||||
nserror nsgtk_local_history_hide(void)
|
||||
{
|
||||
nserror res = NSERROR_OK;
|
||||
|
||||
if (local_history_window != NULL) {
|
||||
gtk_widget_hide(GTK_WIDGET(local_history_window->wnd));
|
||||
|
||||
res = local_history_set(local_history_window->session, NULL);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* exported function documented gtk/history.h */
|
||||
nserror nsgtk_local_history_destroy(void)
|
||||
{
|
||||
nserror res;
|
||||
|
||||
if (local_history_window == NULL) {
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
res = local_history_fini(local_history_window->session);
|
||||
if (res == NSERROR_OK) {
|
||||
res = nsgtk_corewindow_fini(&local_history_window->core);
|
||||
gtk_widget_destroy(GTK_WIDGET(local_history_window->wnd));
|
||||
g_object_unref(G_OBJECT(local_history_window->builder));
|
||||
free(local_history_window);
|
||||
local_history_window = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
49
frontends/gtk/local_history.h
Normal file
49
frontends/gtk/local_history.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2017 Vincent Sanders <vince@kyllikki.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Interface to GTK local history manager
|
||||
*/
|
||||
|
||||
#ifndef NSGTK_LOCAL_HISTORY_H
|
||||
#define NSGTK_LOCAL_HISTORY_H
|
||||
|
||||
struct browser_window;
|
||||
|
||||
/**
|
||||
* make the local history window visible.
|
||||
*
|
||||
* \return NSERROR_OK on success else appropriate error code on faliure.
|
||||
*/
|
||||
nserror nsgtk_local_history_present(GtkWindow *parent, struct browser_window *bw);
|
||||
|
||||
/**
|
||||
* hide the local history window from being visible.
|
||||
*
|
||||
* \return NSERROR_OK on success else appropriate error code on faliure.
|
||||
*/
|
||||
nserror nsgtk_local_history_hide(void);
|
||||
|
||||
/**
|
||||
* Destroys the local history window and performs any other necessary cleanup
|
||||
* actions.
|
||||
*/
|
||||
nserror nsgtk_local_history_destroy(void);
|
||||
|
||||
#endif
|
45
frontends/gtk/res/localhistory.gtk2.ui
Normal file
45
frontends/gtk/res/localhistory.gtk2.ui
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkWindow" id="wndHistory">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">NetSurf Local History</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="default_width">20</property>
|
||||
<property name="default_height">20</property>
|
||||
<property name="type_hint">utility</property>
|
||||
<property name="decorated">False</property>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="HistoryScrolled">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkViewport" id="HistoryViewport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resize_mode">queue</property>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="HistoryDrawingArea">
|
||||
<property name="visible">True</property>
|
||||
<property name="app_paintable">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="events">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</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
45
frontends/gtk/res/localhistory.gtk3.ui
Normal file
45
frontends/gtk/res/localhistory.gtk3.ui
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkWindow" id="wndHistory">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">NetSurf Local History</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="default_width">20</property>
|
||||
<property name="default_height">20</property>
|
||||
<property name="type_hint">utility</property>
|
||||
<property name="decorated">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="HistoryScrolled">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkViewport" id="HistoryViewport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="HistoryDrawingArea">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="events">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</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@ -2,7 +2,8 @@
|
||||
<gresources>
|
||||
<gresource prefix="/org/netsurf">
|
||||
<file>cookies.gtk2.ui</file>
|
||||
<file>history.gtk3.ui</file>
|
||||
<file>globalhistory.gtk3.ui</file>
|
||||
<file>localhistory.gtk3.ui</file>
|
||||
<file>netsurf.gtk2.ui</file>
|
||||
<file>password.gtk3.ui</file>
|
||||
<file>toolbar.gtk2.ui</file>
|
||||
@ -22,7 +23,8 @@
|
||||
<file>options.gtk3.ui</file>
|
||||
<file>tabcontents.gtk2.ui</file>
|
||||
<file>viewdata.gtk3.ui</file>
|
||||
<file>history.gtk2.ui</file>
|
||||
<file>localhistory.gtk2.ui</file>
|
||||
<file>globalhistory.gtk2.ui</file>
|
||||
<file>login.gtk3.ui</file>
|
||||
<file>password.gtk2.ui</file>
|
||||
<file>tabcontents.gtk3.ui</file>
|
||||
|
@ -81,7 +81,8 @@ static struct nsgtk_resource_s ui_resource[] = {
|
||||
RES_ENTRY("ssl"),
|
||||
RES_ENTRY("toolbar"),
|
||||
RES_ENTRY("downloads"),
|
||||
RES_ENTRY("history"),
|
||||
RES_ENTRY("globalhistory"),
|
||||
RES_ENTRY("localhistory"),
|
||||
RES_ENTRY("options"),
|
||||
RES_ENTRY("hotlist"),
|
||||
RES_ENTRY("cookies"),
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "gtk/bitmap.h"
|
||||
#include "gtk/gui.h"
|
||||
#include "gtk/global_history.h"
|
||||
#include "gtk/local_history.h"
|
||||
#include "gtk/hotlist.h"
|
||||
#include "gtk/download.h"
|
||||
#include "gtk/menu.h"
|
||||
@ -109,9 +110,6 @@ struct nsgtk_scaffolding {
|
||||
/** currently active gui browsing context */
|
||||
struct gui_window *top_level;
|
||||
|
||||
/** local history window */
|
||||
struct gtk_history_window *history_window;
|
||||
|
||||
/** Builder object scaffold was created from */
|
||||
GtkBuilder *builder;
|
||||
|
||||
@ -247,9 +245,7 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data)
|
||||
|
||||
LOG("scaffold:%p", gs);
|
||||
|
||||
if ((gs->history_window) && (gs->history_window->window)) {
|
||||
gtk_widget_destroy(GTK_WIDGET(gs->history_window->window));
|
||||
}
|
||||
nsgtk_local_history_hide();
|
||||
|
||||
if (gs->prev != NULL) {
|
||||
gs->prev->next = gs->next;
|
||||
@ -287,7 +283,6 @@ static gboolean scaffolding_window_delete_event(GtkWidget *widget,
|
||||
*/
|
||||
static void scaffolding_update_context(struct nsgtk_scaffolding *g)
|
||||
{
|
||||
int width, height;
|
||||
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
|
||||
|
||||
g->buttons[BACK_BUTTON]->sensitivity =
|
||||
@ -300,13 +295,7 @@ static void scaffolding_update_context(struct nsgtk_scaffolding *g)
|
||||
/* update the url bar, particularly necessary when tabbing */
|
||||
browser_window_refresh_url_bar(bw);
|
||||
|
||||
/* update the local history window, as well as queuing a redraw
|
||||
* for it.
|
||||
*/
|
||||
browser_window_history_size(bw, &width, &height);
|
||||
gtk_widget_set_size_request(GTK_WIDGET(g->history_window->drawing_area),
|
||||
width, height);
|
||||
gtk_widget_queue_draw(GTK_WIDGET(g->history_window->drawing_area));
|
||||
nsgtk_local_history_hide();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1466,31 +1455,12 @@ MULTIHANDLER(home)
|
||||
MULTIHANDLER(localhistory)
|
||||
{
|
||||
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
|
||||
nserror res;
|
||||
|
||||
int x,y, width, height, mainwidth, mainheight, margin = 20;
|
||||
/* if entries of the same url but different frag_ids have been added
|
||||
* the history needs redrawing (what throbber code normally does)
|
||||
*/
|
||||
|
||||
scaffolding_update_context(g);
|
||||
gtk_window_get_position(g->window, &x, &y);
|
||||
gtk_window_get_size(g->window, &mainwidth, &mainheight);
|
||||
browser_window_history_size(bw, &width, &height);
|
||||
width = (width + g->historybase + margin > mainwidth) ?
|
||||
mainwidth - g->historybase : width + margin;
|
||||
height = (height + g->toolbarbase + margin > mainheight) ?
|
||||
mainheight - g->toolbarbase : height + margin;
|
||||
gtk_window_set_default_size(g->history_window->window, width, height);
|
||||
gtk_widget_set_size_request(GTK_WIDGET(g->history_window->window),
|
||||
-1, -1);
|
||||
gtk_window_resize(g->history_window->window, width, height);
|
||||
gtk_window_set_transient_for(g->history_window->window, g->window);
|
||||
nsgtk_window_set_opacity(g->history_window->window, 0.9);
|
||||
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(nsgtk_widget_get_window(GTK_WIDGET(g->history_window->window)));
|
||||
|
||||
res = nsgtk_local_history_present(g->window, bw);
|
||||
if (res != NSERROR_OK) {
|
||||
LOG("Unable to initialise local history window.");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1643,91 +1613,6 @@ 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_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(&ctx, &clip);
|
||||
|
||||
browser_window_history_redraw(bw, &ctx);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
|
||||
/* signal handler functions for the local history window */
|
||||
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;
|
||||
struct browser_window *bw =
|
||||
nsgtk_get_browser_window(hw->g->top_level);
|
||||
|
||||
struct redraw_context ctx = {
|
||||
.interactive = true,
|
||||
.background_images = true,
|
||||
.plot = &nsgtk_plotters
|
||||
};
|
||||
|
||||
current_cr = gdk_cairo_create(nsgtk_widget_get_window(widget));
|
||||
|
||||
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;
|
||||
ctx.plot->clip(&ctx, &clip);
|
||||
|
||||
browser_window_history_redraw(bw, &ctx);
|
||||
|
||||
cairo_destroy(current_cr);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* GTK_CHECK_VERSION(3,0,0) */
|
||||
|
||||
static gboolean nsgtk_history_button_press_event(GtkWidget *widget,
|
||||
GdkEventButton *event, gpointer g)
|
||||
{
|
||||
struct gtk_history_window *hw = (struct gtk_history_window *)g;
|
||||
struct browser_window *bw =
|
||||
nsgtk_get_browser_window(hw->g->top_level);
|
||||
|
||||
LOG("X=%g, Y=%g", event->x, event->y);
|
||||
|
||||
browser_window_history_click(bw, event->x, event->y, false);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void nsgtk_attach_menu_handlers(struct nsgtk_scaffolding *g)
|
||||
{
|
||||
for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
|
||||
@ -2181,35 +2066,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
|
||||
gtk_widget_set_size_request(GTK_WIDGET(
|
||||
gs->buttons[HISTORY_BUTTON]->button), 20, -1);
|
||||
|
||||
/* create the local history window to be associated with this scaffold */
|
||||
gs->history_window = malloc(sizeof(struct gtk_history_window));
|
||||
gs->history_window->g = gs;
|
||||
gs->history_window->window =
|
||||
GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
|
||||
gtk_window_set_transient_for(gs->history_window->window, gs->window);
|
||||
gtk_window_set_title(gs->history_window->window, "NetSurf History");
|
||||
gtk_window_set_type_hint(gs->history_window->window,
|
||||
GDK_WINDOW_TYPE_HINT_UTILITY);
|
||||
gs->history_window->scrolled =
|
||||
GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(0, 0));
|
||||
gtk_container_add(GTK_CONTAINER(gs->history_window->window),
|
||||
GTK_WIDGET(gs->history_window->scrolled));
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(gs->history_window->scrolled));
|
||||
gs->history_window->drawing_area =
|
||||
GTK_DRAWING_AREA(gtk_drawing_area_new());
|
||||
|
||||
gtk_widget_set_events(GTK_WIDGET(gs->history_window->drawing_area),
|
||||
GDK_EXPOSURE_MASK |
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_BUTTON_PRESS_MASK);
|
||||
nsgtk_widget_override_background_color(GTK_WIDGET(gs->history_window->drawing_area),
|
||||
GTK_STATE_NORMAL,
|
||||
0, 0xffff, 0xffff, 0xffff);
|
||||
nsgtk_scrolled_window_add_with_viewport(gs->history_window->scrolled,
|
||||
GTK_WIDGET(gs->history_window->drawing_area));
|
||||
gtk_widget_show(GTK_WIDGET(gs->history_window->drawing_area));
|
||||
|
||||
|
||||
/* set up URL bar completion */
|
||||
gs->url_bar_completion = nsgtk_url_entry_completion_new(gs);
|
||||
@ -2221,17 +2077,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
|
||||
#define CONNECT(obj, sig, callback, ptr) \
|
||||
g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
|
||||
|
||||
/* connect history window signals to their handlers */
|
||||
nsgtk_connect_draw_event(GTK_WIDGET(gs->history_window->drawing_area),
|
||||
G_CALLBACK(nsgtk_history_draw_event),
|
||||
gs->history_window);
|
||||
/*CONNECT(gs->history_window->drawing_area, "motion_notify_event",
|
||||
nsgtk_history_motion_notify_event, gs->history_window);*/
|
||||
CONNECT(gs->history_window->drawing_area, "button_press_event",
|
||||
nsgtk_history_button_press_event, gs->history_window);
|
||||
CONNECT(gs->history_window->window, "delete_event",
|
||||
gtk_widget_hide_on_delete, NULL);
|
||||
|
||||
g_signal_connect_after(gs->notebook, "page-added",
|
||||
G_CALLBACK(nsgtk_window_tabs_add), gs);
|
||||
g_signal_connect_after(gs->notebook, "page-removed",
|
||||
@ -2591,13 +2436,6 @@ GtkMenuBar *nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *g)
|
||||
return g->menu_bar->bar_menu;
|
||||
}
|
||||
|
||||
/* exported interface documented in gtk/scaffolding.h */
|
||||
struct gtk_history_window *
|
||||
nsgtk_scaffolding_history_window(struct nsgtk_scaffolding *g)
|
||||
{
|
||||
return g->history_window;
|
||||
}
|
||||
|
||||
/* exported interface documented in gtk/scaffolding.h */
|
||||
struct nsgtk_scaffolding *nsgtk_scaffolding_iterate(struct nsgtk_scaffolding *g)
|
||||
{
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "gtk/compat.h"
|
||||
#include "gtk/gui.h"
|
||||
#include "gtk/scaffolding.h"
|
||||
#include "gtk/local_history.h"
|
||||
#include "gtk/plotters.h"
|
||||
#include "gtk/schedule.h"
|
||||
#include "gtk/tabs.h"
|
||||
@ -339,8 +340,7 @@ static gboolean nsgtk_window_button_press_event(GtkWidget *widget,
|
||||
|
||||
gtk_im_context_reset(g->input_method);
|
||||
gtk_widget_grab_focus(GTK_WIDGET(g->layout));
|
||||
gtk_widget_hide(GTK_WIDGET(nsgtk_scaffolding_history_window(
|
||||
g->scaffold)->window));
|
||||
nsgtk_local_history_hide();
|
||||
|
||||
g->mouse.pressed_x = event->x / browser_window_get_scale(g->bw);
|
||||
g->mouse.pressed_y = event->y / browser_window_get_scale(g->bw);
|
||||
|
Loading…
Reference in New Issue
Block a user