Get more GTK+ 3 ready and respect seals.
This commit is contained in:
parent
cf5260990c
commit
4196a10ece
|
@ -13,6 +13,8 @@ else (OPTION_NOINSTALL)
|
||||||
set (OPTION_NOINSTALL 0)
|
set (OPTION_NOINSTALL 0)
|
||||||
endif (OPTION_NOINSTALL)
|
endif (OPTION_NOINSTALL)
|
||||||
|
|
||||||
|
add_definitions (-DGSEAL_ENABLE)
|
||||||
|
|
||||||
# Project information
|
# Project information
|
||||||
set (project_VERSION_MAJOR "0")
|
set (project_VERSION_MAJOR "0")
|
||||||
set (project_VERSION_MINOR "1")
|
set (project_VERSION_MINOR "1")
|
||||||
|
|
|
@ -611,10 +611,10 @@ ld_diagram_view_real_set_scroll_adjustments (LdDiagramView *self,
|
||||||
GtkAdjustment *horizontal, GtkAdjustment *vertical)
|
GtkAdjustment *horizontal, GtkAdjustment *vertical)
|
||||||
{
|
{
|
||||||
/* TODO: Infinite area. */
|
/* TODO: Infinite area. */
|
||||||
GtkWidget *widget;
|
GtkAllocation allocation;
|
||||||
gdouble scale;
|
gdouble scale, page_size;
|
||||||
|
|
||||||
widget = GTK_WIDGET (self);
|
gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
|
||||||
scale = ld_diagram_view_get_scale_in_px (self);
|
scale = ld_diagram_view_get_scale_in_px (self);
|
||||||
|
|
||||||
if (horizontal != self->priv->adjustment_h)
|
if (horizontal != self->priv->adjustment_h)
|
||||||
|
@ -633,12 +633,9 @@ ld_diagram_view_real_set_scroll_adjustments (LdDiagramView *self,
|
||||||
g_signal_connect (horizontal, "value-changed",
|
g_signal_connect (horizontal, "value-changed",
|
||||||
G_CALLBACK (on_adjustment_value_changed), self);
|
G_CALLBACK (on_adjustment_value_changed), self);
|
||||||
|
|
||||||
horizontal->upper = 100;
|
page_size = allocation.width / scale;
|
||||||
horizontal->lower = -100;
|
gtk_adjustment_configure (horizontal,
|
||||||
horizontal->step_increment = 0.5;
|
-page_size / 2, -100, 100, 0.5, 5, page_size);
|
||||||
horizontal->page_increment = 5;
|
|
||||||
horizontal->page_size = widget->allocation.width / scale;
|
|
||||||
horizontal->value = -horizontal->page_size / 2;
|
|
||||||
|
|
||||||
self->priv->adjustment_h = horizontal;
|
self->priv->adjustment_h = horizontal;
|
||||||
}
|
}
|
||||||
|
@ -660,12 +657,9 @@ ld_diagram_view_real_set_scroll_adjustments (LdDiagramView *self,
|
||||||
g_signal_connect (vertical, "value-changed",
|
g_signal_connect (vertical, "value-changed",
|
||||||
G_CALLBACK (on_adjustment_value_changed), self);
|
G_CALLBACK (on_adjustment_value_changed), self);
|
||||||
|
|
||||||
vertical->upper = 100;
|
page_size = allocation.height / scale;
|
||||||
vertical->lower = -100;
|
gtk_adjustment_configure (vertical,
|
||||||
vertical->step_increment = 0.5;
|
-page_size / 2, -100, 100, 0.5, 5, page_size);
|
||||||
vertical->page_increment = 5;
|
|
||||||
vertical->page_size = widget->allocation.height / scale;
|
|
||||||
vertical->value = -vertical->page_size / 2;
|
|
||||||
|
|
||||||
self->priv->adjustment_v = vertical;
|
self->priv->adjustment_v = vertical;
|
||||||
}
|
}
|
||||||
|
@ -675,18 +669,18 @@ ld_diagram_view_real_set_scroll_adjustments (LdDiagramView *self,
|
||||||
static void
|
static void
|
||||||
on_adjustment_value_changed (GtkAdjustment *adjustment, LdDiagramView *self)
|
on_adjustment_value_changed (GtkAdjustment *adjustment, LdDiagramView *self)
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkAllocation allocation;
|
||||||
gdouble scale;
|
gdouble scale;
|
||||||
|
|
||||||
widget = GTK_WIDGET (self);
|
gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
|
||||||
scale = ld_diagram_view_get_scale_in_px (self);
|
scale = ld_diagram_view_get_scale_in_px (self);
|
||||||
|
|
||||||
if (adjustment == self->priv->adjustment_h)
|
if (adjustment == self->priv->adjustment_h)
|
||||||
ld_diagram_view_set_x (self, adjustment->value
|
ld_diagram_view_set_x (self, gtk_adjustment_get_value (adjustment)
|
||||||
+ widget->allocation.width / scale / 2);
|
+ allocation.width / scale / 2);
|
||||||
else if (adjustment == self->priv->adjustment_v)
|
else if (adjustment == self->priv->adjustment_v)
|
||||||
ld_diagram_view_set_y (self, adjustment->value
|
ld_diagram_view_set_y (self, gtk_adjustment_get_value (adjustment)
|
||||||
+ widget->allocation.height / scale / 2);
|
+ allocation.height / scale / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -706,24 +700,26 @@ on_size_allocate (GtkWidget *widget, GtkAllocation *allocation,
|
||||||
static void
|
static void
|
||||||
update_adjustments (LdDiagramView *self)
|
update_adjustments (LdDiagramView *self)
|
||||||
{
|
{
|
||||||
gdouble scale;
|
GtkAllocation allocation;
|
||||||
|
gdouble scale, page_size;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
|
||||||
scale = ld_diagram_view_get_scale_in_px (self);
|
scale = ld_diagram_view_get_scale_in_px (self);
|
||||||
|
|
||||||
if (self->priv->adjustment_h)
|
if (self->priv->adjustment_h)
|
||||||
{
|
{
|
||||||
self->priv->adjustment_h->page_size
|
page_size = allocation.width / scale;
|
||||||
= GTK_WIDGET (self)->allocation.width / scale;
|
gtk_adjustment_set_page_size (self->priv->adjustment_h, page_size);
|
||||||
self->priv->adjustment_h->value
|
gtk_adjustment_set_value (self->priv->adjustment_h,
|
||||||
= self->priv->x - self->priv->adjustment_h->page_size / 2;
|
self->priv->x - page_size / 2);
|
||||||
gtk_adjustment_changed (self->priv->adjustment_h);
|
gtk_adjustment_changed (self->priv->adjustment_h);
|
||||||
}
|
}
|
||||||
if (self->priv->adjustment_v)
|
if (self->priv->adjustment_v)
|
||||||
{
|
{
|
||||||
self->priv->adjustment_v->page_size
|
page_size = allocation.height / scale;
|
||||||
= GTK_WIDGET (self)->allocation.height / scale;
|
gtk_adjustment_set_page_size (self->priv->adjustment_v, page_size);
|
||||||
self->priv->adjustment_v->value
|
gtk_adjustment_set_value (self->priv->adjustment_v,
|
||||||
= self->priv->y - self->priv->adjustment_v->page_size / 2;
|
self->priv->y - page_size / 2);
|
||||||
gtk_adjustment_changed (self->priv->adjustment_v);
|
gtk_adjustment_changed (self->priv->adjustment_v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -907,22 +903,22 @@ void
|
||||||
ld_diagram_view_widget_to_diagram_coords (LdDiagramView *self,
|
ld_diagram_view_widget_to_diagram_coords (LdDiagramView *self,
|
||||||
gdouble wx, gdouble wy, gdouble *dx, gdouble *dy)
|
gdouble wx, gdouble wy, gdouble *dx, gdouble *dy)
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkAllocation allocation;
|
||||||
gdouble scale;
|
gdouble scale;
|
||||||
|
|
||||||
g_return_if_fail (LD_IS_DIAGRAM_VIEW (self));
|
g_return_if_fail (LD_IS_DIAGRAM_VIEW (self));
|
||||||
g_return_if_fail (dx != NULL);
|
g_return_if_fail (dx != NULL);
|
||||||
g_return_if_fail (dy != NULL);
|
g_return_if_fail (dy != NULL);
|
||||||
|
|
||||||
widget = GTK_WIDGET (self);
|
gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
|
||||||
scale = ld_diagram_view_get_scale_in_px (self);
|
scale = ld_diagram_view_get_scale_in_px (self);
|
||||||
|
|
||||||
/* We know diagram coordinates of the center of view, so we may
|
/* We know diagram coordinates of the center of view, so we may
|
||||||
* translate the given X and Y coordinates to this center and then scale
|
* translate the given X and Y coordinates to this center and then scale
|
||||||
* them by dividing them by the current scale.
|
* them by dividing them by the current scale.
|
||||||
*/
|
*/
|
||||||
*dx = self->priv->x + (wx - (widget->allocation.width * 0.5)) / scale;
|
*dx = self->priv->x + (wx - (allocation.width * 0.5)) / scale;
|
||||||
*dy = self->priv->y + (wy - (widget->allocation.height * 0.5)) / scale;
|
*dy = self->priv->y + (wy - (allocation.height * 0.5)) / scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -939,19 +935,19 @@ void
|
||||||
ld_diagram_view_diagram_to_widget_coords (LdDiagramView *self,
|
ld_diagram_view_diagram_to_widget_coords (LdDiagramView *self,
|
||||||
gdouble dx, gdouble dy, gdouble *wx, gdouble *wy)
|
gdouble dx, gdouble dy, gdouble *wx, gdouble *wy)
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkAllocation allocation;
|
||||||
gdouble scale;
|
gdouble scale;
|
||||||
|
|
||||||
g_return_if_fail (LD_IS_DIAGRAM_VIEW (self));
|
g_return_if_fail (LD_IS_DIAGRAM_VIEW (self));
|
||||||
g_return_if_fail (wx != NULL);
|
g_return_if_fail (wx != NULL);
|
||||||
g_return_if_fail (wy != NULL);
|
g_return_if_fail (wy != NULL);
|
||||||
|
|
||||||
widget = GTK_WIDGET (self);
|
gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
|
||||||
scale = ld_diagram_view_get_scale_in_px (self);
|
scale = ld_diagram_view_get_scale_in_px (self);
|
||||||
|
|
||||||
/* Just the reversal of ld_diagram_view_widget_to_diagram_coords(). */
|
/* Just the reversal of ld_diagram_view_widget_to_diagram_coords(). */
|
||||||
*wx = scale * (dx - self->priv->x) + 0.5 * widget->allocation.width;
|
*wx = scale * (dx - self->priv->x) + 0.5 * allocation.width;
|
||||||
*wy = scale * (dy - self->priv->y) + 0.5 * widget->allocation.height;
|
*wy = scale * (dy - self->priv->y) + 0.5 * allocation.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1770,7 +1766,8 @@ oper_move_view_begin (LdDiagramView *self, const LdPoint *point)
|
||||||
data->last_pos = *point;
|
data->last_pos = *point;
|
||||||
|
|
||||||
move_cursor = gdk_cursor_new (GDK_FLEUR);
|
move_cursor = gdk_cursor_new (GDK_FLEUR);
|
||||||
gdk_window_set_cursor (GTK_WIDGET (self)->window, move_cursor);
|
gdk_window_set_cursor
|
||||||
|
(gtk_widget_get_window (GTK_WIDGET (self)), move_cursor);
|
||||||
gdk_cursor_unref (move_cursor);
|
gdk_cursor_unref (move_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1794,7 +1791,7 @@ oper_move_view_motion (LdDiagramView *self, const LdPoint *point)
|
||||||
static void
|
static void
|
||||||
oper_move_view_end (LdDiagramView *self)
|
oper_move_view_end (LdDiagramView *self)
|
||||||
{
|
{
|
||||||
gdk_window_set_cursor (GTK_WIDGET (self)->window, NULL);
|
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2131,18 +2128,19 @@ simulate_motion (LdDiagramView *self)
|
||||||
{
|
{
|
||||||
GdkEventMotion event;
|
GdkEventMotion event;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
GdkWindow *window;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
GdkModifierType state;
|
GdkModifierType state;
|
||||||
|
|
||||||
widget = GTK_WIDGET (self);
|
widget = GTK_WIDGET (self);
|
||||||
|
window = gtk_widget_get_window (widget);
|
||||||
|
|
||||||
if (gdk_window_get_pointer (widget->window, &x, &y, &state)
|
if (gdk_window_get_pointer (window, &x, &y, &state) != window)
|
||||||
!= widget->window)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memset (&event, 0, sizeof (event));
|
memset (&event, 0, sizeof (event));
|
||||||
event.type = GDK_MOTION_NOTIFY;
|
event.type = GDK_MOTION_NOTIFY;
|
||||||
event.window = widget->window;
|
event.window = window;
|
||||||
event.x = x;
|
event.x = x;
|
||||||
event.y = y;
|
event.y = y;
|
||||||
event.state = state;
|
event.state = state;
|
||||||
|
@ -2430,7 +2428,7 @@ on_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
|
||||||
{
|
{
|
||||||
DrawData data;
|
DrawData data;
|
||||||
|
|
||||||
data.cr = gdk_cairo_create (widget->window);
|
data.cr = gdk_cairo_create (gtk_widget_get_window (widget));
|
||||||
data.self = LD_DIAGRAM_VIEW (widget);
|
data.self = LD_DIAGRAM_VIEW (widget);
|
||||||
data.scale = ld_diagram_view_get_scale_in_px (data.self);
|
data.scale = ld_diagram_view_get_scale_in_px (data.self);
|
||||||
data.exposed_rect.x = event->area.x;
|
data.exposed_rect.x = event->area.x;
|
||||||
|
|
Loading…
Reference in New Issue