bigboard r7346 - in trunk: . bigboard/empathy bigboard/stocks/people
- From: marco svn gnome org
- To: svn-commits-list gnome org
- Subject: bigboard r7346 - in trunk: . bigboard/empathy bigboard/stocks/people
- Date: Tue, 10 Jun 2008 09:43:17 +0000 (UTC)
Author: marco
Date: Tue Jun 10 09:43:17 2008
New Revision: 7346
URL: http://svn.gnome.org/viewvc/bigboard?rev=7346&view=rev
Log:
First go at empathy/bigboard integration.
Added:
trunk/bigboard/empathy/
trunk/bigboard/empathy/Makefile.am
trunk/bigboard/empathy/__init__.py
trunk/bigboard/empathy/_empathy.defs
trunk/bigboard/empathy/_empathy.override
trunk/bigboard/empathy/_empathymodule.c
trunk/bigboard/empathy/bb-empathy.c
trunk/bigboard/empathy/bb-empathy.h
trunk/bigboard/empathy/gen-defs.sh (contents, props changed)
trunk/bigboard/stocks/people/imclient.py
Modified:
trunk/bigboard/stocks/people/PeopleStock.py
trunk/configure.ac
Added: trunk/bigboard/empathy/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/bigboard/empathy/Makefile.am Tue Jun 10 09:43:17 2008
@@ -0,0 +1,32 @@
+INCLUDES = $(PYTHON_INCLUDES) $(EMPATHY_CFLAGS)
+
+_empathydir = $(pyexecdir)/bigboard/empathy
+_empathy_LTLIBRARIES = _empathy.la
+_empathy_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_empathy
+_empathy_la_LIBADD = $(EMPATHY_LIBS)
+_empathy_la_SOURCES = \
+ _empathymodule.c \
+ bb-empathy.h \
+ bb-empathy.c
+
+nodist__empathy_la_SOURCES = _empathy.c
+
+_empathy_PYTHON = \
+ __init__.py
+
+CLEANFILES = _empathy.c
+EXTRA_DIST = \
+ _empathy.defs \
+ _empathy.override \
+ gen-defs.sh
+
+_empathy.c: _empathy.defs _empathy.override
+.defs.c:
+ (cd $(srcdir) \
+ && $(PYGTK_CODEGEN) \
+ --override $*.override \
+ --register $(PYGTK_DEFSDIR)/gtk-types.defs \
+ --prefix py$* $*.defs) > gen-$*.c \
+ && cp gen-$*.c $*.c \
+ && rm -f gen-$*.c
+
Added: trunk/bigboard/empathy/__init__.py
==============================================================================
--- (empty file)
+++ trunk/bigboard/empathy/__init__.py Tue Jun 10 09:43:17 2008
@@ -0,0 +1 @@
+from _empathy import *
Added: trunk/bigboard/empathy/_empathy.defs
==============================================================================
--- (empty file)
+++ trunk/bigboard/empathy/_empathy.defs Tue Jun 10 09:43:17 2008
@@ -0,0 +1,35 @@
+;; -*- scheme -*-
+; object definitions ...
+;; Enumerations and flags ...
+
+
+;; From bb-empathy.h
+
+(define-function is_configured
+ (c-name "bb_empathy_is_configured")
+ (return-type "gboolean")
+)
+
+(define-function configure_accounts
+ (c-name "bb_empathy_configure_accounts")
+ (return-type "GtkWidget*")
+)
+
+(define-function set_online
+ (c-name "bb_empathy_set_online")
+ (return-type "none")
+ (parameters
+ '("gboolean" "online")
+ )
+)
+
+(define-function open_chat_with
+ (c-name "bb_empathy_open_chat_with")
+ (return-type "none")
+ (parameters
+ '("const-char*" "account_id")
+ '("const-char*" "buddy_id")
+ )
+)
+
+
Added: trunk/bigboard/empathy/_empathy.override
==============================================================================
--- (empty file)
+++ trunk/bigboard/empathy/_empathy.override Tue Jun 10 09:43:17 2008
@@ -0,0 +1,13 @@
+/* -*- Mode: C; c-basic-offset: 4 -*- */
+%%
+headers
+#include <Python.h>
+#include <pygobject.h>
+#include <bb-empathy.h>
+%%
+modulename _empathy
+%%
+ignore-glob
+ empathy_init
+ *_get_type
+%%
Added: trunk/bigboard/empathy/_empathymodule.c
==============================================================================
--- (empty file)
+++ trunk/bigboard/empathy/_empathymodule.c Tue Jun 10 09:43:17 2008
@@ -0,0 +1,23 @@
+/* -*- Mode: C; c-basic-offset: 4 -*- */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <pygobject.h>
+
+extern PyMethodDef py_empathy_functions[];
+
+DL_EXPORT(void)
+init_empathy(void)
+{
+ PyObject *m, *d;
+
+ /* perform any initialisation required by the library here */
+ init_pygobject();
+
+ m = Py_InitModule("_empathy", py_empathy_functions);
+ d = PyModule_GetDict(m);
+
+ if (PyErr_Occurred())
+ Py_FatalError("could not initialise module _empathy");
+}
Added: trunk/bigboard/empathy/bb-empathy.c
==============================================================================
--- (empty file)
+++ trunk/bigboard/empathy/bb-empathy.c Tue Jun 10 09:43:17 2008
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2008, Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <libmissioncontrol/mission-control.h>
+#include <libmissioncontrol/mc-account.h>
+#include <libempathy/empathy-dispatcher.h>
+#include <libempathy/empathy-utils.h>
+#include <libempathy-gtk/empathy-accounts-dialog.h>
+
+#include "bb-empathy.h"
+
+gboolean
+bb_empathy_is_configured(void)
+{
+ GList *accounts;
+
+ accounts = mc_accounts_list_by_enabled (TRUE);
+ if (accounts) {
+ mc_accounts_list_free (accounts);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void
+bb_empathy_set_online(gboolean online)
+{
+ MissionControl *mc;
+
+ mc = empathy_mission_control_new();
+ mission_control_set_presence (mc, online ? MC_PRESENCE_AVAILABLE : MC_PRESENCE_OFFLINE,
+ NULL, NULL, NULL);
+ g_object_unref(mc);
+}
+
+GtkWidget *
+bb_empathy_configure_accounts(void)
+{
+ return empathy_accounts_dialog_show(NULL);
+}
+
+void
+bb_empathy_open_chat_with(const char *account_id,
+ const char *buddy_id)
+{
+ McAccount *account;
+
+ account = mc_account_lookup (account_id);
+ if (account != NULL) {
+ empathy_dispatcher_chat_with_contact_id (account, buddy_id);
+ g_object_unref (account);
+ }
+}
Added: trunk/bigboard/empathy/bb-empathy.h
==============================================================================
--- (empty file)
+++ trunk/bigboard/empathy/bb-empathy.h Tue Jun 10 09:43:17 2008
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008, Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __EMPATHY_H__
+#define __EMPATHY_H__
+
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+gboolean bb_empathy_is_configured (void);
+GtkWidget *bb_empathy_configure_accounts (void);
+void bb_empathy_set_online (gboolean online);
+void bb_empathy_open_chat_with (const char *account_id,
+ const char *buddy_id);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_H__ */
+
Added: trunk/bigboard/empathy/gen-defs.sh
==============================================================================
--- (empty file)
+++ trunk/bigboard/empathy/gen-defs.sh Tue Jun 10 09:43:17 2008
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+python `pkg-config pygtk-2.0 --variable=codegendir`/h2def.py \
+ -m bb_empathy bb-empathy.h > _empathy.defs
Modified: trunk/bigboard/stocks/people/PeopleStock.py
==============================================================================
--- trunk/bigboard/stocks/people/PeopleStock.py (original)
+++ trunk/bigboard/stocks/people/PeopleStock.py Tue Jun 10 09:43:17 2008
@@ -3,10 +3,6 @@
import gtk
import hippo
-import gnomevfs
-import dbus
-
-from pyonlinedesktop.fsutil import VfsMonitor
import bigboard
from bigboard.people_tracker import PeopleTracker, sort_people
@@ -16,6 +12,7 @@
import bigboard.libbig as libbig
import bigboard.scroll_ribbon as scroll_ribbon
+import imclient
import peoplebrowser
from peoplewidgets import PersonItem, ProfileItem
@@ -59,24 +56,19 @@
search.enable_search_provider('people',
lambda: PeopleSearchProvider(self.__tracker))
- self.__accounts_config = os.path.expanduser('~/.purple/accounts.xml')
- VfsMonitor('file://' + self.__accounts_config, gnomevfs.MONITOR_FILE,
- lambda: self.__sync_accounts_message())
+ imclient.get_default().connect(
+ 'notify::configured', self.__on_imclient_configured_changed)
self.__sync_accounts_message()
def __sync_accounts_message(self):
- self.__box.set_child_visible(self.__accounts_link,
- not os.path.exists(self.__accounts_config))
+ visible = not imclient.get_default().configured
+ self.__box.set_child_visible(self.__accounts_link, visible)
- def __on_accounts_link_activated(self, link):
- bus = dbus.SessionBus()
+ def __on_imclient_configured_changed(self, client, pspec):
+ self.__sync_accounts_message()
- try:
- obj = bus.get_object('im.pidgin.purple.PurpleService', '/org/freedesktop/od/im')
- im = dbus.Interface(obj, 'org.freedesktop.od.IMClient')
- im.Configure()
- except dbus.DBusException:
- os.spawnlp(os.P_NOWAIT, 'pidgin', 'pidgin')
+ def __on_accounts_link_activated(self, link):
+ imclient.get_default().configure()
def get_authed_content(self, size):
return self.__box
Added: trunk/bigboard/stocks/people/imclient.py
==============================================================================
--- (empty file)
+++ trunk/bigboard/stocks/people/imclient.py Tue Jun 10 09:43:17 2008
@@ -0,0 +1,60 @@
+import dbus
+import os
+import gobject
+import gnomevfs
+
+from bigboard import empathy
+from pyonlinedesktop.fsutil import VfsMonitor
+
+_client = None
+
+class Pidgin(gobject.GObject):
+ def __init__(self):
+ gobject.GObject.__init__(self)
+
+ self.__accounts_config = os.path.expanduser('~/.purple/accounts.xml')
+ VfsMonitor('file://' + self.__accounts_config, gnomevfs.MONITOR_FILE,
+ lambda: self.notify('configured'))
+
+ def get_configured(self):
+ return os.path.exists(self.__accounts_config)
+
+ def configure(self):
+ bus = dbus.SessionBus()
+
+ try:
+ obj = bus.get_object('im.pidgin.purple.PurpleService', '/org/freedesktop/od/im')
+ im = dbus.Interface(obj, 'org.freedesktop.od.IMClient')
+ im.Configure()
+ except dbus.DBusException:
+ os.spawnlp(os.P_NOWAIT, 'pidgin', 'pidgin')
+
+ configured = gobject.property(type=object, getter=get_configured)
+
+class Empathy(gobject.GObject):
+ def __init__(self):
+ gobject.GObject.__init__(self)
+
+ def get_configured(self):
+ return empathy.is_configured()
+
+ def configure(self):
+ dialog = empathy.configure_accounts()
+ dialog.connect('destroy', self.__on_configure_dialog_destroy)
+
+ def __on_configure_dialog_destroy(self, widget):
+ if self.configured:
+ empathy.set_online(True)
+ self.notify('configured')
+
+ configured = gobject.property(type=object, getter=get_configured)
+
+def get_default():
+ global _client
+
+ if _client == None:
+ _client = Pidgin()
+ #_client = Empathy()
+
+ return _client
+
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Tue Jun 10 09:43:17 2008
@@ -165,6 +165,8 @@
AC_SUBST(BIGBOARD_APPLET_LIBS)
AC_SUBST(BIGBOARD_APPLET_CFLAGS)
+PKG_CHECK_MODULES(EMPATHY, libmissioncontrol libempathy libempathy-gtk pygobject-2.0)
+
AC_PATH_PROG(GCONFTOOL, gconftool-2)
AM_GCONF_SOURCE_2
@@ -194,6 +196,7 @@
applet/Makefile
bigboard/Makefile
bigboard/keybinder/Makefile
+bigboard/empathy/Makefile
data/Makefile
scripts/Makefile
po/Makefile.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]