mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 23:09:39 +03:00
[project @ 2006-03-26 17:22:29 by dsilvers]
Implement the history window, and re-tabify gtk_window.c svn path=/import/netsurf/; revision=2178
This commit is contained in:
parent
d7447adc6c
commit
41b71fc15a
131
gtk/gtk_window.c
131
gtk/gtk_window.c
@ -25,7 +25,9 @@
|
||||
#include "netsurf/render/form.h"
|
||||
#include "netsurf/utils/messages.h"
|
||||
#include "netsurf/utils/utils.h"
|
||||
#include "netsurf/utils/log.h"
|
||||
|
||||
struct gtk_history_window;
|
||||
|
||||
struct gui_window {
|
||||
GtkWidget *window;
|
||||
@ -40,7 +42,15 @@ struct gui_window {
|
||||
int target_height;
|
||||
gui_pointer_shape current_pointer;
|
||||
float scale;
|
||||
struct gtk_history_window *history_window;
|
||||
GtkWidget *history_window_widget;
|
||||
};
|
||||
|
||||
struct gtk_history_window {
|
||||
struct gui_window *g;
|
||||
GtkWidget *drawing_area;
|
||||
};
|
||||
|
||||
GtkWidget *current_widget;
|
||||
GdkDrawable *current_drawable;
|
||||
GdkGC *current_gc;
|
||||
@ -51,12 +61,20 @@ cairo_t *current_cr;
|
||||
static void gui_window_zoomin_button_event(GtkWidget *widget, gpointer data);
|
||||
static void gui_window_zoom100_button_event(GtkWidget *widget, gpointer data);
|
||||
static void gui_window_zoomout_button_event(GtkWidget *widget, gpointer data);
|
||||
static void gui_window_history_button_event(GtkWidget *widget, gpointer data);
|
||||
|
||||
static void gui_window_stop_button_event(GtkWidget *widget, gpointer data);
|
||||
static void gui_window_back_button_event(GtkWidget *widget, gpointer data);
|
||||
static void gui_window_forward_button_event(GtkWidget *widget, gpointer data);
|
||||
static void gui_window_update_back_forward(struct gui_window *g);
|
||||
|
||||
static gboolean gui_history_expose_event(GtkWidget *widget,
|
||||
GdkEventExpose *event, gpointer data);
|
||||
static gboolean gui_history_motion_notify_event(GtkWidget *widget,
|
||||
GdkEventMotion *event, gpointer data);
|
||||
static gboolean gui_history_button_press_event(GtkWidget *widget,
|
||||
GdkEventButton *event, gpointer data);
|
||||
|
||||
static void gui_window_destroy_event(GtkWidget *widget, gpointer data);
|
||||
static gboolean gui_window_expose_event(GtkWidget *widget,
|
||||
GdkEventExpose *event, gpointer data);
|
||||
@ -77,7 +95,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
||||
struct browser_window *clone)
|
||||
{
|
||||
struct gui_window *g;
|
||||
GtkWidget *window;
|
||||
GtkWidget *window, *history_window;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *toolbar;
|
||||
GtkToolItem *back_button, *forward_button, *stop_button, *reload_button;
|
||||
@ -85,8 +103,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
||||
GtkToolItem *home_button, *history_button;
|
||||
GtkToolItem *url_item;
|
||||
GtkWidget *url_bar;
|
||||
GtkWidget *scrolled;
|
||||
GtkWidget *drawing_area;
|
||||
GtkWidget *scrolled, *history_scrolled;
|
||||
GtkWidget *drawing_area, *history_area;
|
||||
GtkWidget *status_bar;
|
||||
|
||||
g = malloc(sizeof *g);
|
||||
@ -99,6 +117,21 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), 600, 600);
|
||||
gtk_window_set_title(GTK_WINDOW(window), "NetSurf");
|
||||
|
||||
g->history_window = malloc(sizeof(struct gtk_history_window));
|
||||
if (!g->history_window) {
|
||||
warn_user("NoMemory", 0);
|
||||
return 0;
|
||||
}
|
||||
g->history_window->g = g;
|
||||
|
||||
history_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_transient_for(GTK_WINDOW(history_window),
|
||||
GTK_WINDOW(window));
|
||||
gtk_window_set_default_size(GTK_WINDOW(history_window), 400, 400);
|
||||
gtk_window_set_title(GTK_WINDOW(history_window), "NetSurf History");
|
||||
|
||||
g->history_window_widget = GTK_WIDGET(history_window);
|
||||
|
||||
vbox = gtk_vbox_new(false, 0);
|
||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||
gtk_widget_show(vbox);
|
||||
@ -166,6 +199,10 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
||||
gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
|
||||
gtk_widget_show(scrolled);
|
||||
|
||||
history_scrolled = gtk_scrolled_window_new(0, 0);
|
||||
gtk_container_add(GTK_CONTAINER(history_window), history_scrolled);
|
||||
gtk_widget_show(history_scrolled);
|
||||
|
||||
drawing_area = gtk_drawing_area_new();
|
||||
gtk_widget_set_events(drawing_area,
|
||||
GDK_EXPOSURE_MASK |
|
||||
@ -177,6 +214,19 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled),
|
||||
drawing_area);
|
||||
gtk_widget_show(drawing_area);
|
||||
|
||||
history_area = gtk_drawing_area_new();
|
||||
gtk_widget_set_events(history_area,
|
||||
GDK_EXPOSURE_MASK |
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_BUTTON_PRESS_MASK);
|
||||
gtk_widget_modify_bg(history_area, GTK_STATE_NORMAL,
|
||||
&((GdkColor) { 0, 0xffff, 0xffff, 0xffff }));
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(history_scrolled),
|
||||
history_area);
|
||||
gtk_widget_show(history_area);
|
||||
g->history_window->drawing_area = history_area;
|
||||
|
||||
status_bar = gtk_statusbar_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox), status_bar, FALSE, TRUE, 0);
|
||||
gtk_widget_show(status_bar);
|
||||
@ -223,6 +273,18 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
||||
NS_SIGNAL_CONNECT(g->back_button, "clicked", gui_window_back_button_event, g);
|
||||
NS_SIGNAL_CONNECT(g->forward_button, "clicked", gui_window_forward_button_event, g);
|
||||
|
||||
NS_SIGNAL_CONNECT(history_button, "clicked", gui_window_history_button_event, g);
|
||||
|
||||
/* History window events */
|
||||
NS_SIGNAL_CONNECT(history_area, "expose_event",
|
||||
gui_history_expose_event, g->history_window);
|
||||
NS_SIGNAL_CONNECT(history_area, "motion_notify_event",
|
||||
gui_history_motion_notify_event, g->history_window);
|
||||
NS_SIGNAL_CONNECT(history_area, "button_press_event",
|
||||
gui_history_button_press_event, g->history_window);
|
||||
NS_SIGNAL_CONNECT(g->history_window_widget, "delete_event",
|
||||
gtk_widget_hide_on_delete, NULL);
|
||||
|
||||
#undef NS_SIGNAL_CONNECT
|
||||
|
||||
return g;
|
||||
@ -280,10 +342,22 @@ void gui_window_forward_button_event(GtkWidget *widget, gpointer data)
|
||||
|
||||
void gui_window_update_back_forward(struct gui_window *g)
|
||||
{
|
||||
int width, height;
|
||||
gtk_widget_set_sensitive(g->back_button,
|
||||
history_back_available(g->bw->history));
|
||||
gtk_widget_set_sensitive(g->forward_button,
|
||||
history_forward_available(g->bw->history));
|
||||
history_size(g->bw->history, &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_widget));
|
||||
}
|
||||
|
||||
void gui_window_history_button_event(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
struct gui_window *g = data;
|
||||
gtk_widget_show(GTK_WIDGET(g->history_window_widget));
|
||||
gdk_window_raise(g->history_window_widget->window);
|
||||
}
|
||||
|
||||
gboolean gui_window_expose_event(GtkWidget *widget,
|
||||
@ -322,6 +396,52 @@ gboolean gui_window_expose_event(GtkWidget *widget,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean gui_history_expose_event(GtkWidget *widget,
|
||||
GdkEventExpose *event,
|
||||
gpointer data)
|
||||
{
|
||||
struct gtk_history_window *hw = data;
|
||||
current_widget = widget;
|
||||
current_drawable = widget->window;
|
||||
current_gc = gdk_gc_new(current_drawable);
|
||||
#ifdef CAIRO_VERSION
|
||||
current_cr = gdk_cairo_create(current_drawable);
|
||||
#endif
|
||||
plot = nsgtk_plotters;
|
||||
nsgtk_plot_set_scale(1.0);
|
||||
|
||||
history_redraw(hw->g->bw->history);
|
||||
|
||||
g_object_unref(current_gc);
|
||||
#ifdef CAIRO_VERSION
|
||||
cairo_destroy(current_cr);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean gui_history_motion_notify_event(GtkWidget *widget,
|
||||
GdkEventMotion *event, gpointer data)
|
||||
{
|
||||
struct gtk_history_window *hw = data;
|
||||
|
||||
/* Not sure what to do here */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean gui_history_button_press_event(GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
struct gtk_history_window *hw = data;
|
||||
|
||||
LOG(("History click %d,%d", event->x, event->y));
|
||||
|
||||
history_click(hw->g->bw, hw->g->bw->history,
|
||||
event->x, event->y, false);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean gui_window_url_key_press_event(GtkWidget *widget,
|
||||
GdkEventKey *event, gpointer data)
|
||||
@ -371,7 +491,7 @@ void gtk_perform_deferred_resize(void *p)
|
||||
return;
|
||||
content_reformat(g->bw->current_content, g->target_width, g->target_height);
|
||||
if (GTK_WIDGET_SENSITIVE (g->stop_button)) {
|
||||
schedule(25, gtk_perform_deferred_resize, g);
|
||||
schedule(100, gtk_perform_deferred_resize, g);
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,6 +533,7 @@ gboolean gui_window_button_press_event(GtkWidget *widget,
|
||||
|
||||
void gui_window_destroy(struct gui_window *g)
|
||||
{
|
||||
/* XXX: Destroy history window etc here */
|
||||
}
|
||||
|
||||
|
||||
@ -574,7 +695,7 @@ void gui_window_set_url(struct gui_window *g, const char *url)
|
||||
void gui_window_start_throbber(struct gui_window* g)
|
||||
{
|
||||
gtk_widget_set_sensitive(g->stop_button, TRUE);
|
||||
schedule(25, gtk_perform_deferred_resize, g);
|
||||
schedule(100, gtk_perform_deferred_resize, g);
|
||||
gui_window_update_back_forward(g);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user