aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-07-20 18:17:49 +0100
committerConor Curran <conor.curran@canonical.com>2011-07-20 18:17:49 +0100
commitec2941976b938e93fc94cdc4309a221b3194c881 (patch)
tree6b31e639a1ac96070d5f8451231976aefd736323 /src
parent34a5a7289ede2d662d6c64457afcd1c22354d21b (diff)
downloadayatana-indicator-session-ec2941976b938e93fc94cdc4309a221b3194c881.tar.gz
ayatana-indicator-session-ec2941976b938e93fc94cdc4309a221b3194c881.tar.bz2
ayatana-indicator-session-ec2941976b938e93fc94cdc4309a221b3194c881.zip
apt watcher now controlling menuitem with signals and methods in place
Diffstat (limited to 'src')
-rw-r--r--src/apt-watcher.c40
-rw-r--r--src/apt-watcher.h7
-rw-r--r--src/dbus-shared-names.h7
-rw-r--r--src/device-menu-mgr.c23
-rw-r--r--src/device-menu-mgr.h1
-rw-r--r--src/indicator-session.c4
-rw-r--r--src/session-dbus.xml6
-rw-r--r--src/session-service.c5
8 files changed, 66 insertions, 27 deletions
diff --git a/src/apt-watcher.c b/src/apt-watcher.c
index daab2ee..bc012ed 100644
--- a/src/apt-watcher.c
+++ b/src/apt-watcher.c
@@ -17,9 +17,10 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "apt-watcher.h"
#include <gio/gio.h>
+#include "apt-watcher.h"
+
static guint watcher_id;
struct _AptWatcher
@@ -27,6 +28,8 @@ struct _AptWatcher
GObject parent_instance;
GCancellable * proxy_cancel;
GDBusProxy * proxy;
+ SessionDbus* session_dbus_interface;
+ DbusmenuMenuitem* apt_item;
};
static void
@@ -47,6 +50,10 @@ fetch_proxy_cb (GObject * object,
GAsyncResult * res,
gpointer user_data);
+static void apt_watcher_show_apt_dialog (DbusmenuMenuitem* mi,
+ guint timestamp,
+ gchar * type);
+
G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT);
static void
@@ -159,11 +166,16 @@ apt_watcher_get_active_transactions_cb (GObject * obj,
g_error_free (error);
return;
}
-
g_debug ("WE GOT SOME ACTIVE TRANSACTIONS TO EXAMINE, type is %s",
g_variant_get_type_string (result));
- //gchar ** transactions = g_variant_get_strv (result);
+ //g_variant_get (result, "(sas)");
+ gchar* first_param = NULL;
+ gchar ** transactions = NULL;
+ g_variant_get (result, "(sas)", first_param, transactions);
+ g_debug ("And the size is the string array %u",
+ g_strv_length (transactions));
+ g_debug ("first param = %s", first_param);
}
static void
@@ -175,3 +187,25 @@ apt_watcher_on_name_vanished (GDBusConnection *connection,
name,
"the system bus");
}
+
+static void
+apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi,
+ guint timestamp,
+ gchar * type)
+{
+
+}
+
+
+AptWatcher* apt_watcher_new (SessionDbus* session_dbus,
+ DbusmenuMenuitem* item)
+{
+ AptWatcher* watcher = g_object_new (APT_TYPE_WATCHER, NULL);
+ watcher->session_dbus_interface = session_dbus;
+ watcher->apt_item = item;
+ g_signal_connect (G_OBJECT(watcher->apt_item),
+ DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK(apt_watcher_show_apt_dialog), watcher);
+ return watcher;
+}
+
diff --git a/src/apt-watcher.h b/src/apt-watcher.h
index 148072f..cbe0e29 100644
--- a/src/apt-watcher.h
+++ b/src/apt-watcher.h
@@ -21,6 +21,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define _APT_WATCHER_H_
#include <glib-object.h>
+#include <libdbusmenu-glib/client.h>
+#include <libdbusmenu-gtk3/menuitem.h>
+
+#include "session-dbus.h"
G_BEGIN_DECLS
@@ -41,6 +45,9 @@ struct _AptWatcherClass
GType apt_watcher_get_type (void) G_GNUC_CONST;
+AptWatcher* apt_watcher_new (SessionDbus* session_dbus,
+ DbusmenuMenuitem* apt_item);
+
G_END_DECLS
#endif /* _APT_WATCHER_H_ */
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index c4ccd05..f2dbede 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -20,6 +20,13 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+typedef enum {
+ RESTART_NEEDED,
+ UPDATES_IN_PROGRESS,
+ UPDATES_AVAILABLE,
+ UP_TO_DATE,
+}AptState;
+
#ifndef __DBUS_SHARED_NAMES_H__
#define __DBUS_SHARED_NAMES_H__ 1
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c
index a3cea61..9c54ef3 100644
--- a/src/device-menu-mgr.c
+++ b/src/device-menu-mgr.c
@@ -18,6 +18,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libdbusmenu-glib/client.h>
+#include <libdbusmenu-gtk3/menuitem.h>
#include "device-menu-mgr.h"
#include "gconf-helper.h"
@@ -39,6 +40,7 @@ struct _DeviceMenuMgr
GObject parent_instance;
DbusmenuMenuitem* root_item;
SessionDbus* session_dbus_interface;
+ AptWatcher* apt_watcher;
};
static GConfClient *gconf_client = NULL;
@@ -79,16 +81,12 @@ static void machine_sleep_with_context (DeviceMenuMgr* self,
gchar* type);
static void show_system_settings_with_context (DbusmenuMenuitem * mi,
guint timestamp,
- gchar * type);
-static void show_apt_dialog (DbusmenuMenuitem* mi,
- guint timestamp,
- gchar * type);
+ gchar * type);
static void
machine_sleep_from_hibernate (DbusmenuMenuitem * mi,
guint timestamp,
gpointer userdata);
-static AptWatcher* watcher = NULL;
/*static void
machine_sleep_from_suspend (DbusmenuMenuitem * mi,
guint timestamp,
@@ -99,11 +97,11 @@ G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT);
static void
device_menu_mgr_init (DeviceMenuMgr *self)
{
+ self->apt_watcher = NULL;
self->root_item = dbusmenu_menuitem_new ();
setup_restart_watch(self);
setup_up(self);
g_idle_add(lock_screen_setup, NULL);
-
}
static void
@@ -120,7 +118,6 @@ device_menu_mgr_class_init (DeviceMenuMgrClass *klass)
GObjectClass* object_class = G_OBJECT_CLASS (klass);
//GObjectClass* parent_class = G_OBJECT_CLASS (klass);
object_class->finalize = device_menu_mgr_finalize;
- watcher = g_object_new (APT_TYPE_WATCHER, NULL);
}
// TODO
@@ -438,11 +435,6 @@ show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type)
}
static void
-show_apt_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type)
-{
-}
-
-static void
show_system_settings_with_context (DbusmenuMenuitem * mi,
guint timestamp,
gchar * type)
@@ -513,9 +505,6 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self)
dbusmenu_menuitem_property_set (software_updates_menuitem,
DBUSMENU_MENUITEM_PROP_LABEL,
_("Software Up to Date"));
- g_signal_connect (G_OBJECT(login_settings_menuitem),
- DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK(show_apt_dialog), NULL);
dbusmenu_menuitem_child_add_position(self->root_item,
software_updates_menuitem,
4);
@@ -870,6 +859,8 @@ DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus)
{
DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL);
device_mgr->session_dbus_interface = session_dbus;
- device_menu_mgr_build_static_items (device_mgr);
+ device_menu_mgr_build_static_items (device_mgr);
+ device_mgr->apt_watcher = apt_watcher_new (session_dbus,
+ software_updates_menuitem);
return device_mgr;
}
diff --git a/src/device-menu-mgr.h b/src/device-menu-mgr.h
index caa9aee..503b36a 100644
--- a/src/device-menu-mgr.h
+++ b/src/device-menu-mgr.h
@@ -22,7 +22,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define _DEVICE_MENU_MGR_H_
#include <glib-object.h>
-#include <libdbusmenu-gtk3/menuitem.h>
#include "session-dbus.h"
diff --git a/src/indicator-session.c b/src/indicator-session.c
index 068ffef..df8cbdf 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -6,7 +6,8 @@ Copyright 2009 Canonical Ltd.
Authors:
Ted Gould <ted@canonical.com>
-
+ Conor Curran <conor.curran@canonical.com>
+
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
@@ -20,7 +21,6 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-//TODO - remember to reinsert Ted's comments.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/src/session-dbus.xml b/src/session-dbus.xml
index f496ff1..c42aca8 100644
--- a/src/session-dbus.xml
+++ b/src/session-dbus.xml
@@ -8,11 +8,17 @@
<method name="GetUserMenuVisibility">
<arg name="update" direction="out" type="b"/>
</method>
+ <method name="IsUpdateNeeded">
+ <arg name="update" direction="out" type="b"/>
+ </method>
<signal name="UserRealNameUpdated">
<arg name="name" type="s"/>
</signal>
<signal name="UserMenuIsVisible">
<arg name="update" type="b"/>
</signal>
+ <signal name="RestartNeeded">
+ <arg name="name" type="s"/>
+ </signal>
</interface>
</node>
diff --git a/src/session-service.c b/src/session-service.c
index e043d65..22552dc 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -52,12 +52,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "users-service-dbus.h"
#include "user-menu-mgr.h"
#include "device-menu-mgr.h"
-
-//#include "gconf-helper.h"
-
#include "session-dbus.h"
-//#include "lock-helper.h"
-
typedef struct _ActivateData ActivateData;
struct _ActivateData