gnome-applets r10951 - in trunk: . drivemount gweather
- From: callum svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-applets r10951 - in trunk: . drivemount gweather
- Date: Thu, 4 Sep 2008 23:36:54 +0000 (UTC)
Author: callum
Date: Thu Sep 4 23:36:54 2008
New Revision: 10951
URL: http://svn.gnome.org/viewvc/gnome-applets?rev=10951&view=rev
Log:
Removal of gnome-vfs and drivemount port to GIO. Bug 543711
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.in
trunk/drivemount/ChangeLog
trunk/drivemount/drive-button.c
trunk/drivemount/drive-button.h
trunk/drivemount/drive-list.c
trunk/drivemount/drive-list.h
trunk/drivemount/drivemount.c
trunk/gweather/ChangeLog
trunk/gweather/Makefile.am
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Thu Sep 4 23:36:54 2008
@@ -11,12 +11,6 @@
libgweather_SUBDIRS = $(libgweather_applets)
endif
-vfs_applets = \
- drivemount
-if BUILD_GNOME_VFS_APPLETS
-vfs_SUBDIRS = $(vfs_applets)
-endif
-
mixer_applets = \
mixer
if APPLET_MIXER
@@ -51,6 +45,7 @@
always_built_SUBDIRS = \
charpick \
+ drivemount \
geyes \
mini-commander \
gkb-new \
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Sep 4 23:36:54 2008
@@ -11,12 +11,11 @@
dnl ***************************************************************************
dnl *** Minimum library versions for GNOME-APPLETS ***
dnl ***************************************************************************
-GTK_REQUIRED=2.12.0
-GLIB_REQUIRED=2.13.0
+GTK_REQUIRED=2.13.0
+GLIB_REQUIRED=2.18.0
GIO_REQUIRED=2.15.3
LIBGNOME_REQUIRED=2.8.0
LIBGNOMEUI_REQUIRED=2.8.0
-GNOME_VFS_REQUIRED=2.15.4
GCONF_REQUIRED=2.8.0
SCROLLKEEPER_REQUIRED=0.1.4
LIBPANEL_REQUIRED=2.13.4
@@ -138,15 +137,6 @@
AC_SUBST(GNOMEDESKTOP_CFLAGS)
AC_SUBST(GNOMEDESKTOP_LIBS)
-dnl -- check for gnome-vfs (optional) -----------------------------------------
-build_gnome_vfs_applets=false
-PKG_CHECK_MODULES(GNOME_VFS_APPLETS,
- [gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED],
- build_gnome_vfs_applets=true,)
-AC_SUBST(GNOME_VFS_APPLETS_CFLAGS)
-AC_SUBST(GNOME_VFS_APPLETS_LIBS)
-AM_CONDITIONAL(BUILD_GNOME_VFS_APPLETS, $build_gnome_vfs_applets)
-
dnl -- check for libgtop (optional) -------------------------------------------
build_gtop_applets=false
PKG_CHECK_MODULES(GTOP_APPLETS,
@@ -822,7 +812,7 @@
- using PolicyKit $HAVE_POLKIT
- using PolicyKit-gnome $polkit_gnome
- enabling suid bit $suid
- - drivemount $build_gnome_vfs_applets
+ - drivemount always
- geyes always
- keyboard-applet $BUILD_KEYBOARD_APPLET
- gweather $build_libgweather_applets
@@ -832,7 +822,7 @@
- modemlights $BUILD_MODEM_LIGHTS
- multiload $build_gtop_applets
- stickynotes $enable_stickynotes
- - trashapplet $build_gnome_vfs_applets
+ - trashapplet always
Using DBUS: $HAVE_DBUS
Using HAL: $HAVE_HAL
Modified: trunk/drivemount/drive-button.c
==============================================================================
--- trunk/drivemount/drive-button.c (original)
+++ trunk/drivemount/drive-button.c Thu Sep 4 23:36:54 2008
@@ -1,6 +1,7 @@
/* -*- mode: C; c-basic-offset: 4 -*-
* Drive Mount Applet
* Copyright (c) 2004 Canonical Ltd
+ * Copyright 2008 Pierre Ossman
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -24,6 +25,7 @@
# include <config.h>
#endif
+#include <gio/gio.h>
#include "drive-button.h"
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
@@ -43,10 +45,10 @@
/* type registration boilerplate code */
G_DEFINE_TYPE(DriveButton, drive_button, GTK_TYPE_BUTTON)
-static void drive_button_set_drive (DriveButton *self,
- GnomeVFSDrive *drive);
static void drive_button_set_volume (DriveButton *self,
- GnomeVFSVolume *volume);
+ GVolume *volume);
+static void drive_button_set_mount (DriveButton *self,
+ GMount *mount);
static void drive_button_reset_popup (DriveButton *self);
static void drive_button_ensure_popup (DriveButton *self);
@@ -92,8 +94,8 @@
gtk_container_add (GTK_CONTAINER (self), image);
gtk_widget_show(image);
- self->drive = NULL;
self->volume = NULL;
+ self->mount = NULL;
self->icon_size = 24;
self->update_tag = 0;
@@ -101,12 +103,12 @@
}
GtkWidget *
-drive_button_new (GnomeVFSDrive *drive)
+drive_button_new (GVolume *volume)
{
DriveButton *self;
self = g_object_new (DRIVE_TYPE_BUTTON, NULL);
- drive_button_set_drive (self, drive);
+ drive_button_set_volume (self, volume);
g_signal_connect (gtk_icon_theme_get_default (),
"changed", G_CALLBACK (drive_button_theme_change),
@@ -116,12 +118,12 @@
}
GtkWidget *
-drive_button_new_from_volume (GnomeVFSVolume *volume)
+drive_button_new_from_mount (GMount *mount)
{
DriveButton *self;
self = g_object_new (DRIVE_TYPE_BUTTON, NULL);
- drive_button_set_volume (self, volume);
+ drive_button_set_mount (self, mount);
g_signal_connect (gtk_icon_theme_get_default (),
"changed", G_CALLBACK (drive_button_theme_change),
@@ -135,7 +137,7 @@
{
DriveButton *self = DRIVE_BUTTON (object);
- drive_button_set_drive (self, NULL);
+ drive_button_set_volume (self, NULL);
if (self->update_tag)
g_source_remove (self->update_tag);
@@ -261,41 +263,41 @@
}
static void
-drive_button_set_drive (DriveButton *self, GnomeVFSDrive *drive)
+drive_button_set_volume (DriveButton *self, GVolume *volume)
{
g_return_if_fail (DRIVE_IS_BUTTON (self));
- if (self->drive) {
- gnome_vfs_drive_unref (self->drive);
- }
- self->drive = NULL;
if (self->volume) {
- gnome_vfs_volume_unref (self->volume);
+ g_object_unref (self->volume);
}
self->volume = NULL;
+ if (self->mount) {
+ g_object_unref (self->mount);
+ }
+ self->mount = NULL;
- if (drive) {
- self->drive = gnome_vfs_drive_ref (drive);
+ if (volume) {
+ self->volume = g_object_ref (volume);
}
drive_button_queue_update (self);
}
static void
-drive_button_set_volume (DriveButton *self, GnomeVFSVolume *volume)
+drive_button_set_mount (DriveButton *self, GMount *mount)
{
g_return_if_fail (DRIVE_IS_BUTTON (self));
- if (self->drive) {
- gnome_vfs_drive_unref (self->drive);
- }
- self->drive = NULL;
if (self->volume) {
- gnome_vfs_volume_unref (self->volume);
+ g_object_unref (self->volume);
}
self->volume = NULL;
+ if (self->mount) {
+ g_object_unref (self->mount);
+ }
+ self->mount = NULL;
- if (volume) {
- self->volume = gnome_vfs_volume_ref (volume);
+ if (mount) {
+ self->mount = g_object_ref (mount);
}
drive_button_queue_update (self);
}
@@ -306,7 +308,8 @@
DriveButton *self;
GdkScreen *screen;
GtkIconTheme *icon_theme;
- char *icon_name;
+ GtkIconInfo *icon_info;
+ GIcon *icon;
int width, height;
GdkPixbuf *pixbuf, *scaled;
GtkRequisition button_req, image_req;
@@ -318,51 +321,41 @@
drive_button_reset_popup (self);
- /* if no drive or volume, unset image */
- if (!self->drive && !self->volume) {
+ /* if no volume or mount, unset image */
+ if (!self->volume && !self->mount) {
if (GTK_BIN (self)->child != NULL)
gtk_image_set_from_pixbuf (GTK_IMAGE (GTK_BIN (self)->child), NULL);
return FALSE;
}
- if (self->drive) {
- display_name = gnome_vfs_drive_get_display_name (self->drive);
- if (gnome_vfs_drive_is_mounted (self->drive))
+ if (self->volume) {
+ GMount *mount;
+
+ display_name = g_volume_get_name (self->volume);
+ mount = g_volume_get_mount (self->volume);
+
+ if (mount)
tip = g_strdup_printf ("%s\n%s", display_name, _("(mounted)"));
- else if (gnome_vfs_drive_is_connected (self->drive))
+ else
tip = g_strdup_printf ("%s\n%s", display_name, _("(not mounted)"));
+
+ if (mount)
+ icon = g_mount_get_icon (mount);
else
- tip = g_strdup_printf ("%s\n%s", display_name, _("(not connected)"));
+ icon = g_volume_get_icon (self->volume);
+
+ if (mount)
+ g_object_unref (mount);
} else {
- display_name = gnome_vfs_volume_get_display_name (self->volume);
- if (gnome_vfs_volume_is_mounted (self->volume))
- tip = g_strdup_printf ("%s\n%s", display_name, _("(mounted)"));
- else
- tip = g_strdup_printf ("%s\n%s", display_name, _("(not mounted)"));
+ display_name = g_mount_get_name (self->mount);
+ tip = g_strdup_printf ("%s\n%s", display_name, _("(mounted)"));
+ icon = g_mount_get_icon (self->mount);
}
gtk_widget_set_tooltip_text (GTK_WIDGET (self), tip);
g_free (tip);
g_free (display_name);
- /* get the icon for the first mounted volume, or the drive itself */
- if (self->drive) {
- if (gnome_vfs_drive_is_mounted (self->drive)) {
- GList *volumes;
- GnomeVFSVolume *volume;
-
- volumes = gnome_vfs_drive_get_mounted_volumes (self->drive);
- volume = GNOME_VFS_VOLUME (volumes->data);
- icon_name = gnome_vfs_volume_get_icon (volume);
- g_list_foreach (volumes, (GFunc)gnome_vfs_volume_unref, NULL);
- g_list_free (volumes);
- } else {
- icon_name = gnome_vfs_drive_get_icon (self->drive);
- }
- } else {
- icon_name = gnome_vfs_volume_get_icon (self->volume);
- }
-
/* base the icon size on the desired button size */
gtk_widget_size_request (GTK_WIDGET (self), &button_req);
gtk_widget_size_request (GTK_BIN (self)->child, &image_req);
@@ -371,9 +364,16 @@
screen = gtk_widget_get_screen (GTK_WIDGET (self));
icon_theme = gtk_icon_theme_get_for_screen (screen);
- pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
- MIN (width, height), 0, NULL);
- g_free (icon_name);
+ icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon,
+ MIN (width, height),
+ GTK_ICON_LOOKUP_USE_BUILTIN);
+ if (icon_info)
+ {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
+ }
+
+ g_object_unref (icon);
if (!pixbuf)
return FALSE;
@@ -415,16 +415,38 @@
drive_button_compare (DriveButton *button, DriveButton *other_button)
{
/* sort drives before driveless volumes volumes */
- if (button->drive) {
- if (other_button->drive)
- return gnome_vfs_drive_compare (button->drive, other_button->drive);
- else
+ if (button->volume) {
+ if (other_button->volume)
+ {
+ int cmp;
+ gchar *str1, *str2;
+
+ str1 = g_volume_get_name (button->volume);
+ str2 = g_volume_get_name (other_button->volume);
+ cmp = g_utf8_collate (str1, str2);
+ g_free (str2);
+ g_free (str1);
+
+ return cmp;
+ } else {
return -1;
+ }
} else {
- if (other_button->drive)
+ if (other_button->volume)
+ {
return 1;
- else
- return gnome_vfs_volume_compare (button->volume, other_button->volume);
+ } else {
+ int cmp;
+ gchar *str1, *str2;
+
+ str1 = g_mount_get_name (button->mount);
+ str2 = g_mount_get_name (other_button->mount);
+ cmp = g_utf8_collate (str1, str2);
+ g_free (str2);
+ g_free (str1);
+
+ return cmp;
+ }
}
}
@@ -467,15 +489,15 @@
return new_str;
}
static GtkWidget *
-create_menu_item (DriveButton *self, const gchar *stock_id,
+create_menu_item (DriveButton *self, const gchar *icon_name,
const gchar *label, GCallback callback,
gboolean sensitive)
{
GtkWidget *item, *image;
item = gtk_image_menu_item_new_with_mnemonic (label);
- if (stock_id) {
- image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
+ if (icon_name) {
+ image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
}
@@ -497,26 +519,27 @@
screen = gtk_widget_get_screen (GTK_WIDGET (self));
- if (self->drive) {
- argv[1] = gnome_vfs_drive_get_activation_uri (self->drive);
- /* if the drive has no activation URI, get the activation URI
- * of it's first mounted volume */
- if (!argv[1]) {
- GList *volumes;
- GnomeVFSVolume *volume;
-
- volumes = gnome_vfs_drive_get_mounted_volumes (self->drive);
- if (volumes) {
- volume = GNOME_VFS_VOLUME (volumes->data);
-
- argv[1] = gnome_vfs_volume_get_activation_uri (volume);
- g_list_foreach (volumes, (GFunc)gnome_vfs_volume_unref, NULL);
- g_list_free (volumes);
- }
+ if (self->volume) {
+ GMount *mount;
+
+ mount = g_volume_get_mount (self->volume);
+ if (mount) {
+ GFile *file;
+
+ file = g_mount_get_root (mount);
+
+ argv[1] = g_file_get_uri (file);
+ g_object_unref(file);
+
+ g_object_unref(mount);
}
- } else if (self->volume)
- argv[1] = gnome_vfs_volume_get_activation_uri (self->volume);
- else
+ } else if (self->mount) {
+ GFile *file;
+
+ file = g_mount_get_root (self->mount);
+ argv[1] = g_file_get_uri (file);
+ g_object_unref(file);
+ } else
g_return_if_reached();
if (!gdk_spawn_on_screen (screen, NULL, argv, NULL,
@@ -537,84 +560,6 @@
g_free (argv[1]);
}
-static void
-mount_result (gboolean succeeded,
- char *error,
- char *detailed_error,
- gpointer data)
-{
- GtkWidget *dialog, *hbox, *vbox, *image, *label;
- char *title, *str;
-
- if (!succeeded) {
- switch (GPOINTER_TO_INT(data)) {
- case CMD_MOUNT_OR_PLAY:
- title = _("Mount Error");
- break;
- case CMD_UNMOUNT:
- title = _("Unmount Error");
- break;
- case CMD_EJECT:
- title = _("Eject Error");
- break;
- default:
- title = _("Error");
- }
-
- dialog = gtk_dialog_new ();
- atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT);
- gtk_window_set_title (GTK_WINDOW (dialog), title);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
- FALSE, FALSE, 0);
-
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR,
- GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-
- vbox = gtk_vbox_new (FALSE, 12);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
- gtk_widget_show (vbox);
-
- str = g_strconcat ("<span weight=\"bold\" size=\"larger\">",
- error, "</span>", NULL);
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
- g_free (str);
-
- label = gtk_label_new (detailed_error);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK,
- GTK_RESPONSE_OK);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_YES);
-
- gtk_widget_show (dialog);
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_object_destroy), NULL);
-
- }
-}
-
/* copied from gnome-volume-manager/src/manager.c maybe there is a better way than
* duplicating this code? */
@@ -699,27 +644,54 @@
/* END copied from gnome-volume-manager/src/manager.c */
static gboolean
-check_dvd_video (GnomeVFSVolume *volume)
+check_dvd_video (DriveButton *self)
{
- char *device_path = gnome_vfs_volume_get_device_path (volume);
- char *uri = gnome_vfs_volume_get_activation_uri (volume);
- char *mount_path = gnome_vfs_get_local_path_from_uri (uri);
- char *udi = gnome_vfs_volume_get_hal_udi (volume);
+ GFile *file;
+ char *udi, *device_path, *mount_path;
+ gboolean result;
+
+ if (!self->volume)
+ return FALSE;
+
+ file = g_volume_get_activation_root (self->volume);
+ if (!file)
+ return FALSE;
+
+ mount_path = g_file_get_path (file);
- gboolean result = gvm_check_dvd_only (udi, device_path, mount_path);
+ g_object_unref (file);
+
+ device_path = g_volume_get_identifier (self->volume,
+ G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+ udi = g_volume_get_identifier (self->volume,
+ G_VOLUME_IDENTIFIER_KIND_HAL_UDI);
+
+ result = gvm_check_dvd_only (udi, device_path, mount_path);
g_free (device_path);
g_free (udi);
- g_free (uri);
g_free (mount_path);
return result;
}
static gboolean
-check_audio_cd (DriveButton *self, GnomeVFSVolume *volume)
+check_audio_cd (DriveButton *self)
{
- char *activation_uri = gnome_vfs_volume_get_activation_uri (volume);
+ GFile *file;
+ char *activation_uri;
+
+ if (!self->volume)
+ return FALSE;
+
+ file = g_volume_get_activation_root (self->volume);
+ if (!file)
+ return FALSE;
+
+ activation_uri = g_file_get_uri (file);
+
+ g_object_unref (file);
+
// we have an audioCD if the activation URI starts by 'cdda://'
gboolean result = (strncmp ("cdda://", activation_uri, 7) == 0);
g_free (activation_uri);
@@ -729,24 +701,23 @@
static void
run_command (DriveButton *self, const char *command)
{
- char *uri, *mount_path;
- char *device_path = gnome_vfs_drive_get_device_path (self->drive);
+ GFile *file;
+ char *mount_path, *device_path;
+
+ if (!self->volume)
+ return;
+
+ file = g_volume_get_activation_root (self->volume);
+ g_assert (file);
- GList *volumes;
- GnomeVFSVolume *volume;
+ mount_path = g_file_get_path (file);
- volumes = gnome_vfs_drive_get_mounted_volumes (self->drive);
- volume = GNOME_VFS_VOLUME (volumes->data);
- uri = gnome_vfs_volume_get_activation_uri (volume);
- mount_path = gnome_vfs_get_local_path_from_uri (uri);
- g_free (uri);
-
- gnome_vfs_drive_get_display_name (self->drive);
- gvm_run_command (device_path, command,
- mount_path);
+ g_object_unref (file);
- g_list_foreach (volumes, (GFunc)gnome_vfs_volume_unref, NULL);
- g_list_free (volumes);
+ device_path = g_volume_get_identifier (self->volume,
+ G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+
+ gvm_run_command (device_path, command, mount_path);
g_free (mount_path);
g_free (device_path);
@@ -755,9 +726,9 @@
static void
mount_drive (DriveButton *self, GtkWidget *item)
{
- if (self->drive) {
- gnome_vfs_drive_mount (self->drive, mount_result,
- GINT_TO_POINTER(CMD_MOUNT_OR_PLAY));
+ if (self->volume) {
+ g_volume_mount (self->volume, G_MOUNT_MOUNT_NONE,
+ NULL, NULL, NULL, NULL);
} else {
g_return_if_reached();
}
@@ -765,12 +736,19 @@
static void
unmount_drive (DriveButton *self, GtkWidget *item)
{
- if (self->drive) {
- gnome_vfs_drive_unmount (self->drive, mount_result,
- GINT_TO_POINTER(CMD_UNMOUNT));
- } else if (self->volume) {
- gnome_vfs_volume_unmount (self->volume, mount_result,
- GINT_TO_POINTER(CMD_UNMOUNT));
+ if (self->volume) {
+ GMount *mount;
+
+ mount = g_volume_get_mount (self->volume);
+ if (mount)
+ {
+ g_mount_unmount (mount, G_MOUNT_UNMOUNT_NONE,
+ NULL, NULL, NULL);
+ g_object_unref (mount);
+ }
+ } else if (self->mount) {
+ g_mount_unmount (self->mount, G_MOUNT_UNMOUNT_NONE,
+ NULL, NULL, NULL);
} else {
g_return_if_reached();
}
@@ -778,12 +756,12 @@
static void
eject_drive (DriveButton *self, GtkWidget *item)
{
- if (self->drive) {
- gnome_vfs_drive_eject (self->drive, mount_result,
- GINT_TO_POINTER(CMD_EJECT));
- } else if (self->volume) {
- gnome_vfs_volume_eject (self->volume, mount_result,
- GINT_TO_POINTER(CMD_EJECT));
+ if (self->volume) {
+ g_volume_eject (self->volume, G_MOUNT_UNMOUNT_NONE,
+ NULL, NULL, NULL);
+ } else if (self->mount) {
+ g_mount_eject (self->mount, G_MOUNT_UNMOUNT_NONE,
+ NULL, NULL, NULL);
} else {
g_return_if_reached();
}
@@ -814,73 +792,29 @@
static void
drive_button_ensure_popup (DriveButton *self)
{
- GnomeVFSDeviceType device_type;
char *display_name, *tmp, *label;
- int action = CMD_NONE;
GtkWidget *item;
- GCallback callback;
- const char *action_icon;
- gboolean ejectable;
+ gboolean mounted, ejectable;
if (self->popup_menu) return;
- if (self->drive) {
- GnomeVFSVolume *volume = NULL;
- GList *volumes;
-
- if (!gnome_vfs_drive_is_connected (self->drive)) return;
-
- device_type = gnome_vfs_drive_get_device_type (self->drive);
- display_name = gnome_vfs_drive_get_display_name (self->drive);
- ejectable = gnome_vfs_drive_needs_eject (self->drive);
-
- if (gnome_vfs_drive_is_mounted (self->drive)) {
- if (!ejectable)
- action = CMD_UNMOUNT;
- } else {
- action = CMD_MOUNT_OR_PLAY;
- }
-
- volumes = gnome_vfs_drive_get_mounted_volumes (self->drive);
- if (volumes != NULL)
- {
- volume = GNOME_VFS_VOLUME (volumes->data);
- device_type = gnome_vfs_volume_get_device_type (volume);
- }
-
- /*
- * For some reason, on my computer, I get GNOME_VFS_DEVICE_TYPE_CDROM
- * also for DVDs and Audio CDs, while for DVD the icon is correctly the
- * one for DVDs and for Audio CDs the description correctly that of an
- * audio CD? So i have this hack.
- */
- if (volume)
- {
- if (check_dvd_video (volume))
- {
- device_type = GNOME_VFS_DEVICE_TYPE_VIDEO_DVD;
- }
- if (check_audio_cd (self, volume))
- {
- device_type = GNOME_VFS_DEVICE_TYPE_AUDIO_CD;
- }
- }
+ mounted = FALSE;
- g_list_foreach (volumes, (GFunc)gnome_vfs_volume_unref, NULL);
- g_list_free (volumes);
- } else {
- GnomeVFSDrive* drive = gnome_vfs_volume_get_drive (self->volume);
+ if (self->volume) {
+ GMount *mount = NULL;
- if (!gnome_vfs_volume_is_mounted (self->volume)) return;
+ display_name = g_volume_get_name (self->volume);
+ ejectable = g_volume_can_eject (self->volume);
- device_type = gnome_vfs_volume_get_device_type (self->volume);
- display_name = gnome_vfs_volume_get_display_name (self->volume);
- if (drive)
- ejectable = gnome_vfs_drive_needs_eject (drive);
- else
- ejectable = FALSE;
- if (!ejectable)
- action = CMD_UNMOUNT;
+ mount = g_volume_get_mount (self->volume);
+ if (mount) {
+ mounted = TRUE;
+ g_object_unref (mount);
+ }
+ } else {
+ display_name = g_mount_get_name (self->mount);
+ ejectable = g_mount_can_eject (self->mount);
+ mounted = TRUE;
}
self->popup_menu = gtk_menu_new ();
@@ -890,57 +824,43 @@
g_free (display_name);
display_name = tmp;
- callback = G_CALLBACK (open_drive);
- action_icon = GTK_STOCK_OPEN;
-
- switch (device_type) {
- case GNOME_VFS_DEVICE_TYPE_VIDEO_DVD:
- label = g_strdup (_("_Play DVD"));
- callback = G_CALLBACK (play_dvd);
- action_icon = GTK_STOCK_MEDIA_PLAY;
- break;
- case GNOME_VFS_DEVICE_TYPE_AUDIO_CD:
- label = g_strdup (_("_Play CD"));
- callback = G_CALLBACK (play_cda);
- action_icon = GTK_STOCK_MEDIA_PLAY;
- break;
- default:
- label = g_strdup_printf (_("_Open %s"), display_name);
- }
-
- item = create_menu_item (self, action_icon, label,
- callback,
- action != CMD_MOUNT_OR_PLAY);
- g_free (label);
+ if (check_dvd_video (self)) {
+ item = create_menu_item (self, "media-playback-start",
+ _("_Play DVD"), G_CALLBACK (play_dvd),
+ TRUE);
+ } else if (check_audio_cd (self)) {
+ item = create_menu_item (self, "media-playback-start",
+ _("_Play CD"), G_CALLBACK (play_cda),
+ TRUE);
+ } else {
+ label = g_strdup_printf (_("_Open %s"), display_name);
+ item = create_menu_item (self, "document-open", label,
+ G_CALLBACK (open_drive), mounted);
+ g_free (label);
+ }
gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
- switch (action) {
- case CMD_MOUNT_OR_PLAY:
+ if (mounted) {
+ if (!ejectable) {
+ label = g_strdup_printf (_("Un_mount %s"), display_name);
+ item = create_menu_item (self, NULL, label,
+ G_CALLBACK (unmount_drive), TRUE);
+ g_free (label);
+ gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
+ }
+ } else {
label = g_strdup_printf (_("_Mount %s"), display_name);
item = create_menu_item (self, NULL, label,
G_CALLBACK (mount_drive), TRUE);
g_free (label);
gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
- break;
- case CMD_UNMOUNT:
- label = g_strdup_printf (_("Un_mount %s"), display_name);
- item = create_menu_item (self, NULL, label,
- G_CALLBACK (unmount_drive), TRUE);
- g_free (label);
- gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
- break;
- default:
- break;
}
- if (ejectable)
- {
+ if (ejectable) {
label = g_strdup_printf (_("_Eject %s"), display_name);
- item = create_menu_item (self, NULL, label,
+ item = create_menu_item (self, "media-eject", label,
G_CALLBACK (eject_drive), TRUE);
g_free (label);
gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
}
-
- g_free (display_name);
}
Modified: trunk/drivemount/drive-button.h
==============================================================================
--- trunk/drivemount/drive-button.h (original)
+++ trunk/drivemount/drive-button.h Thu Sep 4 23:36:54 2008
@@ -24,7 +24,6 @@
#define DRIVE_BUTTON_H
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
G_BEGIN_DECLS
@@ -42,8 +41,8 @@
{
GtkButton parent;
- GnomeVFSDrive *drive;
- GnomeVFSVolume *volume;
+ GVolume *volume;
+ GMount *mount;
int icon_size;
guint update_tag;
@@ -56,8 +55,8 @@
};
GType drive_button_get_type (void);
-GtkWidget *drive_button_new (GnomeVFSDrive *drive);
-GtkWidget *drive_button_new_from_volume (GnomeVFSVolume *volume);
+GtkWidget *drive_button_new (GVolume *volume);
+GtkWidget *drive_button_new_from_mount (GMount *mount);
void drive_button_queue_update (DriveButton *button);
void drive_button_set_size (DriveButton *button,
int icon_size);
Modified: trunk/drivemount/drive-list.c
==============================================================================
--- trunk/drivemount/drive-list.c (original)
+++ trunk/drivemount/drive-list.c Thu Sep 4 23:36:54 2008
@@ -1,6 +1,7 @@
/* -*- mode: C; c-basic-offset: 4 -*-
* Drive Mount Applet
* Copyright (c) 2004 Canonical Ltd
+ * Copyright 2008 Pierre Ossman
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -24,39 +25,46 @@
# include <config.h>
#endif
+#include <gio/gio.h>
#include "drive-list.h"
#include "drive-button.h"
#include <glib/gi18n.h>
G_DEFINE_TYPE (DriveList, drive_list, GTK_TYPE_TABLE);
-static GnomeVFSVolumeMonitor *volume_monitor = NULL;
+static GVolumeMonitor *volume_monitor = NULL;
static void drive_list_finalize (GObject *object);
static void drive_list_destroy (GtkObject *object);
static void drive_list_add (GtkContainer *container, GtkWidget *child);
static void drive_list_remove (GtkContainer *container, GtkWidget *child);
-static void volume_mounted (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
+static void mount_added (GVolumeMonitor *monitor,
+ GMount *mount,
DriveList *self);
-static void volume_unmounted (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
+static void mount_changed (GVolumeMonitor *monitor,
+ GMount *mount,
DriveList *self);
-static void drive_connected (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSDrive *drive,
+static void mount_removed (GVolumeMonitor *monitor,
+ GMount *mount,
DriveList *self);
-static void drive_disconnected (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSDrive *drive,
+static void volume_added (GVolumeMonitor *monitor,
+ GVolume *volume,
+ DriveList *self);
+static void volume_changed (GVolumeMonitor *monitor,
+ GVolume *volume,
+ DriveList *self);
+static void volume_removed (GVolumeMonitor *monitor,
+ GVolume *volume,
DriveList *self);
-static void add_drive (DriveList *self,
- GnomeVFSDrive *drive);
-static void remove_drive (DriveList *self,
- GnomeVFSDrive *drive);
static void add_volume (DriveList *self,
- GnomeVFSVolume *volume);
+ GVolume *volume);
static void remove_volume (DriveList *self,
- GnomeVFSVolume *volume);
+ GVolume *volume);
+static void add_mount (DriveList *self,
+ GMount *mount);
+static void remove_mount (DriveList *self,
+ GMount *mount);
static void
drive_list_class_init (DriveListClass *class)
@@ -70,12 +78,12 @@
static void
drive_list_init (DriveList *self)
{
- GList *connected_drives, *mounted_volumes, *tmp;
+ GList *volumes, *mounts, *tmp;
gtk_table_set_homogeneous (GTK_TABLE (self), TRUE);
- self->drives = g_hash_table_new (NULL, NULL);
self->volumes = g_hash_table_new (NULL, NULL);
+ self->mounts = g_hash_table_new (NULL, NULL);
self->orientation = GTK_ORIENTATION_HORIZONTAL;
self->layout_tag = 0;
self->icon_size = 24;
@@ -84,33 +92,37 @@
/* listen for drive connects/disconnects, and add
* currently connected drives. */
if (!volume_monitor)
- volume_monitor = gnome_vfs_get_volume_monitor ();
+ volume_monitor = g_volume_monitor_get ();
- g_signal_connect_object (volume_monitor, "volume_mounted",
- G_CALLBACK (volume_mounted), self, 0);
- g_signal_connect_object (volume_monitor, "volume_unmounted",
- G_CALLBACK (volume_unmounted), self, 0);
- g_signal_connect_object (volume_monitor, "drive_connected",
- G_CALLBACK (drive_connected), self, 0);
- g_signal_connect_object (volume_monitor, "drive_disconnected",
- G_CALLBACK (drive_disconnected), self, 0);
- connected_drives = gnome_vfs_volume_monitor_get_connected_drives (volume_monitor);
- for (tmp = connected_drives; tmp != NULL; tmp = tmp->next) {
- GnomeVFSDrive *drive = tmp->data;
+ g_signal_connect_object (volume_monitor, "mount_added",
+ G_CALLBACK (mount_added), self, 0);
+ g_signal_connect_object (volume_monitor, "mount_changed",
+ G_CALLBACK (mount_changed), self, 0);
+ g_signal_connect_object (volume_monitor, "mount_removed",
+ G_CALLBACK (mount_removed), self, 0);
+ g_signal_connect_object (volume_monitor, "volume_added",
+ G_CALLBACK (volume_added), self, 0);
+ g_signal_connect_object (volume_monitor, "volume_changed",
+ G_CALLBACK (volume_changed), self, 0);
+ g_signal_connect_object (volume_monitor, "volume_removed",
+ G_CALLBACK (volume_removed), self, 0);
+ volumes = g_volume_monitor_get_volumes (volume_monitor);
+ for (tmp = volumes; tmp != NULL; tmp = tmp->next) {
+ GVolume *volume = tmp->data;
- add_drive (self, drive);
- gnome_vfs_drive_unref (drive);
+ add_volume (self, volume);
+ g_object_unref (volume);
}
- g_list_free (connected_drives);
+ g_list_free (volumes);
- mounted_volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
- for (tmp = mounted_volumes; tmp != NULL; tmp = tmp->next) {
- GnomeVFSVolume *volume = tmp->data;
+ mounts = g_volume_monitor_get_mounts (volume_monitor);
+ for (tmp = mounts; tmp != NULL; tmp = tmp->next) {
+ GMount *mount = tmp->data;
- add_volume (self, volume);
- gnome_vfs_volume_unref (volume);
+ add_mount (self, mount);
+ g_object_unref (mount);
}
- g_list_free (mounted_volumes);
+ g_list_free (mounts);
}
GtkWidget *
@@ -124,8 +136,8 @@
{
DriveList *self = DRIVE_LIST (object);
- g_hash_table_destroy (self->drives);
g_hash_table_destroy (self->volumes);
+ g_hash_table_destroy (self->mounts);
if (G_OBJECT_CLASS (drive_list_parent_class)->finalize)
(* G_OBJECT_CLASS (drive_list_parent_class)->finalize) (object);
@@ -137,13 +149,17 @@
DriveList *self = DRIVE_LIST (object);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (volume_mounted), self);
+ G_CALLBACK (mount_added), self);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (volume_unmounted), self);
+ G_CALLBACK (mount_changed), self);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (drive_connected), self);
+ G_CALLBACK (mount_removed), self);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (drive_disconnected), self);
+ G_CALLBACK (volume_added), self);
+ g_signal_handlers_disconnect_by_func (volume_monitor,
+ G_CALLBACK (volume_changed), self);
+ g_signal_handlers_disconnect_by_func (volume_monitor,
+ G_CALLBACK (volume_removed), self);
if (self->layout_tag)
g_source_remove (self->layout_tag);
@@ -168,10 +184,10 @@
self = DRIVE_LIST (container);
button = DRIVE_BUTTON (child);
- if (button->drive)
- g_hash_table_insert (self->drives, button->drive, button);
- else
+ if (button->volume)
g_hash_table_insert (self->volumes, button->volume, button);
+ else
+ g_hash_table_insert (self->mounts, button->mount, button);
}
static void
@@ -185,10 +201,10 @@
self = DRIVE_LIST (container);
button = DRIVE_BUTTON (child);
- if (button->drive)
- g_hash_table_remove (self->drives, button->drive);
- else
+ if (button->volume)
g_hash_table_remove (self->volumes, button->volume);
+ else
+ g_hash_table_remove (self->mounts, button->mount);
if (GTK_CONTAINER_CLASS (drive_list_parent_class)->remove)
(* GTK_CONTAINER_CLASS (drive_list_parent_class)->remove) (container,
@@ -214,8 +230,8 @@
self->layout_tag = 0;
- g_hash_table_foreach (self->drives, list_buttons, &sorted_buttons);
g_hash_table_foreach (self->volumes, list_buttons, &sorted_buttons);
+ g_hash_table_foreach (self->mounts, list_buttons, &sorted_buttons);
/* position buttons in the table according to their sorted order */
for (tmp = sorted_buttons, i = 0; tmp != NULL; tmp = tmp->next, i++) {
@@ -252,77 +268,82 @@
}
static void
-volume_mounted (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
- DriveList *self)
+mount_added (GVolumeMonitor *monitor,
+ GMount *mount,
+ DriveList *self)
{
- GnomeVFSDrive *drive;
- DriveButton *button = NULL;;
+ add_mount (self, mount);
- add_volume (self, volume);
+ mount_changed(monitor, mount, self);
+}
- drive = gnome_vfs_volume_get_drive (volume);
- if (drive) {
- button = g_hash_table_lookup (self->drives, drive);
- gnome_vfs_drive_unref (drive);
- } else {
+static void
+mount_changed (GVolumeMonitor *monitor,
+ GMount *mount,
+ DriveList *self)
+{
+ GVolume *volume;
+ DriveButton *button = NULL;;
+
+ volume = g_mount_get_volume (mount);
+ if (volume) {
button = g_hash_table_lookup (self->volumes, volume);
+ g_object_unref (volume);
+ } else {
+ button = g_hash_table_lookup (self->mounts, mount);
}
if (button)
drive_button_queue_update (button);
}
static void
-volume_unmounted (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
- DriveList *self)
+mount_removed (GVolumeMonitor *monitor,
+ GMount *mount,
+ DriveList *self)
{
- GnomeVFSDrive *drive;
- DriveButton *button = NULL;;
+ remove_mount (self, mount);
- remove_volume (self, volume);
+ mount_changed(monitor, mount, self);
+}
- drive = gnome_vfs_volume_get_drive (volume);
- if (drive) {
- button = g_hash_table_lookup (self->drives, drive);
- gnome_vfs_drive_unref (drive);
- } else {
- button = g_hash_table_lookup (self->volumes, volume);
- }
- if (button)
- drive_button_queue_update (button);
+static void
+volume_added (GVolumeMonitor *monitor,
+ GVolume *volume,
+ DriveList *self)
+{
+ add_volume (self, volume);
}
static void
-drive_connected (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSDrive *drive,
- DriveList *self)
+volume_changed (GVolumeMonitor *monitor,
+ GVolume *volume,
+ DriveList *self)
{
- add_drive (self, drive);
+ DriveButton *button = NULL;;
+
+ button = g_hash_table_lookup (self->volumes, volume);
+ if (button)
+ drive_button_queue_update (button);
}
static void
-drive_disconnected (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSDrive *drive,
- DriveList *self)
+volume_removed (GVolumeMonitor *monitor,
+ GVolume *volume,
+ DriveList *self)
{
- remove_drive (self, drive);
+ remove_volume (self, volume);
}
static void
-add_drive (DriveList *self, GnomeVFSDrive *drive)
+add_volume (DriveList *self, GVolume *volume)
{
GtkWidget *button;
- /* ignore non user visible drives */
- if (!gnome_vfs_drive_is_user_visible (drive))
- return;
-
- /* if the drive has already been added, return */
- if (g_hash_table_lookup (self->drives, drive) != NULL)
+ /* if the volume has already been added, return */
+ if (g_hash_table_lookup (self->volumes, volume) != NULL)
return;
- button = drive_button_new (drive);
+ button = drive_button_new (volume);
gtk_button_set_relief (GTK_BUTTON (button), self->relief);
drive_button_set_size (DRIVE_BUTTON (button), self->icon_size);
gtk_container_add (GTK_CONTAINER (self), button);
@@ -331,12 +352,12 @@
}
static void
-remove_drive (DriveList *self, GnomeVFSDrive *drive)
+remove_volume (DriveList *self, GVolume *volume)
{
GtkWidget *button;
- /* if the drive has already been added, return */
- button = g_hash_table_lookup (self->drives, drive);
+ /* if the volume has already been added, return */
+ button = g_hash_table_lookup (self->volumes, volume);
if (button) {
gtk_container_remove (GTK_CONTAINER (self), button);
queue_relayout (self);
@@ -344,32 +365,23 @@
}
static void
-add_volume (DriveList *self, GnomeVFSVolume *volume)
+add_mount (DriveList *self, GMount *mount)
{
GtkWidget *button;
- GnomeVFSDrive *drive;
+ GVolume *volume;
- /* ignore non user visible volumes */
- if (!gnome_vfs_volume_is_user_visible (volume))
- return;
-
- /* ignore "connected servers" style volumes */
- if (gnome_vfs_volume_get_volume_type (volume)
- == GNOME_VFS_VOLUME_TYPE_CONNECTED_SERVER)
- return;
-
- /* ignore volumes attached to a drive */
- drive = gnome_vfs_volume_get_drive (volume);
- if (drive) {
- gnome_vfs_drive_unref (drive);
+ /* ignore mounts attached to a volume */
+ volume = g_mount_get_volume (mount);
+ if (volume) {
+ g_object_unref (volume);
return;
}
- /* if the volume has already been added, return */
- if (g_hash_table_lookup (self->volumes, volume) != NULL)
+ /* if the mount has already been added, return */
+ if (g_hash_table_lookup (self->mounts, mount) != NULL)
return;
- button = drive_button_new_from_volume (volume);
+ button = drive_button_new_from_mount (mount);
gtk_button_set_relief (GTK_BUTTON (button), self->relief);
drive_button_set_size (DRIVE_BUTTON (button), self->icon_size);
gtk_container_add (GTK_CONTAINER (self), button);
@@ -378,12 +390,12 @@
}
static void
-remove_volume (DriveList *self, GnomeVFSVolume *volume)
+remove_mount (DriveList *self, GMount *mount)
{
GtkWidget *button;
- /* if the drive has already been added, return */
- button = g_hash_table_lookup (self->volumes, volume);
+ /* if the mount has already been added, return */
+ button = g_hash_table_lookup (self->mounts, mount);
if (button) {
gtk_container_remove (GTK_CONTAINER (self), button);
queue_relayout (self);
@@ -419,8 +431,8 @@
if (self->icon_size != panel_size) {
self->icon_size = panel_size;
- g_hash_table_foreach (self->drives, set_icon_size, self);
g_hash_table_foreach (self->volumes, set_icon_size, self);
+ g_hash_table_foreach (self->mounts, set_icon_size, self);
}
}
@@ -444,6 +456,6 @@
return;
self->relief = relief;
- g_hash_table_foreach (self->drives, set_button_relief, self);
g_hash_table_foreach (self->volumes, set_button_relief, self);
+ g_hash_table_foreach (self->mounts, set_button_relief, self);
}
Modified: trunk/drivemount/drive-list.h
==============================================================================
--- trunk/drivemount/drive-list.h (original)
+++ trunk/drivemount/drive-list.h Thu Sep 4 23:36:54 2008
@@ -24,7 +24,6 @@
#define DRIVE_LIST_H
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
G_BEGIN_DECLS
@@ -42,8 +41,8 @@
{
GtkTable parent;
- GHashTable *drives;
GHashTable *volumes;
+ GHashTable *mounts;
GtkOrientation orientation;
guint layout_tag;
GtkReliefStyle relief;
Modified: trunk/drivemount/drivemount.c
==============================================================================
--- trunk/drivemount/drivemount.c (original)
+++ trunk/drivemount/drivemount.c Thu Sep 4 23:36:54 2008
@@ -27,7 +27,6 @@
#include <string.h>
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libgnomeui/gnome-help.h>
#include <panel-applet.h>
Modified: trunk/gweather/Makefile.am
==============================================================================
--- trunk/gweather/Makefile.am (original)
+++ trunk/gweather/Makefile.am Thu Sep 4 23:36:54 2008
@@ -7,7 +7,6 @@
-I$(top_srcdir) \
-DGTK_ENABLE_BROKEN \
$(GNOME_APPLETS_CFLAGS) \
- $(GNOME_VFS_APPLETS_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
$(LIBGWEATHER_CFLAGS)
@@ -24,7 +23,6 @@
gweather_applet_2_LDADD = \
$(LIBNOTIFY_LIBS) \
$(GNOME_APPLETS_LIBS) \
- $(GNOME_VFS_APPLETS_LIBS) \
$(LIBGWEATHER_LIBS)
uidir = $(datadir)/gnome-2.0/ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]