[Goodies-commits] r2931 - ristretto/trunk/src
Stephan Arts
stephan at xfce.org
Mon Jul 30 00:40:37 CEST 2007
Author: stephan
Date: 2007-07-29 22:40:37 +0000 (Sun, 29 Jul 2007)
New Revision: 2931
Added:
ristretto/trunk/src/navigator.c
ristretto/trunk/src/navigator.h
Modified:
ristretto/trunk/src/Makefile.am
ristretto/trunk/src/main.c
ristretto/trunk/src/picture_viewer.c
ristretto/trunk/src/picture_viewer.h
Log:
move navigation code into a separate object
Modified: ristretto/trunk/src/Makefile.am
===================================================================
--- ristretto/trunk/src/Makefile.am 2007-07-29 17:56:06 UTC (rev 2930)
+++ ristretto/trunk/src/Makefile.am 2007-07-29 22:40:37 UTC (rev 2931)
@@ -2,7 +2,8 @@
ristretto_SOURCES = \
main.c \
- picture_viewer.c picture_viewer.h
+ picture_viewer.c picture_viewer.h \
+ navigator.c navigator.h
ristretto_CFLAGS = \
$(GTK_CFLAGS) \
Modified: ristretto/trunk/src/main.c
===================================================================
--- ristretto/trunk/src/main.c 2007-07-29 17:56:06 UTC (rev 2930)
+++ ristretto/trunk/src/main.c 2007-07-29 22:40:37 UTC (rev 2931)
@@ -21,11 +21,10 @@
#include <thunar-vfs/thunar-vfs.h>
#include "picture_viewer.h"
+#include "navigator.h"
static ThunarVfsMimeDatabase *mime_dbase = NULL;
-static gboolean playing = FALSE;
-
static void
cb_rstto_zoom_fit(GtkToolItem *item, RsttoPictureViewer *viewer);
static void
@@ -36,22 +35,19 @@
cb_rstto_zoom_out(GtkToolItem *item, RsttoPictureViewer *viewer);
static void
-cb_rstto_previous(GtkToolItem *item, RsttoPictureViewer *viewer);
+cb_rstto_previous(GtkToolItem *item, RsttoNavigator *);
static void
-cb_rstto_forward(GtkToolItem *item, RsttoPictureViewer *viewer);
-static void
-cb_rstto_play(GtkToolItem *item, RsttoPictureViewer *viewer);
+cb_rstto_forward(GtkToolItem *item, RsttoNavigator *);
-static gboolean
-play_forward(RsttoPictureViewer *viewer);
-
static void
-cb_rstto_open(GtkToolItem *item, RsttoPictureViewer *viewer);
+cb_rstto_open(GtkToolItem *item, RsttoNavigator *);
int main(int argc, char **argv)
{
ThunarVfsPath *path = NULL;
+ RsttoNavigator *navigator = NULL;
+
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -74,6 +70,8 @@
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
GtkWidget *viewer = rstto_picture_viewer_new();
+ navigator = rstto_navigator_new(RSTTO_PICTURE_VIEWER(viewer));
+
GtkWidget *s_window = gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(s_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
GtkWidget *main_vbox = gtk_vbox_new(0, FALSE);
@@ -84,15 +82,19 @@
GtkWidget *status_bar = gtk_statusbar_new();
GtkWidget *menu_item_file = gtk_menu_item_new_with_mnemonic(_("_File"));
+ GtkWidget *menu_item_quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
+ GtkWidget *menu_file = gtk_menu_new();
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), menu_item_file);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item_file), menu_file);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu_file), menu_item_quit);
+
GtkToolItem *zoom_fit= gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_FIT);
GtkToolItem *zoom_100= gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_100);
GtkToolItem *zoom_out= gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_OUT);
GtkToolItem *zoom_in = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_IN);
- GtkToolItem *forward = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_FORWARD);
- GtkToolItem *play = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PLAY);
- GtkToolItem *previous = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_REWIND);
+ GtkToolItem *forward = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
+ GtkToolItem *previous = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
GtkToolItem *open = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
GtkToolItem *spacer = gtk_tool_item_new();
GtkToolItem *separator = gtk_separator_tool_item_new();
@@ -101,11 +103,11 @@
gtk_tool_item_set_expand(spacer, TRUE);
gtk_tool_item_set_homogeneous(spacer, FALSE);
- rstto_picture_viewer_set_path(RSTTO_PICTURE_VIEWER(viewer), path);
-
gtk_widget_set_size_request(window, 300, 200);
+ rstto_navigator_set_path(navigator, path);
+
gtk_container_add(GTK_CONTAINER(s_window), viewer);
gtk_toolbar_set_orientation(GTK_TOOLBAR(image_tool_bar), GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start(GTK_BOX(main_hbox), image_tool_bar, FALSE, TRUE, 0);
@@ -124,7 +126,6 @@
gtk_toolbar_insert(GTK_TOOLBAR(image_tool_bar), zoom_in, 0);
//gtk_toolbar_insert(GTK_TOOLBAR(image_tool_bar), spacer, 0);
gtk_toolbar_insert(GTK_TOOLBAR(app_tool_bar), forward, 0);
- gtk_toolbar_insert(GTK_TOOLBAR(app_tool_bar), play, 0);
gtk_toolbar_insert(GTK_TOOLBAR(app_tool_bar), previous, 0);
gtk_toolbar_insert(GTK_TOOLBAR(app_tool_bar), separator, 0);
gtk_toolbar_insert(GTK_TOOLBAR(app_tool_bar), open, 0);
@@ -133,11 +134,14 @@
g_signal_connect(G_OBJECT(zoom_100), "clicked", G_CALLBACK(cb_rstto_zoom_100), viewer);
g_signal_connect(G_OBJECT(zoom_in), "clicked", G_CALLBACK(cb_rstto_zoom_in), viewer);
g_signal_connect(G_OBJECT(zoom_out), "clicked", G_CALLBACK(cb_rstto_zoom_out), viewer);
- g_signal_connect(G_OBJECT(forward), "clicked", G_CALLBACK(cb_rstto_forward), viewer);
- g_signal_connect(G_OBJECT(play), "clicked", G_CALLBACK(cb_rstto_play), viewer);
- g_signal_connect(G_OBJECT(previous), "clicked", G_CALLBACK(cb_rstto_previous), viewer);
- g_signal_connect(G_OBJECT(open), "clicked", G_CALLBACK(cb_rstto_open), viewer);
+ g_signal_connect(G_OBJECT(forward), "clicked", G_CALLBACK(cb_rstto_forward), navigator);
+ g_signal_connect(G_OBJECT(previous), "clicked", G_CALLBACK(cb_rstto_previous), navigator);
+ g_signal_connect(G_OBJECT(open), "clicked", G_CALLBACK(cb_rstto_open), navigator);
+ g_signal_connect(G_OBJECT(menu_item_quit), "activate", G_CALLBACK(gtk_main_quit), NULL);
+
+ /* g_signal_connect(G_OBJECT(window), "window-state-event", G_CALLBACK(cb_rstto_fullscreen), viewer);*/
+
gtk_container_add(GTK_CONTAINER(window), main_vbox);
gtk_widget_show_all(window);
@@ -175,7 +179,7 @@
}
static void
-cb_rstto_open(GtkToolItem *item, RsttoPictureViewer *viewer)
+cb_rstto_open(GtkToolItem *item, RsttoNavigator *navigator)
{
GtkWidget *window = gtk_widget_get_toplevel(GTK_WIDGET(item));
@@ -193,45 +197,23 @@
ThunarVfsPath *path = thunar_vfs_path_new(filename, NULL);
- rstto_picture_viewer_set_path(RSTTO_PICTURE_VIEWER(viewer), path);
+ rstto_navigator_set_path(navigator, path);
+ thunar_vfs_path_unref(path);
+
}
gtk_widget_destroy(dialog);
}
static void
-cb_rstto_forward(GtkToolItem *item, RsttoPictureViewer *viewer)
+cb_rstto_forward(GtkToolItem *item, RsttoNavigator *navigator)
{
- rstto_picture_viewer_forward(viewer);
+ rstto_navigator_forward(navigator);
}
static void
-cb_rstto_previous(GtkToolItem *item, RsttoPictureViewer *viewer)
+cb_rstto_previous(GtkToolItem *item, RsttoNavigator *navigator)
{
- rstto_picture_viewer_reverse(viewer);
+ rstto_navigator_back(navigator);
}
-
-static void
-cb_rstto_play(GtkToolItem *item, RsttoPictureViewer *viewer)
-{
- if(playing == TRUE)
- {
- gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(item), GTK_STOCK_MEDIA_PLAY);
- playing = FALSE;
- }
- else
- {
- gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(item), GTK_STOCK_MEDIA_PAUSE);
- g_timeout_add(5000, (GSourceFunc)play_forward, viewer);
- playing = TRUE;
- }
-}
-
-static gboolean
-play_forward(RsttoPictureViewer *viewer)
-{
- if(playing == TRUE)
- cb_rstto_forward(NULL, viewer);
- return playing;
-}
Added: ristretto/trunk/src/navigator.c
===================================================================
--- ristretto/trunk/src/navigator.c (rev 0)
+++ ristretto/trunk/src/navigator.c 2007-07-29 22:40:37 UTC (rev 2931)
@@ -0,0 +1,223 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkmarshal.h>
+#include <string.h>
+
+#include <thunar-vfs/thunar-vfs.h>
+
+#include "picture_viewer.h"
+#include "navigator.h"
+
+static void
+rstto_navigator_init(RsttoNavigator *);
+static void
+rstto_navigator_class_init(RsttoNavigatorClass *);
+static void
+rstto_navigator_dispose(GObject *object);
+
+static GObjectClass *parent_class = NULL;
+
+GType
+rstto_navigator_get_type ()
+{
+ static GType rstto_navigator_type = 0;
+
+ if (!rstto_navigator_type)
+ {
+ static const GTypeInfo rstto_navigator_info =
+ {
+ sizeof (RsttoNavigatorClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_navigator_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoNavigator),
+ 0,
+ (GInstanceInitFunc) rstto_navigator_init,
+ NULL
+ };
+
+ rstto_navigator_type = g_type_register_static (G_TYPE_OBJECT, "RsttoNavigator", &rstto_navigator_info, 0);
+ }
+ return rstto_navigator_type;
+}
+
+static void
+rstto_navigator_init(RsttoNavigator *viewer)
+{
+
+}
+
+static void
+rstto_navigator_class_init(RsttoNavigatorClass *nav_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(nav_class);
+
+ parent_class = g_type_class_peek_parent(nav_class);
+
+ object_class->dispose = rstto_navigator_dispose;
+}
+
+static void
+rstto_navigator_dispose(GObject *object)
+{
+ RsttoNavigator *navigator = RSTTO_NAVIGATOR(object);
+
+ if(navigator->file_list)
+ {
+ g_list_foreach(navigator->file_list, (GFunc)thunar_vfs_info_unref, NULL);
+ navigator->file_list = NULL;
+ }
+}
+
+RsttoNavigator *
+rstto_navigator_new(RsttoPictureViewer *viewer)
+{
+ RsttoNavigator *navigator;
+
+ navigator = g_object_new(RSTTO_TYPE_NAVIGATOR, NULL);
+
+ navigator->viewer = viewer;
+ navigator->icon_theme = gtk_icon_theme_new();
+
+ return navigator;
+}
+
+void
+rstto_navigator_set_path(RsttoNavigator *navigator, ThunarVfsPath *path)
+{
+ if(navigator->path)
+ {
+ thunar_vfs_path_unref(navigator->path);
+ navigator->path = NULL;
+ }
+
+ if(navigator->file_list)
+ {
+ g_list_foreach(navigator->file_list, (GFunc)thunar_vfs_info_unref, NULL);
+ navigator->file_list = NULL;
+ navigator->file_iter = NULL;
+ }
+
+ if(path)
+ {
+ ThunarVfsInfo *info = thunar_vfs_info_new_for_path(path, NULL);
+
+ if(strcmp(thunar_vfs_mime_info_get_name(info->mime_info), "inode/directory"))
+ {
+ navigator->path = thunar_vfs_path_get_parent(path);
+ }
+ else
+ {
+ thunar_vfs_path_ref(path);
+ navigator->path = path;
+ }
+
+ gchar *dir_name = thunar_vfs_path_dup_string(navigator->path);
+
+ GDir *dir = g_dir_open(dir_name, 0, NULL);
+ const gchar *filename = g_dir_read_name(dir);
+ while(filename)
+ {
+ ThunarVfsPath *file_path = thunar_vfs_path_relative(navigator->path, filename);
+ ThunarVfsInfo *file_info = thunar_vfs_info_new_for_path(file_path, NULL);
+
+ navigator->file_list = g_list_prepend(navigator->file_list, file_info);
+
+ if(thunar_vfs_path_equal(path, file_path))
+ {
+ navigator->file_iter = navigator->file_list;
+ }
+
+ thunar_vfs_path_unref(file_path);
+ filename = g_dir_read_name(dir);
+ }
+ g_free(dir_name);
+ if(!navigator->file_iter)
+ {
+ navigator->file_iter = navigator->file_list;
+ }
+ }
+
+ if(navigator->file_iter)
+ {
+ gchar *filename = thunar_vfs_path_dup_string(((ThunarVfsInfo *)navigator->file_iter->data)->path);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(!pixbuf)
+ pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
+
+ rstto_picture_viewer_set_pixbuf(navigator->viewer, pixbuf);
+ if(pixbuf)
+ gdk_pixbuf_unref(pixbuf);
+
+ g_free(filename);
+ }
+}
+
+void
+rstto_navigator_forward (RsttoNavigator *navigator)
+{
+
+ if(navigator->file_iter)
+ navigator->file_iter = g_list_next(navigator->file_iter);
+ if(!navigator->file_iter)
+ navigator->file_iter = g_list_first(navigator->file_list);
+
+ if(navigator->file_iter)
+ {
+ gchar *filename = thunar_vfs_path_dup_string(((ThunarVfsInfo *)navigator->file_iter->data)->path);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(!pixbuf)
+ pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
+
+ rstto_picture_viewer_set_pixbuf(navigator->viewer, pixbuf);
+ if(pixbuf)
+ gdk_pixbuf_unref(pixbuf);
+
+ g_free(filename);
+ }
+}
+
+void
+rstto_navigator_back (RsttoNavigator *navigator)
+{
+ if(navigator->file_iter)
+ navigator->file_iter = g_list_previous(navigator->file_iter);
+ if(!navigator->file_iter)
+ navigator->file_iter = g_list_last(navigator->file_list);
+
+ if(navigator->file_iter)
+ {
+ gchar *filename = thunar_vfs_path_dup_string(((ThunarVfsInfo *)navigator->file_iter->data)->path);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(!pixbuf)
+ {
+ pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
+ rstto_picture_viewer_set_scale(navigator->viewer, 1);
+ }
+
+ rstto_picture_viewer_set_pixbuf(navigator->viewer, pixbuf);
+ if(pixbuf)
+ gdk_pixbuf_unref(pixbuf);
+
+ g_free(filename);
+ }
+}
+
Added: ristretto/trunk/src/navigator.h
===================================================================
--- ristretto/trunk/src/navigator.h (rev 0)
+++ ristretto/trunk/src/navigator.h 2007-07-29 22:40:37 UTC (rev 2931)
@@ -0,0 +1,72 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __RISTRETTO_NAVIGATOR_H__
+#define __RISTRETTO_NAVIGATOR_H__
+
+G_BEGIN_DECLS
+
+#define RSTTO_TYPE_NAVIGATOR rstto_navigator_get_type()
+
+#define RSTTO_NAVIGATOR(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ RSTTO_TYPE_NAVIGATOR, \
+ RsttoNavigator))
+
+#define RSTTO_IS_NAVIGATOR(obj)( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ RSTTO_TYPE_NAVIGATOR))
+
+#define RSTTO_NAVIGATOR_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ RSTTO_TYPE_NAVIGATOR, \
+ RsttoNavigatorClass))
+
+#define RSTTO_IS_NAVIGATOR_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ RSTTO_TYPE_NAVIGATOR()))
+
+typedef struct _RsttoNavigator RsttoNavigator;
+
+struct _RsttoNavigator
+{
+ GObject parent;
+ RsttoPictureViewer *viewer;
+ GtkIconTheme *icon_theme;
+ ThunarVfsPath *path;
+ GList *file_list;
+ GList *file_iter;
+};
+
+typedef struct _RsttoNavigatorClass RsttoNavigatorClass;
+struct _RsttoNavigatorClass
+{
+ GObjectClass parent_class;
+};
+
+GType rstto_navigator_get_type ();
+
+RsttoNavigator *
+rstto_navigator_new (RsttoPictureViewer *viewer);
+
+void rstto_navigator_set_path (RsttoNavigator *navigator,
+ ThunarVfsPath *path);
+void rstto_navigator_forward (RsttoNavigator *navigator);
+void rstto_navigator_back (RsttoNavigator *navigator);
+
+G_END_DECLS
+
+#endif /* __RISTRETTO_NAVIGATOR_H__ */
Modified: ristretto/trunk/src/picture_viewer.c
===================================================================
--- ristretto/trunk/src/picture_viewer.c 2007-07-29 17:56:06 UTC (rev 2930)
+++ ristretto/trunk/src/picture_viewer.c 2007-07-29 22:40:37 UTC (rev 2931)
@@ -19,8 +19,6 @@
#include <gtk/gtkmarshal.h>
#include <string.h>
-#include <thunar-vfs/thunar-vfs.h>
-
#include "picture_viewer.h"
static void
@@ -42,8 +40,6 @@
rstto_picture_viewer_expose(GtkWidget *, GdkEventExpose *);
static void
-rstto_picture_viewer_set_pixbuf(RsttoPictureViewer *viewer, GdkPixbuf *pixbuf);
-static void
rstto_picture_viewer_paint(GtkWidget *widget);
static void
rstto_picture_viewer_refresh(RsttoPictureViewer *viewer);
@@ -367,7 +363,7 @@
return viewer->scale;
}
-static void
+void
rstto_picture_viewer_set_pixbuf(RsttoPictureViewer *viewer, GdkPixbuf *pixbuf)
{
if(viewer->src_pixbuf)
@@ -449,125 +445,3 @@
}
}
-
-void
-rstto_picture_viewer_set_path(RsttoPictureViewer *viewer, ThunarVfsPath *path)
-{
- if(path)
- {
- ThunarVfsInfo *info = thunar_vfs_info_new_for_path(path, NULL);
-
- if(strcmp(thunar_vfs_mime_info_get_name(info->mime_info), "inode/directory"))
- {
- viewer->working_path = thunar_vfs_path_get_parent(path);
- }
- else
- {
- thunar_vfs_path_ref(path);
- viewer->working_path = path;
- }
-
- gchar *dir_name = thunar_vfs_path_dup_string(viewer->working_path);
-
- GDir *dir = g_dir_open(dir_name, 0, NULL);
- const gchar *filename = g_dir_read_name(dir);
- while(filename)
- {
- ThunarVfsPath *file_path = thunar_vfs_path_relative(viewer->working_path, filename);
- ThunarVfsInfo *file_info = thunar_vfs_info_new_for_path(file_path, NULL);
- gchar *file_media = thunar_vfs_mime_info_get_media(file_info->mime_info);
- if(!strcmp(file_media, "image"))
- {
- viewer->file_list = g_list_prepend(viewer->file_list, file_info);
-
- if(thunar_vfs_path_equal(path, file_path))
- {
- viewer->file_iter = viewer->file_list;
- }
- }
- if(file_media)
- g_free(file_media);
- thunar_vfs_path_unref(file_path);
- filename = g_dir_read_name(dir);
- }
- g_free(dir_name);
- if(!viewer->file_iter)
- {
- viewer->file_iter = viewer->file_list;
- }
- }
- else
- {
- thunar_vfs_path_unref(viewer->working_path);
- viewer->working_path = NULL;
-
- g_list_foreach(viewer->file_list, (GFunc)thunar_vfs_info_unref, NULL);
- viewer->file_list = NULL;
- viewer->file_iter = NULL;
- }
-}
-
-void
-rstto_picture_viewer_forward (RsttoPictureViewer *viewer)
-{
- GdkPixbuf *pixbuf = NULL;
- if(viewer->file_iter)
- viewer->file_iter = g_list_next(viewer->file_iter);
- if(!viewer->file_iter)
- viewer->file_iter = g_list_first(viewer->file_list);
-
- while(!pixbuf && viewer->file_iter)
- {
- gchar *filename = thunar_vfs_path_dup_string(((ThunarVfsInfo *)viewer->file_iter->data)->path);
- pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
- if(!pixbuf)
- {
- GList *_file_iter = g_list_next(viewer->file_iter);
- thunar_vfs_info_unref(viewer->file_iter->data);
- viewer->file_list = g_list_remove(viewer->file_list, viewer->file_iter->data);
- if(_file_iter)
- viewer->file_iter = _file_iter;
- else
- viewer->file_iter = viewer->file_list;
- }
- if(pixbuf)
- {
- rstto_picture_viewer_set_pixbuf(RSTTO_PICTURE_VIEWER(viewer), pixbuf);
- g_object_unref(pixbuf);
- }
- g_free(filename);
- }
-}
-
-void
-rstto_picture_viewer_reverse (RsttoPictureViewer *viewer)
-{
- GdkPixbuf *pixbuf = NULL;
-
- if(viewer->file_iter)
- viewer->file_iter = g_list_previous(viewer->file_iter);
- if(!viewer->file_iter)
- viewer->file_iter = g_list_last(viewer->file_list);
-
- while(!pixbuf && viewer->file_iter)
- {
- gchar *filename = thunar_vfs_path_dup_string(((ThunarVfsInfo *)viewer->file_iter->data)->path);
- pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
- if(!pixbuf)
- {
- GList *_file_iter = g_list_previous(viewer->file_iter);
- thunar_vfs_info_unref(viewer->file_iter->data);
- viewer->file_list = g_list_remove(viewer->file_list, viewer->file_iter->data);
- if(_file_iter)
- viewer->file_iter = _file_iter;
- else
- viewer->file_iter = g_list_last(viewer->file_list);
- }
- if(pixbuf)
- {
- rstto_picture_viewer_set_pixbuf(RSTTO_PICTURE_VIEWER(viewer), pixbuf);
- g_object_unref(pixbuf);
- }
- g_free(filename);
- }
-}
Modified: ristretto/trunk/src/picture_viewer.h
===================================================================
--- ristretto/trunk/src/picture_viewer.h 2007-07-29 17:56:06 UTC (rev 2930)
+++ ristretto/trunk/src/picture_viewer.h 2007-07-29 22:40:37 UTC (rev 2931)
@@ -1,6 +1,4 @@
/*
- * Copyright (c) 2006 Stephan Arts <stephan at xfce.org>
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,8 +14,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef __RISTRETTO_PICTURE_VIEWER__
-#define __RISTRETTO_PICTURE_VIEWER__
+#ifndef __RISTRETTO_PICTURE_VIEWER_H__
+#define __RISTRETTO_PICTURE_VIEWER_H__
G_BEGIN_DECLS
@@ -52,9 +50,6 @@
GtkAdjustment *hadjustment;
gdouble scale;
gboolean scale_fts; /* Scale image to fit to screen */
- ThunarVfsPath *working_path;
- GList *file_list;
- GList *file_iter;
void (*cb_value_changed)(GtkAdjustment *, RsttoPictureViewer *);
};
@@ -72,14 +67,12 @@
GType rstto_picture_viewer_get_type();
GtkWidget *rstto_picture_viewer_new();
-void rstto_picture_viewer_set_path(RsttoPictureViewer *viewer, ThunarVfsPath *path);
void rstto_picture_viewer_set_scale(RsttoPictureViewer *viewer, gdouble scale);
gdouble rstto_picture_viewer_get_scale(RsttoPictureViewer *viewer);
gdouble rstto_picture_viewer_fit_scale(RsttoPictureViewer *viewer);
-void rstto_picture_viewer_forward (RsttoPictureViewer *viewer);
-void rstto_picture_viewer_reverse (RsttoPictureViewer *viewer);
+void rstto_picture_viewer_set_pixbuf(RsttoPictureViewer *viewer, GdkPixbuf *pixbuf);
G_END_DECLS
-#endif /* __RISTRETTO_PICTURE_VIEWER__ */
+#endif /* __RISTRETTO_PICTURE_VIEWER_H__ */
More information about the Goodies-commits
mailing list