mirror of https://github.com/GNOME/gimp.git
added the title pango layout to the GimpDockable struct. Made
2003-09-23 Sven Neumann <sven@gimp.org> * app/widgets/gimpdockable.[ch]: added the title pango layout to the GimpDockable struct. Made gimp_dockable_menu_position() handle RTL layout correctly. * app/display/gimpdisplayshell-callbacks.c (gimp_display_shell_origin_menu_position): handle RTL layout.
This commit is contained in:
parent
9407b3bc42
commit
a52de434be
|
@ -1,3 +1,12 @@
|
|||
2003-09-23 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gimpdockable.[ch]: added the title pango layout to
|
||||
the GimpDockable struct. Made gimp_dockable_menu_position() handle
|
||||
RTL layout correctly.
|
||||
|
||||
* app/display/gimpdisplayshell-callbacks.c
|
||||
(gimp_display_shell_origin_menu_position): handle RTL layout.
|
||||
|
||||
2003-09-23 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpchainbutton.c (gimp_chain_button_draw_lines):
|
||||
|
|
|
@ -1641,25 +1641,40 @@ gimp_display_shell_origin_menu_position (GtkMenu *menu,
|
|||
gint *y,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *origin;
|
||||
GdkScreen *screen;
|
||||
gint origin_x;
|
||||
gint origin_y;
|
||||
GtkRequisition menu_requisition;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *origin;
|
||||
GdkScreen *screen;
|
||||
gint origin_x;
|
||||
gint origin_y;
|
||||
|
||||
origin = (GtkWidget *) data;
|
||||
widget = GTK_WIDGET (menu);
|
||||
origin = GTK_WIDGET (data);
|
||||
|
||||
gdk_window_get_origin (origin->window, &origin_x, &origin_y);
|
||||
|
||||
*x = origin_x + origin->allocation.x + origin->allocation.width - 1;
|
||||
gtk_widget_size_request (widget, &menu_requisition);
|
||||
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
||||
*x = origin_x + origin->allocation.x + origin->allocation.width - 1;
|
||||
else
|
||||
*x = origin_x + origin->allocation.x - menu_requisition.width - 1;
|
||||
|
||||
*y = origin_y + origin->allocation.y + (origin->allocation.height - 1) / 2;
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
|
||||
screen = gtk_widget_get_screen (menu);
|
||||
|
||||
if (*x + GTK_WIDGET (menu)->allocation.width > gdk_screen_get_width (screen))
|
||||
*x -= (GTK_WIDGET (menu)->allocation.width + origin->allocation.width);
|
||||
if (*x + menu_requisition.width > gdk_screen_get_width (screen))
|
||||
*x -= menu_requisition.width + origin->allocation.width;
|
||||
|
||||
if (*y + GTK_WIDGET (menu)->allocation.height > gdk_screen_get_height (screen))
|
||||
*y -= (GTK_WIDGET (menu)->allocation.height);
|
||||
if (*x < 0)
|
||||
*x += menu_requisition.width + origin->allocation.width;
|
||||
|
||||
if (*y + widget->allocation.height > gdk_screen_get_height (screen))
|
||||
*y -= menu_requisition.height;
|
||||
|
||||
if (*y < 0)
|
||||
*y = 0;
|
||||
}
|
||||
|
||||
/* gimp_display_shell_compress_motion:
|
||||
|
|
|
@ -153,6 +153,8 @@ gimp_dockable_init (GimpDockable *dockable)
|
|||
dockable->get_preview_data = NULL;
|
||||
dockable->set_context_func = NULL;
|
||||
|
||||
dockable->title_layout = NULL;
|
||||
|
||||
gtk_widget_push_composite_child ();
|
||||
dockable->menu_button = gtk_button_new ();
|
||||
gtk_widget_pop_composite_child ();
|
||||
|
@ -220,6 +222,12 @@ gimp_dockable_destroy (GtkObject *object)
|
|||
dockable->help_id = NULL;
|
||||
}
|
||||
|
||||
if (dockable->title_layout)
|
||||
{
|
||||
g_object_unref (dockable->title_layout);
|
||||
dockable->title_layout = NULL;
|
||||
}
|
||||
|
||||
if (dockable->menu_button)
|
||||
{
|
||||
gtk_widget_unparent (dockable->menu_button);
|
||||
|
@ -290,12 +298,15 @@ gimp_dockable_size_allocate (GtkWidget *widget,
|
|||
{
|
||||
gtk_widget_size_request (dockable->close_button, &button_requisition);
|
||||
|
||||
child_allocation.x = (allocation->x +
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
||||
child_allocation.x = (allocation->x +
|
||||
allocation->width -
|
||||
container->border_width -
|
||||
button_requisition.width);
|
||||
child_allocation.y = (allocation->y +
|
||||
container->border_width);
|
||||
else
|
||||
child_allocation.x = allocation->x + container->border_width;
|
||||
|
||||
child_allocation.y = allocation->y + container->border_width;
|
||||
child_allocation.width = button_requisition.width;
|
||||
child_allocation.height = button_requisition.height;
|
||||
|
||||
|
@ -304,10 +315,15 @@ gimp_dockable_size_allocate (GtkWidget *widget,
|
|||
|
||||
if (dockable->menu_button)
|
||||
{
|
||||
child_allocation.x = (allocation->x +
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
||||
child_allocation.x = (allocation->x +
|
||||
allocation->width -
|
||||
container->border_width -
|
||||
2 * button_requisition.width);
|
||||
else
|
||||
child_allocation.x = (allocation->x + container->border_width +
|
||||
button_requisition.width);
|
||||
|
||||
child_allocation.y = allocation->y + container->border_width;
|
||||
child_allocation.width = button_requisition.width;
|
||||
child_allocation.height = button_requisition.height;
|
||||
|
@ -337,7 +353,8 @@ static void
|
|||
gimp_dockable_style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style)
|
||||
{
|
||||
gint content_border;
|
||||
GimpDockable *dockable;
|
||||
gint content_border;
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"content_border", &content_border,
|
||||
|
@ -345,6 +362,14 @@ gimp_dockable_style_set (GtkWidget *widget,
|
|||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (widget), content_border);
|
||||
|
||||
dockable = GIMP_DOCKABLE (widget);
|
||||
|
||||
if (dockable->title_layout)
|
||||
{
|
||||
g_object_unref (dockable->title_layout);
|
||||
dockable->title_layout = NULL;
|
||||
}
|
||||
|
||||
if (GTK_WIDGET_CLASS (parent_class)->style_set)
|
||||
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
|
||||
}
|
||||
|
@ -365,21 +390,30 @@ gimp_dockable_expose_event (GtkWidget *widget,
|
|||
|
||||
title_area.x = widget->allocation.x + container->border_width;
|
||||
title_area.y = widget->allocation.y + container->border_width;
|
||||
|
||||
title_area.width = (widget->allocation.width -
|
||||
2 * container->border_width -
|
||||
2 * dockable->close_button->allocation.width);
|
||||
title_area.height = dockable->close_button->allocation.height;
|
||||
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
||||
title_area.x += 2 * dockable->close_button->allocation.width;
|
||||
|
||||
if (gdk_rectangle_intersect (&title_area, &event->area, &expose_area))
|
||||
{
|
||||
PangoLayout *layout;
|
||||
gint layout_width;
|
||||
gint layout_height;
|
||||
gint text_x;
|
||||
gint text_y;
|
||||
gint layout_width;
|
||||
gint layout_height;
|
||||
gint text_x;
|
||||
gint text_y;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, dockable->blurb);
|
||||
pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
|
||||
if (!dockable->title_layout)
|
||||
{
|
||||
dockable->title_layout =
|
||||
gtk_widget_create_pango_layout (widget, dockable->blurb);
|
||||
}
|
||||
|
||||
pango_layout_get_pixel_size (dockable->title_layout,
|
||||
&layout_width, &layout_height);
|
||||
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
||||
{
|
||||
|
@ -395,9 +429,7 @@ gimp_dockable_expose_event (GtkWidget *widget,
|
|||
gtk_paint_layout (widget->style, widget->window,
|
||||
widget->state, TRUE,
|
||||
&expose_area, widget, NULL,
|
||||
text_x, text_y, layout);
|
||||
|
||||
g_object_unref (layout);
|
||||
text_x, text_y, dockable->title_layout);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,20 +690,24 @@ gimp_dockable_menu_position (GtkMenu *menu,
|
|||
gtk_widget_size_request (GIMP_DOCKABLE (dockable)->close_button,
|
||||
&button_requisition);
|
||||
|
||||
*x += (dockable->allocation.x + dockable->allocation.width -
|
||||
container->border_width -
|
||||
2 * button_requisition.width -
|
||||
menu_requisition.width);
|
||||
if (gtk_widget_get_direction (GTK_WIDGET (menu)) == GTK_TEXT_DIR_LTR)
|
||||
*x += (dockable->allocation.x + dockable->allocation.width -
|
||||
container->border_width - 2 * button_requisition.width -
|
||||
menu_requisition.width);
|
||||
else
|
||||
*x += (dockable->allocation.x + container->border_width +
|
||||
2 * button_requisition.width);
|
||||
|
||||
*y += (dockable->allocation.y + container->border_width +
|
||||
button_requisition.height / 2);
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
|
||||
|
||||
if (*x + menu_requisition.width > gdk_screen_get_width (screen))
|
||||
*x -= menu_requisition.width;
|
||||
*x -= menu_requisition.width + button_requisition.width;
|
||||
|
||||
if (*x < 0)
|
||||
*x = 0;
|
||||
*x += menu_requisition.width + button_requisition.width;
|
||||
|
||||
if (*y + menu_requisition.height > gdk_screen_get_height (screen))
|
||||
*y -= menu_requisition.height;
|
||||
|
|
|
@ -60,6 +60,7 @@ struct _GimpDockable
|
|||
|
||||
GimpContext *context;
|
||||
|
||||
PangoLayout *title_layout;
|
||||
GtkWidget *menu_button;
|
||||
GtkWidget *close_button;
|
||||
|
||||
|
|
Loading…
Reference in New Issue