From 6cd216d78dc05e818ce8e9a244be16a7d523d7d3 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Tue, 31 Aug 2010 01:00:11 +0200 Subject: Imported Upstream version 2.31.91 --- src/Makefile.in | 13 +------------ src/book-view.c | 9 +++++++++ src/book.c | 28 ++++++++++++++++++++++++++++ src/book.h | 5 +++++ src/ui.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 100 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Makefile.in b/src/Makefile.in index 0a456c1..946fc6c 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -39,7 +39,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" @@ -90,8 +90,6 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ -CATALOGS = @CATALOGS@ -CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -112,7 +110,6 @@ EXEEXT = @EXEEXT@ GCONF_SCHEMA_CONFIG_SOURCE = @GCONF_SCHEMA_CONFIG_SOURCE@ GCONF_SCHEMA_FILE_DIR = @GCONF_SCHEMA_FILE_DIR@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GREP = @GREP@ HELP_DIR = @HELP_DIR@ @@ -121,8 +118,6 @@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ -INTLLIBS = @INTLLIBS@ INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ INTLTOOL_MERGE = @INTLTOOL_MERGE@ INTLTOOL_PERL = @INTLTOOL_PERL@ @@ -135,9 +130,7 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ -MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ -MSGFMT_OPTS = @MSGFMT_OPTS@ MSGMERGE = @MSGMERGE@ OBJEXT = @OBJEXT@ OMF_DIR = @OMF_DIR@ @@ -152,10 +145,6 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POFILES = @POFILES@ -POSUB = @POSUB@ -PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ -PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SIMPLE_SCAN_CFLAGS = @SIMPLE_SCAN_CFLAGS@ diff --git a/src/book-view.c b/src/book-view.c index 377a156..ac6e32c 100644 --- a/src/book-view.c +++ b/src/book-view.c @@ -235,6 +235,14 @@ remove_cb (Book *book, Page *page, BookView *view) } +static void +reorder_cb (Book *book, BookView *view) +{ + view->priv->need_layout = TRUE; + book_view_redraw (view); +} + + static void clear_cb (Book *book, BookView *view) { @@ -676,6 +684,7 @@ book_view_set_property(GObject *object, /* Watch for new pages */ g_signal_connect (self->priv->book, "page-added", G_CALLBACK (add_cb), self); g_signal_connect (self->priv->book, "page-removed", G_CALLBACK (remove_cb), self); + g_signal_connect (self->priv->book, "reordered", G_CALLBACK (reorder_cb), self); g_signal_connect (self->priv->book, "cleared", G_CALLBACK (clear_cb), self); break; default: diff --git a/src/book.c b/src/book.c index 0e33d8b..b3ec0b6 100644 --- a/src/book.c +++ b/src/book.c @@ -29,6 +29,7 @@ enum { enum { PAGE_ADDED, PAGE_REMOVED, + REORDERED, CLEARED, LAST_SIGNAL }; @@ -91,6 +92,18 @@ book_append_page (Book *book, gint width, gint height, gint dpi, ScanDirection s } +void +book_move_page (Book *book, Page *page, gint location) +{ + book->priv->pages = g_list_remove (book->priv->pages, page); + book->priv->pages = g_list_insert (book->priv->pages, page, location); + + g_signal_emit (book, signals[REORDERED], 0, page); + + book_set_needs_saving (book, TRUE); +} + + void book_delete_page (Book *book, Page *page) { @@ -121,6 +134,13 @@ book_get_page (Book *book, gint page_number) } +gint +book_get_page_index (Book *book, Page *page) +{ + return g_list_index (book->priv->pages, page); +} + + static GFile * make_indexed_file (const gchar *uri, gint i) { @@ -805,6 +825,14 @@ book_class_init (BookClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, page_get_type ()); + signals[REORDERED] = + g_signal_new ("reordered", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (BookClass, reordered), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); signals[CLEARED] = g_signal_new ("cleared", G_TYPE_FROM_CLASS (klass), diff --git a/src/book.h b/src/book.h index 7a336ef..cf82978 100644 --- a/src/book.h +++ b/src/book.h @@ -37,6 +37,7 @@ typedef struct void (*page_added) (Book *book, Page *page); void (*page_removed) (Book *book, Page *page); + void (*reordered) (Book *book); void (*cleared) (Book *book); } BookClass; @@ -49,12 +50,16 @@ void book_clear (Book *book); Page *book_append_page (Book *book, gint width, gint height, gint dpi, ScanDirection orientation); +void book_move_page (Book *book, Page *page, gint location); + void book_delete_page (Book *book, Page *page); gint book_get_n_pages (Book *book); Page *book_get_page (Book *book, gint page_number); +gint book_get_page_index (Book *book, Page *page); + gboolean book_save (Book *book, const gchar *type, GFile *file, GError **error); void book_set_needs_saving (Book *book, gboolean needs_saving); diff --git a/src/ui.c b/src/ui.c index 2bea246..a62123c 100644 --- a/src/ui.c +++ b/src/ui.c @@ -44,6 +44,7 @@ struct SimpleScanPrivate GtkWidget *window, *main_vbox; GtkWidget *info_bar, *info_bar_image, *info_bar_label; GtkWidget *info_bar_close_button, *info_bar_change_scanner_button; + GtkWidget *page_move_left_menuitem, *page_move_right_menuitem; GtkWidget *page_delete_menuitem, *crop_rotate_menuitem; GtkWidget *save_menuitem, *save_as_menuitem, *save_toolbutton; GtkWidget *stop_menuitem, *stop_toolbutton; @@ -852,6 +853,19 @@ preferences_dialog_response_cb (GtkWidget *widget, gint response_id, SimpleScan } +static void +update_page_menu (SimpleScan *ui) +{ + Book *book; + gint index; + + book = book_view_get_book (ui->priv->book_view); + index = book_get_page_index (book, book_view_get_selected (ui->priv->book_view)); + gtk_widget_set_sensitive (ui->priv->page_move_left_menuitem, index > 0); + gtk_widget_set_sensitive (ui->priv->page_move_right_menuitem, index < book_get_n_pages (book) - 1); +} + + static void page_selected_cb (BookView *view, Page *page, SimpleScan *ui) { @@ -861,7 +875,9 @@ page_selected_cb (BookView *view, Page *page, SimpleScan *ui) return; ui->priv->updating_page_menu = TRUE; - + + update_page_menu (ui); + if (page_has_crop (page)) { char *crop_name; @@ -1136,6 +1152,40 @@ crop_rotate_menuitem_activate_cb (GtkWidget *widget, SimpleScan *ui) } +void page_move_left_menuitem_activate_cb (GtkWidget *widget, SimpleScan *ui); +G_MODULE_EXPORT +void +page_move_left_menuitem_activate_cb (GtkWidget *widget, SimpleScan *ui) +{ + Book *book = book_view_get_book (ui->priv->book_view); + Page *page = book_view_get_selected (ui->priv->book_view); + gint index; + + index = book_get_page_index (book, page); + if (index > 0) + book_move_page (book, page, index - 1); + + update_page_menu (ui); +} + + +void page_move_right_menuitem_activate_cb (GtkWidget *widget, SimpleScan *ui); +G_MODULE_EXPORT +void +page_move_right_menuitem_activate_cb (GtkWidget *widget, SimpleScan *ui) +{ + Book *book = book_view_get_book (ui->priv->book_view); + Page *page = book_view_get_selected (ui->priv->book_view); + gint index; + + index = book_get_page_index (book, page); + if (index < book_get_n_pages (book) - 1) + book_move_page (book, page, book_get_page_index (book, page) + 1); + + update_page_menu (ui); +} + + void page_delete_menuitem_activate_cb (GtkWidget *widget, SimpleScan *ui); G_MODULE_EXPORT void @@ -1424,6 +1474,8 @@ page_added_cb (Book *book, Page *page, SimpleScan *ui) ui->priv->default_page_scan_direction = page_get_scan_direction (page); g_signal_connect (page, "size-changed", G_CALLBACK (page_size_changed_cb), ui); g_signal_connect (page, "scan-direction-changed", G_CALLBACK (page_scan_direction_changed_cb), ui); + + update_page_menu (ui); } @@ -1433,6 +1485,8 @@ page_removed_cb (Book *book, Page *page, SimpleScan *ui) /* If this is the last page add a new blank one */ if (book_get_n_pages (ui->priv->book) == 1) add_default_page (ui); + + update_page_menu (ui); } @@ -1529,6 +1583,8 @@ ui_load (SimpleScan *ui) ui->priv->window = GTK_WIDGET (gtk_builder_get_object (builder, "simple_scan_window")); ui->priv->main_vbox = GTK_WIDGET (gtk_builder_get_object (builder, "main_vbox")); + ui->priv->page_move_left_menuitem = GTK_WIDGET (gtk_builder_get_object (builder, "page_move_left_menuitem")); + ui->priv->page_move_right_menuitem = GTK_WIDGET (gtk_builder_get_object (builder, "page_move_right_menuitem")); ui->priv->page_delete_menuitem = GTK_WIDGET (gtk_builder_get_object (builder, "page_delete_menuitem")); ui->priv->crop_rotate_menuitem = GTK_WIDGET (gtk_builder_get_object (builder, "crop_rotate_menuitem")); ui->priv->save_menuitem = GTK_WIDGET (gtk_builder_get_object (builder, "save_menuitem")); -- cgit v1.2.3