mirror of
https://gitlab.gnome.org/GNOME/eog
synced 2024-10-19 14:34:42 +00:00
Add the image size to the window title.
2000-04-20 Federico Mena Quintero <federico@helixcode.com> * window.c (window_open_image): Add the image size to the window title. * image-view.c (drag_to): New function to drag the image to a specified mouse position. (image_view_button_press): Handle button presses by initiating the drag. (image_view_button_release): Handler button releases by terminating the drag. (image_view_motion): Handle motion events by dragging the image.
This commit is contained in:
parent
960f82b0b9
commit
cfb9617b76
|
@ -1,3 +1,8 @@
|
|||
2000-04-20 Federico Mena Quintero <federico@helixcode.com>
|
||||
|
||||
* configure.in (have_gprint): We require gnome-print 0.18 or
|
||||
later.
|
||||
|
||||
2000-04-19 Ville Hautamaki <villeh@cs.joensuu.fi>
|
||||
|
||||
* configure.in: (ALL_LINGUAS): added Finnish
|
||||
|
|
|
@ -77,11 +77,11 @@ dnl ******************************
|
|||
gprint=
|
||||
gprint_msg=no
|
||||
have_gprint=false
|
||||
AC_MSG_CHECKING(for GnomePrint libraries >= 0.16)
|
||||
AC_MSG_CHECKING(for GnomePrint libraries >= 0.18)
|
||||
if gnome-config --libs print > /dev/null 2>&1; then
|
||||
vers=`gnome-config --modversion print | sed -e "s/gnome-print-//" | \
|
||||
awk 'BEGIN { FS = "."; } { print $1 * 1000 + $2;}'`
|
||||
if test "$vers" -ge 16; then
|
||||
if test "$vers" -ge 18; then
|
||||
AC_MSG_RESULT(found)
|
||||
AC_DEFINE(ENABLE_GPRINT)
|
||||
have_gprint=true
|
||||
|
|
|
@ -62,6 +62,13 @@ typedef struct {
|
|||
|
||||
/* Idle handler ID */
|
||||
guint idle_id;
|
||||
|
||||
/* Anchor point and offsets for dragging */
|
||||
int drag_anchor_x, drag_anchor_y;
|
||||
int drag_ofs_x, drag_ofs_y;
|
||||
|
||||
/* Whether the image is being dragged */
|
||||
guint dragging : 1;
|
||||
} ImageViewPrivate;
|
||||
|
||||
|
||||
|
@ -77,6 +84,9 @@ static void image_view_unrealize (GtkWidget *widget);
|
|||
static void image_view_size_request (GtkWidget *widget, GtkRequisition *requisition);
|
||||
static void image_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
|
||||
static void image_view_draw (GtkWidget *widget, GdkRectangle *area);
|
||||
static gint image_view_button_press (GtkWidget *widget, GdkEventButton *event);
|
||||
static gint image_view_button_release (GtkWidget *widget, GdkEventButton *event);
|
||||
static gint image_view_motion (GtkWidget *widget, GdkEventMotion *event);
|
||||
static gint image_view_expose (GtkWidget *widget, GdkEventExpose *event);
|
||||
|
||||
static void image_view_set_scroll_adjustments (GtkWidget *widget,
|
||||
|
@ -150,6 +160,9 @@ image_view_class_init (ImageViewClass *class)
|
|||
widget_class->size_request = image_view_size_request;
|
||||
widget_class->size_allocate = image_view_size_allocate;
|
||||
widget_class->draw = image_view_draw;
|
||||
widget_class->button_press_event = image_view_button_press;
|
||||
widget_class->button_release_event = image_view_button_release;
|
||||
widget_class->motion_notify_event = image_view_motion;
|
||||
widget_class->expose_event = image_view_expose;
|
||||
}
|
||||
|
||||
|
@ -637,6 +650,125 @@ image_view_draw (GtkWidget *widget, GdkRectangle *area)
|
|||
request_paint_area (view, area);
|
||||
}
|
||||
|
||||
/* Button press handler for the image view */
|
||||
static gint
|
||||
image_view_button_press (GtkWidget *widget, GdkEventButton *event)
|
||||
{
|
||||
ImageView *view;
|
||||
ImageViewPrivate *priv;
|
||||
GdkCursor *cursor;
|
||||
|
||||
view = IMAGE_VIEW (widget);
|
||||
priv = view->priv;
|
||||
|
||||
if (priv->dragging || event->button != 1)
|
||||
return FALSE;
|
||||
|
||||
priv->dragging = TRUE;
|
||||
priv->drag_anchor_x = event->x;
|
||||
priv->drag_anchor_y = event->y;
|
||||
|
||||
priv->drag_ofs_x = priv->hadj->value;
|
||||
priv->drag_ofs_y = priv->vadj->value;
|
||||
|
||||
cursor = cursor_get (widget->window, CURSOR_HAND_CLOSED);
|
||||
gdk_pointer_grab (widget->window,
|
||||
FALSE,
|
||||
(GDK_POINTER_MOTION_MASK
|
||||
| GDK_POINTER_MOTION_HINT_MASK
|
||||
| GDK_BUTTON_RELEASE_MASK),
|
||||
NULL,
|
||||
cursor,
|
||||
event->time);
|
||||
gdk_cursor_destroy (cursor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Drags the image to the specified position */
|
||||
static void
|
||||
drag_to (ImageView *view, int x, int y)
|
||||
{
|
||||
ImageViewPrivate *priv;
|
||||
int dx, dy;
|
||||
GdkRectangle area;
|
||||
|
||||
priv = view->priv;
|
||||
|
||||
dx = priv->drag_anchor_x - x;
|
||||
dy = priv->drag_anchor_y - y;
|
||||
|
||||
x = CLAMP (priv->drag_ofs_x + dx, 0, priv->hadj->upper - priv->hadj->page_size);
|
||||
y = CLAMP (priv->drag_ofs_y + dy, 0, priv->vadj->upper - priv->vadj->page_size);
|
||||
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->hadj), view);
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->vadj), view);
|
||||
|
||||
priv->hadj->value = x;
|
||||
priv->vadj->value = y;
|
||||
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (priv->hadj), "value_changed");
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (priv->vadj), "value_changed");
|
||||
|
||||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->hadj), view);
|
||||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->vadj), view);
|
||||
|
||||
/* FIXME: use copy_area() for the window and the uta */
|
||||
|
||||
area.x = 0;
|
||||
area.y = 0;
|
||||
area.width = GTK_WIDGET (view)->allocation.width;
|
||||
area.height = GTK_WIDGET (view)->allocation.height;
|
||||
|
||||
request_paint_area (view, &area);
|
||||
}
|
||||
|
||||
/* Button release handler for the image view */
|
||||
static gint
|
||||
image_view_button_release (GtkWidget *widget, GdkEventButton *event)
|
||||
{
|
||||
ImageView *view;
|
||||
ImageViewPrivate *priv;
|
||||
|
||||
view = IMAGE_VIEW (widget);
|
||||
priv = view->priv;
|
||||
|
||||
if (!priv->dragging || event->button != 1)
|
||||
return FALSE;
|
||||
|
||||
drag_to (view, event->x, event->y);
|
||||
priv->dragging = FALSE;
|
||||
gdk_pointer_ungrab (event->time);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Motion handler for the image view */
|
||||
static gint
|
||||
image_view_motion (GtkWidget *widget, GdkEventMotion *event)
|
||||
{
|
||||
ImageView *view;
|
||||
ImageViewPrivate *priv;
|
||||
gint x, y;
|
||||
GdkModifierType mods;
|
||||
|
||||
view = IMAGE_VIEW (widget);
|
||||
priv = view->priv;
|
||||
|
||||
if (!priv->dragging)
|
||||
return FALSE;
|
||||
|
||||
if (event->is_hint)
|
||||
gdk_window_get_pointer (widget->window, &x, &y, &mods);
|
||||
else {
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
}
|
||||
|
||||
drag_to (view, x, y);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Expose handler for the image view */
|
||||
static gint
|
||||
image_view_expose (GtkWidget *widget, GdkEventExpose *event)
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
2000-04-20 Federico Mena Quintero <federico@helixcode.com>
|
||||
|
||||
* window.c (window_open_image): Add the image size to the window
|
||||
title.
|
||||
|
||||
* image-view.c (drag_to): New function to drag the image to a
|
||||
specified mouse position.
|
||||
(image_view_button_press): Handle button presses by initiating the
|
||||
drag.
|
||||
(image_view_button_release): Handler button releases by
|
||||
terminating the drag.
|
||||
(image_view_motion): Handle motion events by dragging the image.
|
||||
|
||||
2000-04-14 Federico Mena Quintero <federico@helixcode.com>
|
||||
|
||||
* image-view.c (image_view_unrealize): Doh, call the parent class
|
||||
|
|
132
src/image-view.c
132
src/image-view.c
|
@ -62,6 +62,13 @@ typedef struct {
|
|||
|
||||
/* Idle handler ID */
|
||||
guint idle_id;
|
||||
|
||||
/* Anchor point and offsets for dragging */
|
||||
int drag_anchor_x, drag_anchor_y;
|
||||
int drag_ofs_x, drag_ofs_y;
|
||||
|
||||
/* Whether the image is being dragged */
|
||||
guint dragging : 1;
|
||||
} ImageViewPrivate;
|
||||
|
||||
|
||||
|
@ -77,6 +84,9 @@ static void image_view_unrealize (GtkWidget *widget);
|
|||
static void image_view_size_request (GtkWidget *widget, GtkRequisition *requisition);
|
||||
static void image_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
|
||||
static void image_view_draw (GtkWidget *widget, GdkRectangle *area);
|
||||
static gint image_view_button_press (GtkWidget *widget, GdkEventButton *event);
|
||||
static gint image_view_button_release (GtkWidget *widget, GdkEventButton *event);
|
||||
static gint image_view_motion (GtkWidget *widget, GdkEventMotion *event);
|
||||
static gint image_view_expose (GtkWidget *widget, GdkEventExpose *event);
|
||||
|
||||
static void image_view_set_scroll_adjustments (GtkWidget *widget,
|
||||
|
@ -150,6 +160,9 @@ image_view_class_init (ImageViewClass *class)
|
|||
widget_class->size_request = image_view_size_request;
|
||||
widget_class->size_allocate = image_view_size_allocate;
|
||||
widget_class->draw = image_view_draw;
|
||||
widget_class->button_press_event = image_view_button_press;
|
||||
widget_class->button_release_event = image_view_button_release;
|
||||
widget_class->motion_notify_event = image_view_motion;
|
||||
widget_class->expose_event = image_view_expose;
|
||||
}
|
||||
|
||||
|
@ -637,6 +650,125 @@ image_view_draw (GtkWidget *widget, GdkRectangle *area)
|
|||
request_paint_area (view, area);
|
||||
}
|
||||
|
||||
/* Button press handler for the image view */
|
||||
static gint
|
||||
image_view_button_press (GtkWidget *widget, GdkEventButton *event)
|
||||
{
|
||||
ImageView *view;
|
||||
ImageViewPrivate *priv;
|
||||
GdkCursor *cursor;
|
||||
|
||||
view = IMAGE_VIEW (widget);
|
||||
priv = view->priv;
|
||||
|
||||
if (priv->dragging || event->button != 1)
|
||||
return FALSE;
|
||||
|
||||
priv->dragging = TRUE;
|
||||
priv->drag_anchor_x = event->x;
|
||||
priv->drag_anchor_y = event->y;
|
||||
|
||||
priv->drag_ofs_x = priv->hadj->value;
|
||||
priv->drag_ofs_y = priv->vadj->value;
|
||||
|
||||
cursor = cursor_get (widget->window, CURSOR_HAND_CLOSED);
|
||||
gdk_pointer_grab (widget->window,
|
||||
FALSE,
|
||||
(GDK_POINTER_MOTION_MASK
|
||||
| GDK_POINTER_MOTION_HINT_MASK
|
||||
| GDK_BUTTON_RELEASE_MASK),
|
||||
NULL,
|
||||
cursor,
|
||||
event->time);
|
||||
gdk_cursor_destroy (cursor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Drags the image to the specified position */
|
||||
static void
|
||||
drag_to (ImageView *view, int x, int y)
|
||||
{
|
||||
ImageViewPrivate *priv;
|
||||
int dx, dy;
|
||||
GdkRectangle area;
|
||||
|
||||
priv = view->priv;
|
||||
|
||||
dx = priv->drag_anchor_x - x;
|
||||
dy = priv->drag_anchor_y - y;
|
||||
|
||||
x = CLAMP (priv->drag_ofs_x + dx, 0, priv->hadj->upper - priv->hadj->page_size);
|
||||
y = CLAMP (priv->drag_ofs_y + dy, 0, priv->vadj->upper - priv->vadj->page_size);
|
||||
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->hadj), view);
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->vadj), view);
|
||||
|
||||
priv->hadj->value = x;
|
||||
priv->vadj->value = y;
|
||||
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (priv->hadj), "value_changed");
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (priv->vadj), "value_changed");
|
||||
|
||||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->hadj), view);
|
||||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->vadj), view);
|
||||
|
||||
/* FIXME: use copy_area() for the window and the uta */
|
||||
|
||||
area.x = 0;
|
||||
area.y = 0;
|
||||
area.width = GTK_WIDGET (view)->allocation.width;
|
||||
area.height = GTK_WIDGET (view)->allocation.height;
|
||||
|
||||
request_paint_area (view, &area);
|
||||
}
|
||||
|
||||
/* Button release handler for the image view */
|
||||
static gint
|
||||
image_view_button_release (GtkWidget *widget, GdkEventButton *event)
|
||||
{
|
||||
ImageView *view;
|
||||
ImageViewPrivate *priv;
|
||||
|
||||
view = IMAGE_VIEW (widget);
|
||||
priv = view->priv;
|
||||
|
||||
if (!priv->dragging || event->button != 1)
|
||||
return FALSE;
|
||||
|
||||
drag_to (view, event->x, event->y);
|
||||
priv->dragging = FALSE;
|
||||
gdk_pointer_ungrab (event->time);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Motion handler for the image view */
|
||||
static gint
|
||||
image_view_motion (GtkWidget *widget, GdkEventMotion *event)
|
||||
{
|
||||
ImageView *view;
|
||||
ImageViewPrivate *priv;
|
||||
gint x, y;
|
||||
GdkModifierType mods;
|
||||
|
||||
view = IMAGE_VIEW (widget);
|
||||
priv = view->priv;
|
||||
|
||||
if (!priv->dragging)
|
||||
return FALSE;
|
||||
|
||||
if (event->is_hint)
|
||||
gdk_window_get_pointer (widget->window, &x, &y, &mods);
|
||||
else {
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
}
|
||||
|
||||
drag_to (view, x, y);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Expose handler for the image view */
|
||||
static gint
|
||||
image_view_expose (GtkWidget *widget, GdkEventExpose *event)
|
||||
|
|
19
src/window.c
19
src/window.c
|
@ -705,6 +705,7 @@ window_open_image (Window *window, const char *filename)
|
|||
Image *image;
|
||||
gboolean retval;
|
||||
char *fname;
|
||||
gboolean free_fname;
|
||||
|
||||
g_return_val_if_fail (window != NULL, FALSE);
|
||||
g_return_val_if_fail (IS_WINDOW (window), FALSE);
|
||||
|
@ -719,13 +720,25 @@ window_open_image (Window *window, const char *filename)
|
|||
retval = image_load (image, filename);
|
||||
ui_image_set_image (UI_IMAGE (priv->content), image);
|
||||
|
||||
if (image->filename)
|
||||
fname = g_basename (image->filename);
|
||||
else
|
||||
free_fname = FALSE;
|
||||
|
||||
if (image->filename) {
|
||||
if (image->pixbuf) {
|
||||
fname = g_strdup_printf ("%s (%dx%d)",
|
||||
g_basename (image->filename),
|
||||
gdk_pixbuf_get_width (image->pixbuf),
|
||||
gdk_pixbuf_get_height (image->pixbuf));
|
||||
free_fname = TRUE;
|
||||
} else
|
||||
fname = g_basename (image->filename);
|
||||
} else
|
||||
fname = _("Eye of Gnome");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), fname);
|
||||
|
||||
if (free_fname)
|
||||
g_free (fname);
|
||||
|
||||
image_unref (image);
|
||||
return retval;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue