From 34c2bf92974c27693b06e549e55853f0d8d8659a Mon Sep 17 00:00:00 2001 From: James Bursa Date: Thu, 22 Jul 2004 12:03:37 +0000 Subject: [project @ 2004-07-22 12:03:37 by bursa] Make the gtk build compile again and implement mouse clicks. svn path=/import/netsurf/; revision=1137 --- gtk/font_pango.c | 2 +- gtk/gtk_gui.c | 34 ++++++++++---------- gtk/gtk_window.c | 97 +++++++++++++++++++++++++++++++++++++------------------- 3 files changed, 82 insertions(+), 51 deletions(-) diff --git a/gtk/font_pango.c b/gtk/font_pango.c index a376967a5..22fbc6024 100644 --- a/gtk/font_pango.c +++ b/gtk/font_pango.c @@ -70,7 +70,7 @@ struct font_data *nsfont_open(struct font_set *set, struct css_style *style) data->id = fontdesc; data->size = size; - data->space_width = font_width(data, " ", 1); + data->space_width = nsfont_width(data, " ", 1); return data; } diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c index b0109ed5a..fe51fbb3e 100644 --- a/gtk/gtk_gui.c +++ b/gtk/gtk_gui.c @@ -13,6 +13,7 @@ #include #include "netsurf/content/content.h" #include "netsurf/desktop/browser.h" +#include "netsurf/desktop/gui.h" #include "netsurf/desktop/netsurf.h" #include "netsurf/render/box.h" #include "netsurf/render/form.h" @@ -34,7 +35,7 @@ void gui_init(int argc, char** argv) void gui_poll(bool active) { if (gui_start) { - browser_window_create("", 0); + browser_window_create("http://netsurf.sourceforge.net/", 0); gui_start = false; } @@ -57,30 +58,33 @@ void gui_quit(void) - -gui_window *gui_create_download_window(struct content *content) +struct gui_download_window *gui_download_window_create(const char *url, + const char *mime_type, struct fetch *fetch, + unsigned int total_size) { return 0; } -void gui_download_window_update_status(gui_window *g) +void gui_download_window_data(struct gui_download_window *dw, const char *data, + unsigned int size) { } -void gui_download_window_done(gui_window *g) +void gui_download_window_error(struct gui_download_window *dw, + const char *error_msg) { } -void gui_download_window_error(gui_window *g, const char *error) +void gui_download_window_done(struct gui_download_window *dw) { } -void gui_gadget_combo(struct browser_window* bw, struct form_control* g, - unsigned long mx, unsigned long my) +void gui_create_form_select_menu(struct browser_window *bw, + struct form_control *control) { } @@ -95,9 +99,6 @@ void warn_user(const char *warning, const char *detail) } - - - void html_add_instance(struct content *c, struct browser_window *bw, struct content *page, struct box *box, struct object_params *params, void **state) {} @@ -116,6 +117,11 @@ void die(const char * const error) } +void hotlist_visited(struct content *content) +{ +} + + struct history *history_create(void) { return 0; } void history_add(struct history *history, struct content *content) {} void history_update(struct history *history, struct content *content) {} @@ -123,11 +129,5 @@ void history_destroy(struct history *history) {} void history_back(struct browser_window *bw, struct history *history) {} void history_forward(struct browser_window *bw, struct history *history) {} -struct content *about_create(const char *url, - void (*callback)(content_msg msg, struct content *c, void *p1, - void *p2, const char *error), - void *p1, void *p2, unsigned long width, unsigned long height) -{ return 0; } - void gui_401login_open(struct browser_window *bw, struct content *c, char *realm) {} diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c index 499afc073..2a70925b8 100644 --- a/gtk/gtk_window.c +++ b/gtk/gtk_window.c @@ -13,6 +13,7 @@ #include #include "netsurf/content/content.h" #include "netsurf/desktop/browser.h" +#include "netsurf/desktop/gui.h" #include "netsurf/desktop/netsurf.h" #include "netsurf/render/box.h" #include "netsurf/render/form.h" @@ -42,14 +43,18 @@ static gboolean gui_window_url_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data); static gboolean gui_window_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); +static gboolean gui_window_motion_notify_event(GtkWidget *widget, + GdkEventMotion *event, gpointer data); +static gboolean gui_window_button_press_event(GtkWidget *widget, + GdkEventButton *event, gpointer data); static void html_redraw_box(struct content *content, struct box *box, int x, int y); -gui_window *gui_create_browser_window(struct browser_window *bw, +struct gui_window *gui_create_browser_window(struct browser_window *bw, struct browser_window *clone) { - gui_window *g; + struct gui_window *g; GtkWidget *window; GtkWidget *vbox; GtkWidget *toolbar; @@ -110,6 +115,11 @@ gui_window *gui_create_browser_window(struct browser_window *bw, gtk_widget_show(scrolled); drawing_area = gtk_drawing_area_new(); + gtk_widget_set_events(drawing_area, + GDK_EXPOSURE_MASK | + GDK_LEAVE_NOTIFY_MASK | + GDK_BUTTON_PRESS_MASK | + GDK_POINTER_MOTION_MASK); gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &((GdkColor) { 0, 0xffff, 0xffff, 0xffff })); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), @@ -132,6 +142,10 @@ gui_window *gui_create_browser_window(struct browser_window *bw, G_CALLBACK(gui_window_expose_event), g); g_signal_connect(G_OBJECT(drawing_area), "configure_event", G_CALLBACK(gui_window_configure_event), g); + g_signal_connect(G_OBJECT(drawing_area), "motion_notify_event", + G_CALLBACK(gui_window_motion_notify_event), g); + g_signal_connect(G_OBJECT(drawing_area), "button_press_event", + G_CALLBACK(gui_window_button_press_event), g); return g; } @@ -140,7 +154,7 @@ gui_window *gui_create_browser_window(struct browser_window *bw, gboolean gui_window_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) { - gui_window *g = data; + struct gui_window *g = data; struct content *c = g->bw->current_content; if (!c) @@ -168,7 +182,7 @@ gboolean gui_window_expose_event(GtkWidget *widget, gboolean gui_window_url_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) { - gui_window *g = data; + struct gui_window *g = data; if (event->keyval != GDK_Return) return FALSE; @@ -182,7 +196,7 @@ gboolean gui_window_url_key_press_event(GtkWidget *widget, gboolean gui_window_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) { - gui_window *g = data; + struct gui_window *g = data; if (gui_in_multitask) return FALSE; @@ -200,47 +214,76 @@ gboolean gui_window_configure_event(GtkWidget *widget, } -void gui_window_destroy(gui_window* g) +gboolean gui_window_motion_notify_event(GtkWidget *widget, + GdkEventMotion *event, gpointer data) { + struct gui_window *g = data; + + browser_window_mouse_click(g->bw, BROWSER_MOUSE_HOVER, + event->x, event->y); + + return TRUE; +} + + +gboolean gui_window_button_press_event(GtkWidget *widget, + GdkEventButton *event, gpointer data) +{ + struct gui_window *g = data; + + browser_window_mouse_click(g->bw, BROWSER_MOUSE_CLICK_1, + event->x, event->y); + + return TRUE; +} + + +void gui_window_destroy(struct gui_window *g) +{ +} + + +void gui_window_set_title(struct gui_window *g, const char *title) +{ + gtk_window_set_title(GTK_WINDOW(g->window), title); } -void gui_window_redraw(gui_window* g, unsigned long x0, unsigned long y0, - unsigned long x1, unsigned long y1) +void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1) { } -void gui_window_redraw_window(gui_window* g) +void gui_window_redraw_window(struct gui_window* g) { gtk_widget_queue_draw(g->drawing_area); } -void gui_window_update_box(gui_window *g, const union content_msg_data *data) +void gui_window_update_box(struct gui_window *g, + const union content_msg_data *data) { } -void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy) +void gui_window_set_scroll(struct gui_window *g, int sx, int sy) { } -unsigned long gui_window_get_width(gui_window* g) +int gui_window_get_width(struct gui_window* g) { return g->drawing_area->allocation.width; } -void gui_window_set_extent(gui_window* g, unsigned long width, - unsigned long height) +void gui_window_set_extent(struct gui_window *g, int width, int height) { gtk_widget_set_size_request(g->drawing_area, width, height); } -void gui_window_set_status(gui_window *g, const char *text) +void gui_window_set_status(struct gui_window *g, const char *text) { guint context_id; @@ -256,45 +299,33 @@ void gui_window_set_pointer(gui_pointer_shape shape) } -void gui_window_set_title(gui_window *g, char *title) -{ - gtk_window_set_title(GTK_WINDOW(g->window), title); -} - - -void gui_window_set_url(gui_window *g, char *url) +void gui_window_set_url(struct gui_window *g, const char *url) { gtk_entry_set_text(GTK_ENTRY(g->url_bar), url); } -void gui_window_clone_options(struct browser_window *new_bw, - struct browser_window *old_bw) +void gui_window_start_throbber(struct gui_window* g) { } -void gui_window_default_options(struct browser_window *bw) +void gui_window_stop_throbber(struct gui_window* g) { } -void gui_window_start_throbber(gui_window* g) +void gui_window_place_caret(struct gui_window *g, int x, int y, int height) { } -void gui_window_stop_throbber(gui_window* g) -{ -} - - -void gui_window_place_caret(gui_window *g, int x, int y, int height) +void gui_window_remove_caret(struct gui_window *g) { } -void gui_window_remove_caret(struct gui_window *g) +void gui_window_new_content(struct gui_window *g) { } -- cgit v1.2.3