diff options
author | Dan Vrátil <dvratil@redhat.com> | 2011-06-02 22:57:23 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2011-06-02 22:57:23 +0800 |
commit | 6dc3c692264a04470d842400e909034c3633bdae (patch) | |
tree | 709170ee01d9a95e8806c21607fd8d46dcb01772 /modules | |
parent | 2971a9ce87c365808901941b50be1a897620e5b5 (diff) | |
download | gsoc2013-evolution-6dc3c692264a04470d842400e909034c3633bdae.tar.gz gsoc2013-evolution-6dc3c692264a04470d842400e909034c3633bdae.tar.zst gsoc2013-evolution-6dc3c692264a04470d842400e909034c3633bdae.zip |
Bug #642557 - Display maps in contact preview
Diffstat (limited to 'modules')
-rw-r--r-- | modules/addressbook/Makefile.am | 3 | ||||
-rw-r--r-- | modules/addressbook/apps_evolution_addressbook.schemas.in | 12 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-content.c | 56 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-content.h | 5 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-actions.c | 164 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-actions.h | 6 |
6 files changed, 243 insertions, 3 deletions
diff --git a/modules/addressbook/Makefile.am b/modules/addressbook/Makefile.am index 35cf16aa7c..b6dec30b0a 100644 --- a/modules/addressbook/Makefile.am +++ b/modules/addressbook/Makefile.am @@ -21,7 +21,8 @@ libevolution_module_addressbook_la_CPPFLAGS = \ -DPREFIX=\""$(prefix)"\" \ $(GNOME_PLATFORM_CFLAGS) \ $(EVOLUTION_ADDRESSBOOK_CFLAGS) \ - $(LDAP_CFLAGS) + $(LDAP_CFLAGS) \ + $(CHAMPLAIN_CFLAGS) libevolution_module_addressbook_la_SOURCES = \ evolution-module-addressbook.c \ diff --git a/modules/addressbook/apps_evolution_addressbook.schemas.in b/modules/addressbook/apps_evolution_addressbook.schemas.in index 03e6006527..e13337e82c 100644 --- a/modules/addressbook/apps_evolution_addressbook.schemas.in +++ b/modules/addressbook/apps_evolution_addressbook.schemas.in @@ -125,6 +125,18 @@ <long>Whether to show the preview pane.</long> </locale> </schema> + + <schema> + <key>/schemas/apps/evolution/addressbook/display/preview_show_maps</key> + <applyto>/apps/evolution/addressbook/display/preview_show_maps</applyto> + <owner>evolution-addressbook</owner> + <type>bool</type> + <default>false</default> + <locale name="C"> + <short>Show maps</short> + <long>Whether to show maps in preview pane.</long> + </locale> + </schema> </schemalist> </gconfschemafile> diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c index bb0c4a0a4d..a86d101e1b 100644 --- a/modules/addressbook/e-book-shell-content.c +++ b/modules/addressbook/e-book-shell-content.c @@ -41,6 +41,7 @@ struct _EBookShellContentPrivate { GtkOrientation orientation; + gboolean preview_show_maps; guint preview_visible : 1; }; @@ -49,7 +50,8 @@ enum { PROP_CURRENT_VIEW, PROP_ORIENTATION, PROP_PREVIEW_CONTACT, - PROP_PREVIEW_VISIBLE + PROP_PREVIEW_VISIBLE, + PROP_PREVIEW_SHOW_MAPS }; static gpointer parent_class; @@ -144,6 +146,12 @@ book_shell_content_set_property (GObject *object, E_BOOK_SHELL_CONTENT (object), g_value_get_boolean (value)); return; + + case PROP_PREVIEW_SHOW_MAPS: + e_book_shell_content_set_preview_show_maps ( + E_BOOK_SHELL_CONTENT (object), + g_value_get_boolean (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -183,6 +191,13 @@ book_shell_content_get_property (GObject *object, e_book_shell_content_get_preview_visible ( E_BOOK_SHELL_CONTENT (object))); return; + + case PROP_PREVIEW_SHOW_MAPS: + g_value_set_boolean ( + value, + e_book_shell_content_get_preview_show_maps ( + E_BOOK_SHELL_CONTENT (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -265,11 +280,20 @@ book_shell_content_constructed (GObject *object) EAB_CONTACT_DISPLAY (widget), priv->orientation); + eab_contact_display_set_show_maps ( + EAB_CONTACT_DISPLAY (widget), + priv->preview_show_maps); + g_object_bind_property ( object, "orientation", widget, "orientation", G_BINDING_SYNC_CREATE); + g_object_bind_property ( + object, "preview-show-maps", + widget, "show-maps", + G_BINDING_SYNC_CREATE); + gtk_widget_show (widget); g_signal_connect_swapped ( @@ -448,6 +472,16 @@ book_shell_content_class_init (EBookShellContentClass *class) g_object_class_override_property ( object_class, PROP_ORIENTATION, "orientation"); + + g_object_class_install_property ( + object_class, + PROP_PREVIEW_SHOW_MAPS, + g_param_spec_boolean ( + "preview-show-maps", + NULL, + NULL, + FALSE, + G_PARAM_READWRITE)); } static void @@ -686,6 +720,26 @@ e_book_shell_content_set_preview_visible (EBookShellContent *book_shell_content, g_object_notify (G_OBJECT (book_shell_content), "preview-visible"); } +gboolean +e_book_shell_content_get_preview_show_maps (EBookShellContent *book_shell_content) +{ + g_return_val_if_fail ( + E_IS_BOOK_SHELL_CONTENT (book_shell_content), FALSE); + + return book_shell_content->priv->preview_show_maps; +} + +void +e_book_shell_content_set_preview_show_maps (EBookShellContent *book_shell_content, + gboolean show_maps) +{ + g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content)); + + book_shell_content->priv->preview_show_maps = show_maps; + + g_object_notify (G_OBJECT (book_shell_content), "preview-show-maps"); +} + EShellSearchbar * e_book_shell_content_get_searchbar (EBookShellContent *book_shell_content) { diff --git a/modules/addressbook/e-book-shell-content.h b/modules/addressbook/e-book-shell-content.h index 0876ec968c..28fef270bd 100644 --- a/modules/addressbook/e-book-shell-content.h +++ b/modules/addressbook/e-book-shell-content.h @@ -105,6 +105,11 @@ gboolean e_book_shell_content_get_preview_visible void e_book_shell_content_set_preview_visible (EBookShellContent *book_shell_content, gboolean preview_visible); +gboolean e_book_shell_content_get_preview_show_maps + (EBookShellContent *book_shell_content); +void e_book_shell_content_set_preview_show_maps + (EBookShellContent *book_shell_content, + gboolean show_maps); EShellSearchbar * e_book_shell_content_get_searchbar (EBookShellContent *book_shell_content); diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c index b8e6c4f21c..5116232161 100644 --- a/modules/addressbook/e-book-shell-view-actions.c +++ b/modules/addressbook/e-book-shell-view-actions.c @@ -29,6 +29,10 @@ #include <e-util/e-util.h> #include <filter/e-filter-rule.h> +#ifdef WITH_CONTACT_MAPS +#include <widgets/misc/e-contact-map-window.h> +#endif + #include <addressbook-config.h> static void @@ -211,6 +215,118 @@ action_address_book_properties_cb (GtkAction *action, gtk_window_present (GTK_WINDOW (closure->editor)); } +#ifdef WITH_CONTACT_MAPS +static void +contact_editor_contact_modified_cb (EABEditor *editor, + const GError *error, + EContact *contact, + gpointer user_data) +{ + EContactMapWindow *window = user_data; + EContactMap *map; + const gchar *contact_uid; + + if (error) { + g_warning ("Error modifying contact: %s", error->message); + return; + } + + map = e_contact_map_window_get_map (window); + + contact_uid = e_contact_get_const (contact, E_CONTACT_UID); + + e_contact_map_remove_contact (map, contact_uid); + e_contact_map_add_contact (map, contact); +} + +static void +map_window_show_contact_editor_cb (EContactMapWindow *window, + const gchar *contact_uid, + gpointer user_data) +{ + EShell *shell = e_shell_get_default(); + EBookShellView *book_shell_view = user_data; + EBookShellSidebar *book_shell_sidebar; + ESource *source; + ESourceSelector *selector; + EBook *book; + EContact *contact; + EABEditor *editor; + GError *error = NULL; + + book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; + selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); + source = e_source_selector_get_primary_selection (selector); + + g_return_if_fail (source != NULL); + book = e_book_new (source, &error); + if (error) { + g_warning ("Error loading addressbook: %s", error->message); + g_error_free (error); + g_object_unref (book); + return; + } + + e_book_get_contact (book, contact_uid, &contact, &error); + if (error) { + g_warning ("Error getting contact from addressbook: %s", error->message); + g_error_free (error); + g_object_unref (book); + return; + } + + editor = e_contact_editor_new (shell, book, contact, FALSE, TRUE); + + g_signal_connect (editor, "contact-modified", + G_CALLBACK (contact_editor_contact_modified_cb), window); + g_signal_connect_swapped (editor, "editor-closed", + G_CALLBACK (g_object_unref), editor); + + eab_editor_show (editor); + g_object_unref (book); +} +#endif + +/* We need this function to he defined all the time. */ +static void +action_address_book_map_cb (GtkAction *action, + EBookShellView *book_shell_view) +{ +#ifdef WITH_CONTACT_MAPS + EContactMapWindow *map_window; + EBookShellSidebar *book_shell_sidebar; + ESource *source; + ESourceSelector *selector; + EBook *book; + GError *error = NULL; + + book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; + selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); + source = e_source_selector_get_primary_selection (selector); + + g_return_if_fail (source != NULL); + book = e_book_new (source, &error); + if (error != NULL) { + g_warning ("Error loading addressbook: %s", error->message); + g_error_free (error); + return; + } + + map_window = e_contact_map_window_new (); + e_contact_map_window_load_addressbook (map_window, book); + + /* Free the map_window automatically when it is closed */ + g_signal_connect_swapped (GTK_WIDGET (map_window), "hide", + G_CALLBACK (gtk_widget_destroy), GTK_WIDGET (map_window)); + g_signal_connect (map_window, "show-contact-editor", + G_CALLBACK (map_window_show_contact_editor_cb), book_shell_view); + + gtk_widget_show_all (GTK_WIDGET (map_window)); + + g_object_unref (book); +#endif +} + static void action_address_book_rename_cb (GtkAction *action, EBookShellView *book_shell_view) @@ -503,6 +619,18 @@ action_contact_preview_cb (GtkToggleAction *action, } static void +action_contact_preview_show_maps_cb (GtkToggleAction *action, + EBookShellView *book_shell_view) +{ + EBookShellContent *book_shell_content; + gboolean show_maps; + + book_shell_content = book_shell_view->priv->book_shell_content; + show_maps = gtk_toggle_action_get_active (action); + e_book_shell_content_set_preview_show_maps (book_shell_content, show_maps); +} + +static void action_contact_print_cb (GtkAction *action, EBookShellView *book_shell_view) { @@ -714,6 +842,13 @@ static GtkActionEntry contact_entries[] = { N_("Show properties of the selected address book"), G_CALLBACK (action_address_book_properties_cb) }, + { "address-book-map", + NULL, + N_("Address Book _Map"), + NULL, + N_("Show map with all contacts from selected address book"), + G_CALLBACK (action_address_book_map_cb) }, + { "address-book-rename", NULL, N_("_Rename..."), @@ -818,6 +953,10 @@ static EPopupActionEntry contact_popup_entries[] = { N_("_Properties"), "address-book-properties" }, + { "address-book-popup-map", + N_("Addressbook Map"), + "address-book-map" }, + { "address-book-popup-rename", NULL, "address-book-rename" }, @@ -851,7 +990,15 @@ static GtkToggleActionEntry contact_toggle_entries[] = { "<Control>m", N_("Show contact preview window"), G_CALLBACK (action_contact_preview_cb), - TRUE } + TRUE }, + + { "contact-preview-show-maps", + NULL, + N_("Show _Maps"), + NULL, + N_("Show maps in contact preview window"), + G_CALLBACK (action_contact_preview_show_maps_cb), + FALSE } }; static GtkRadioActionEntry contact_view_entries[] = { @@ -1071,6 +1218,10 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) key = "/apps/evolution/addressbook/display/layout"; gconf_bridge_bind_property (bridge, key, object, "current-value"); + object = G_OBJECT (ACTION (CONTACT_PREVIEW_SHOW_MAPS)); + key = "/apps/evolution/addressbook/display/preview_show_maps"; + gconf_bridge_bind_property (bridge, key, object, "active"); + /* Fine tuning. */ g_signal_connect ( @@ -1087,9 +1238,20 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) ACTION (CONTACT_VIEW_VERTICAL), "sensitive", G_BINDING_SYNC_CREATE); + g_object_bind_property ( + ACTION (CONTACT_PREVIEW), "active", + ACTION (CONTACT_PREVIEW_SHOW_MAPS), "sensitive", + G_BINDING_SYNC_CREATE); + e_web_view_set_open_proxy (web_view, ACTION (CONTACT_OPEN)); e_web_view_set_print_proxy (web_view, ACTION (CONTACT_PRINT)); e_web_view_set_save_as_proxy (web_view, ACTION (CONTACT_SAVE_AS)); + +#ifndef WITH_CONTACT_MAPS + gtk_action_set_visible (ACTION (CONTACT_PREVIEW_SHOW_MAPS), FALSE); + gtk_action_set_visible (ACTION (ADDRESS_BOOK_MAP), FALSE); + gtk_action_set_visible (ACTION (ADDRESS_BOOK_POPUP_MAP), FALSE); +#endif } void diff --git a/modules/addressbook/e-book-shell-view-actions.h b/modules/addressbook/e-book-shell-view-actions.h index ef40dd169f..87eeaa8b17 100644 --- a/modules/addressbook/e-book-shell-view-actions.h +++ b/modules/addressbook/e-book-shell-view-actions.h @@ -43,6 +43,10 @@ E_SHELL_WINDOW_ACTION ((window), "address-book-save-as") #define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_STOP(window) \ E_SHELL_WINDOW_ACTION ((window), "address-book-stop") +#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_MAP(window) \ + E_SHELL_WINDOW_ACTION ((window), "address-book-map") +#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_POPUP_MAP(window) \ + E_SHELL_WINDOW_ACTION ((window), "address-book-popup-map") /* Contact Actions */ #define E_SHELL_WINDOW_ACTION_CONTACT_COPY(window) \ @@ -63,6 +67,8 @@ E_SHELL_WINDOW_ACTION ((window), "contact-open") #define E_SHELL_WINDOW_ACTION_CONTACT_PREVIEW(window) \ E_SHELL_WINDOW_ACTION ((window), "contact-preview") +#define E_SHELL_WINDOW_ACTION_CONTACT_PREVIEW_SHOW_MAPS(window) \ + E_SHELL_WINDOW_ACTION ((window), "contact-preview-show-maps") #define E_SHELL_WINDOW_ACTION_CONTACT_PRINT(window) \ E_SHELL_WINDOW_ACTION ((window), "contact-print") #define E_SHELL_WINDOW_ACTION_CONTACT_SAVE_AS(window) \ |