[evolution] Bug 601769 - Print issues in address book



commit 77a05d6576078fbd7495668bfa95b0a66d0c2fa5
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Nov 13 18:18:26 2009 -0500

    Bug 601769 - Print issues in address book

 addressbook/gui/widgets/e-addressbook-view.c    |   20 +++++--
 addressbook/gui/widgets/e-addressbook-view.h    |    1 +
 modules/addressbook/e-book-shell-view-actions.c |   67 +++++++++++++++--------
 modules/addressbook/e-book-shell-view-actions.h |    6 ++-
 modules/addressbook/e-book-shell-view.c         |   12 +++--
 ui/evolution-contacts.ui                        |    6 +-
 6 files changed, 75 insertions(+), 37 deletions(-)
---
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index cfff431..2cb8094 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -944,6 +944,7 @@ e_contact_print_button (EPrintable *printable, GtkPrintOperationAction action)
 
 void
 e_addressbook_view_print (EAddressbookView *view,
+                          gboolean selection_only,
                           GtkPrintOperationAction action)
 {
 	GalView *gal_view;
@@ -954,12 +955,21 @@ e_addressbook_view_print (EAddressbookView *view,
 	view_instance = e_addressbook_view_get_view_instance (view);
 	gal_view = gal_view_instance_get_current_view (view_instance);
 
-	if (GAL_IS_VIEW_MINICARD (gal_view)) {
+	/* Print the selected contacts. */
+	if (GAL_IS_VIEW_MINICARD (gal_view) && selection_only) {
+		GList *contact_list;
+
+		contact_list = e_addressbook_view_get_selected (view);
+		e_contact_print (NULL, NULL, contact_list, action);
+		g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
+		g_list_free (contact_list);
+
+	/* Print the latest query results. */
+	} else if (GAL_IS_VIEW_MINICARD (gal_view)) {
 		EAddressbookModel *model;
 		EBook *book;
 		EBookQuery *query;
 		gchar *query_string;
-		GList *contact_list;
 
 		model = e_addressbook_view_get_model (view);
 		book = e_addressbook_model_get_book (model);
@@ -971,14 +981,12 @@ e_addressbook_view_print (EAddressbookView *view,
 			query = NULL;
 		g_free (query_string);
 
-		contact_list = e_addressbook_view_get_selected (view);
-		e_contact_print (book, query, contact_list, action);
-		g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
-		g_list_free (contact_list);
+		e_contact_print (book, query, NULL, action);
 
 		if (query != NULL)
 			e_book_query_unref (query);
 
+	/* XXX Does this print the entire table or just selected? */
 	} else if (GAL_IS_VIEW_ETABLE (gal_view)) {
 		EPrintable *printable;
 		ETable *table;
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
index ca709ff..28307ad 100644
--- a/addressbook/gui/widgets/e-addressbook-view.h
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -99,6 +99,7 @@ EShellView *	e_addressbook_view_get_shell_view
 ESource *	e_addressbook_view_get_source	(EAddressbookView *view);
 void		e_addressbook_view_view		(EAddressbookView *view);
 void		e_addressbook_view_print	(EAddressbookView *view,
+						 gboolean selection_only,
 						 GtkPrintOperationAction action);
 void		e_addressbook_view_delete_selection
 						(EAddressbookView *view,
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 495aed6..41b88ef 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -130,6 +130,38 @@ action_address_book_new_cb (GtkAction *action,
 }
 
 static void
+action_address_book_print_cb (GtkAction *action,
+                              EBookShellView *book_shell_view)
+{
+	EBookShellContent *book_shell_content;
+	EAddressbookView *view;
+	GtkPrintOperationAction print_action;
+
+	book_shell_content = book_shell_view->priv->book_shell_content;
+	view = e_book_shell_content_get_current_view (book_shell_content);
+	g_return_if_fail (view != NULL);
+
+	print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
+	e_addressbook_view_print (view, FALSE, print_action);
+}
+
+static void
+action_address_book_print_preview_cb (GtkAction *action,
+                                      EBookShellView *book_shell_view)
+{
+	EBookShellContent *book_shell_content;
+	EAddressbookView *view;
+	GtkPrintOperationAction print_action;
+
+	book_shell_content = book_shell_view->priv->book_shell_content;
+	view = e_book_shell_content_get_current_view (book_shell_content);
+	g_return_if_fail (view != NULL);
+
+	print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
+	e_addressbook_view_print (view, FALSE, print_action);
+}
+
+static void
 action_address_book_properties_cb (GtkAction *action,
                                    EBookShellView *book_shell_view)
 {
@@ -494,23 +526,7 @@ action_contact_print_cb (GtkAction *action,
 	g_return_if_fail (view != NULL);
 
 	print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
-	e_addressbook_view_print (view, print_action);
-}
-
-static void
-action_contact_print_preview_cb (GtkAction *action,
-                                 EBookShellView *book_shell_view)
-{
-	EBookShellContent *book_shell_content;
-	EAddressbookView *view;
-	GtkPrintOperationAction print_action;
-
-	book_shell_content = book_shell_view->priv->book_shell_content;
-	view = e_book_shell_content_get_current_view (book_shell_content);
-	g_return_if_fail (view != NULL);
-
-	print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
-	e_addressbook_view_print (view, print_action);
+	e_addressbook_view_print (view, TRUE, print_action);
 }
 
 static void
@@ -1002,19 +1018,26 @@ static GtkRadioActionEntry contact_search_entries[] = {
 
 static GtkActionEntry lockdown_printing_entries[] = {
 
-	{ "contact-print",
+	{ "address-book-print",
 	  GTK_STOCK_PRINT,
 	  NULL,
 	  "<Control>p",
-	  N_("Print selected contacts"),
-	  G_CALLBACK (action_contact_print_cb) },
+	  N_("Print all shown contacts"),
+	  G_CALLBACK (action_address_book_print_cb) },
 
-	{ "contact-print-preview",
+	{ "address-book-print-preview",
 	  GTK_STOCK_PRINT_PREVIEW,
 	  NULL,
 	  NULL,
 	  N_("Preview the contacts to be printed"),
-	  G_CALLBACK (action_contact_print_preview_cb) }
+	  G_CALLBACK (action_address_book_print_preview_cb) },
+
+	{ "contact-print",
+	  GTK_STOCK_PRINT,
+	  NULL,
+	  NULL,
+	  N_("Print selected contacts"),
+	  G_CALLBACK (action_contact_print_cb) }
 };
 
 static EPopupActionEntry lockdown_printing_popup_entries[] = {
diff --git a/modules/addressbook/e-book-shell-view-actions.h b/modules/addressbook/e-book-shell-view-actions.h
index 4c3a18b..e5eea1f 100644
--- a/modules/addressbook/e-book-shell-view-actions.h
+++ b/modules/addressbook/e-book-shell-view-actions.h
@@ -31,6 +31,10 @@
 	E_SHELL_WINDOW_ACTION ((window), "address-book-delete")
 #define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_MOVE(window) \
 	E_SHELL_WINDOW_ACTION ((window), "address-book-move")
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_PRINT(window) \
+	E_SHELL_WINDOW_ACTION ((window), "address-book-print")
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_PRINT_PREVIEW(window) \
+	E_SHELL_WINDOW_ACTION ((window), "address-book-print-preview")
 #define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_PROPERTIES(window) \
 	E_SHELL_WINDOW_ACTION ((window), "address-book-properties")
 #define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_RENAME(window) \
@@ -65,8 +69,6 @@
 	E_SHELL_WINDOW_ACTION ((window), "contact-preview")
 #define E_SHELL_WINDOW_ACTION_CONTACT_PRINT(window) \
 	E_SHELL_WINDOW_ACTION ((window), "contact-print")
-#define E_SHELL_WINDOW_ACTION_CONTACT_PRINT_PREVIEW(window) \
-	E_SHELL_WINDOW_ACTION ((window), "contact-print-preview")
 #define E_SHELL_WINDOW_ACTION_CONTACT_SAVE_AS(window) \
 	E_SHELL_WINDOW_ACTION ((window), "contact-save-as")
 #define E_SHELL_WINDOW_ACTION_CONTACT_SELECT_ALL(window) \
diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c
index 88a503b..d5f160d 100644
--- a/modules/addressbook/e-book-shell-view.c
+++ b/modules/addressbook/e-book-shell-view.c
@@ -287,6 +287,14 @@ book_shell_view_update_actions (EShellView *shell_view)
 	sensitive = has_primary_source && !primary_source_is_system;
 	gtk_action_set_sensitive (action, sensitive);
 
+	action = ACTION (ADDRESS_BOOK_PRINT);
+	sensitive = has_primary_source;
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (ADDRESS_BOOK_PRINT_PREVIEW);
+	sensitive = has_primary_source;
+	gtk_action_set_sensitive (action, sensitive);
+
 	action = ACTION (ADDRESS_BOOK_RENAME);
 	sensitive = has_primary_source;
 	gtk_action_set_sensitive (action, sensitive);
@@ -336,10 +344,6 @@ book_shell_view_update_actions (EShellView *shell_view)
 	sensitive = any_contacts_selected;
 	gtk_action_set_sensitive (action, sensitive);
 
-	action = ACTION (CONTACT_PRINT_PREVIEW);
-	sensitive = any_contacts_selected;
-	gtk_action_set_sensitive (action, sensitive);
-
 	action = ACTION (CONTACT_SAVE_AS);
 	sensitive = any_contacts_selected;
 	gtk_action_set_sensitive (action, sensitive);
diff --git a/ui/evolution-contacts.ui b/ui/evolution-contacts.ui
index 2b95d86..8b04c3b 100644
--- a/ui/evolution-contacts.ui
+++ b/ui/evolution-contacts.ui
@@ -7,8 +7,8 @@
         <menuitem action='address-book-save-as'/>
       </placeholder>
       <placeholder name='print-actions'>
-        <menuitem action='contact-print-preview'/>
-        <menuitem action='contact-print'/>
+        <menuitem action='address-book-print-preview'/>
+        <menuitem action='address-book-print'/>
       </placeholder>
     </menu>
     <menu action='edit-menu'>
@@ -50,7 +50,7 @@
     </placeholder>
   </menubar>
   <toolbar name='main-toolbar'>
-    <toolitem action='contact-print'/>
+    <toolitem action='address-book-print'/>
     <toolitem action='contact-delete'/>
     <toolitem action='address-book-stop'/>
   </toolbar>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]