summaryrefslogtreecommitdiff
path: root/eel/eel-gtk-extensions.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-11-16 05:08:48 -0800
committerStefano Karapetsas <[email protected]>2012-11-16 05:08:48 -0800
commitdc66bc40724191f0068869773576dc4edf042c6f (patch)
tree74b9684feea188736b21f2c829f29befaaf2e9da /eel/eel-gtk-extensions.c
parent935e1fed604f48e68d125d205c890a59f46f8f21 (diff)
parent1466df20591105550738a1d0784a623af9909abf (diff)
downloadcaja-dc66bc40724191f0068869773576dc4edf042c6f.tar.bz2
caja-dc66bc40724191f0068869773576dc4edf042c6f.tar.xz
Merge pull request #42 from jasmineaura/develop
Bring Caja up to speed, stage1
Diffstat (limited to 'eel/eel-gtk-extensions.c')
-rw-r--r--eel/eel-gtk-extensions.c792
1 files changed, 17 insertions, 775 deletions
diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c
index 94c4987d..5b8121b6 100644
--- a/eel/eel-gtk-extensions.c
+++ b/eel/eel-gtk-extensions.c
@@ -32,17 +32,17 @@
#include "eel-gdk-pixbuf-extensions.h"
#include "eel-glib-extensions.h"
#include "eel-mate-extensions.h"
-#include "eel-pango-extensions.h"
+#include "eel-marshal.h"
#include "eel-string.h"
+
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
+#include <glib/gi18n-lib.h>
#include <math.h>
-#include "eel-marshal.h"
-#include "eel-marshal.c"
/* This number is fairly arbitrary. Long enough to show a pretty long
* menu title, but not so long to make a menu grotesquely wide.
@@ -84,103 +84,6 @@ eel_gtk_window_get_geometry_string (GtkWindow *window)
}
static void
-send_delete_event (GtkWindow *window)
-{
- /* Synthesize delete_event to close window. */
-
- GdkEvent event;
- GtkWidget *widget;
-
- widget = GTK_WIDGET (window);
-
- event.any.type = GDK_DELETE;
- event.any.window = gtk_widget_get_window (widget);
- event.any.send_event = TRUE;
-
- g_object_ref (event.any.window);
- gtk_main_do_event (&event);
- g_object_unref (event.any.window);
-}
-
-static int
-handle_standard_close_accelerator (GtkWindow *window,
- GdkEventKey *event,
- gpointer user_data)
-{
- g_assert (GTK_IS_WINDOW (window));
- g_assert (event != NULL);
- g_assert (user_data == NULL);
-
- if (eel_gtk_window_event_is_close_accelerator (window, event))
- {
- send_delete_event (window);
- g_signal_stop_emission_by_name (
- G_OBJECT (window), "key_press_event");
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- * eel_gtk_window_event_is_close_accelerator:
- *
- * Tests whether a key event is a standard window close accelerator.
- * Not needed for clients that use eel_gtk_window_set_up_close_accelerator;
- * use only if you must set up your own key_event handler for your own reasons.
- **/
-gboolean
-eel_gtk_window_event_is_close_accelerator (GtkWindow *window, GdkEventKey *event)
-{
- g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (event->state & GDK_CONTROL_MASK)
- {
- /* Note: menu item equivalents are case-sensitive, so we will
- * be case-sensitive here too.
- */
- if (event->keyval == EEL_STANDARD_CLOSE_WINDOW_CONTROL_KEY)
- {
- return TRUE;
- }
- }
-
-
- return FALSE;
-}
-
-/**
- * eel_gtk_window_set_up_close_accelerator:
- *
- * Sets up the standard keyboard equivalent to close the window.
- * Call this for windows that don't set up a keyboard equivalent to
- * close the window some other way, e.g. via a menu item accelerator.
- *
- * NOTE: do not use for GtkDialog, it already sets up the right
- * stuff here.
- *
- * @window: The GtkWindow that should be hidden when the standard
- * keyboard equivalent is typed.
- **/
-void
-eel_gtk_window_set_up_close_accelerator (GtkWindow *window)
-{
- g_return_if_fail (GTK_IS_WINDOW (window));
-
- if (GTK_IS_DIALOG (window))
- {
- g_warning ("eel_gtk_window_set_up_close_accelerator: Should not mess with close accelerator on GtkDialogs");
- return;
- }
-
- g_signal_connect (window,
- "key_press_event",
- G_CALLBACK (handle_standard_close_accelerator),
- NULL);
-}
-
-static void
sanity_check_window_position (int *left, int *top)
{
g_assert (left != NULL);
@@ -430,30 +333,6 @@ eel_gtk_menu_insert_separator (GtkMenu *menu, int index)
return GTK_MENU_ITEM (menu_item);
}
-void
-eel_gtk_menu_set_item_visibility (GtkMenu *menu, int index, gboolean visible)
-{
- GList *children;
- GtkWidget *menu_item;
-
- g_return_if_fail (GTK_IS_MENU (menu));
-
- children = gtk_container_get_children (GTK_CONTAINER (menu));
- g_return_if_fail (index >= 0 && index < (int) g_list_length (children));
-
- menu_item = GTK_WIDGET (g_list_nth_data (children, index));
- if (visible)
- {
- gtk_widget_show (menu_item);
- }
- else
- {
- gtk_widget_hide (menu_item);
- }
-
- g_list_free (children);
-}
-
GtkWidget *
eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button)
{
@@ -474,296 +353,6 @@ eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button)
return button;
}
-gboolean
-eel_point_in_allocation (const GtkAllocation *allocation,
- int x, int y)
-{
- g_return_val_if_fail (allocation != NULL, FALSE);
- return x >= allocation->x
- && y >= allocation->y
- && x < allocation->x + allocation->width
- && y < allocation->y + allocation->height;
-}
-
-/* FIXME this function is dangerous, because gtk_widget_get_window (widget) coords (or
- * other window-belonging-to-widget coords) do not need to be in the
- * same coordinate system as widget->allocation.
- * If you use this function, be aware of that. Someone should probably
- * audit all uses, too.
- */
-gboolean
-eel_point_in_widget (GtkWidget *widget,
- int x, int y)
-{
- GtkAllocation allocation;
- if (widget == NULL)
- {
- return FALSE;
- }
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- gtk_widget_get_allocation (widget, &allocation);
- return eel_point_in_allocation (&allocation, x, y);
-}
-
-/**
- * eel_gtk_widget_set_shown
- *
- * Show or hide a widget.
- * @widget: The widget.
- * @shown: Boolean value indicating whether the widget should be shown or hidden.
- **/
-void
-eel_gtk_widget_set_shown (GtkWidget *widget, gboolean shown)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (shown)
- {
- gtk_widget_show (widget);
- }
- else
- {
- gtk_widget_hide (widget);
- }
-}
-
-/* This stuff is stolen from Gtk. */
-
-typedef struct DisconnectInfo
-{
- GtkObject *object1;
- guint disconnect_handler1;
- guint signal_handler;
- GtkObject *object2;
- guint disconnect_handler2;
-} DisconnectInfo;
-
-static void
-alive_disconnecter (GtkObject *object, DisconnectInfo *info)
-{
- g_assert (info != NULL);
- g_assert (GTK_IS_OBJECT (info->object1));
- g_assert (info->disconnect_handler1 != 0);
- g_assert (info->signal_handler != 0);
- g_assert (GTK_IS_OBJECT (info->object2));
- g_assert (info->disconnect_handler2 != 0);
- g_assert (object == info->object1 || object == info->object2);
-
- g_signal_handler_disconnect (info->object1, info->disconnect_handler1);
- g_signal_handler_disconnect (info->object1, info->signal_handler);
- g_signal_handler_disconnect (info->object2, info->disconnect_handler2);
-
- g_free (info);
-}
-
-/**
- * eel_gtk_signal_connect_full_while_alive
- *
- * Like gtk_signal_connect_while_alive, but works with full parameters.
- **/
-void
-eel_gtk_signal_connect_full_while_alive (GtkObject *object,
- const gchar *name,
- GCallback func,
- GtkCallbackMarshal marshal,
- gpointer data,
- GDestroyNotify destroy_func,
- gboolean object_signal,
- gboolean after,
- GtkObject *alive_object)
-{
- DisconnectInfo *info;
-
- g_return_if_fail (GTK_IS_OBJECT (object));
- g_return_if_fail (name != NULL);
- g_return_if_fail (func != NULL || marshal != NULL);
- g_return_if_fail (object_signal == FALSE || object_signal == TRUE);
- g_return_if_fail (after == FALSE || after == TRUE);
- g_return_if_fail (GTK_IS_OBJECT (alive_object));
-
- info = g_new (DisconnectInfo, 1);
- info->object1 = object;
- info->object2 = alive_object;
-
-
- info->signal_handler = g_signal_connect_closure (
- object, name,
- (object_signal
- ? g_cclosure_new_swap
- : g_cclosure_new) (func, data, (GClosureNotify) destroy_func),
- after);
-
- info->disconnect_handler1 = g_signal_connect (G_OBJECT (object),
- "destroy",
- G_CALLBACK (alive_disconnecter),
- info);
- info->disconnect_handler2 = g_signal_connect (G_OBJECT (alive_object),
- "destroy",
- G_CALLBACK (alive_disconnecter),
- info);
-}
-
-typedef struct
-{
- GtkObject *object;
- guint object_destroy_handler;
-
- GtkWidget *realized_widget;
- guint realized_widget_destroy_handler;
- guint realized_widget_unrealized_handler;
-
- guint signal_handler;
-} RealizeDisconnectInfo;
-
-static void
-while_realized_disconnecter (GtkObject *object,
- RealizeDisconnectInfo *info)
-{
- g_assert (GTK_IS_OBJECT (object));
- g_assert (info != NULL);
- g_assert (GTK_IS_OBJECT (info->object));
- g_assert (info->object_destroy_handler != 0);
- g_assert (info->object_destroy_handler != 0);
- g_assert (info->realized_widget_destroy_handler != 0);
- g_assert (info->realized_widget_unrealized_handler != 0);
-
- g_signal_handler_disconnect (info->object, info->object_destroy_handler);
- g_signal_handler_disconnect (info->object, info->signal_handler);
- g_signal_handler_disconnect (info->realized_widget, info->realized_widget_destroy_handler);
- g_signal_handler_disconnect (info->realized_widget, info->realized_widget_unrealized_handler);
- g_free (info);
-}
-
-/**
- * eel_gtk_signal_connect_while_realized:
- *
- * @object: Object to connect to.
- * @name: Name of signal to connect to.
- * @callback: Caller's callback.
- * @callback_data: Caller's callback_data.
- * @realized_widget: Widget to monitor for realized state. Signal is connected
- * while this wigget is realized.
- *
- * Connect to a signal of an object while another widget is realized. This is
- * useful for non windowed widgets that need to monitor events in their ancestored
- * windowed widget. The signal is automatically disconnected when &widget is
- * unrealized. Also, the signal is automatically disconnected when either &object
- * or &widget are destroyed.
- **/
-void
-eel_gtk_signal_connect_while_realized (GtkObject *object,
- const char *name,
- GCallback callback,
- gpointer callback_data,
- GtkWidget *realized_widget)
-{
- RealizeDisconnectInfo *info;
-
- g_return_if_fail (GTK_IS_OBJECT (object));
- g_return_if_fail (name != NULL);
- g_return_if_fail (name[0] != '\0');
- g_return_if_fail (callback != NULL);
- g_return_if_fail (GTK_IS_WIDGET (realized_widget));
- g_return_if_fail (gtk_widget_get_realized (realized_widget));
-
- info = g_new0 (RealizeDisconnectInfo, 1);
-
- info->object = object;
- info->object_destroy_handler =
- g_signal_connect (G_OBJECT (info->object),
- "destroy",
- G_CALLBACK (while_realized_disconnecter),
- info);
-
- info->realized_widget = realized_widget;
- info->realized_widget_destroy_handler =
- g_signal_connect (G_OBJECT (info->realized_widget),
- "destroy",
- G_CALLBACK (while_realized_disconnecter),
- info);
- info->realized_widget_unrealized_handler =
- g_signal_connect_after (G_OBJECT (info->realized_widget),
- "unrealize",
- G_CALLBACK (while_realized_disconnecter),
- info);
-
- info->signal_handler = g_signal_connect (G_OBJECT (info->object),
- name, callback, callback_data);
-}
-
-/**
- * eel_gtk_container_get_first_child.
- *
- * Returns the first child of a container.
- * @container: The container.
- **/
-
-static void
-get_first_callback (GtkWidget *widget, gpointer callback_data)
-{
- GtkWidget **first_child_slot;
-
- g_assert (GTK_IS_WIDGET (widget));
- g_assert (callback_data != NULL);
-
- first_child_slot = callback_data;
-
- if (*first_child_slot == NULL)
- {
- *first_child_slot = widget;
- /* We'd stop the iterating now if we could. */
- }
- else
- {
- g_assert (GTK_IS_WIDGET (*first_child_slot));
- }
-}
-
-GtkWidget *
-eel_gtk_container_get_first_child (GtkContainer *container)
-{
- GtkWidget *first_child;
-
- g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
-
- first_child = NULL;
- gtk_container_foreach (container, get_first_callback, &first_child);
- g_assert (first_child == NULL || GTK_IS_WIDGET (first_child));
- return first_child;
-}
-
-typedef struct
-{
- GtkCallback callback;
- gpointer callback_data;
-} container_foreach_deep_callback_data;
-
-static void
-container_foreach_deep_callback (GtkWidget *child, gpointer data)
-{
- container_foreach_deep_callback_data *deep_data;
-
- deep_data = (container_foreach_deep_callback_data *) data;
-
- deep_data->callback (child, deep_data->callback_data);
-
- if (GTK_IS_CONTAINER (child))
- {
- gtk_container_foreach (GTK_CONTAINER (child), container_foreach_deep_callback, data);
- }
-}
-
-void
-eel_gtk_container_foreach_deep (GtkContainer *container,
- GtkCallback callback,
- gpointer callback_data)
-{
- container_foreach_deep_callback_data deep_data;
- deep_data.callback = callback;
- deep_data.callback_data = callback_data;
- gtk_container_foreach (container, container_foreach_deep_callback, &deep_data);
-}
-
/* The standard gtk_adjustment_set_value ignores page size, which
* disagrees with the logic used by scroll bars, for example.
*/
@@ -822,276 +411,6 @@ eel_gtk_label_make_bold (GtkLabel *label)
pango_font_description_free (font_desc);
}
-/**
- * eel_gtk_label_set_scale:
- * @label:
- * @num_steps:
- *
- * Function is broken, see eel_gtk_label_make_larger() for explanation
- *
- **/
-void
-eel_gtk_label_set_scale (GtkLabel *label,
- double scale_factor)
-{
- PangoAttrList *old_attr_list;
- PangoAttrList *attr_list;
-
- g_return_if_fail (GTK_IS_LABEL (label));
- g_return_if_fail (scale_factor > 0);
-
- old_attr_list = gtk_label_get_attributes (label);
- attr_list = eel_pango_attr_list_apply_global_attribute (old_attr_list,
- pango_attr_scale_new (scale_factor));
- gtk_label_set_attributes (label, attr_list);
- pango_attr_list_unref (attr_list);
-}
-
-static void
-get_layout_location (GtkLabel *label,
- gint *xp,
- gint *yp)
-{
- GtkMisc *misc;
- GtkWidget *widget;
- float xalign, yalign;
- int x, y, xpad, ypad;
- int shadow_offset;
- GtkAllocation allocation;
- GtkRequisition req;
-
- shadow_offset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label),
- "eel-label-shadow-offset"));
-
- misc = GTK_MISC (label);
- widget = GTK_WIDGET (label);
- gtk_misc_get_alignment (misc, &xalign, &yalign);
- gtk_misc_get_padding (misc, &xpad, &ypad);
-
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
- xalign = 1.0 - xalign;
-
- gtk_widget_get_allocation (widget, &allocation);
- gtk_widget_get_requisition (widget, &req);
- x = floor (allocation.x + xpad
- + ((allocation.width - req.width - shadow_offset) * xalign)
- + 0.5);
-
- y = floor (allocation.y + ypad
- + ((allocation.height - req.height - shadow_offset) * yalign)
- + 0.5);
-
-
- if (xp)
- *xp = x;
-
- if (yp)
- *yp = y;
-}
-
-static gboolean
-eel_gtk_label_expose_event (GtkLabel *label, GdkEventExpose *event, gpointer user_data)
-{
- int x, y;
- GdkColor color;
- GtkWidget *widget;
- GdkGC *gc;
- guint32 shadow_color;
- int shadow_offset;
-
- shadow_color = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label),
- "eel-label-shadow-color"));
- shadow_offset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label),
- "eel-label-shadow-offset"));
-
- color = eel_gdk_rgb_to_color (shadow_color);
-
- get_layout_location (label, &x, &y);
-
- widget = GTK_WIDGET (label);
- if (shadow_offset > 0)
- {
- gc = gdk_gc_new (gtk_widget_get_window (widget));
- gdk_gc_set_rgb_fg_color (gc, &color);
- gdk_gc_set_clip_rectangle (gc, &event->area);
-
- gdk_draw_layout (gtk_widget_get_window (widget),
- gc,
- x + shadow_offset, y + shadow_offset,
- gtk_label_get_layout (label));
- g_object_unref (gc);
- }
-
- gtk_paint_layout (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- FALSE,
- &event->area,
- widget,
- "label",
- x, y,
- gtk_label_get_layout (label));
-
- return TRUE;
-}
-
-static void
-eel_gtk_label_size_request (GtkLabel *label, GtkRequisition *requisition, gpointer user_data)
-{
- gint shadow_offset;
-
- shadow_offset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label),
- "eel-label-shadow-offset"));
-
- requisition->width += shadow_offset;
- requisition->height += shadow_offset;
-}
-
-static void
-set_up_label (GtkLabel *label)
-{
-
- if (g_object_get_data (G_OBJECT (label), "eel-label-set-up") != NULL)
- {
- return;
- }
-
- g_signal_connect (label, "expose_event",
- G_CALLBACK (eel_gtk_label_expose_event), NULL);
- g_signal_connect_after (label, "size_request",
- G_CALLBACK (eel_gtk_label_size_request), NULL);
-
- g_object_set_data (G_OBJECT (label), "eel-label-set-up", "eel-label-set-up");
-}
-
-void
-eel_gtk_label_set_drop_shadow_color (GtkLabel *label,
- guint32 color)
-{
- set_up_label (label);
-
- g_object_set_data (G_OBJECT (label), "eel-label-shadow-color",
- GINT_TO_POINTER (color));
-
- gtk_widget_queue_draw (GTK_WIDGET (label));
-}
-
-void
-eel_gtk_label_set_drop_shadow_offset (GtkLabel *label,
- gint offset)
-{
- set_up_label (label);
-
- g_object_set_data (G_OBJECT (label), "eel-label-shadow-offset",
- GINT_TO_POINTER (offset));
-
- gtk_widget_queue_draw (GTK_WIDGET (label));
-}
-
-void
-eel_gtk_widget_set_background_color (GtkWidget *widget,
- const char *color_spec)
-{
- GdkColor color;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- eel_gdk_color_parse_with_white_default (color_spec, &color);
-
- gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_bg (widget, GTK_STATE_ACTIVE, &color);
- gtk_widget_modify_base (widget, GTK_STATE_ACTIVE, &color);
-}
-
-void
-eel_gtk_widget_set_foreground_color (GtkWidget *widget,
- const char *color_spec)
-{
- GdkColor color;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- eel_gdk_color_parse_with_white_default (color_spec, &color);
-
- gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_text (widget, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_fg (widget, GTK_STATE_ACTIVE, &color);
- gtk_widget_modify_text (widget, GTK_STATE_ACTIVE, &color);
-}
-
-GtkWidget *
-eel_gtk_widget_find_windowed_ancestor (GtkWidget *widget)
-{
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
- while (widget && !gtk_widget_get_has_window (widget))
- {
- widget = gtk_widget_get_parent (widget);
- }
-
- return widget;
-}
-
-/* eel_gtk_get_system_font:
- *
- * Return the system font as selected in the control center. Need to
- * g_object_unref() the result when done with it.
- *
- * Perhaps there is a better way to figure out what that font is, but
- * the following is simple enough and it works.
- */
-PangoFontDescription *
-eel_gtk_get_system_font (void)
-{
- GtkWidget *label;
- PangoFontDescription *font;
-
- label = gtk_label_new ("");
-
- gtk_widget_ensure_style (label);
-
- font = pango_font_description_copy (gtk_widget_get_style (label)->font_desc);
-
- g_object_ref_sink (label);
- g_object_unref (label);
-
- return font;
-}
-
-void
-eel_gtk_widget_get_button_event_location (GtkWidget *widget,
- const GdkEventButton *event,
- int *x,
- int *y)
-{
- int window_x, window_y;
- GtkAllocation allocation;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (event != NULL);
-
- gdk_window_get_position (event->window, &window_x, &window_y);
- gtk_widget_get_allocation (widget, &allocation);
- if (x != NULL)
- {
- *x = event->x + window_x - allocation.x;
- }
- if (y != NULL)
- {
- *y = event->y + window_y - allocation.y;
- }
-}
-
-void
-eel_gtk_widget_get_motion_event_location (GtkWidget *widget,
- const GdkEventMotion *event,
- int *x,
- int *y)
-{
- eel_gtk_widget_get_button_event_location (widget, (const GdkEventButton *) event, x, y);
-}
-
static gboolean
tree_view_button_press_callback (GtkWidget *tree_view,
GdkEventButton *event,
@@ -1147,101 +466,24 @@ eel_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view,
}
}
-gboolean
-eel_gtk_viewport_get_visible_rect (GtkViewport *viewport,
- GdkRectangle *rect)
-{
- GdkRectangle viewport_rect;
- GdkRectangle child_rect;
- gboolean return_val;
-
- g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), FALSE);
- g_return_val_if_fail (rect != NULL, FALSE);
-
- if (gtk_widget_get_realized (GTK_WIDGET (viewport)))
- {
- viewport_rect.x = 0;
- viewport_rect.y = 0;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- viewport_rect.width = gdk_window_get_width(GDK_WINDOW(gtk_viewport_get_view_window(viewport)));
- viewport_rect.height = gdk_window_get_height(GDK_WINDOW(gtk_viewport_get_view_window(viewport)));
-#else
- gdk_drawable_get_size(gtk_viewport_get_view_window(viewport), &viewport_rect.width, &viewport_rect.height);
-#endif
-
- gdk_window_get_position (gtk_viewport_get_bin_window (viewport),
- &child_rect.x,
- &child_rect.y);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- child_rect.width = gdk_window_get_width(GDK_WINDOW(gtk_viewport_get_view_window(viewport)));
- child_rect.height = gdk_window_get_height(GDK_WINDOW(gtk_viewport_get_view_window(viewport)));
-#else
- gdk_drawable_get_size(gtk_viewport_get_bin_window(viewport), &child_rect.width, &child_rect.height);
-#endif
-
- return_val = gdk_rectangle_intersect (&viewport_rect,
- &child_rect,
- rect);
- rect->x -= child_rect.x;
- rect->y -= child_rect.y;
-
- return return_val;
- }
-
- rect->x = rect->y = rect->width = rect->height = 0;
- return FALSE;
-}
-
void
-eel_gtk_viewport_scroll_to_rect (GtkViewport *viewport,
- GdkRectangle *rect)
+eel_gtk_message_dialog_set_details_label (GtkMessageDialog *dialog,
+ const gchar *details_text)
{
- GdkRectangle visible_rect;
- int scroll_x;
- int scroll_y;
- GtkAdjustment *adjustment;
+ GtkWidget *content_area, *expander, *label;
- g_return_if_fail (GTK_IS_VIEWPORT (viewport));
- g_return_if_fail (rect != NULL);
+ content_area = gtk_message_dialog_get_message_area (dialog);
+ expander = gtk_expander_new_with_mnemonic (_("Show more _details"));
+ gtk_expander_set_spacing (GTK_EXPANDER (expander), 6);
- if (eel_gtk_viewport_get_visible_rect (viewport, &visible_rect))
- {
- scroll_x = -1;
- scroll_y = -1;
+ label = gtk_label_new (details_text);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- if (rect->x + rect->width > visible_rect.x + visible_rect.width)
- {
- scroll_x = rect->x - (visible_rect.width - rect->width);
- }
- if (rect->y + rect->height > visible_rect.y + visible_rect.height)
- {
- scroll_y = rect->y - (visible_rect.height - rect->height);
- }
+ gtk_container_add (GTK_CONTAINER (expander), label);
+ gtk_box_pack_start (GTK_BOX (content_area), expander, FALSE, FALSE, 0);
- if (rect->x < visible_rect.x)
- {
- scroll_x = rect->x;
- }
-
- if (rect->y < visible_rect.y)
- {
- scroll_y = rect->y;
- }
-
- adjustment = gtk_viewport_get_hadjustment (viewport);
- if (adjustment && scroll_x != -1)
- {
- eel_gtk_adjustment_set_value (adjustment,
- (double)scroll_x);
- }
-
- adjustment = gtk_viewport_get_vadjustment (viewport);
- if (adjustment && scroll_y != -1)
- {
- eel_gtk_adjustment_set_value (adjustment,
- (double)scroll_y);
- }
- }
+ gtk_widget_show (label);
+ gtk_widget_show (expander);
}