[Goodies-commits] r3085 - in ristretto/trunk: . src
Stephan Arts
stephan at xfce.org
Mon Aug 27 15:58:30 CEST 2007
Author: stephan
Date: 2007-08-27 13:58:29 +0000 (Mon, 27 Aug 2007)
New Revision: 3085
Modified:
ristretto/trunk/ChangeLog
ristretto/trunk/src/main.c
ristretto/trunk/src/navigator.c
ristretto/trunk/src/navigator.h
ristretto/trunk/src/picture_viewer.c
ristretto/trunk/src/thumbnail_viewer.c
Log:
Fix bug 3500 (among other things)
Modified: ristretto/trunk/ChangeLog
===================================================================
--- ristretto/trunk/ChangeLog 2007-08-26 23:17:54 UTC (rev 3084)
+++ ristretto/trunk/ChangeLog 2007-08-27 13:58:29 UTC (rev 3085)
@@ -1,3 +1,10 @@
+2007-08-27:
+ * configure.in.in: Fixed version-numbering
+ * src/thumbnailer.c: Added scrollwheel navigation
+ Fixed backwards scrolling of thumbnailer
+ * src/pictureviewer.c: Added scrollwheel zooming
+ Fix Bug #3500 (Do not upscale images by default)
+ * src/main.c: Added space/backspace navigation
2007-08-26: Release 0.0.1
* */*: Initial release
Modified: ristretto/trunk/src/main.c
===================================================================
--- ristretto/trunk/src/main.c 2007-08-26 23:17:54 UTC (rev 3084)
+++ ristretto/trunk/src/main.c 2007-08-27 13:58:29 UTC (rev 3085)
@@ -86,7 +86,6 @@
static gboolean window_fullscreen = FALSE;
static gboolean viewer_scale = 1.0;
static GtkWidget *menu_bar;
-static GtkWidget *image_tool_bar;
static GtkWidget *app_tool_bar;
static GtkWidget *status_bar;
static gboolean playing = FALSE;
@@ -333,7 +332,7 @@
gtk_box_pack_start(GTK_BOX(main_vbox), main_hbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(main_vbox), status_bar, FALSE, TRUE, 0);
- rstto_picture_viewer_fit_scale(RSTTO_PICTURE_VIEWER(viewer));
+ //rstto_picture_viewer_fit_scale(RSTTO_PICTURE_VIEWER(viewer));
gtk_toolbar_insert(GTK_TOOLBAR(app_tool_bar), zoom_fit, 0);
gtk_toolbar_insert(GTK_TOOLBAR(app_tool_bar), zoom_100, 0);
@@ -511,7 +510,6 @@
{
window_fullscreen = TRUE;
gtk_widget_hide(menu_bar);
- gtk_widget_hide(image_tool_bar);
gtk_widget_hide(app_tool_bar);
gtk_widget_hide(status_bar);
viewer_scale = rstto_picture_viewer_get_scale(viewer);
@@ -521,7 +519,6 @@
{
window_fullscreen = FALSE;
gtk_widget_show(menu_bar);
- gtk_widget_show(image_tool_bar);
gtk_widget_show(app_tool_bar);
gtk_widget_show(status_bar);
if(viewer_scale)
Modified: ristretto/trunk/src/navigator.c
===================================================================
--- ristretto/trunk/src/navigator.c 2007-08-26 23:17:54 UTC (rev 3084)
+++ ristretto/trunk/src/navigator.c 2007-08-27 13:58:29 UTC (rev 3085)
@@ -53,11 +53,13 @@
struct _RsttoNavigatorEntry
{
ThunarVfsInfo *info;
+ GdkPixbuf *thumb;
+ GdkPixbuf *pixbuf;
+ gdouble scale;
+ gboolean fit_to_screen;
GdkPixbufRotation rotation;
gboolean h_flipped;
gboolean v_flipped;
- GdkPixbuf *thumb;
- GdkPixbuf *pixbuf;
};
@@ -495,3 +497,27 @@
{
return navigator->old_position;
}
+
+gdouble
+rstto_navigator_entry_get_scale (RsttoNavigatorEntry *entry)
+{
+ return entry->scale;
+}
+
+void
+rstto_navigator_entry_set_scale (RsttoNavigatorEntry *entry, gdouble scale)
+{
+ entry->scale = scale;
+}
+
+gboolean
+rstto_navigator_entry_get_fit_to_screen (RsttoNavigatorEntry *entry)
+{
+ return entry->fit_to_screen;
+}
+
+void
+rstto_navigator_entry_set_fit_to_screen (RsttoNavigatorEntry *entry, gboolean fts)
+{
+ entry->fit_to_screen = fts;
+}
Modified: ristretto/trunk/src/navigator.h
===================================================================
--- ristretto/trunk/src/navigator.h 2007-08-26 23:17:54 UTC (rev 3084)
+++ ristretto/trunk/src/navigator.h 2007-08-27 13:58:29 UTC (rev 3085)
@@ -103,6 +103,15 @@
rstto_navigator_entry_get_pixbuf (RsttoNavigatorEntry *entry);
ThunarVfsInfo *
rstto_navigator_entry_get_info (RsttoNavigatorEntry *entry);
+gboolean
+rstto_navigator_entry_get_fit_to_screen (RsttoNavigatorEntry *entry);
+gdouble
+rstto_navigator_entry_get_scale (RsttoNavigatorEntry *entry);
+void
+rstto_navigator_entry_set_fit_to_screen (RsttoNavigatorEntry *entry, gboolean);
+void
+rstto_navigator_entry_set_scale (RsttoNavigatorEntry *entry, gdouble);
+
GdkPixbufRotation
rstto_navigator_entry_get_rotation (RsttoNavigatorEntry *entry);
gboolean
Modified: ristretto/trunk/src/picture_viewer.c
===================================================================
--- ristretto/trunk/src/picture_viewer.c 2007-08-26 23:17:54 UTC (rev 3084)
+++ ristretto/trunk/src/picture_viewer.c 2007-08-27 13:58:29 UTC (rev 3085)
@@ -27,11 +27,9 @@
{
GdkPixbuf *src_pixbuf;
GdkPixbuf *dst_pixbuf; /* The pixbuf which ends up on screen */
- gdouble scale;
- gboolean scale_fts; /* Scale image to fit to screen */
+ RsttoNavigator *navigator;
void (*cb_value_changed)(GtkAdjustment *, RsttoPictureViewer *);
gboolean show_border;
- RsttoNavigator *navigator;
};
static void
@@ -107,8 +105,6 @@
viewer->priv->dst_pixbuf = NULL;
gtk_widget_set_redraw_on_allocate(GTK_WIDGET(viewer), TRUE);
- viewer->priv->scale = 1;
- viewer->priv->scale_fts = FALSE;
viewer->priv->show_border = TRUE;
g_signal_connect(G_OBJECT(viewer), "scroll_event", G_CALLBACK(cb_rstto_picture_viewer_scroll_event), NULL);
@@ -369,6 +365,8 @@
static void
cb_rstto_picture_viewer_value_changed(GtkAdjustment *adjustment, RsttoPictureViewer *viewer)
{
+ RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
+ gdouble scale = rstto_navigator_entry_get_scale(entry);
if (viewer->priv->src_pixbuf)
{
gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
@@ -378,14 +376,14 @@
if (viewer->hadjustment && viewer->vadjustment)
{
tmp_pixbuf = gdk_pixbuf_new_subpixbuf(viewer->priv->src_pixbuf,
- viewer->hadjustment->value / viewer->priv->scale >= 0?
- viewer->hadjustment->value / viewer->priv->scale : 0,
- viewer->vadjustment->value / viewer->priv->scale >= 0?
- viewer->vadjustment->value / viewer->priv->scale : 0,
- ((GTK_WIDGET(viewer)->allocation.width/viewer->priv->scale)) < width?
- GTK_WIDGET(viewer)->allocation.width/viewer->priv->scale:width,
- ((GTK_WIDGET(viewer)->allocation.height/viewer->priv->scale)) < height?
- GTK_WIDGET(viewer)->allocation.height/viewer->priv->scale:height);
+ viewer->hadjustment->value / scale >= 0?
+ viewer->hadjustment->value / scale : 0,
+ viewer->vadjustment->value / scale >= 0?
+ viewer->vadjustment->value / scale : 0,
+ ((GTK_WIDGET(viewer)->allocation.width/scale)) < width?
+ GTK_WIDGET(viewer)->allocation.width/scale:width,
+ ((GTK_WIDGET(viewer)->allocation.height/scale)) < height?
+ GTK_WIDGET(viewer)->allocation.height/scale:height);
}
if(viewer->priv->dst_pixbuf)
@@ -397,8 +395,8 @@
if(tmp_pixbuf)
{
viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf,
- gdk_pixbuf_get_width(tmp_pixbuf)*viewer->priv->scale,
- gdk_pixbuf_get_height(tmp_pixbuf)*viewer->priv->scale,
+ gdk_pixbuf_get_width(tmp_pixbuf)*scale,
+ gdk_pixbuf_get_height(tmp_pixbuf)*scale,
GDK_INTERP_BILINEAR);
g_object_unref(tmp_pixbuf);
tmp_pixbuf = NULL;
@@ -423,8 +421,9 @@
rstto_picture_viewer_set_scale(RsttoPictureViewer *viewer, gdouble scale)
{
g_return_if_fail(scale > 0);
- viewer->priv->scale_fts = FALSE;
- viewer->priv->scale = scale;
+ RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
+ rstto_navigator_entry_set_scale(entry, scale);
+ rstto_navigator_entry_set_fit_to_screen (entry, FALSE);
if(rstto_picture_viewer_refresh(viewer))
{
@@ -435,48 +434,74 @@
gdouble
rstto_picture_viewer_fit_scale(RsttoPictureViewer *viewer)
{
- viewer->priv->scale_fts = TRUE;
+ RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
+ rstto_navigator_entry_set_fit_to_screen (entry, TRUE);
if(rstto_picture_viewer_refresh(viewer))
{
rstto_picture_viewer_paint(GTK_WIDGET(viewer));
}
- return viewer->priv->scale;
+ return rstto_navigator_entry_get_scale(entry);
}
gdouble
rstto_picture_viewer_get_scale(RsttoPictureViewer *viewer)
{
- return viewer->priv->scale;
+ RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
+ return rstto_navigator_entry_get_scale(entry);
}
static gboolean
rstto_picture_viewer_refresh(RsttoPictureViewer *viewer)
{
GtkWidget *widget = GTK_WIDGET(viewer);
+ RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
+ gboolean fit_to_screen = rstto_navigator_entry_get_fit_to_screen(entry);
+ gdouble scale = rstto_navigator_entry_get_scale(entry);
+
gboolean changed;
gboolean vadjustment_changed = FALSE;
gboolean hadjustment_changed = FALSE;
if(viewer->priv->src_pixbuf)
{
+ gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
+ gdouble height = (gdouble)gdk_pixbuf_get_height(viewer->priv->src_pixbuf);
+ if (scale == 0)
+ {
+ if ((widget->allocation.width > width) && (widget->allocation.height > height))
+ {
+ scale = 1.0;
+ rstto_navigator_entry_set_scale(entry, scale);
+ fit_to_screen = FALSE;
+ }
+ else
+ {
+ fit_to_screen = TRUE;
+ rstto_navigator_entry_set_fit_to_screen(entry, TRUE);
+ }
+ }
- if(viewer->priv->scale_fts)
+ if(fit_to_screen)
{
- gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
- gdouble height = (gdouble)gdk_pixbuf_get_height(viewer->priv->src_pixbuf);
gdouble h_scale = GTK_WIDGET(viewer)->allocation.width / width;
gdouble v_scale = GTK_WIDGET(viewer)->allocation.height / height;
if(h_scale < v_scale)
{
- if(viewer->priv->scale != h_scale)
+ if(scale != h_scale)
+ {
+ scale = h_scale;
changed = TRUE;
- viewer->priv->scale = h_scale;
+ }
+ rstto_navigator_entry_set_scale(entry, h_scale);
}
else
{
- if(viewer->priv->scale != v_scale)
+ if(scale != v_scale)
+ {
+ scale = v_scale;
changed = TRUE;
- viewer->priv->scale = v_scale;
+ }
+ rstto_navigator_entry_set_scale(entry, v_scale);
}
}
if(GTK_WIDGET_REALIZED(widget))
@@ -491,7 +516,7 @@
if(viewer->hadjustment)
{
viewer->hadjustment->page_size = widget->allocation.width;
- viewer->hadjustment->upper = width * viewer->priv->scale;
+ viewer->hadjustment->upper = width * scale;
viewer->hadjustment->lower = 0;
viewer->hadjustment->step_increment = 1;
viewer->hadjustment->page_increment = 100;
@@ -504,7 +529,7 @@
if(viewer->vadjustment)
{
viewer->vadjustment->page_size = widget->allocation.height;
- viewer->vadjustment->upper = height * viewer->priv->scale;
+ viewer->vadjustment->upper = height * scale;
viewer->vadjustment->lower = 0;
viewer->vadjustment->step_increment = 1;
viewer->vadjustment->page_increment = 100;
@@ -519,15 +544,23 @@
GdkPixbuf *tmp_pixbuf = NULL;
if (viewer->vadjustment && viewer->hadjustment)
{
- tmp_pixbuf = gdk_pixbuf_new_subpixbuf(viewer->priv->src_pixbuf,
- viewer->hadjustment->value / viewer->priv->scale >= 0?
- viewer->hadjustment->value / viewer->priv->scale : 0,
- viewer->vadjustment->value / viewer->priv->scale >= 0?
- viewer->vadjustment->value / viewer->priv->scale : 0,
- ((widget->allocation.width/viewer->priv->scale)) < width?
- widget->allocation.width/viewer->priv->scale:width,
- ((widget->allocation.height/viewer->priv->scale))< height?
- widget->allocation.height/viewer->priv->scale:height);
+ if (scale != 1.0)
+ {
+ tmp_pixbuf = gdk_pixbuf_new_subpixbuf(viewer->priv->src_pixbuf,
+ viewer->hadjustment->value / scale >= 0?
+ viewer->hadjustment->value / scale : 0,
+ viewer->vadjustment->value / scale >= 0?
+ viewer->vadjustment->value / scale : 0,
+ ((widget->allocation.width/scale)) < width?
+ widget->allocation.width/scale:width,
+ ((widget->allocation.height/scale))< height?
+ widget->allocation.height/scale:height);
+ }
+ else
+ {
+ tmp_pixbuf = viewer->priv->src_pixbuf;
+ g_object_ref(tmp_pixbuf);
+ }
}
if(viewer->priv->dst_pixbuf)
@@ -539,8 +572,8 @@
if(tmp_pixbuf)
{
viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf,
- gdk_pixbuf_get_width(tmp_pixbuf) * viewer->priv->scale,
- gdk_pixbuf_get_height(tmp_pixbuf) * viewer->priv->scale,
+ gdk_pixbuf_get_width(tmp_pixbuf) * scale,
+ gdk_pixbuf_get_height(tmp_pixbuf) * scale,
GDK_INTERP_BILINEAR);
g_object_unref(tmp_pixbuf);
tmp_pixbuf = NULL;
@@ -582,8 +615,11 @@
if(viewer->priv->src_pixbuf)
{
g_object_ref(viewer->priv->src_pixbuf);
- rstto_picture_viewer_refresh(viewer);
- rstto_picture_viewer_paint(GTK_WIDGET(viewer));
+ if (GTK_WIDGET_REALIZED(widget))
+ {
+ rstto_picture_viewer_refresh(viewer);
+ rstto_picture_viewer_paint(GTK_WIDGET(viewer));
+ }
}
if(GTK_WIDGET_REALIZED(widget))
@@ -597,15 +633,17 @@
static void
cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll *event)
{
+ RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
+ gdouble scale = rstto_navigator_entry_get_scale(entry);
switch(event->direction)
{
case GDK_SCROLL_UP:
case GDK_SCROLL_LEFT:
- rstto_picture_viewer_set_scale(viewer, viewer->priv->scale / 1.2);
+ rstto_picture_viewer_set_scale(viewer, scale / 1.2);
break;
case GDK_SCROLL_DOWN:
case GDK_SCROLL_RIGHT:
- rstto_picture_viewer_set_scale(viewer, viewer->priv->scale * 1.2);
+ rstto_picture_viewer_set_scale(viewer, scale * 1.2);
break;
}
Modified: ristretto/trunk/src/thumbnail_viewer.c
===================================================================
--- ristretto/trunk/src/thumbnail_viewer.c 2007-08-26 23:17:54 UTC (rev 3084)
+++ ristretto/trunk/src/thumbnail_viewer.c 2007-08-27 13:58:29 UTC (rev 3085)
@@ -511,7 +511,10 @@
if (GTK_WIDGET_REALIZED(viewer))
{
/* Check if the entry is visible */
- viewer->priv->end = widget->allocation.width / viewer->priv->dimension + viewer->priv->begin;
+ if (viewer->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ viewer->priv->end = widget->allocation.width / viewer->priv->dimension + viewer->priv->begin;
+ else
+ viewer->priv->end = widget->allocation.height / viewer->priv->dimension + viewer->priv->begin;
if ((nr >= viewer->priv->begin) && (nr <= viewer->priv->end))
{
RsttoNavigatorEntry *s_entry = rstto_navigator_get_file(nav);
@@ -566,15 +569,7 @@
if (viewer->priv->offset == old_offset)
{
rstto_thumbnail_viewer_paint_entry(viewer, rstto_navigator_get_old_position(viewer->priv->navigator), FALSE);
- RsttoNavigatorEntry *s_entry = rstto_navigator_get_file(nav);
- if (s_entry == entry)
- {
- rstto_thumbnail_viewer_paint_entry(viewer, nr, TRUE);
- }
- else
- {
- rstto_thumbnail_viewer_paint_entry(viewer, nr, FALSE);
- }
+ rstto_thumbnail_viewer_paint_entry(viewer, nr, TRUE);
}
else
{
More information about the Goodies-commits
mailing list