gtkhtml r9090 - in trunk: components/editor gtkhtml
- From: mbarnes svn gnome org
- To: svn-commits-list gnome org
- Subject: gtkhtml r9090 - in trunk: components/editor gtkhtml
- Date: Sun, 11 Jan 2009 20:20:25 +0000 (UTC)
Author: mbarnes
Date: Sun Jan 11 20:20:24 2009
New Revision: 9090
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=9090&view=rev
Log:
2009-01-11 Matthew Barnes <mbarnes redhat com>
** Fixes bug #564529
* gtkhtml/gtkhtml.c:
* gtkhtml/gtkhtml-embedded.c:
* gtkhtml/htmlcolorset.c:
* gtkhtml/htmlembedded.c:
* gtkhtml/htmlengine-search.c:
* gtkhtml/htmlengine.c:
* gtkhtml/htmlprinter.c:
* gtkhtml/htmlselect.c:
* gtkhtml/htmltextarea.c:
* gtkhtml/testgtkhtml.c:
* components/editor/main.c:
* components/editor/gtkhtml-color-combo.c:
* components/editor/gtkhtml-color-swatch.c:
* components/editor/gtkhtml-spell-dialog.c:
* components/editor/gtkhtml-editor-signals.c:
* components/editor/gtkhtml-face-tool-button.c:
Fix what we can with GSEAL_ENABLE defined.
Modified:
trunk/components/editor/ChangeLog
trunk/components/editor/gtkhtml-color-combo.c
trunk/components/editor/gtkhtml-color-swatch.c
trunk/components/editor/gtkhtml-editor-signals.c
trunk/components/editor/gtkhtml-face-tool-button.c
trunk/components/editor/gtkhtml-spell-dialog.c
trunk/components/editor/main.c
trunk/gtkhtml/ChangeLog
trunk/gtkhtml/gtkhtml-embedded.c
trunk/gtkhtml/gtkhtml.c
trunk/gtkhtml/htmlcolorset.c
trunk/gtkhtml/htmlembedded.c
trunk/gtkhtml/htmlengine-search.c
trunk/gtkhtml/htmlengine.c
trunk/gtkhtml/htmlprinter.c
trunk/gtkhtml/htmlselect.c
trunk/gtkhtml/htmltextarea.c
trunk/gtkhtml/testgtkhtml.c
Modified: trunk/components/editor/gtkhtml-color-combo.c
==============================================================================
--- trunk/components/editor/gtkhtml-color-combo.c (original)
+++ trunk/components/editor/gtkhtml-color-combo.c Sun Jan 11 20:20:24 2009
@@ -150,8 +150,8 @@
gint monitor_num;
gint x, y, width, height;
- window = GTK_WIDGET (combo)->window;
screen = gtk_widget_get_screen (GTK_WIDGET (combo));
+ window = gtk_widget_get_window (GTK_WIDGET (combo));
monitor_num = gdk_screen_get_monitor_at_window (screen, window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
@@ -267,7 +267,8 @@
gtkhtml_color_combo_popdown (combo);
dialog = gtk_color_selection_dialog_new (_("Choose Custom Color"));
- colorsel = GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel;
+ colorsel = gtk_color_selection_dialog_get_color_selection (
+ GTK_COLOR_SELECTION_DIALOG (dialog));
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo));
if (GTK_WIDGET_TOPLEVEL (toplevel))
@@ -625,7 +626,7 @@
gtk_toggle_button_set_active (toggle_button, TRUE);
/* Try to grab the pointer and keyboard. */
- window = combo->priv->window->window;
+ window = gtk_widget_get_window (combo->priv->window);
status = gdk_pointer_grab (
window, TRUE,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
Modified: trunk/components/editor/gtkhtml-color-swatch.c
==============================================================================
--- trunk/components/editor/gtkhtml-color-swatch.c (original)
+++ trunk/components/editor/gtkhtml-color-swatch.c Sun Jan 11 20:20:24 2009
@@ -43,15 +43,20 @@
color_swatch_expose_cb (GtkWidget *drawing_area,
GdkEventExpose *event)
{
+ GtkStyle *style;
+ GdkWindow *window;
GdkColor *color;
cairo_t *cr;
- if (drawing_area->window == NULL)
+ style = gtk_widget_get_style (drawing_area);
+ window = gtk_widget_get_window (drawing_area);
+
+ if (window == NULL)
return FALSE;
- cr = gdk_cairo_create (drawing_area->window);
+ cr = gdk_cairo_create (window);
- color = &drawing_area->style->bg[GTK_STATE_NORMAL];
+ color = &style->bg[GTK_STATE_NORMAL];
gdk_cairo_set_source_color (cr, color);
gdk_cairo_rectangle (cr, &event->area);
cairo_fill (cr);
@@ -253,15 +258,17 @@
gtkhtml_color_swatch_get_color (GtkhtmlColorSwatch *swatch,
GdkColor *color)
{
+ GtkStyle *style;
GtkWidget *drawing_area;
g_return_if_fail (GTKHTML_IS_COLOR_SWATCH (swatch));
g_return_if_fail (color != NULL);
drawing_area = swatch->priv->drawing_area;
- color->red = drawing_area->style->bg[GTK_STATE_NORMAL].red;
- color->green = drawing_area->style->bg[GTK_STATE_NORMAL].green;
- color->blue = drawing_area->style->bg[GTK_STATE_NORMAL].blue;
+ style = gtk_widget_get_style (drawing_area);
+ color->red = style->bg[GTK_STATE_NORMAL].red;
+ color->green = style->bg[GTK_STATE_NORMAL].green;
+ color->blue = style->bg[GTK_STATE_NORMAL].blue;
}
void
Modified: trunk/components/editor/gtkhtml-editor-signals.c
==============================================================================
--- trunk/components/editor/gtkhtml-editor-signals.c (original)
+++ trunk/components/editor/gtkhtml-editor-signals.c Sun Jan 11 20:20:24 2009
@@ -566,6 +566,7 @@
GtkAdjustment *adjustment;
GtkWidget *widget;
gboolean sensitive;
+ gdouble value;
gint active;
editor = extract_gtkhtml_editor (window);
@@ -582,15 +583,16 @@
gtk_widget_set_sensitive (widget, sensitive);
if (active == SIZE_UNIT_PERCENT) {
- adjustment->upper = 100;
+ gtk_adjustment_set_upper (adjustment, 100.0);
gtk_adjustment_changed (adjustment);
} else {
- adjustment->upper = (gdouble) G_MAXINT;
+ gtk_adjustment_set_upper (adjustment, (gdouble) G_MAXINT);
gtk_adjustment_changed (adjustment);
}
/* Clamp the value between the new bounds. */
- gtk_adjustment_set_value (adjustment, adjustment->value);
+ value = gtk_adjustment_get_value (adjustment);
+ gtk_adjustment_set_value (adjustment, value);
cell_properties_set (
editor, cell_properties_set_width_cb,
@@ -1593,6 +1595,7 @@
GtkWidget *widget;
GtkHTML *html;
HTMLRule *rule;
+ gdouble value;
gint active;
editor = extract_gtkhtml_editor (window);
@@ -1606,20 +1609,22 @@
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
if (active == SIZE_UNIT_PERCENT) {
- adjustment->upper = 100;
+ gtk_adjustment_set_upper (adjustment, 100.0);
gtk_adjustment_changed (adjustment);
} else {
- adjustment->upper = (gdouble) G_MAXINT;
+ gtk_adjustment_set_upper (adjustment, (gdouble) G_MAXINT);
gtk_adjustment_changed (adjustment);
}
/* Clamp the value between the new bounds. */
- gtk_adjustment_set_value (adjustment, adjustment->value);
+ value = gtk_adjustment_get_value (adjustment);
+ gtk_adjustment_set_value (adjustment, value);
+ value = gtk_adjustment_get_value (adjustment);
html_rule_set_length (
rule, html->engine,
- (active == SIZE_UNIT_PX) ? (gint) adjustment->value : 0,
- (active == SIZE_UNIT_PX) ? 0 : (gint) adjustment->value);
+ (active == SIZE_UNIT_PX) ? (gint) value : 0,
+ (active == SIZE_UNIT_PX) ? 0 : (gint) value);
g_object_unref (editor);
}
@@ -1893,6 +1898,7 @@
GtkHTML *html;
HTMLTable *table;
gboolean sensitive;
+ gdouble value;
gint active;
editor = extract_gtkhtml_editor (window);
@@ -1911,19 +1917,21 @@
gtk_widget_set_sensitive (widget, sensitive);
if (active == SIZE_UNIT_PERCENT) {
- adjustment->upper = 100;
+ gtk_adjustment_set_upper (adjustment, 100.0);
gtk_adjustment_changed (adjustment);
} else {
- adjustment->upper = (gdouble) G_MAXINT;
+ gtk_adjustment_set_upper (adjustment, (gdouble) G_MAXINT);
gtk_adjustment_changed (adjustment);
}
/* Clamp the value between the new bounds. */
- gtk_adjustment_set_value (adjustment, adjustment->value);
+ value = gtk_adjustment_get_value (adjustment);
+ gtk_adjustment_set_value (adjustment, value);
+ value = gtk_adjustment_get_value (adjustment);
html_engine_table_set_width (
html->engine, table,
- sensitive ? (gint) adjustment->value : 0,
+ sensitive ? (gint) value : 0,
(active == SIZE_UNIT_PERCENT));
g_object_unref (editor);
Modified: trunk/components/editor/gtkhtml-face-tool-button.c
==============================================================================
--- trunk/components/editor/gtkhtml-face-tool-button.c (original)
+++ trunk/components/editor/gtkhtml-face-tool-button.c Sun Jan 11 20:20:24 2009
@@ -112,8 +112,8 @@
gint monitor_num;
gint x, y, width, height;
- window = GTK_WIDGET (button)->window;
screen = gtk_widget_get_screen (GTK_WIDGET (button));
+ window = gtk_widget_get_window (GTK_WIDGET (button));
monitor_num = gdk_screen_get_monitor_at_window (screen, window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
@@ -342,7 +342,7 @@
gtk_toggle_tool_button_set_active (tool_button, TRUE);
/* Try to grab the pointer and keyboard. */
- window = button->priv->window->window;
+ window = gtk_widget_get_window (button->priv->window);
status = gdk_pointer_grab (
window, TRUE,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
Modified: trunk/components/editor/gtkhtml-spell-dialog.c
==============================================================================
--- trunk/components/editor/gtkhtml-spell-dialog.c (original)
+++ trunk/components/editor/gtkhtml-spell-dialog.c Sun Jan 11 20:20:24 2009
@@ -419,8 +419,8 @@
GtkCellRenderer *renderer;
GtkWidget *action_area;
GtkWidget *container;
+ GtkWidget *content_area;
GtkWidget *table;
- GtkWidget *vbox;
GtkWidget *widget;
gchar *markup;
@@ -440,8 +440,8 @@
/* Build the widgets. */
- vbox = GTK_DIALOG (dialog)->vbox;
- action_area = GTK_DIALOG (dialog)->action_area;
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
gtk_dialog_add_button (
GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
@@ -449,7 +449,7 @@
gtk_window_set_title (GTK_WINDOW (dialog), _("Spell Checker"));
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (vbox), 2);
+ gtk_box_set_spacing (GTK_BOX (content_area), 2);
/* Table */
widget = gtk_table_new (4, 2, FALSE);
@@ -457,7 +457,7 @@
gtk_table_set_row_spacings (GTK_TABLE (widget), 6);
gtk_table_set_col_spacings (GTK_TABLE (widget), 6);
gtk_table_set_row_spacing (GTK_TABLE (widget), 1, 12);
- gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 0);
gtk_widget_show (widget);
table = widget;
Modified: trunk/components/editor/main.c
==============================================================================
--- trunk/components/editor/main.c (original)
+++ trunk/components/editor/main.c Sun Jan 11 20:20:24 2009
@@ -147,6 +147,7 @@
{
GtkWidget *dialog;
GtkWidget *content;
+ GtkWidget *content_area;
GtkWidget *scrolled_window;
GString *string;
@@ -157,6 +158,8 @@
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (
GTK_SCROLLED_WINDOW (scrolled_window),
@@ -164,7 +167,7 @@
gtk_scrolled_window_set_shadow_type (
GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
gtk_box_pack_start (
- GTK_BOX (GTK_DIALOG (dialog)->vbox),
+ GTK_BOX (content_area),
scrolled_window, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
Modified: trunk/gtkhtml/gtkhtml-embedded.c
==============================================================================
--- trunk/gtkhtml/gtkhtml-embedded.c (original)
+++ trunk/gtkhtml/gtkhtml-embedded.c Sun Jan 11 20:20:24 2009
@@ -103,7 +103,7 @@
g_return_if_fail (container != NULL);
/* can't add something twice */
- g_return_if_fail( GTK_BIN(container)->child == NULL );
+ g_return_if_fail (gtk_bin_get_child (GTK_BIN (container)) == NULL);
old_add(container, child);
gtk_html_embedded_changed(GTK_HTML_EMBEDDED(container));
@@ -112,7 +112,7 @@
static void gtk_html_embedded_remove (GtkContainer *container, GtkWidget *child)
{
g_return_if_fail (container != NULL);
- g_return_if_fail( GTK_BIN(container)->child != NULL );
+ g_return_if_fail (gtk_bin_get_child (GTK_BIN (container)) != NULL);
old_remove(container, child);
@@ -169,7 +169,7 @@
widget_class = GTK_WIDGET_CLASS (class);
container_class = GTK_CONTAINER_CLASS (class);
- parent_class = gtk_type_class (gtk_bin_get_type ());
+ parent_class = g_type_class_peek_parent (class);
signals [CHANGED] =
g_signal_new ("changed",
@@ -213,15 +213,15 @@
static void
gtk_html_embedded_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
- GtkBin *bin;
+ GtkWidget *child;
g_return_if_fail (widget != NULL);
g_return_if_fail (requisition != NULL);
- bin = GTK_BIN (widget);
+ child = gtk_bin_get_child (GTK_BIN (widget));
- if (bin->child) {
- gtk_widget_size_request (bin->child, requisition);
+ if (child) {
+ gtk_widget_size_request (child, requisition);
} else {
requisition->width = widget->requisition.width;
requisition->height = widget->requisition.height;
@@ -231,15 +231,15 @@
static void
gtk_html_embedded_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
- GtkBin *bin;
+ GtkWidget *child;
g_return_if_fail (widget != NULL);
g_return_if_fail (allocation != NULL);
- bin = GTK_BIN (widget);
+ child = gtk_bin_get_child (GTK_BIN (widget));
- if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) {
- gtk_widget_size_allocate(bin->child, allocation);
+ if (child && GTK_WIDGET_VISIBLE (child)) {
+ gtk_widget_size_allocate (child, allocation);
}
widget->allocation = *allocation;
}
Modified: trunk/gtkhtml/gtkhtml.c
==============================================================================
--- trunk/gtkhtml/gtkhtml.c (original)
+++ trunk/gtkhtml/gtkhtml.c Sun Jan 11 20:20:24 2009
@@ -187,7 +187,7 @@
static void update_primary_selection (GtkHTML *html);
static void clipboard_paste_received_cb (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
- gpointer data);
+ gpointer user_data);
static gint motion_notify_event (GtkWidget *widget, GdkEventMotion *event);
/* keybindings signal hadlers */
@@ -404,6 +404,8 @@
gtk_html_adjust_cursor_position (GtkHTML *html)
{
HTMLEngine *e;
+ GtkAdjustment *hadjustment;
+ GtkAdjustment *vadjustment;
e = html->engine;
if (html->priv->scroll_timeout_id == 0 &&
@@ -411,8 +413,11 @@
!html_engine_frozen (html->engine))
html_engine_make_cursor_visible (e);
- gtk_adjustment_set_value (GTK_LAYOUT (html)->hadjustment, (gfloat) e->x_offset);
- gtk_adjustment_set_value (GTK_LAYOUT (html)->vadjustment, (gfloat) e->y_offset);
+ hadjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (html));
+ vadjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
+
+ gtk_adjustment_set_value (hadjustment, (gfloat) e->x_offset);
+ gtk_adjustment_set_value (vadjustment, (gfloat) e->y_offset);
gtk_html_private_calc_scrollbars (html, NULL, NULL);
}
@@ -541,27 +546,38 @@
static void
scroll_update_mouse (GtkWidget *widget)
{
+ GdkWindow *window;
+ GdkWindow *bin_window;
gint x, y;
- if (GTK_WIDGET_REALIZED (widget)) {
- gdk_window_get_pointer (GTK_LAYOUT (widget)->bin_window, &x, &y, NULL);
- mouse_change_pos (widget, widget->window, x, y, 0);
- }
+ if (!GTK_WIDGET_REALIZED (widget))
+ return;
+
+ window = gtk_widget_get_window (widget);
+ bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
+
+ gdk_window_get_pointer (bin_window, &x, &y, NULL);
+ mouse_change_pos (widget, window, x, y, 0);
}
static void
vertical_scroll_cb (GtkAdjustment *adjustment, gpointer data)
{
GtkHTML *html = GTK_HTML (data);
+ gdouble page_increment;
+ gdouble value;
+
+ value = gtk_adjustment_get_value (adjustment);
+ page_increment = gtk_adjustment_get_page_increment (adjustment);
/* check if adjustment is valid, it's changed in
Layout::size_allocate and we can't do anything about it,
because it uses private fields we cannot access, so we have
to use it*/
- if (html->engine->keep_scroll || html->engine->height != adjustment->page_increment)
+ if (html->engine->keep_scroll || html->engine->height != page_increment)
return;
- html->engine->y_offset = (gint) adjustment->value;
+ html->engine->y_offset = (gint) value;
scroll_update_mouse (GTK_WIDGET (data));
}
@@ -569,15 +585,20 @@
horizontal_scroll_cb (GtkAdjustment *adjustment, gpointer data)
{
GtkHTML *html = GTK_HTML (data);
+ gdouble page_increment;
+ gdouble value;
+
+ value = gtk_adjustment_get_value (adjustment);
+ page_increment = gtk_adjustment_get_page_increment (adjustment);
/* check if adjustment is valid, it's changed in
Layout::size_allocate and we can't do anything about it,
because it uses private fields we cannot access, so we have
to use it*/
- if (html->engine->keep_scroll || html->engine->width != adjustment->page_increment)
+ if (html->engine->keep_scroll || html->engine->width != page_increment)
return;
- html->engine->x_offset = (gint) adjustment->value;
+ html->engine->x_offset = (gint) value;
scroll_update_mouse (GTK_WIDGET (data));
}
@@ -586,15 +607,17 @@
GtkAdjustment *hadj,
GtkAdjustment *vadj)
{
- GtkLayout *layout;
+ GtkAdjustment *hadjustment;
+ GtkAdjustment *vadjustment;
- layout = GTK_LAYOUT (html);
+ hadjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (html));
+ vadjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
if (html->hadj_connection != 0)
- g_signal_handler_disconnect (layout->hadjustment, html->hadj_connection);
+ g_signal_handler_disconnect (hadjustment, html->hadj_connection);
if (html->vadj_connection != 0)
- g_signal_handler_disconnect (layout->vadjustment, html->vadj_connection);
+ g_signal_handler_disconnect (vadjustment, html->vadj_connection);
if (vadj != NULL)
html->vadj_connection =
@@ -618,7 +641,7 @@
gfloat value;
gint max;
- value = adj->value + (gfloat) inc;
+ value = gtk_adjustment_get_value (adj) + (gfloat) inc;
if (doc_width > alloc_width)
max = doc_width - alloc_width;
@@ -637,10 +660,12 @@
scroll_timeout_cb (gpointer data)
{
GtkWidget *widget;
+ GdkWindow *window;
GtkHTML *html;
HTMLEngine *engine;
- GtkLayout *layout;
+ GtkAdjustment *hadjustment;
+ GtkAdjustment *vadjustment;
gint x_scroll, y_scroll;
gint x, y;
@@ -650,7 +675,8 @@
html = GTK_HTML (data);
engine = html->engine;
- gdk_window_get_pointer (widget->window, &x, &y, NULL);
+ window = gtk_widget_get_window (widget);
+ gdk_window_get_pointer (window, &x, &y, NULL);
if (x < 0) {
x_scroll = x;
@@ -680,11 +706,12 @@
html_engine_select_region (engine, html->selection_x1, html->selection_y1,
x + engine->x_offset, y + engine->y_offset);
- layout = GTK_LAYOUT (widget);
+ hadjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (widget));
+ vadjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (widget));
- inc_adjustment (layout->hadjustment, html_engine_get_doc_width (html->engine),
+ inc_adjustment (hadjustment, html_engine_get_doc_width (html->engine),
widget->allocation.width, x_scroll);
- inc_adjustment (layout->vadjustment, html_engine_get_doc_height (html->engine),
+ inc_adjustment (vadjustment, html_engine_get_doc_height (html->engine),
widget->allocation.height, y_scroll);
GDK_THREADS_LEAVE ();
@@ -978,7 +1005,7 @@
/* a bit hacky here */
memset (&event, 0, sizeof (GdkEventMotion));
event.type = GDK_MOTION_NOTIFY;
- event.window = widget->window;
+ event.window = gtk_widget_get_window (widget);
event.send_event = FALSE;
event.state = state;
@@ -1103,20 +1130,31 @@
realize (GtkWidget *widget)
{
GtkHTML *html;
- GtkLayout *layout;
+ GtkStyle *style;
+ GdkWindow *window;
+ GdkWindow *bin_window;
+ GtkAdjustment *hadjustment;
+ GtkAdjustment *vadjustment;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HTML (widget));
html = GTK_HTML (widget);
- layout = GTK_LAYOUT (widget);
+ hadjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (widget));
+ vadjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (widget));
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_events (html->layout.bin_window,
- (gdk_window_get_events (html->layout.bin_window)
+ window = gtk_widget_get_window (widget);
+ bin_window = gtk_layout_get_bin_window (&html->layout);
+
+ style = gtk_widget_get_style (widget);
+ style = gtk_style_attach (style, window);
+ gtk_widget_set_style (widget, style);
+
+ gdk_window_set_events (bin_window,
+ (gdk_window_get_events (bin_window)
| GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK
| GDK_ENTER_NOTIFY_MASK
| GDK_BUTTON_PRESS_MASK
@@ -1124,33 +1162,31 @@
| GDK_VISIBILITY_NOTIFY_MASK
| GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK));
- html_engine_realize (html->engine, html->layout.bin_window);
+ html_engine_realize (html->engine, bin_window);
- gdk_window_set_cursor (widget->window, NULL);
+ gdk_window_set_cursor (window, NULL);
/* This sets the backing pixmap to None, so that scrolling does not
erase the newly exposed area, thus making the thing smoother. */
- gdk_window_set_back_pixmap (html->layout.bin_window, NULL, FALSE);
+ gdk_window_set_back_pixmap (bin_window, NULL, FALSE);
/* If someone was silly enough to stick us in something that doesn't
* have adjustments, go ahead and create them now since we expect them
* and love them and pat them
*/
- if (layout->hadjustment == NULL) {
- layout->hadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
-
- g_object_ref_sink (layout->hadjustment);
+ if (hadjustment == NULL) {
+ hadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+ gtk_layout_set_hadjustment (GTK_LAYOUT (widget), hadjustment);
}
- if (layout->vadjustment == NULL) {
- layout->vadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
-
- g_object_ref_sink (layout->vadjustment);
+ if (vadjustment == NULL) {
+ vadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+ gtk_layout_set_vadjustment (GTK_LAYOUT (widget), vadjustment);
}
gtk_html_drag_dest_set (html);
- gtk_im_context_set_client_window (html->priv->im_context, widget->window);
+ gtk_im_context_set_client_window (html->priv->im_context, window);
html_image_factory_start_animations (html->engine->image_factory);
}
@@ -1229,6 +1265,7 @@
size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
GtkHTML *html;
+ GtkLayout *layout;
gboolean changed_x = FALSE, changed_y = FALSE;
GList *children;
@@ -1236,6 +1273,9 @@
g_return_if_fail (GTK_IS_HTML (widget));
g_return_if_fail (allocation != NULL);
+ html = GTK_HTML (widget);
+ layout = GTK_LAYOUT (widget);
+
/* isolate childs from layout - we want to set them after calc size is performed
and we know the children positions */
children = GTK_LAYOUT (widget)->children;
@@ -1244,8 +1284,6 @@
(*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
GTK_LAYOUT (widget)->children = children;
- html = GTK_HTML (widget);
-
if (html->engine->width != allocation->width
|| html->engine->height != allocation->height) {
HTMLEngine *e = html->engine;
@@ -1265,12 +1303,18 @@
}
if (!html->engine->keep_scroll) {
+ GtkAdjustment *adjustment;
+
gtk_html_private_calc_scrollbars (html, &changed_x, &changed_y);
- if (changed_x)
- gtk_adjustment_value_changed (GTK_LAYOUT (html)->hadjustment);
- if (changed_y)
- gtk_adjustment_value_changed (GTK_LAYOUT (html)->vadjustment);
+ if (changed_x) {
+ adjustment = gtk_layout_get_hadjustment (layout);
+ gtk_adjustment_value_changed (adjustment);
+ }
+ if (changed_y) {
+ adjustment = gtk_layout_get_vadjustment (layout);
+ gtk_adjustment_value_changed (adjustment);
+ }
}
if (html->engine->clue)
@@ -1695,7 +1739,8 @@
motion_notify_event (GtkWidget *widget,
GdkEventMotion *event)
{
- GdkWindow *window = widget->window;
+ GdkWindow *window;
+ GdkWindow *bin_window;
HTMLEngine *engine;
gint x, y;
@@ -1710,7 +1755,10 @@
widget = shift_to_iframe_parent (widget, &x, &y);
- gdk_window_get_pointer (GTK_LAYOUT (widget)->bin_window, &x, &y, NULL);
+ window = gtk_widget_get_window (widget);
+ bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
+
+ gdk_window_get_pointer (bin_window, &x, &y, NULL);
if (!mouse_change_pos (widget, window, x, y, event->state))
return FALSE;
@@ -1786,9 +1834,19 @@
gtk_widget_grab_focus (widget);
if (event->type == GDK_BUTTON_PRESS) {
- GtkAdjustment *vadj;
-
- vadj = GTK_LAYOUT (widget)->vadjustment;
+ GtkAdjustment *adjustment;
+ gdouble adj_value;
+ gdouble lower;
+ gdouble upper;
+ gdouble page_size;
+ gdouble step_increment;
+
+ adjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (widget));
+ adj_value = gtk_adjustment_get_value (adjustment);
+ lower = gtk_adjustment_get_lower (adjustment);
+ upper = gtk_adjustment_get_upper (adjustment);
+ page_size = gtk_adjustment_get_page_size (adjustment);
+ step_increment = gtk_adjustment_get_step_increment (adjustment);
switch (event->button) {
case 4:
@@ -1796,12 +1854,12 @@
if (event->state & GDK_CONTROL_MASK)
gtk_html_command (html, "zoom-out");
else {
- value = vadj->value - vadj->step_increment * 3;
+ value = adj_value - step_increment * 3;
- if (value < vadj->lower)
- value = vadj->lower;
+ if (value < lower)
+ value = lower;
- gtk_adjustment_set_value (vadj, value);
+ gtk_adjustment_set_value (adjustment, value);
}
return TRUE;
case 5:
@@ -1809,12 +1867,12 @@
if (event->state & GDK_CONTROL_MASK)
gtk_html_command (html, "zoom-in");
else {
- value = vadj->value + vadj->step_increment * 3;
+ value = adj_value + step_increment * 3;
- if (value > (vadj->upper - vadj->page_size))
- value = vadj->upper - vadj->page_size;
+ if (value > (upper - page_size))
+ value = upper - page_size;
- gtk_adjustment_set_value (vadj, value);
+ gtk_adjustment_set_value (adjustment, value);
}
return TRUE;
case 2:
@@ -1878,8 +1936,11 @@
html_engine_select_region (engine,
html->selection_x1, html->selection_y1, x, y);
else {
+ GdkWindow *bin_window;
+
+ bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
html_engine_disable_selection (engine);
- if (gdk_pointer_grab (GTK_LAYOUT (widget)->bin_window, FALSE,
+ if (gdk_pointer_grab (bin_window, FALSE,
(GDK_BUTTON_RELEASE_MASK
| GDK_BUTTON_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK),
@@ -2005,15 +2066,21 @@
g_return_val_if_fail (GTK_IS_HTML (html), FALSE);
if (html->priv->caret_first_focus_anchor && html_object_find_anchor (html->engine->clue, html->priv->caret_first_focus_anchor, &x, &y)) {
- GtkAdjustment *vadj;
+ GtkAdjustment *adjustment;
+ GtkLayout *layout;
+ gdouble page_size;
+ gdouble value;
html_engine_jump_at (html->engine, x, y);
- vadj = GTK_LAYOUT (html->engine->widget)->vadjustment;
+ layout = GTK_LAYOUT (html->engine->widget);
+ adjustment = gtk_layout_get_vadjustment (layout);
+ page_size = gtk_adjustment_get_page_size (adjustment);
+ value = gtk_adjustment_get_value (adjustment);
/* scroll to the position on screen if not visible */
- if (y < vadj->value || y > vadj->value + vadj->page_size)
- gtk_adjustment_set_value (vadj, y);
+ if (y < value || y > value + page_size)
+ gtk_adjustment_set_value (adjustment, y);
return TRUE;
}
@@ -2076,13 +2143,15 @@
static gint
enter_notify_event (GtkWidget *widget, GdkEventCrossing *event)
{
+ GdkWindow *window;
gint x, y;
x = event->x;
y = event->y;
+ window = gtk_widget_get_window (widget);
widget = shift_to_iframe_parent (widget, &x, &y);
- mouse_change_pos (widget, widget->window, x, y, event->state);
+ mouse_change_pos (widget, window, x, y, event->state);
return TRUE;
}
@@ -2280,7 +2349,7 @@
HTMLObject *o = NULL;
while (w && !(o = g_object_get_data (G_OBJECT (w), "embeddedelement")))
- w = w->parent;
+ w = gtk_widget_get_parent (w);
if (o && !html_object_is_frame (o))
html_engine_set_focus_object (GTK_HTML (containter)->engine, o, 0);
@@ -2359,10 +2428,18 @@
if (e->height > 2*TOP_BORDER && e->y_offset >= y1)
e->y_offset = MAX (y1 - TOP_BORDER, 0);
- if (e->x_offset != xo)
- gtk_adjustment_set_value (GTK_LAYOUT (w)->hadjustment, (gfloat) e->x_offset);
- if (e->y_offset != yo)
- gtk_adjustment_set_value (GTK_LAYOUT (w)->vadjustment, (gfloat) e->y_offset);
+ if (e->x_offset != xo) {
+ GtkAdjustment *adjustment;
+
+ adjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (w));
+ gtk_adjustment_set_value (adjustment, (gfloat) e->x_offset);
+ }
+ if (e->y_offset != yo) {
+ GtkAdjustment *adjustment;
+
+ adjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (w));
+ gtk_adjustment_set_value (adjustment, (gfloat) e->y_offset);
+ }
/* printf ("engine pos: %d,%d x %d,%d\n",
e->x_offset, e->y_offset, e->x_offset + e->width, e->y_offset + e->height); */
@@ -2440,6 +2517,7 @@
char *utf16;
char *utf8;
gsize written_len;
+ GdkAtom target;
if (HTML_IS_TEXT (obj)) {
Link *link = html_text_get_link_at_offset (HTML_TEXT (obj), offset);
@@ -2452,13 +2530,17 @@
utf8 = g_strconcat (complete_url, "\n", complete_url, NULL);
utf16 = g_convert (utf8, strlen (utf8), "UTF-16", "UTF-8", NULL, &written_len, NULL);
- gtk_selection_data_set (selection_data, selection_data->target, 8,
+ target = gtk_selection_data_get_target (selection_data);
+ gtk_selection_data_set (selection_data, target, 8,
(guchar *) utf16, written_len);
g_free (utf8);
g_free (complete_url);
GTK_HTML (widget)->priv->dnd_url = utf16;
} else {
- gtk_selection_data_set (selection_data, selection_data->target, 8,
+ GdkAtom target;
+
+ target = gtk_selection_data_get_target (selection_data);
+ gtk_selection_data_set (selection_data, target, 8,
(guchar *) complete_url, strlen (complete_url));
/* printf ("complete URL %s\n", complete_url); */
GTK_HTML (widget)->priv->dnd_url = complete_url;
@@ -2550,14 +2632,21 @@
gint x, gint y, GtkSelectionData *selection_data, guint info, guint time)
{
HTMLEngine *engine = GTK_HTML (widget)->engine;
+ GdkWindow *bin_window;
gboolean pasted = FALSE;
+ const guchar *data;
+ gint length;
/* printf ("drag data received at %d,%d\n", x, y); */
- if (!selection_data->data || selection_data->length < 0 || !html_engine_get_editable (engine))
+ data = gtk_selection_data_get_data (selection_data);
+ length = gtk_selection_data_get_length (selection_data);
+
+ if (!data || length < 0 || !html_engine_get_editable (engine))
return;
- gdk_window_get_pointer (GTK_LAYOUT (widget)->bin_window, &x, &y, NULL);
+ bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
+ gdk_window_get_pointer (bin_window, &x, &y, NULL);
move_before_paste (widget, x, y);
switch (info) {
@@ -2578,9 +2667,9 @@
gint list_len, len;
gchar *uri;
html_undo_level_begin (engine->undo, "Dropped URI(s)", "Remove Dropped URI(s)");
- list_len = selection_data->length;
+ list_len = length;
do {
- uri = next_uri (&selection_data->data, &len, &list_len);
+ uri = next_uri ((guchar **) &data, &len, &list_len);
obj = new_img_obj_from_uri (engine, uri, NULL, -1);
if (obj) {
html_engine_paste_object (engine, obj, html_object_get_length (obj));
@@ -2597,12 +2686,15 @@
static gboolean
drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time)
{
- GdkWindow *window = widget->window;
+ GdkWindow *window;
+ GdkWindow *bin_window;
if (!gtk_html_get_editable (GTK_HTML (widget)))
return FALSE;
- gdk_window_get_pointer (GTK_LAYOUT (widget)->bin_window, &x, &y, NULL);
+ window = gtk_widget_get_window (widget);
+ bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
+ gdk_window_get_pointer (bin_window, &x, &y, NULL);
html_engine_disable_selection (GTK_HTML (widget)->engine);
html_engine_jump_at (GTK_HTML (widget)->engine, x, y);
@@ -2703,7 +2795,7 @@
object_class->destroy = destroy;
- parent_class = gtk_type_class (GTK_TYPE_LAYOUT);
+ parent_class = g_type_class_peek_parent (klass);
signals [TITLE_CHANGED] =
g_signal_new ("title_changed",
@@ -3726,29 +3818,33 @@
gdouble old_width, gdouble old_height,
gboolean *changed_x, gboolean *changed_y)
{
- GtkLayout *layout;
GtkAdjustment *vadj, *hadj;
gdouble doc_width, doc_height;
/* printf ("update on resize\n"); */
- layout = GTK_LAYOUT (html);
- hadj = layout->hadjustment;
- vadj = layout->vadjustment;
+ hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (html));
+ vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
doc_height = html_engine_get_doc_height (html->engine);
doc_width = html_engine_get_doc_width (html->engine);
if (!html->engine->keep_scroll) {
if (old_doc_width - old_width > 0) {
- html->engine->x_offset = (gint) (hadj->value * (doc_width - html->engine->width)
+ gdouble value;
+
+ value = gtk_adjustment_get_value (hadj);
+ html->engine->x_offset = (gint) (value * (doc_width - html->engine->width)
/ (old_doc_width - old_width));
gtk_adjustment_set_value (hadj, html->engine->x_offset);
}
if (old_doc_height - old_height > 0) {
- html->engine->y_offset = (gint) (vadj->value * (doc_height - html->engine->height)
+ gdouble value;
+
+ value = gtk_adjustment_get_value (vadj);
+ html->engine->y_offset = (gint) (value * (doc_height - html->engine->height)
/ (old_doc_height - old_height));
gtk_adjustment_set_value (vadj, html->engine->y_offset);
}
@@ -3760,7 +3856,9 @@
{
GtkLayout *layout;
GtkAdjustment *vadj, *hadj;
+ guint layout_width, layout_height;
gint width, height;
+ gdouble value;
if (!GTK_WIDGET_REALIZED (html))
return;
@@ -3771,29 +3869,32 @@
width = html_engine_get_doc_width (html->engine);
layout = GTK_LAYOUT (html);
- hadj = layout->hadjustment;
- vadj = layout->vadjustment;
+ hadj = gtk_layout_get_hadjustment (layout);
+ vadj = gtk_layout_get_vadjustment (layout);
- vadj->page_size = html->engine->height;
- vadj->step_increment = 14; /* FIXME */
- vadj->page_increment = html->engine->height;
+ gtk_adjustment_set_page_size (vadj, html->engine->height);
+ gtk_adjustment_set_step_increment (vadj, 14); /* FIXME */
+ gtk_adjustment_set_page_increment (vadj, html->engine->height);
- if (vadj->value > height - html->engine->height) {
+ value = gtk_adjustment_get_value (vadj);
+ if (value > height - html->engine->height) {
gtk_adjustment_set_value (vadj, height - html->engine->height);
if (changed_y)
*changed_y = TRUE;
}
- hadj->page_size = html->engine->width;
- hadj->step_increment = 14; /* FIXME */
- hadj->page_increment = html->engine->width;
+ gtk_adjustment_set_page_size (hadj, html->engine->width);
+ gtk_adjustment_set_step_increment (hadj, 14); /* FIXME */
+ gtk_adjustment_set_page_increment (hadj, html->engine->width);
- if ((width != layout->width) || (height != layout->height)) {
+ gtk_layout_get_size (layout, &layout_width, &layout_height);
+ if ((width != layout_width) || (height != layout_height)) {
g_signal_emit (html, signals [SIZE_CHANGED], 0);
gtk_layout_set_size (layout, width, height);
}
- if (hadj->value > width - html->engine->width || hadj->value > MAX_WIDGET_WIDTH - html->engine->width) {
+ value = gtk_adjustment_get_value (hadj);
+ if (value > width - html->engine->width || value > MAX_WIDGET_WIDTH - html->engine->width) {
gtk_adjustment_set_value (hadj, MIN (width - html->engine->width, MAX_WIDGET_WIDTH - html->engine->width));
if (changed_x)
*changed_x = TRUE;
@@ -4282,27 +4383,35 @@
static void
clipboard_paste_received_cb (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
- gpointer data)
+ gpointer user_data)
{
gint i = 0;
- GtkWidget *widget = GTK_WIDGET (data);
- GdkAtom type = selection_data->type;
+ GtkWidget *widget = GTK_WIDGET (user_data);
+ GdkAtom data_type;
+ GdkAtom target;
gboolean as_cite;
HTMLEngine *e;
+ const guchar *data;
+ gint length;
e = GTK_HTML (widget)->engine;
as_cite = GTK_HTML (widget)->priv->selection_as_cite;
- if (selection_data->length > 0) {
+ data = gtk_selection_data_get_data (selection_data);
+ length = gtk_selection_data_get_length (selection_data);
+ target = gtk_selection_data_get_target (selection_data);
+ data_type = gtk_selection_data_get_data_type (selection_data);
+
+ if (length > 0) {
gchar *utf8 = NULL;
- if (type == gdk_atom_intern (selection_targets[TARGET_HTML].target, FALSE)) {
- if (selection_data->length > 1 &&
- !g_utf8_validate ((const gchar *) selection_data->data, selection_data->length - 1, NULL)) {
- utf8 = utf16_to_utf8_with_bom_check (selection_data->data, selection_data->length);
+ if (data_type == gdk_atom_intern (selection_targets[TARGET_HTML].target, FALSE)) {
+ if (length > 1 &&
+ !g_utf8_validate ((const gchar *) data, length - 1, NULL)) {
+ utf8 = utf16_to_utf8_with_bom_check ((guchar *) data, length);
} else {
- utf8 = utf8_filter_out_bom (g_strndup ((const gchar *)selection_data->data, selection_data->length));
+ utf8 = utf8_filter_out_bom (g_strndup ((const gchar *) data, length));
}
if (as_cite && utf8) {
@@ -4344,7 +4453,7 @@
}
while (i < n_selection_targets - 1) {
- if (selection_data->target == gdk_atom_intern (selection_targets[i].target, FALSE))
+ if (target == gdk_atom_intern (selection_targets[i].target, FALSE))
break;
i++;
}
@@ -4556,34 +4665,47 @@
GtkScrollType scroll_type,
gfloat position)
{
- GtkAdjustment *adj;
+ GtkAdjustment *adjustment;
gint line_height;
gfloat delta;
+ gdouble value;
+ gdouble lower;
+ gdouble upper;
+ gdouble page_size;
+ gdouble page_increment;
+ gdouble step_increment;
/* we dont want scroll in editable (move cursor instead) */
if (html_engine_get_editable (html->engine) || html->engine->caret_mode)
return;
- adj = (orientation == GTK_ORIENTATION_VERTICAL)
- ? gtk_layout_get_vadjustment (GTK_LAYOUT (html)) : gtk_layout_get_hadjustment (GTK_LAYOUT (html));
+ adjustment = (orientation == GTK_ORIENTATION_VERTICAL) ?
+ gtk_layout_get_vadjustment (GTK_LAYOUT (html)) :
+ gtk_layout_get_hadjustment (GTK_LAYOUT (html));
+
+ value = gtk_adjustment_get_value (adjustment);
+ lower = gtk_adjustment_get_lower (adjustment);
+ upper = gtk_adjustment_get_upper (adjustment);
+ page_size = gtk_adjustment_get_page_size (adjustment);
+ page_increment = gtk_adjustment_get_page_increment (adjustment);
+ step_increment = gtk_adjustment_get_step_increment (adjustment);
-
- line_height = (html->engine && adj->page_increment > (3 * get_line_height (html)))
+ line_height = (html->engine && page_increment > (3 * get_line_height (html)))
? get_line_height (html)
: 0;
switch (scroll_type) {
case GTK_SCROLL_STEP_FORWARD:
- delta = adj->step_increment;
+ delta = step_increment;
break;
case GTK_SCROLL_STEP_BACKWARD:
- delta = -adj->step_increment;
+ delta = -step_increment;
break;
case GTK_SCROLL_PAGE_FORWARD:
- delta = adj->page_increment - line_height;
+ delta = page_increment - line_height;
break;
case GTK_SCROLL_PAGE_BACKWARD:
- delta = -adj->page_increment + line_height;
+ delta = -page_increment + line_height;
break;
default:
g_warning ("invalid scroll parameters: %d %d %f\n", orientation, scroll_type, position);
@@ -4592,21 +4714,21 @@
}
if (position == 1.0) {
- if (adj->lower > (adj->value + delta)) {
- if (adj->lower >= adj->value) {
+ if (lower > (value + delta)) {
+ if (lower >= value) {
html->binding_handled = FALSE;
return;
}
- } else if (MAX (0.0, adj->upper - adj->page_size) < (adj->value + delta)) {
+ } else if (MAX (0.0, upper - page_size) < (value + delta)) {
- if (MAX (0.0, adj->upper - adj->page_size) <= adj->value) {
+ if (MAX (0.0, upper - page_size) <= value) {
html->binding_handled = FALSE;
return;
}
}
}
- gtk_adjustment_set_value (adj, CLAMP (adj->value + delta, adj->lower, MAX (0.0, adj->upper - adj->page_size)));
+ gtk_adjustment_set_value (adjustment, CLAMP (value + delta, lower, MAX (0.0, upper - page_size)));
html->binding_handled = TRUE;
}
@@ -4615,46 +4737,55 @@
scroll_command (GtkHTML *html,
GtkScrollType scroll_type)
{
- GtkAdjustment *adj;
+ GtkAdjustment *adjustment;
gint line_height;
gfloat delta = 0;
+ gdouble value;
+ gdouble lower;
+ gdouble upper;
+ gdouble page_increment;
+ gdouble page_size;
/* we dont want scroll in editable (move cursor instead) */
if (html_engine_get_editable (html->engine) || html->engine->caret_mode)
return FALSE;
- adj = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
-
+ adjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
+ value = gtk_adjustment_get_value (adjustment);
+ lower = gtk_adjustment_get_lower (adjustment);
+ upper = gtk_adjustment_get_upper (adjustment);
+ page_increment = gtk_adjustment_get_page_increment (adjustment);
+ page_size = gtk_adjustment_get_page_size (adjustment);
- line_height = (html->engine && adj->page_increment > (3 * get_line_height (html)))
+ line_height = (html->engine && page_increment > (3 * get_line_height (html)))
? get_line_height (html)
: 0;
switch (scroll_type) {
case GTK_SCROLL_PAGE_FORWARD:
- delta = adj->page_increment - line_height;
+ delta = page_increment - line_height;
break;
case GTK_SCROLL_PAGE_BACKWARD:
- delta = -adj->page_increment + line_height;
+ delta = -page_increment + line_height;
break;
default:
break;
return FALSE;
}
- d_s(printf("%f %f %f\n", adj->value + delta, adj->lower, MAX (0.0, adj->upper - adj->page_size));)
+ d_s(printf("%f %f %f\n", value + delta, lower, MAX (0.0, upper - page_size));)
- if (adj->lower > (adj->value + delta)) {
- if (adj->lower >= adj->value)
+ if (lower > (value + delta)) {
+ if (lower >= value)
return FALSE;
- } else if (MAX (0.0, adj->upper - adj->page_size) < (adj->value + delta)) {
+ } else if (MAX (0.0, upper - page_size) < (value + delta)) {
- if (MAX (0.0, adj->upper - adj->page_size) <= adj->value) {
+ if (MAX (0.0, upper - page_size) <= value) {
return FALSE;
}
}
- gtk_adjustment_set_value (adj, CLAMP (adj->value + delta, adj->lower, MAX (0.0, adj->upper - adj->page_size)));
+ gtk_adjustment_set_value (adjustment, CLAMP (value + delta, lower, MAX (0.0, upper - page_size)));
return TRUE;
}
@@ -4662,11 +4793,21 @@
static void
scroll_by_amount (GtkHTML *html, gint amount)
{
- GtkAdjustment *adj;
-
- adj = GTK_LAYOUT (html)->vadjustment;
- gtk_adjustment_set_value (adj,
- CLAMP (adj->value + (gfloat) amount, adj->lower, MAX (0.0, adj->upper - adj->page_size)));
+ GtkAdjustment *adjustment;
+ gdouble value;
+ gdouble lower;
+ gdouble upper;
+ gdouble page_size;
+
+ adjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
+ value = gtk_adjustment_get_value (adjustment);
+ lower = gtk_adjustment_get_lower (adjustment);
+ upper = gtk_adjustment_get_upper (adjustment);
+ page_size = gtk_adjustment_get_page_size (adjustment);
+
+ gtk_adjustment_set_value (
+ adjustment, CLAMP (value + (gfloat) amount,
+ lower, MAX (0.0, upper - page_size)));
}
static void
@@ -4941,8 +5082,13 @@
break;
case GTK_HTML_COMMAND_SCROLL_EOD:
if (!html_engine_get_editable (e) && !e->caret_mode) {
- GtkAdjustment *vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
- gtk_adjustment_set_value (vadj, vadj->upper - vadj->page_size);
+ GtkAdjustment *adjustment;
+ gdouble upper, page_size;
+
+ adjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
+ upper = gtk_adjustment_get_upper (adjustment);
+ page_size = gtk_adjustment_get_page_size (adjustment);
+ gtk_adjustment_set_value (adjustment, upper - page_size);
}
break;
case GTK_HTML_COMMAND_COPY:
@@ -5835,14 +5981,19 @@
gboolean
gtk_html_edit_make_cursor_visible (GtkHTML *html)
{
+ GtkAdjustment *hadjustment;
+ GtkAdjustment *vadjustment;
gboolean rv = FALSE;
g_return_val_if_fail (GTK_IS_HTML (html), rv);
+ hadjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (html));
+ vadjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
+
html_engine_hide_cursor (html->engine);
if (html_engine_make_cursor_visible (html->engine)) {
- gtk_adjustment_set_value (GTK_LAYOUT (html)->hadjustment, (gfloat) html->engine->x_offset);
- gtk_adjustment_set_value (GTK_LAYOUT (html)->vadjustment, (gfloat) html->engine->y_offset);
+ gtk_adjustment_set_value (hadjustment, (gfloat) html->engine->x_offset);
+ gtk_adjustment_set_value (vadjustment, (gfloat) html->engine->y_offset);
rv = TRUE;
}
html_engine_show_cursor (html->engine);
@@ -5861,11 +6012,15 @@
{
if (html_object_is_embedded (o)) {
HTMLEmbedded *eo = HTML_EMBEDDED (o);
+ GtkWidget *parent = NULL;
+
+ if (eo->widget != NULL)
+ parent = gtk_widget_get_parent (eo->widget);
- if (eo->widget && eo->widget->parent && GTK_IS_HTML (eo->widget->parent) &&
- GTK_HTML (eo->widget->parent)->iframe_parent == NULL) {
+ if (parent && GTK_IS_HTML (parent) &&
+ GTK_HTML (parent)->iframe_parent == NULL) {
g_object_ref (eo->widget);
- gtk_container_remove (GTK_CONTAINER (eo->widget->parent), eo->widget);
+ gtk_container_remove (GTK_CONTAINER (parent), eo->widget);
g_object_force_floating (G_OBJECT (eo->widget));
}
eo->parent = data;
Modified: trunk/gtkhtml/htmlcolorset.c
==============================================================================
--- trunk/gtkhtml/htmlcolorset.c (original)
+++ trunk/gtkhtml/htmlcolorset.c Sun Jan 11 20:20:24 2009
@@ -140,7 +140,9 @@
{
GdkColor c;
GdkColor *color = NULL;
+ GtkStyle *style;
+ style = gtk_widget_get_style (w);
gtk_widget_style_get (w, name, &color, NULL);
if (color)
@@ -153,7 +155,7 @@
return gdk_color_copy (gdk_color);
g_warning ("falling back to text color");
- return (gdk_color_copy (&w->style->text [GTK_STATE_NORMAL]));
+ return (gdk_color_copy (&style->text [GTK_STATE_NORMAL]));
}
#define SET_GCOLOR(t,c) \
Modified: trunk/gtkhtml/htmlembedded.c
==============================================================================
--- trunk/gtkhtml/htmlembedded.c (original)
+++ trunk/gtkhtml/htmlembedded.c Sun Jan 11 20:20:24 2009
@@ -78,7 +78,7 @@
new_x = o->x + tx;
new_y = o->y + ty - o->ascent;
- if (element->widget->parent) {
+ if (gtk_widget_get_parent (element->widget)) {
if (new_x != element->abs_x || new_y != element->abs_y) {
d (printf ("element: %p moveto: %d,%d shown: %d\n", element, new_x, new_y, GTK_WIDGET_VISIBLE (element->widget)));
gtk_layout_move (GTK_LAYOUT(element->parent), element->widget, new_x, new_y);
@@ -89,7 +89,7 @@
element->abs_x = new_x;
element->abs_y = new_y;
- if (!element->widget->parent) {
+ if (!gtk_widget_get_parent (element->widget)) {
d (printf ("element: %p put: %d,%d shown: %d\n", element, new_x, new_y, GTK_WIDGET_VISIBLE (element->widget)));
gtk_layout_put (GTK_LAYOUT(element->parent), element->widget, new_x, new_y);
}
@@ -112,13 +112,16 @@
if(element->value)
g_free(element->value);
if(element->widget) {
+ GtkWidget *parent;
+
gtk_widget_hide (element->widget);
+ parent = gtk_widget_get_parent (element->widget);
g_signal_handlers_disconnect_matched (element->widget, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, element);
if (element->changed_id > 0)
g_signal_handler_disconnect (element->widget, element->changed_id);
g_object_set_data (G_OBJECT (element->widget), "embeddedelement", NULL);
- if (element->widget->parent && element->parent) {
- g_assert (element->widget->parent == element->parent);
+ if (parent && element->parent) {
+ g_assert (parent == element->parent);
gtk_container_remove (GTK_CONTAINER (element->parent), element->widget);
} else {
g_object_ref_sink (element->widget);
@@ -390,6 +393,10 @@
static void
html_embedded_allocate (GtkWidget *w, GtkAllocation *allocation, HTMLEmbedded *e)
{
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (w);
+
if (e->width != allocation->width || e->height != allocation->height) {
if (e->width != allocation->width) {
html_object_change_set (HTML_OBJECT (e), HTML_CHANGE_ALL_CALC);
@@ -397,8 +404,8 @@
}
e->height = allocation->height;
- if (GTK_IS_HTML (w->parent))
- html_engine_schedule_update (GTK_HTML (w->parent)->engine);
+ if (GTK_IS_HTML (parent))
+ html_engine_schedule_update (GTK_HTML (parent)->engine);
}
}
Modified: trunk/gtkhtml/htmlengine-search.c
==============================================================================
--- trunk/gtkhtml/htmlengine-search.c (original)
+++ trunk/gtkhtml/htmlengine-search.c Sun Jan 11 20:20:24 2009
@@ -57,6 +57,8 @@
HTMLObject *first = HTML_OBJECT (info->found->data);
HTMLObject *last = HTML_OBJECT (g_list_last (info->found)->data);
HTMLTextSlave *slave;
+ GtkAdjustment *adjustment;
+ GtkLayout *layout;
gint x, y, ex, ey, w, h;
gint nx = e->x_offset;
gint ny = e->y_offset;
@@ -107,11 +109,15 @@
ny = y + h - ep->height;
/* finally adjust them if they changed */
- if (ep->x_offset != nx)
- gtk_adjustment_set_value (GTK_LAYOUT (ep->widget)->hadjustment, nx);
-
- if (ep->y_offset != ny)
- gtk_adjustment_set_value (GTK_LAYOUT (ep->widget)->vadjustment, ny);
+ layout = GTK_LAYOUT (ep->widget);
+ if (ep->x_offset != nx) {
+ adjustment = gtk_layout_get_hadjustment (layout);
+ gtk_adjustment_set_value (adjustment, nx);
+ }
+ if (ep->y_offset != ny) {
+ adjustment = gtk_layout_get_vadjustment (layout);
+ gtk_adjustment_set_value (adjustment, ny);
+ }
}
static void
Modified: trunk/gtkhtml/htmlengine.c
==============================================================================
--- trunk/gtkhtml/htmlengine.c (original)
+++ trunk/gtkhtml/htmlengine.c Sun Jan 11 20:20:24 2009
@@ -4748,7 +4748,7 @@
x += obj->x;
y += obj->y - obj->ascent;
- if (!emb->widget->parent) {
+ if (!gtk_widget_get_parent (emb->widget)) {
gtk_layout_put (GTK_LAYOUT (emb->parent), emb->widget, x, y);
} else {
gtk_layout_move (GTK_LAYOUT(emb->parent), emb->widget, x, y);
@@ -4760,17 +4760,25 @@
static gboolean
html_engine_update_event (HTMLEngine *e)
{
+ GtkLayout *layout;
+ GtkAdjustment *hadjustment;
+ GtkAdjustment *vadjustment;
+
DI (printf ("html_engine_update_event idle %p\n", e);)
g_return_val_if_fail (HTML_IS_ENGINE (e), FALSE);
+ layout = GTK_LAYOUT (e->widget);
+ hadjustment = gtk_layout_get_hadjustment (layout);
+ vadjustment = gtk_layout_get_vadjustment (layout);
+
e->updateTimer = 0;
if (html_engine_get_editable (e))
html_engine_hide_cursor (e);
html_engine_calc_size (e, FALSE);
- if (GTK_LAYOUT (e->widget)->vadjustment == NULL
+ if (vadjustment == NULL
|| ! html_gdk_painter_realized (HTML_GDK_PAINTER (e->painter))) {
e->need_update = TRUE;
return FALSE;
@@ -4785,7 +4793,7 @@
/* Scroll page to the top on first display */
if (e->newPage) {
- gtk_adjustment_set_value (GTK_LAYOUT (e->widget)->vadjustment, 0);
+ gtk_adjustment_set_value (vadjustment, 0);
e->newPage = FALSE;
if (! e->parsing && e->editable)
html_cursor_home (e->cursor, e);
@@ -4806,8 +4814,8 @@
e->x_offset = 0;
}
- gtk_adjustment_set_value (GTK_LAYOUT (e->widget)->vadjustment, e->y_offset);
- gtk_adjustment_set_value (GTK_LAYOUT (e->widget)->hadjustment, e->x_offset);
+ gtk_adjustment_set_value (vadjustment, e->y_offset);
+ gtk_adjustment_set_value (hadjustment, e->x_offset);
}
html_image_factory_deactivate_animations (e->image_factory);
gtk_container_forall (GTK_CONTAINER (e->widget), update_embedded, e->widget);
@@ -4838,9 +4846,12 @@
html_engine_goto_anchor (HTMLEngine *e,
const gchar *anchor)
{
- GtkAdjustment *vadj;
+ GtkAdjustment *vadjustment;
+ GtkLayout *layout;
HTMLAnchor *a;
gint x, y;
+ gdouble upper;
+ gdouble page_size;
g_return_val_if_fail (anchor != NULL, FALSE);
@@ -4855,12 +4866,15 @@
return FALSE;
}
- vadj = GTK_LAYOUT (e->widget)->vadjustment;
+ layout = GTK_LAYOUT (e->widget);
+ vadjustment = gtk_layout_get_vadjustment (layout);
+ page_size = gtk_adjustment_get_page_size (vadjustment);
+ upper = gtk_adjustment_get_upper (vadjustment);
- if (y < vadj->upper - vadj->page_size)
- gtk_adjustment_set_value (vadj, y);
+ if (y < upper - page_size)
+ gtk_adjustment_set_value (vadjustment, y);
else
- gtk_adjustment_set_value (vadj, vadj->upper - vadj->page_size);
+ gtk_adjustment_set_value (vadjustment, upper - page_size);
return TRUE;
}
@@ -4999,6 +5013,7 @@
static void
html_engine_draw_real (HTMLEngine *e, gint x, gint y, gint width, gint height, gboolean expose)
{
+ GtkWidget *parent;
gint x1, x2, y1, y2;
g_return_if_fail (HTML_IS_ENGINE (e));
@@ -5012,13 +5027,22 @@
if (width == 0 || height == 0)
return;
+ parent = gtk_widget_get_parent (GTK_WIDGET (e->widget));
+
/* don't draw in case we are longer than available space and scrollbar is going to be shown */
if (e->clue && e->clue->ascent + e->clue->descent > e->height - (html_engine_get_top_border (e) + html_engine_get_bottom_border (e))) {
- if (GTK_WIDGET (e->widget)->parent) {
- if (GTK_IS_SCROLLED_WINDOW (GTK_WIDGET (e->widget)->parent)) {
- if (GTK_SCROLLED_WINDOW (GTK_WIDGET (e->widget)->parent)->vscrollbar
- && !GTK_WIDGET_VISIBLE (GTK_SCROLLED_WINDOW (GTK_WIDGET (e->widget)->parent)->vscrollbar)
- && GTK_SCROLLED_WINDOW (GTK_WIDGET (e->widget)->parent)->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ if (GTK_IS_SCROLLED_WINDOW (parent)) {
+ GtkWidget *vscrollbar;
+
+ vscrollbar = gtk_scrolled_window_get_vscrollbar (
+ GTK_SCROLLED_WINDOW (parent));
+ if (vscrollbar != NULL && !GTK_WIDGET_VISIBLE (vscrollbar)) {
+ GtkPolicyType vscrollbar_policy;
+
+ gtk_scrolled_window_get_policy (
+ GTK_SCROLLED_WINDOW (parent),
+ NULL, &vscrollbar_policy);
+ if (vscrollbar_policy == GTK_POLICY_AUTOMATIC)
return;
}
}
@@ -5026,11 +5050,18 @@
/* don't draw in case we are shorter than available space and scrollbar is going to be hidden */
if (e->clue && e->clue->ascent + e->clue->descent <= e->height - (html_engine_get_top_border (e) + html_engine_get_bottom_border (e))) {
- if (GTK_WIDGET (e->widget)->parent) {
- if (GTK_IS_SCROLLED_WINDOW (GTK_WIDGET (e->widget)->parent)) {
- if (GTK_SCROLLED_WINDOW (GTK_WIDGET (e->widget)->parent)->vscrollbar
- && GTK_WIDGET_VISIBLE (GTK_SCROLLED_WINDOW (GTK_WIDGET (e->widget)->parent)->vscrollbar)
- && GTK_SCROLLED_WINDOW (GTK_WIDGET (e->widget)->parent)->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ if (GTK_IS_SCROLLED_WINDOW (parent)) {
+ GtkWidget *vscrollbar;
+
+ vscrollbar = gtk_scrolled_window_get_vscrollbar (
+ GTK_SCROLLED_WINDOW (parent));
+ if (vscrollbar != NULL && GTK_WIDGET_VISIBLE (vscrollbar)) {
+ GtkPolicyType vscrollbar_policy;
+
+ gtk_scrolled_window_get_policy (
+ GTK_SCROLLED_WINDOW (parent),
+ NULL, &vscrollbar_policy);
+ if (vscrollbar_policy == GTK_POLICY_AUTOMATIC)
return;
}
}
@@ -6903,17 +6934,20 @@
e->opened_streams = value;
if (value == 0 && e->keep_scroll) {
- GtkAdjustment *vadj, *hadj;
+ GtkAdjustment *hadjustment;
+ GtkAdjustment *vadjustment;
+ GtkLayout *layout;
e->keep_scroll = FALSE;
/*html_engine_calc_size (e, FALSE);
gtk_html_private_calc_scrollbars (e->widget, NULL, NULL);*/
- hadj = GTK_LAYOUT (e->widget)->hadjustment;
- vadj = GTK_LAYOUT (e->widget)->vadjustment;
+ layout = GTK_LAYOUT (e->widget);
+ hadjustment = gtk_layout_get_hadjustment (layout);
+ vadjustment = gtk_layout_get_vadjustment (layout);
- gtk_adjustment_set_value (hadj, e->x_offset);
- gtk_adjustment_set_value (vadj, e->y_offset);
+ gtk_adjustment_set_value (hadjustment, e->x_offset);
+ gtk_adjustment_set_value (vadjustment, e->y_offset);
html_engine_schedule_update (e);
}
Modified: trunk/gtkhtml/htmlprinter.c
==============================================================================
--- trunk/gtkhtml/htmlprinter.c (original)
+++ trunk/gtkhtml/htmlprinter.c Sun Jan 11 20:20:24 2009
@@ -654,6 +654,7 @@
HTMLPainter *
html_printer_new (GtkWidget *widget, GtkPrintContext *context)
{
+ GtkStyle *style;
HTMLPrinter *printer;
HTMLPainter *painter;
@@ -662,10 +663,11 @@
painter = HTML_PAINTER (printer);
html_painter_set_widget (painter, widget);
+ style = gtk_widget_get_style (widget);
painter->pango_context =
gtk_print_context_create_pango_context (context);
pango_context_set_font_description (
- painter->pango_context, widget->style->font_desc);
+ painter->pango_context, style->font_desc);
return painter;
Modified: trunk/gtkhtml/htmlselect.c
==============================================================================
--- trunk/gtkhtml/htmlselect.c (original)
+++ trunk/gtkhtml/htmlselect.c Sun Jan 11 20:20:24 2009
@@ -342,7 +342,7 @@
GtkWidget *scrollbar;
gint width;
- scrollbar = GTK_SCROLLED_WINDOW (w)->vscrollbar;
+ scrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (w));
gtk_widget_size_request (select->view, &req);
width = req.width;
Modified: trunk/gtkhtml/htmltextarea.c
==============================================================================
--- trunk/gtkhtml/htmltextarea.c (original)
+++ trunk/gtkhtml/htmltextarea.c Sun Jan 11 20:20:24 2009
@@ -132,6 +132,7 @@
gint col)
{
GtkWidget *sw;
+ GtkStyle *style;
HTMLEmbedded *element;
PangoLayout *layout;
gint width, height;
@@ -154,8 +155,9 @@
gtk_widget_show_all (sw);
html_embedded_set_widget (element, sw);
+ style = gtk_widget_get_style (ta->text);
layout = pango_layout_new (gtk_widget_get_pango_context (ta->text));
- pango_layout_set_font_description (layout, ta->text->style->font_desc);
+ pango_layout_set_font_description (layout, style->font_desc);
pango_layout_set_text (layout, "0", 1);
pango_layout_get_size (layout, &width, &height);
g_object_unref (layout);
Modified: trunk/gtkhtml/testgtkhtml.c
==============================================================================
--- trunk/gtkhtml/testgtkhtml.c (original)
+++ trunk/gtkhtml/testgtkhtml.c Sun Jan 11 20:20:24 2009
@@ -794,7 +794,7 @@
go_item *item;
int num;
/* Only if the item was selected, not deselected */
- if(GTK_CHECK_MENU_ITEM(widget)->active) {
+ if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget))) {
go_position = GPOINTER_TO_INT(data);
@@ -914,6 +914,8 @@
group = NULL;
for(i=0;i<tmp;i++) {
+ GtkWidget *submenu;
+
item = g_list_nth_data(go_list, i);
item->widget = gtk_radio_menu_item_new_with_label(group, item->url);
@@ -925,7 +927,8 @@
if(i == 0)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->widget), TRUE);
- gtk_menu_shell_append (GTK_MENU_SHELL (GTK_MENU_ITEM(main_menu[3].widget)->submenu), item->widget);
+ submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (main_menu[3].widget));
+ gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item->widget);
gtk_widget_show(item->widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]