soylent r55 - trunk/src
- From: treitter svn gnome org
- To: svn-commits-list gnome org
- Subject: soylent r55 - trunk/src
- Date: Sat, 26 Jan 2008 06:12:43 +0000 (GMT)
Author: treitter
Date: Sat Jan 26 06:12:42 2008
New Revision: 55
URL: http://svn.gnome.org/viewvc/soylent?rev=55&view=rev
Log:
rename eds-callbacks.* to a more-appropriate name; clean up the SoylentBrowser e-d-s setup functions a little more
Added:
trunk/src/soylent-browser-eds.c
- copied, changed from r50, /trunk/src/eds-callbacks.c
trunk/src/soylent-browser-eds.h
- copied, changed from r49, /trunk/src/eds-callbacks.h
Removed:
trunk/src/eds-callbacks.c
trunk/src/eds-callbacks.h
Modified:
trunk/src/Makefile.am
trunk/src/soylent-browser-person-view.c
trunk/src/soylent-browser.c
trunk/src/soylent-browser.h
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sat Jan 26 06:12:42 2008
@@ -1,12 +1,12 @@
bin_PROGRAMS = soylent
soylent_SOURCES = \
- eds-callbacks.c \
- eds-callbacks.h \
eds-utils.c \
eds-utils.h \
soylent-browser.c \
soylent-browser.h \
+ soylent-browser-eds.c \
+ soylent-browser-eds.h \
soylent-browser-person-view.c \
soylent-browser-person-view.h \
soylent-defs.c \
Copied: trunk/src/soylent-browser-eds.c (from r50, /trunk/src/eds-callbacks.c)
==============================================================================
--- /trunk/src/eds-callbacks.c (original)
+++ trunk/src/soylent-browser-eds.c Sat Jan 26 06:12:42 2008
@@ -28,11 +28,16 @@
#include <libebook/e-book.h>
#include "eds-utils.h"
-#include "eds-callbacks.h"
#include "soylent-browser.h"
+#include "soylent-browser-eds.h"
#include "soylent-person.h"
#include "soylent.h"
+static void start_query (EBook *book, EBookStatus status, EBookView *book_view,
+ gpointer closure);
+static void opened_book (EBook *book, EBookStatus status, gpointer closure);
+static gboolean open_book (gpointer data);
+
/* Check for groups on the given EContact, and union them with the existing
* browser-visible group list. */
static gboolean
@@ -328,3 +333,227 @@
return retval;
}
+
+/* Set up the main EBookView's signal handlers and initiate it */
+static void
+start_query (EBook *book, EBookStatus status, EBookView *book_view,
+ gpointer closure)
+{
+ gboolean retval = FALSE;
+ SoylentBrowser *browser = NULL;
+
+ g_return_if_fail (closure != NULL);
+ /* FIXME: uncomment once SoylentBrowser is a GObject:
+ g_return_if_fail (SOYLENT_IS_BROWSER (closure));
+ */
+
+ browser = closure;
+
+ if ((status == E_BOOK_ERROR_OK) && book_view && E_IS_BOOK_VIEW (book_view))
+ {
+ gboolean set_book_view_retval = FALSE;
+
+ g_object_ref (book_view);
+
+ /* Connect signals on EBookView */
+ g_signal_connect (G_OBJECT (book_view), "contacts_added",
+ G_CALLBACK (contacts_added_cb), browser);
+ g_signal_connect (G_OBJECT (book_view), "contacts_changed",
+ G_CALLBACK (contacts_changed_cb), browser);
+ g_signal_connect (G_OBJECT (book_view), "contacts_removed",
+ G_CALLBACK (contacts_removed_cb), browser);
+ g_signal_connect (G_OBJECT (book_view), "sequence_complete",
+ G_CALLBACK (contacts_sequence_complete_cb),
+ browser);
+
+ set_book_view_retval = soylent_browser_set_e_book_view (browser,
+ book_view);
+ if (set_book_view_retval)
+ {
+ /* void function, for some bizarre reason */
+ e_book_view_start (book_view);
+
+ retval = TRUE;
+ }
+ }
+ else
+ {
+ g_critical ("Got error %d when getting book view", status);
+ }
+
+ /* XXX: don't actually return, since e_book_async_get_book_view() won't accept
+ * a non-void callback...
+ return retval;
+ */
+}
+
+/* Handler for the just-opened main EBook; initiates the main EBookView setup */
+static void
+opened_book (EBook *book, EBookStatus status, gpointer closure)
+{
+ gboolean retval = FALSE;
+ SoylentBrowser *browser = NULL;
+ EBookQuery *query = NULL;
+
+ g_return_if_fail (closure != NULL);
+ /* FIXME: uncomment once SoylentBrowser is a GObject:
+ g_return_if_fail (SOYLENT_IS_BROWSER (closure));
+ */
+
+ browser = closure;
+
+ if ((status == E_BOOK_ERROR_OK) && book && E_IS_BOOK (book))
+ {
+ gboolean e_book_set_retval = FALSE;
+
+ e_book_set_retval = soylent_browser_set_e_book (browser, book);
+ if (e_book_set_retval)
+ {
+ EBook *e_book = NULL;
+
+ e_book = soylent_browser_get_e_book (browser);
+ if (e_book && E_IS_BOOK (e_book))
+ {
+ query = e_book_query_any_field_contains ("");
+ if (query)
+ {
+ gboolean book_view_retval = FALSE;
+
+ book_view_retval = e_book_async_get_book_view (e_book, query,
+ NULL, -1,
+ start_query,
+ browser);
+ if (book_view_retval)
+ {
+ retval = TRUE;
+ }
+
+ e_book_query_unref (query);
+ }
+ }
+ else
+ {
+ g_critical ("browser has invalid EBook");
+ }
+ }
+ else
+ {
+ g_critical ("failed to set browser's EBookView");
+ }
+ }
+ else
+ {
+ g_critical ("Got error %d when opening book", status);
+ }
+
+ /* XXX: don't actually return, since e_book_async_open() won't accept
+ * a non-void callback...
+ return retval;
+ */
+}
+
+/* Set up EBook post-opening handler */
+static gboolean
+open_book (gpointer data)
+{
+ SoylentBrowser *browser = NULL;
+ EBook *e_book = NULL;
+
+ /* FIXME: once SoylentBrowser is a GObject, also check SOYLENT_IS_BROWSER */
+ if (data)
+ {
+ browser = data;
+
+ e_book = soylent_browser_get_e_book (browser);
+ if (e_book && E_IS_BOOK (e_book))
+ {
+ gboolean open_retval = FALSE;
+
+ open_retval = e_book_async_open (e_book, FALSE, opened_book, browser);
+ if (open_retval)
+ {
+ /* all is well; nothing to do */
+ }
+ else
+ {
+ g_critical ("failed to open browser's EBook");
+ }
+ }
+ else
+ {
+ g_critical ("browser's EBook is invalid");
+ }
+ }
+ else
+ {
+ g_critical ("browser is invalid");
+ }
+
+ /* Return FALSE to only be called once via the g_idle_add() */
+ return FALSE;
+}
+
+/* Instantiate an EBook addressbook and create the SoylentBrowser's contact
+ * lookup table
+ *
+ * Return TRUE for complete success, FALSE otherwise. */
+gboolean
+soylent_browser_eds_ebook_setup (SoylentBrowser *browser)
+{
+ gboolean retval = FALSE;
+ GError *error = NULL;
+ EBook *e_book = NULL;
+
+ g_return_val_if_fail (browser != NULL, retval);
+ /* FIXME: uncomment this once SoylentBrowser is a real GObject
+ g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
+ */
+
+ e_book = e_book_new_system_addressbook (&error);
+ if (e_book && E_IS_BOOK (e_book))
+ {
+ gboolean book_set_retval = FALSE;
+
+ book_set_retval = soylent_browser_set_e_book (browser, e_book);
+ if (book_set_retval)
+ {
+ GHashTable *people_table = NULL;
+
+ people_table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
+ (GDestroyNotify)
+ soylent_person_free);
+ if (people_table)
+ {
+ gboolean table_set_retval = FALSE;
+
+ table_set_retval = soylent_browser_set_people (browser,
+ people_table);
+ if (table_set_retval)
+ {
+ g_idle_add (open_book, browser);
+
+ retval = TRUE;
+ }
+ else
+ {
+ g_critical ("failed to set browser's people lookup table");
+ }
+ }
+ else
+ {
+ g_critical ("failed to create people lookup table");
+ }
+ }
+ else
+ {
+ g_critical ("failed to set browser's EBook");
+ }
+ }
+ else
+ {
+ g_critical ("Could not load system addressbook: %s", error->message);
+ g_error_free (error);
+ }
+
+ return retval;
+}
Copied: trunk/src/soylent-browser-eds.h (from r49, /trunk/src/eds-callbacks.h)
==============================================================================
--- /trunk/src/eds-callbacks.h (original)
+++ trunk/src/soylent-browser-eds.h Sat Jan 26 06:12:42 2008
@@ -22,14 +22,15 @@
*
*/
-#ifndef _EDS_CALLBACKS_H_
-#define _EDS_CALLBACKS_H_
+#ifndef _SOYLENT_BROWSER_EDS_H_
+#define _SOYLENT_BROWSER_EDS_H_
#include <glib.h>
#include <libebook/e-book.h>
#include "eds-utils.h"
#include "soylent-browser.h"
+/* Callbacks */
gboolean contacts_added_cb (EBookView *book_view, const GList *e_contacts,
SoylentBrowser *browser);
gboolean contacts_changed_cb (EBookView *book_view, const GList *e_contacts,
@@ -40,4 +41,7 @@
const GList *e_ids,
SoylentBrowser *browser);
-#endif /* _EDS_CALLBACKS_H_ */
+/* Setup functions */
+gboolean soylent_browser_eds_ebook_setup (SoylentBrowser *browser);
+
+#endif /* _SOYLENT_BROWSER_EDS_H_ */
Modified: trunk/src/soylent-browser-person-view.c
==============================================================================
--- trunk/src/soylent-browser-person-view.c (original)
+++ trunk/src/soylent-browser-person-view.c Sat Jan 26 06:12:42 2008
@@ -20,7 +20,6 @@
*/
#include <string.h>
-#include "eds-callbacks.h"
#include "eds-utils.h"
#include "soylent.h"
#include "soylent-browser.h"
Modified: trunk/src/soylent-browser.c
==============================================================================
--- trunk/src/soylent-browser.c (original)
+++ trunk/src/soylent-browser.c Sat Jan 26 06:12:42 2008
@@ -25,9 +25,9 @@
#include <libempathy/empathy-idle.h>
#include <libempathy-gtk/empathy-status-presets.h>
-#include "eds-callbacks.h"
#include "eds-utils.h"
#include "soylent-browser.h"
+#include "soylent-browser-eds.h"
#include "soylent-person.h"
#include "soylent-utils.h"
@@ -75,7 +75,6 @@
EmpathyContact *empathy_contact);
static gboolean soylent_browser_widget_setup (SoylentBrowser *browser);
-static gboolean soylent_browser_ebook_setup (SoylentBrowser *browser);
static void soylent_browser_dialog_signals_setup (SoylentBrowser *browser);
static void soylent_browser_person_actions_signals_setup
(SoylentBrowser *browser);
@@ -194,7 +193,8 @@
{
gboolean ebook_setup_retval = FALSE;
- ebook_setup_retval = soylent_browser_ebook_setup
+ ebook_setup_retval =
+ soylent_browser_eds_ebook_setup
(browser);
if (ebook_setup_retval)
{
@@ -886,6 +886,63 @@
return retval;
}
+/* Return TRUE for success, FALSE for any failure */
+gboolean
+soylent_browser_set_people (SoylentBrowser *browser, GHashTable *people)
+{
+ gboolean retval = FALSE;
+
+ g_return_val_if_fail (browser != NULL, retval);
+ /* FIXME: uncomment once SoylentBrowser is a GObject:
+ g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
+ */
+ g_return_val_if_fail (people != NULL, retval);
+
+ browser->people = people;
+ retval = TRUE;
+
+ return retval;
+}
+
+/* Return TRUE for success, FALSE for any failure */
+gboolean
+soylent_browser_set_e_book (SoylentBrowser *browser, EBook *e_book)
+{
+ gboolean retval = FALSE;
+
+ g_return_val_if_fail (browser != NULL, retval);
+ /* FIXME: uncomment once SoylentBrowser is a GObject:
+ g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
+ */
+ g_return_val_if_fail (e_book != NULL, retval);
+ g_return_val_if_fail (E_IS_BOOK (e_book), retval);
+
+ browser->book = e_book;
+ retval = TRUE;
+
+ return retval;
+}
+
+/* Return TRUE for success, FALSE for any failure */
+gboolean
+soylent_browser_set_e_book_view (SoylentBrowser *browser,
+ EBookView *e_book_view)
+{
+ gboolean retval = FALSE;
+
+ g_return_val_if_fail (browser != NULL, retval);
+ /* FIXME: uncomment once SoylentBrowser is a GObject:
+ g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
+ */
+ g_return_val_if_fail (e_book_view != NULL, retval);
+ g_return_val_if_fail (E_IS_BOOK_VIEW (e_book_view), retval);
+
+ browser->book_view = e_book_view;
+ retval = TRUE;
+
+ return retval;
+}
+
/* Distribute known, online EmpathyContacts to their matching SoylentPersons.
*
* Return TRUE for success, FALSE for any amount of failure. */
@@ -1426,72 +1483,6 @@
return retval;
}
-/* Set up the main EBookView's signal handlers and initiate it */
-static void
-start_query (EBook *book, EBookStatus status, EBookView *book_view,
- gpointer closure)
-{
- SoylentBrowser *browser = NULL;
-
- browser = closure;
-
- if (status == E_BOOK_ERROR_OK)
- {
- g_object_ref (book_view);
- browser->book_view = book_view;
-
- /* Connect signals on EBookView */
- g_signal_connect (G_OBJECT (book_view), "contacts_added",
- G_CALLBACK (contacts_added_cb), browser);
- g_signal_connect (G_OBJECT (book_view), "contacts_changed",
- G_CALLBACK (contacts_changed_cb), browser);
- g_signal_connect (G_OBJECT (book_view), "contacts_removed",
- G_CALLBACK (contacts_removed_cb), browser);
- g_signal_connect (G_OBJECT (book_view), "sequence_complete",
- G_CALLBACK (contacts_sequence_complete_cb), browser);
-
- e_book_view_start (book_view);
- }
- else
- {
- g_critical ("Got error %d when getting book view", status);
- }
-}
-
-/* Handler for the just-opened main EBook; initiates the main EBookView setup */
-static void
-opened_book (EBook *book, EBookStatus status, gpointer closure)
-{
- SoylentBrowser *browser = NULL;
- EBookQuery *query = NULL;
-
- browser = closure;
-
- if (status == E_BOOK_ERROR_OK)
- {
- query = e_book_query_any_field_contains ("");
- e_book_async_get_book_view (browser->book, query, NULL, -1, start_query,
- browser);
- e_book_query_unref (query);
- }
- else
- {
- g_critical ("Got error %d when opening book", status);
- }
-}
-
-/* Set up EBook post-opening handler */
-static gboolean
-open_book (gpointer data)
-{
- SoylentBrowser *browser = NULL;
-
- browser = data;
- e_book_async_open (browser->book, FALSE, opened_book, browser);
-
- return FALSE;
-}
-
/* Add the given EmpathyContact to the given SoylentPerson in the given
* SoylentBrowser
*
@@ -1587,35 +1578,6 @@
return retval;
}
-/* Instantiate an EBook addressbook and create the SoylentBrowser's contact
- * lookup table
- *
- * Return TRUE for complete success, FALSE otherwise. */
-static gboolean
-soylent_browser_ebook_setup (SoylentBrowser *browser)
-{
- gboolean retval = FALSE;
- GError *error = NULL;
-
- browser->book = e_book_new_system_addressbook (&error);
- if (!browser->book)
- {
- g_critical ("Could not load system addressbook: %s", error->message);
- g_error_free (error);
- }
-
- browser->people = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
- (GDestroyNotify)
- soylent_person_free);
-
- g_idle_add (open_book, browser);
-
- /* FIXME: only set this if everything above succeeds */
- retval = TRUE;
-
- return retval;
-}
-
/* Hook up the dialog box button handlers */
static void
soylent_browser_dialog_signals_setup (SoylentBrowser *browser)
Modified: trunk/src/soylent-browser.h
==============================================================================
--- trunk/src/soylent-browser.h (original)
+++ trunk/src/soylent-browser.h Sat Jan 26 06:12:42 2008
@@ -99,13 +99,13 @@
extern const gchar* MAIL_WIDGET_TYPE_FULL_STRS [MAIL_FIELDS_FULL_NUM];
extern const gchar* MAIL_FIELD_FULL_STRS [MAIL_FIELDS_FULL_NUM];
-EBook* soylent_browser_get_e_book (SoylentBrowser *browser);
-EBookView* soylent_browser_get_e_book_view (SoylentBrowser *browser);
-GHashTable* soylent_browser_get_edits_pending (SoylentBrowser *browser);
-guint soylent_browser_get_icon_height_max (SoylentBrowser *browser);
-guint soylent_browser_get_icon_width_max (SoylentBrowser *browser);
-GHashTable* soylent_browser_get_people (SoylentBrowser *browser);
-GladeXML* soylent_browser_get_widget_tree (SoylentBrowser *browser);
+EBook* soylent_browser_get_e_book (SoylentBrowser *browser);
+EBookView* soylent_browser_get_e_book_view (SoylentBrowser *browser);
+GHashTable* soylent_browser_get_edits_pending (SoylentBrowser *browser);
+guint soylent_browser_get_icon_height_max (SoylentBrowser *browser);
+guint soylent_browser_get_icon_width_max (SoylentBrowser *browser);
+GHashTable* soylent_browser_get_people (SoylentBrowser *browser);
+GladeXML* soylent_browser_get_widget_tree (SoylentBrowser *browser);
EmpathyContactManager* soylent_browser_get_live_manager
(SoylentBrowser *browser);
@@ -120,15 +120,18 @@
SoylentPerson* soylent_browser_get_person_from_e_contact
(SoylentBrowser *browser,
EContact *e_contact);
-GList* soylent_browser_get_selected_people_e_contact
- (SoylentBrowser *browser);
-GList* soylent_browser_get_selected_people_e_uid
- (SoylentBrowser *browser);
+GList* soylent_browser_get_selected_people_e_contact (SoylentBrowser *browser);
+GList* soylent_browser_get_selected_people_e_uid (SoylentBrowser *browser);
SoylentPerson* soylent_browser_get_selected_person (SoylentBrowser *browser);
-EContact* soylent_browser_get_selected_person_e_contact
- (SoylentBrowser *browser);
-gchar* soylent_browser_get_selected_person_e_uid
+EContact* soylent_browser_get_selected_person_e_contact
(SoylentBrowser *browser);
+gchar* soylent_browser_get_selected_person_e_uid (SoylentBrowser *browser);
+
+gboolean soylent_browser_set_people (SoylentBrowser *browser,
+ GHashTable *people);
+gboolean soylent_browser_set_e_book (SoylentBrowser *browser, EBook *e_book);
+gboolean soylent_browser_set_e_book_view (SoylentBrowser *browser,
+ EBookView *e_book_view);
gboolean soylent_browser_live_setup_finish (SoylentBrowser *browser);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]