[gnome-main-menu] main-menu: update hard-drive-status-tile.c migrate to GSettings use GDesktopAppInfo instead of Gnome



commit c03c7acbbf50138f921892e41078123204eb1ffa
Author: Stefano Karapetsas <stefano karapetsas com>
Date:   Sun Dec 9 18:50:56 2012 +0100

    main-menu: update hard-drive-status-tile.c
    migrate to GSettings
    use GDesktopAppInfo instead of GnomeDesktopItem
    use MATE system monitor instead of GNOME system monitor

 main-menu/src/hard-drive-status-tile.c |   58 +++++++++++++------------------
 1 files changed, 24 insertions(+), 34 deletions(-)
---
diff --git a/main-menu/src/hard-drive-status-tile.c b/main-menu/src/hard-drive-status-tile.c
index 16026dc..d73cc6b 100644
--- a/main-menu/src/hard-drive-status-tile.c
+++ b/main-menu/src/hard-drive-status-tile.c
@@ -23,16 +23,15 @@
 #include <string.h>
 #include <sys/statvfs.h>
 #include <glib/gi18n.h>
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
 
 #define GIGA (1024 * 1024 * 1024)
 #define MEGA (1024 * 1024)
 #define KILO (1024)
 
-#define TIMEOUT_KEY_DIR "/apps/procman"
-#define TIMEOUT_KEY     "/apps/procman/disks_interval"
-
-#define SYSTEM_MONITOR_GCONF_KEY "/desktop/gnome/applications/main-menu/system_monitor"
+#define SYSTEM_MONITOR_SCHEMA "org.mate.system-monitor"
+#define TIMEOUT_KEY           "disks-interval"
 
 G_DEFINE_TYPE (HardDriveStatusTile, hard_drive_status_tile, NAMEPLATE_TILE_TYPE)
 
@@ -51,7 +50,7 @@ static void tile_show_event_cb (GtkWidget *, gpointer);
 
 typedef struct
 {
-	GConfClient *gconf;
+	GSettings *settings;
 	
 	gdouble capacity_bytes;
 	gdouble available_bytes;	
@@ -138,8 +137,7 @@ hard_drive_status_tile_init (HardDriveStatusTile * tile)
 {
 	HardDriveStatusTilePrivate *priv = HARD_DRIVE_STATUS_TILE_GET_PRIVATE (tile);
 
-	priv->gconf = gconf_client_get_default ();
-	gconf_client_add_dir (priv->gconf, TIMEOUT_KEY_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL);
+	priv->settings = g_settings_new (SYSTEM_MONITOR_SCHEMA);
 }
 
 static void
@@ -147,7 +145,8 @@ hard_drive_status_tile_finalize (GObject * g_object)
 {
 	HardDriveStatusTilePrivate *priv = HARD_DRIVE_STATUS_TILE_GET_PRIVATE (HARD_DRIVE_STATUS_TILE (g_object));
 
-	g_object_unref (priv->gconf);
+	if (priv->settings)
+		g_object_unref (priv->settings);
 
 	(*G_OBJECT_CLASS (hard_drive_status_tile_parent_class)->finalize) (g_object);
 }
@@ -161,12 +160,6 @@ hard_drive_status_tile_destroy (GtkObject * gtk_object)
 	if (!priv)
 		return;
 
-	if (priv->timeout_notify)
-	{
-		gconf_client_notify_remove (priv->gconf, priv->timeout_notify);
-		priv->timeout_notify = 0;
-	}
-
 	if (priv->update_timeout)
 	{
 		g_source_remove (priv->update_timeout);
@@ -260,7 +253,7 @@ timeout_cb (gpointer user_data)
 }
 
 static void
-timeout_changed_cb (GConfClient * client, guint id, GConfEntry * entry, gpointer user_data)
+timeout_changed_cb (GSettings * settings, gchar * key, gpointer user_data)
 {
 	HardDriveStatusTile *tile = HARD_DRIVE_STATUS_TILE (user_data);
 	HardDriveStatusTilePrivate *priv = HARD_DRIVE_STATUS_TILE_GET_PRIVATE (tile);
@@ -270,7 +263,7 @@ timeout_changed_cb (GConfClient * client, guint id, GConfEntry * entry, gpointer
 	if (priv->update_timeout)
 		g_source_remove (priv->update_timeout);
 
-	timeout = gconf_value_get_int (gconf_entry_get_value (entry));
+	timeout = g_settings_get_int (settings, TIMEOUT_KEY);
 	timeout = MAX (timeout, 1000);
 
 	priv->update_timeout = g_timeout_add (timeout, timeout_cb, tile);
@@ -284,7 +277,7 @@ tile_hide_event_cb (GtkWidget * widget, gpointer user_data)
 
 	if (priv->timeout_notify)
 	{
-		gconf_client_notify_remove (priv->gconf, priv->timeout_notify);
+		g_signal_handler_disconnect (priv->settings, priv->timeout_notify);
 		priv->timeout_notify = 0;
 	}
 
@@ -308,12 +301,11 @@ tile_show_event_cb (GtkWidget * widget, gpointer user_data)
 	{
 		int timeout;
 
-		timeout = gconf_client_get_int (priv->gconf, TIMEOUT_KEY, NULL);
+		timeout = g_settings_get_int (priv->settings, TIMEOUT_KEY);
 		timeout = MAX (timeout, 1000);
 
 		priv->timeout_notify =
-			gconf_client_notify_add (priv->gconf, TIMEOUT_KEY, timeout_changed_cb, tile,
-			NULL, NULL);
+			g_signal_connect (priv->settings, TIMEOUT_KEY, timeout_changed_cb, tile);
 
 		priv->update_timeout = g_timeout_add (timeout, timeout_cb, tile);
 	}
@@ -322,20 +314,18 @@ tile_show_event_cb (GtkWidget * widget, gpointer user_data)
 static void
 open_hard_drive_tile (Tile * tile, TileEvent * event, TileAction * action)
 {
-	GnomeDesktopItem *ditem;
-	gchar *fb_ditem_id;
-	
-
-	fb_ditem_id = (gchar *) libslab_get_gconf_value (SYSTEM_MONITOR_GCONF_KEY);
+	GError *error = NULL;
+	GDesktopAppInfo *appinfo;
 
-	if (! fb_ditem_id)
-		fb_ditem_id = g_strdup ("gnome-system-monitor.desktop");
+	appinfo = g_desktop_app_info_new ("mate-system-monitor.desktop");
 
-	ditem = libslab_gnome_desktop_item_new_from_unknown_id (fb_ditem_id);
-
-	if (! open_desktop_item_exec (ditem))
+	if (appinfo)
+	{
+		g_app_info_launch (G_APP_INFO (appinfo), NULL, NULL, &error);
+		g_object_unref (appinfo);
+	}
+	else
+	{
 		g_warning ("open_hard_drive_tile: couldn't exec item\n");
-
-	gnome_desktop_item_unref (ditem);
-	g_free (fb_ditem_id);
+	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]