[gimp/gtk3-port: 130/130] hacks on top, to be redone
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 130/130] hacks on top, to be redone
- Date: Fri, 19 Nov 2010 11:29:31 +0000 (UTC)
commit 886a9a66d27c55fe919dd0d6f6a67b7ffdf488c9
Author: Michael Natterer <mitch gimp org>
Date: Sun Nov 14 22:55:02 2010 +0100
hacks on top, to be redone
app/display/gimpstatusbar.c | 53 +++++++-----
app/widgets/gimpdockbook.c | 6 +-
app/widgets/gimpspinscale.c | 209 ++++++++++++++++++++++++++++++-------------
app/widgets/gimptoolbox.c | 19 ++++
plug-ins/Makefile.am | 12 ++--
plug-ins/common/Makefile.am | 12 ++--
6 files changed, 213 insertions(+), 98 deletions(-)
---
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index e27a920..1af76c0 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -73,8 +73,8 @@ static void gimp_statusbar_progress_iface_init (GimpProgressInterface *iface
static void gimp_statusbar_dispose (GObject *object);
static void gimp_statusbar_finalize (GObject *object);
-static void gimp_statusbar_hbox_size_request (GtkWidget *widget,
- GtkRequisition *requisition,
+static void gimp_statusbar_hbox_style_set (GtkWidget *widget,
+ GtkStyle *prev_style,
GimpStatusbar *statusbar);
static GimpProgress *
@@ -186,9 +186,9 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
gtk_container_remove (GTK_CONTAINER (hbox), statusbar->label);
- g_signal_connect (hbox, "size-request",
- G_CALLBACK (gimp_statusbar_hbox_size_request),
- statusbar);
+ g_signal_connect_after (hbox, "style-set",
+ G_CALLBACK (gimp_statusbar_hbox_style_set),
+ statusbar);
statusbar->cursor_label = gtk_label_new ("8888, 8888");
gtk_misc_set_alignment (GTK_MISC (statusbar->cursor_label), 0.5, 0.5);
@@ -232,8 +232,10 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
statusbar);
statusbar->progressbar = g_object_new (GTK_TYPE_PROGRESS_BAR,
+#if 0
"text-xalign", 0.0,
"text-yalign", 0.5,
+#endif
"ellipsize", PANGO_ELLIPSIZE_END,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), statusbar->progressbar, TRUE, TRUE, 0);
@@ -296,44 +298,47 @@ gimp_statusbar_finalize (GObject *object)
}
static void
-gimp_statusbar_hbox_size_request (GtkWidget *widget,
- GtkRequisition *requisition,
- GimpStatusbar *statusbar)
+gimp_statusbar_hbox_style_set (GtkWidget *widget,
+ GtkStyle *prev_style,
+ GimpStatusbar *statusbar)
{
- GtkRequisition child_requisition;
- gint width = 0;
+ GtkRequisition requisition;
+ GtkRequisition child_requisition;
+ gint width = 0;
+ gint height;
+
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
+
+ height = requisition.height;
/* also consider the children which can be invisible */
gtk_widget_get_preferred_size (statusbar->cursor_label,
&child_requisition, NULL);
width += child_requisition.width;
- requisition->height = MAX (requisition->height,
- child_requisition.height);
+ height = MAX (height, child_requisition.height);
gtk_widget_get_preferred_size (statusbar->unit_combo,
&child_requisition, NULL);
width += child_requisition.width;
- requisition->height = MAX (requisition->height,
- child_requisition.height);
+ height = MAX (height, child_requisition.height);
gtk_widget_get_preferred_size (statusbar->scale_combo,
&child_requisition, NULL);
width += child_requisition.width;
- requisition->height = MAX (requisition->height,
- child_requisition.height);
+ height = MAX (height, child_requisition.height);
gtk_widget_get_preferred_size (statusbar->progressbar,
&child_requisition, NULL);
- requisition->height = MAX (requisition->height,
- child_requisition.height);
+ height = MAX (height, child_requisition.height);
gtk_widget_get_preferred_size (statusbar->cancel_button,
&child_requisition, NULL);
- requisition->height = MAX (requisition->height,
- child_requisition.height);
+ height = MAX (height, child_requisition.height);
- requisition->width = MAX (requisition->width, width + 32);
+ width = MAX (requisition.width, width + 32);
+
+ gtk_widget_set_size_request (widget, width, height);
}
static GimpProgress *
@@ -609,6 +614,7 @@ gimp_statusbar_set_text (GimpStatusbar *statusbar,
ICON_SPACING);
rect.height = 0;
+
attrs = pango_attr_list_new ();
attr = pango_attr_shape_new (&rect, &rect);
@@ -1327,10 +1333,15 @@ gimp_statusbar_label_draw (GtkWidget *widget,
if (statusbar->icon)
{
PangoRectangle rect;
+ GtkAllocation allocation;
gint x, y;
gtk_label_get_layout_offsets (GTK_LABEL (widget), &x, &y);
+ gtk_widget_get_allocation (widget, &allocation);
+ x -= allocation.x;
+ y -= allocation.y;
+
pango_layout_index_to_pos (gtk_label_get_layout (GTK_LABEL (widget)), 0,
&rect);
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index 8f1c397..494697c 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -366,9 +366,11 @@ gimp_dockbook_style_set (GtkWidget *widget,
"tab-border", &tab_border,
NULL);
+#if 0
g_object_set (widget,
"tab-border", tab_border,
NULL);
+#endif
gimp_dockbook_recreate_tab_widgets (GIMP_DOCKBOOK (widget),
FALSE /*only_auto*/);
@@ -780,7 +782,7 @@ gimp_dockbook_update_automatic_tab_style (GimpDockbook *dockbook)
GimpTabStyle tab_style = 0;
int i = 0;
gint available_space = 0;
- guint tab_hborder = 0;
+ guint tab_hborder = 2;
gint xthickness = 0;
gint tab_curvature = 0;
gint focus_width = 0;
@@ -790,9 +792,11 @@ gimp_dockbook_update_automatic_tab_style (GimpDockbook *dockbook)
gint action_widget_size = 0;
xthickness = gtk_widget_get_style (widget)->xthickness;
+#if 0
g_object_get (widget,
"tab-hborder", &tab_hborder,
NULL);
+#endif
gtk_widget_style_get (widget,
"tab-curvature", &tab_curvature,
"focus-line-width", &focus_width,
diff --git a/app/widgets/gimpspinscale.c b/app/widgets/gimpspinscale.c
index a36b15c..20813d5 100644
--- a/app/widgets/gimpspinscale.c
+++ b/app/widgets/gimpspinscale.c
@@ -64,8 +64,8 @@ static void gimp_spin_scale_get_property (GObject *object,
static void gimp_spin_scale_style_set (GtkWidget *widget,
GtkStyle *prev_style);
-static gboolean gimp_spin_scale_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gimp_spin_scale_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean gimp_spin_scale_button_press (GtkWidget *widget,
GdkEventButton *event);
static gboolean gimp_spin_scale_button_release (GtkWidget *widget,
@@ -94,7 +94,7 @@ gimp_spin_scale_class_init (GimpSpinScaleClass *klass)
object_class->get_property = gimp_spin_scale_get_property;
widget_class->style_set = gimp_spin_scale_style_set;
- widget_class->expose_event = gimp_spin_scale_expose;
+ widget_class->draw = gimp_spin_scale_draw;
widget_class->button_press_event = gimp_spin_scale_button_press;
widget_class->button_release_event = gimp_spin_scale_button_release;
widget_class->motion_notify_event = gimp_spin_scale_button_motion;
@@ -208,59 +208,47 @@ gimp_spin_scale_style_set (GtkWidget *widget,
}
static gboolean
-gimp_spin_scale_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gimp_spin_scale_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GimpSpinScalePrivate *private = GET_PRIVATE (widget);
GtkStyle *style = gtk_widget_get_style (widget);
- cairo_t *cr;
- gint w, h;
+ GtkAllocation allocation;
- GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
+ cairo_save (cr);
+ GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+ cairo_restore (cr);
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
- gdk_drawable_get_size (event->window, &w, &h);
+ gtk_widget_get_allocation (widget, &allocation);
cairo_set_line_width (cr, 1.0);
- if (event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
- {
- /* let right line of rectangle disappear */
- cairo_rectangle (cr, 0.5, 0.5, w, h - 1.0);
- gdk_cairo_set_source_color (cr,
- &style->text[gtk_widget_get_state (widget)]);
- cairo_stroke (cr);
- }
- else
- {
- /* let left line of rectangle disappear */
- cairo_rectangle (cr, -0.5, 0.5, w, h - 1.0);
- gdk_cairo_set_source_color (cr,
- &style->text[gtk_widget_get_state (widget)]);
- cairo_stroke (cr);
-
- cairo_rectangle (cr, 0.5, 1.5, w - 2.0, h - 3.0);
- gdk_cairo_set_source_color (cr,
- &style->base[gtk_widget_get_state (widget)]);
- cairo_stroke (cr);
- }
-
- cairo_destroy (cr);
+ cairo_rectangle (cr, 0.5, 0.5,
+ allocation.width - 1.0, allocation.height - 1.0);
+ gdk_cairo_set_source_color (cr,
+ &style->text[gtk_widget_get_state (widget)]);
+ cairo_stroke (cr);
+
+#if 0
+ {
+ /* let left line of rectangle disappear */
+ cairo_rectangle (cr, -0.5, 0.5, w, h - 1.0);
+ gdk_cairo_set_source_color (cr,
+ &style->text[gtk_widget_get_state (widget)]);
+ cairo_stroke (cr);
+
+ cairo_rectangle (cr, 0.5, 1.5, w - 2.0, h - 3.0);
+ gdk_cairo_set_source_color (cr,
+ &style->base[gtk_widget_get_state (widget)]);
+ cairo_stroke (cr);
+ }
+#endif
- if (private->label &&
- gtk_widget_is_drawable (widget) &&
- event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
+ if (private->label)
{
PangoLayout *layout;
const GtkBorder *border;
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
border = gtk_entry_get_inner_border (GTK_ENTRY (widget));
if (border)
@@ -270,7 +258,6 @@ gimp_spin_scale_expose (GtkWidget *widget,
layout = gtk_widget_create_pango_layout (widget, private->label);
pango_cairo_show_layout (cr, layout);
- cairo_destroy (cr);
g_object_unref (layout);
}
@@ -278,10 +265,92 @@ gimp_spin_scale_expose (GtkWidget *widget,
return FALSE;
}
+/* Returns TRUE if a translation should be done */
+static gboolean
+gtk_widget_get_translation_to_window (GtkWidget *widget,
+ GdkWindow *window,
+ int *x,
+ int *y)
+{
+ GdkWindow *w, *widget_window;
+
+ if (!gtk_widget_get_has_window (widget))
+ {
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ *x = -allocation.x;
+ *y = -allocation.y;
+ }
+ else
+ {
+ *x = 0;
+ *y = 0;
+ }
+
+ widget_window = gtk_widget_get_window (widget);
+
+ for (w = window; w && w != widget_window; w = gdk_window_get_parent (w))
+ {
+ int wx, wy;
+ gdk_window_get_position (w, &wx, &wy);
+ *x += wx;
+ *y += wy;
+ }
+
+ if (w == NULL)
+ {
+ *x = 0;
+ *y = 0;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+gimp_spin_scale_event_to_widget_coords (GtkWidget *widget,
+ GdkWindow *window,
+ gdouble event_x,
+ gdouble event_y,
+ gint *widget_x,
+ gint *widget_y)
+{
+ gint tx, ty;
+
+ if (gtk_widget_get_translation_to_window (widget, window, &tx, &ty))
+ {
+ event_x += tx;
+ event_y += ty;
+ }
+
+ *widget_x = event_x;
+ *widget_y = event_y;
+}
+
+static gboolean
+gimp_spin_scale_in_text_area (GtkWidget *widget,
+ gint x,
+ gint y)
+{
+ GdkRectangle area;
+
+ gtk_entry_get_text_area (GTK_ENTRY (widget), &area);
+
+ if (x >= area.x && x < area.width &&
+ y >= area.y && y < area.height)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static gboolean
gimp_spin_scale_on_number (GtkWidget *widget,
- gdouble x,
- gdouble y)
+ gint x,
+ gint y)
{
gint layout_x;
gint layout_y;
@@ -294,22 +363,21 @@ gimp_spin_scale_on_number (GtkWidget *widget,
}
return FALSE;
- }
+}
static void
gimp_spin_scale_set_value (GtkWidget *widget,
- gdouble x)
+ gint x)
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
- GdkWindow *text_window = gtk_entry_get_text_window (GTK_ENTRY (widget));
- gint width;
+ GdkRectangle area;
gdouble fraction;
gdouble value;
- gdk_drawable_get_size (text_window, &width, NULL);
+ gtk_entry_get_text_area (GTK_ENTRY (widget), &area);
- fraction = x / (gdouble) width;
+ fraction = ((gdouble) x - (gdouble) area.x) / (gdouble) area.width;
value = (fraction * (gtk_adjustment_get_upper (adjustment) -
gtk_adjustment_get_lower (adjustment)) +
@@ -323,21 +391,24 @@ gimp_spin_scale_button_press (GtkWidget *widget,
GdkEventButton *event)
{
GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+ gint x, y;
private->changing_value = FALSE;
- if (event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
+ gimp_spin_scale_event_to_widget_coords (widget, event->window,
+ event->x, event->y,
+ &x, &y);
+
+ if (gimp_spin_scale_in_text_area (widget, x, y) &&
+ ! gimp_spin_scale_on_number (widget, x, y))
{
- if (! gimp_spin_scale_on_number (widget, event->x, event->y))
- {
- private->changing_value = TRUE;
+ private->changing_value = TRUE;
- gtk_widget_grab_focus (widget);
+ gtk_widget_grab_focus (widget);
- gimp_spin_scale_set_value (widget, event->x);
+ gimp_spin_scale_set_value (widget, x);
- return TRUE;
- }
+ return TRUE;
}
return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
@@ -348,12 +419,17 @@ gimp_spin_scale_button_release (GtkWidget *widget,
GdkEventButton *event)
{
GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+ gint x, y;
+
+ gimp_spin_scale_event_to_widget_coords (widget, event->window,
+ event->x, event->y,
+ &x, &y);
if (private->changing_value)
{
private->changing_value = FALSE;
- gimp_spin_scale_set_value (widget, event->x);
+ gimp_spin_scale_set_value (widget, x);
return TRUE;
}
@@ -366,10 +442,15 @@ gimp_spin_scale_button_motion (GtkWidget *widget,
GdkEventMotion *event)
{
GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+ gint x, y;
+
+ gimp_spin_scale_event_to_widget_coords (widget, event->window,
+ event->x, event->y,
+ &x, &y);
if (private->changing_value)
{
- gimp_spin_scale_set_value (widget, event->x);
+ gimp_spin_scale_set_value (widget, x);
return TRUE;
}
@@ -378,9 +459,9 @@ gimp_spin_scale_button_motion (GtkWidget *widget,
if (! (event->state &
(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
- event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
+ gimp_spin_scale_in_text_area (widget, x, y))
{
- if (gimp_spin_scale_on_number (widget, event->x, event->y))
+ if (gimp_spin_scale_on_number (widget, x, y))
{
GdkDisplay *display = gtk_widget_get_display (widget);
GdkCursor *cursor;
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index 613ef35..036ee4c 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -327,6 +327,7 @@ gimp_toolbox_constructor (GType type,
TRUE, TRUE, 0);
gtk_widget_show (toolbox->p->tool_palette);
+#if 0
toolbox->p->area_wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (toolbox->p->area_wbox), GTK_JUSTIFY_TOP);
gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (toolbox->p->area_wbox),
@@ -337,6 +338,7 @@ gimp_toolbox_constructor (GType type,
gtk_box_pack_start (GTK_BOX (toolbox->p->vbox), toolbox->p->area_wbox,
FALSE, FALSE, 0);
gtk_widget_show (toolbox->p->area_wbox);
+#endif
/* We need to know when the current device changes, so we can update
* the correct tool - to do this we connect to motion events.
@@ -370,9 +372,14 @@ gimp_toolbox_constructor (GType type,
toolbox_create_tools (toolbox, toolbox->p->context);
toolbox->p->color_area = toolbox_create_color_area (toolbox, toolbox->p->context);
+#if 0
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (toolbox->p->area_wbox),
toolbox->p->color_area,
TRUE, TRUE, FALSE, TRUE, TRUE);
+#else
+ gtk_box_pack_start (GTK_BOX (toolbox->p->vbox), toolbox->p->color_area,
+ FALSE, FALSE, 0);
+#endif
if (config->toolbox_color_area)
gtk_widget_show (toolbox->p->color_area);
@@ -381,8 +388,13 @@ gimp_toolbox_constructor (GType type,
toolbox->p->color_area, 0);
toolbox->p->foo_area = toolbox_create_foo_area (toolbox, toolbox->p->context);
+#if 0
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->p->area_wbox), toolbox->p->foo_area,
TRUE, TRUE, FALSE, TRUE);
+#else
+ gtk_box_pack_start (GTK_BOX (toolbox->p->vbox), toolbox->p->foo_area,
+ FALSE, FALSE, 0);
+#endif
if (config->toolbox_foo_area)
gtk_widget_show (toolbox->p->foo_area);
@@ -391,8 +403,13 @@ gimp_toolbox_constructor (GType type,
toolbox->p->foo_area, 0);
toolbox->p->image_area = toolbox_create_image_area (toolbox, toolbox->p->context);
+#if 0
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->p->area_wbox), toolbox->p->image_area,
TRUE, TRUE, FALSE, TRUE);
+#else
+ gtk_box_pack_start (GTK_BOX (toolbox->p->vbox), toolbox->p->image_area,
+ FALSE, FALSE, 0);
+#endif
if (config->toolbox_image_area)
gtk_widget_show (toolbox->p->image_area);
@@ -559,6 +576,7 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
}
}
+#if 0
{
GtkRequisition color_requisition;
GtkRequisition foo_requisition;
@@ -603,6 +621,7 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
area_rows * height);
}
}
+#endif
}
static void
diff --git a/plug-ins/Makefile.am b/plug-ins/Makefile.am
index 9f256ca..eedf3a5 100644
--- a/plug-ins/Makefile.am
+++ b/plug-ins/Makefile.am
@@ -54,7 +54,7 @@ endif
SUBDIRS = \
$(script_fu) \
- $(pygimp) \
+## $(pygimp) \
color-rotate \
file-bmp \
file-faxg3 \
@@ -68,15 +68,15 @@ SUBDIRS = \
$(file_xjt) \
flame \
fractal-explorer \
- gfig \
- gimpressionist \
+## gfig \
+## gimpressionist \
gradient-flare \
help \
$(help_browser) \
- ifs-compose \
- imagemap \
+## ifs-compose \
+## imagemap \
lighting \
- map-object \
+## map-object \
maze \
$(metadata) \
pagecurl \
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index bb8d0d2..975c5a3 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -46,7 +46,7 @@ libexec_PROGRAMS = \
alien-map \
align-layers \
animation-optimize \
- animation-play \
+## animation-play \
antialias \
apply-canvas \
blinds \
@@ -75,7 +75,7 @@ libexec_PROGRAMS = \
crop-auto \
crop-zealous \
cubism \
- curve-bend \
+## curve-bend \
decompose \
deinterlace \
depth-merge \
@@ -99,7 +99,7 @@ libexec_PROGRAMS = \
file-gbr \
file-gif-load \
file-gif-save \
- file-gih \
+## file-gih \
file-glob \
file-header \
file-html-table \
@@ -112,7 +112,7 @@ libexec_PROGRAMS = \
file-pix \
$(FILE_PNG) \
file-pnm \
- file-ps \
+## file-ps \
$(FILE_PSP) \
file-raw \
file-sunras \
@@ -126,7 +126,7 @@ libexec_PROGRAMS = \
$(FILE_XPM) \
file-xwd \
film \
- filter-pack \
+## filter-pack \
fractal-trace \
gradient-map \
grid \
@@ -162,7 +162,7 @@ libexec_PROGRAMS = \
ripple \
rotate \
sample-colorize \
- $(SCREENSHOT) \
+## $(SCREENSHOT) \
semi-flatten \
sharpen \
shift \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]