static void book_shell_content_dispose (GObject *object) { EBookShellContentPrivate *priv; priv = E_BOOK_SHELL_CONTENT (object)->priv; if (priv->paned != NULL) { g_object_unref (priv->paned); priv->paned = NULL; } if (priv->notebook != NULL) { g_object_unref (priv->notebook); priv->notebook = NULL; } if (priv->preview_pane != NULL) { g_object_unref (priv->preview_pane); priv->preview_pane = NULL; } /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); }
static void book_shell_content_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_CURRENT_VIEW: g_value_set_object ( value, e_book_shell_content_get_current_view ( E_BOOK_SHELL_CONTENT (object))); return; case PROP_ORIENTATION: g_value_set_enum ( value, book_shell_content_get_orientation ( E_BOOK_SHELL_CONTENT (object))); return; case PROP_PREVIEW_CONTACT: g_value_set_object ( value, e_book_shell_content_get_preview_contact ( E_BOOK_SHELL_CONTENT (object))); return; case PROP_PREVIEW_VISIBLE: g_value_set_boolean ( value, 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); }
static void book_shell_content_focus_search_results (EShellContent *shell_content) { EBookShellContent *book_shell_content; EAddressbookView *view; book_shell_content = E_BOOK_SHELL_CONTENT (shell_content); view = e_book_shell_content_get_current_view (book_shell_content); gtk_widget_grab_focus (GTK_WIDGET (view)); }
static void book_shell_content_restore_state_cb (EShellWindow *shell_window, EShellView *shell_view, EShellContent *shell_content) { EBookShellContentPrivate *priv; GConfBridge *bridge; GObject *object; const gchar *key; priv = E_BOOK_SHELL_CONTENT (shell_content)->priv; /* Bind GObject properties to GConf keys. */ bridge = gconf_bridge_get (); object = G_OBJECT (priv->paned); key = "/apps/evolution/addressbook/display/hpane_position"; gconf_bridge_bind_property_delayed (bridge, key, object, "hposition"); object = G_OBJECT (priv->paned); key = "/apps/evolution/addressbook/display/vpane_position"; gconf_bridge_bind_property_delayed (bridge, key, object, "vposition"); }
static guint32 book_shell_content_check_state (EShellContent *shell_content) { EBookShellContent *book_shell_content; ESelectionModel *selection_model; EAddressbookModel *model; EAddressbookView *view; gboolean has_email = TRUE; gboolean is_contact_list = TRUE; guint32 state = 0; gint n_selected; struct { EAddressbookModel *model; GList *list; } foreach_data; book_shell_content = E_BOOK_SHELL_CONTENT (shell_content); view = e_book_shell_content_get_current_view (book_shell_content); model = e_addressbook_view_get_model (view); selection_model = e_addressbook_view_get_selection_model (view); n_selected = (selection_model != NULL) ? e_selection_model_selected_count (selection_model) : 0; foreach_data.model = model; foreach_data.list = NULL; if (selection_model != NULL) e_selection_model_foreach ( selection_model, (EForeachFunc) book_shell_content_check_state_foreach, &foreach_data); while (foreach_data.list != NULL) { EContact *contact = E_CONTACT (foreach_data.list->data); GList *email_list; email_list = e_contact_get (contact, E_CONTACT_EMAIL); has_email &= (email_list != NULL); g_list_foreach (email_list, (GFunc) g_free, NULL); g_list_free (email_list); is_contact_list &= (e_contact_get (contact, E_CONTACT_IS_LIST) != NULL); g_object_unref (contact); foreach_data.list = g_list_delete_link ( foreach_data.list, foreach_data.list); } if (n_selected == 1) state |= E_BOOK_SHELL_CONTENT_SELECTION_SINGLE; if (n_selected > 1) state |= E_BOOK_SHELL_CONTENT_SELECTION_MULTIPLE; if (n_selected > 0 && has_email) state |= E_BOOK_SHELL_CONTENT_SELECTION_HAS_EMAIL; if (n_selected == 1 && is_contact_list) state |= E_BOOK_SHELL_CONTENT_SELECTION_IS_CONTACT_LIST; if (e_addressbook_model_can_stop (model)) state |= E_BOOK_SHELL_CONTENT_SOURCE_IS_BUSY; if (e_addressbook_model_get_editable (model)) state |= E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE; return state; }
static void book_shell_content_constructed (GObject *object) { EBookShellContentPrivate *priv; EShellView *shell_view; EShellWindow *shell_window; EShellContent *shell_content; EShellTaskbar *shell_taskbar; GtkWidget *container; GtkWidget *widget; priv = E_BOOK_SHELL_CONTENT (object)->priv; /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (parent_class)->constructed (object); shell_content = E_SHELL_CONTENT (object); shell_view = e_shell_content_get_shell_view (shell_content); shell_window = e_shell_view_get_shell_window (shell_view); shell_taskbar = e_shell_view_get_shell_taskbar (shell_view); container = GTK_WIDGET (object); widget = e_paned_new (GTK_ORIENTATION_VERTICAL); gtk_container_add (GTK_CONTAINER (container), widget); priv->paned = g_object_ref (widget); gtk_widget_show (widget); g_object_bind_property ( object, "orientation", widget, "orientation", G_BINDING_SYNC_CREATE); container = widget; widget = gtk_notebook_new (); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE); priv->notebook = g_object_ref (widget); gtk_widget_show (widget); widget = eab_contact_display_new (); eab_contact_display_set_mode ( EAB_CONTACT_DISPLAY (widget), EAB_CONTACT_DISPLAY_RENDER_NORMAL); eab_contact_display_set_orientation ( 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 ( widget, "send-message", G_CALLBACK (book_shell_content_send_message_cb), object); g_signal_connect_swapped ( widget, "status-message", G_CALLBACK (e_shell_taskbar_set_message), shell_taskbar); widget = e_preview_pane_new (E_WEB_VIEW (widget)); gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE); priv->preview_pane = g_object_ref (widget); gtk_widget_show (widget); g_object_bind_property ( object, "preview-visible", widget, "visible", G_BINDING_SYNC_CREATE); /* Restore pane positions from the last session once * the shell view is fully initialized and visible. */ g_signal_connect ( shell_window, "shell-view-created::addressbook", G_CALLBACK (book_shell_content_restore_state_cb), shell_content); }
static void book_shell_view_execute_search (EShellView *shell_view) { EBookShellViewPrivate *priv; EBookShellContent *book_shell_content; EShellWindow *shell_window; EShellContent *shell_content; EShellSearchbar *searchbar; EActionComboBox *combo_box; GtkRadioAction *action; EAddressbookView *view; EAddressbookModel *model; gchar *query; gchar *temp; gint filter_id, search_id; gchar *search_text = NULL; EFilterRule *advanced_search = NULL; priv = E_BOOK_SHELL_VIEW_GET_PRIVATE (shell_view); if (priv->search_locked) return; shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); book_shell_content = E_BOOK_SHELL_CONTENT (shell_content); searchbar = e_book_shell_content_get_searchbar (book_shell_content); action = GTK_RADIO_ACTION (ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS)); search_id = gtk_radio_action_get_current_value (action); if (search_id == CONTACT_SEARCH_ADVANCED) { query = e_shell_view_get_search_query (shell_view); if (query == NULL) query = g_strdup (""); /* internal pointer, no need to free it */ advanced_search = e_shell_view_get_search_rule (shell_view); } else { const gchar *text; const gchar *format; GString *string; text = e_shell_searchbar_get_search_text (searchbar); if (text == NULL || *text == '\0') { text = ""; search_id = CONTACT_SEARCH_ANY_FIELD_CONTAINS; } search_text = text && *text ? g_strdup (text) : NULL; switch (search_id) { case CONTACT_SEARCH_NAME_CONTAINS: format = "(contains \"full_name\" %s)"; break; case CONTACT_SEARCH_EMAIL_BEGINS_WITH: format = "(beginswith \"email\" %s)"; break; default: text = ""; /* fall through */ case CONTACT_SEARCH_ANY_FIELD_CONTAINS: format = "(contains \"x-evolution-any-field\" %s)"; break; } /* Build the query. */ string = g_string_new (""); e_sexp_encode_string (string, text); query = g_strdup_printf (format, string->str); g_string_free (string, TRUE); } /* Apply selected filter. */ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar); filter_id = e_action_combo_box_get_current_value (combo_box); switch (filter_id) { case CONTACT_FILTER_ANY_CATEGORY: break; case CONTACT_FILTER_UNMATCHED: temp = g_strdup_printf ( "(and (not (and (exists \"CATEGORIES\") " "(not (is \"CATEGORIES\" \"\")))) %s)", query); g_free (query); query = temp; break; default: { GList *categories; const gchar *category_name; categories = e_util_dup_searchable_categories (); category_name = g_list_nth_data (categories, filter_id); temp = g_strdup_printf ( "(and (is \"category_list\" \"%s\") %s)", category_name, query); g_free (query); query = temp; g_list_free_full (categories, g_free); break; } } /* Submit the query. */ view = e_book_shell_content_get_current_view (book_shell_content); model = e_addressbook_view_get_model (view); e_addressbook_model_set_query (model, query); e_addressbook_view_set_search ( view, filter_id, search_id, search_text, advanced_search); g_free (query); g_free (search_text); }