X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=gio%2Fgwin32mount.c;h=5ae80c85ce1a2511d4268f79965568b422897a5d;hb=5463c8cedbdf9ea2829f83c53876f21b34f57250;hp=8bc0244a9ecd6508ad64ae66a00e818428337cc4;hpb=b696a978ea9dccf87bdb3c4c2153d3228b808696;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gwin32mount.c b/gio/gwin32mount.c index 8bc0244..5ae80c8 100644 --- a/gio/gwin32mount.c +++ b/gio/gwin32mount.c @@ -14,16 +14,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. + * Public License along with this library; if not, see . * * Author: Alexander Larsson * David Zeuthen * Hans Breuer */ -#include +#include "config.h" #include #define WIN32_MEAN_AND_LEAN @@ -32,13 +30,14 @@ #include #include "gwin32volumemonitor.h" #include "gwin32mount.h" +#include "gmount.h" +#include "gfile.h" #include "gmountprivate.h" #include "gvolumemonitor.h" #include "gthemedicon.h" #include "gsimpleasyncresult.h" #include "glibintl.h" -#include "gioalias.h" struct _GWin32Mount { GObject parent; @@ -51,6 +50,7 @@ struct _GWin32Mount { /* why does all this stuff need to be duplicated? It is in volume already! */ char *name; GIcon *icon; + GIcon *symbolic_icon; char *mount_path; gboolean can_eject; @@ -78,7 +78,12 @@ g_win32_mount_finalize (GObject *object) _g_win32_volume_unset_mount (mount->volume, mount); #endif /* TODO: g_warn_if_fail (volume->volume == NULL); */ - g_object_unref (mount->icon); + + if (mount->icon != NULL) + g_object_unref (mount->icon); + if (mount->symbolic_icon != NULL) + g_object_unref (mount->symbolic_icon); + g_free (mount->name); g_free (mount->mount_path); @@ -99,7 +104,7 @@ g_win32_mount_init (GWin32Mount *win32_mount) { } -gchar * +static gchar * _win32_get_displayname (const char *drive) { gunichar2 *wdrive = g_utf8_to_utf16 (drive, -1, NULL, NULL, NULL); @@ -112,18 +117,18 @@ _win32_get_displayname (const char *drive) return name ? name : g_strdup (drive); } -/** +/* * _g_win32_mount_new: * @volume_monitor: a #GVolumeMonitor. * @path: a win32 path. - * @volume: ususally NULL + * @volume: usually NULL * * Returns: a #GWin32Mount for the given win32 path. **/ GWin32Mount * _g_win32_mount_new (GVolumeMonitor *volume_monitor, - const char *path, - GWin32Volume *volume) + const char *path, + GWin32Volume *volume) { GWin32Mount *mount; const gchar *drive = path; //fixme @@ -166,8 +171,8 @@ _g_win32_mount_unmounted (GWin32Mount *mount) } void -_g_win32_mount_unset_volume (GWin32Mount *mount, - GWin32Volume *volume) +_g_win32_mount_unset_volume (GWin32Mount *mount, + GWin32Volume *volume) { if (mount->volume == volume) { @@ -175,7 +180,7 @@ _g_win32_mount_unset_volume (GWin32Mount *mount, /* TODO: Emit changed in idle to avoid locking issues */ g_signal_emit_by_name (mount, "changed"); if (mount->volume_monitor != NULL) - g_signal_emit_by_name (mount->volume_monitor, "mount_changed", mount); + g_signal_emit_by_name (mount->volume_monitor, "mount-changed", mount); } } @@ -187,16 +192,16 @@ g_win32_mount_get_root (GMount *mount) return g_file_new_for_path (win32_mount->mount_path); } -const char * -_win32_drive_type_to_icon (int type) +static const char * +_win32_drive_type_to_icon (int type, gboolean use_symbolic) { switch (type) { - case DRIVE_REMOVABLE : return "gtk-floppy"; - case DRIVE_FIXED : return "gtk-harddisk"; - case DRIVE_REMOTE : return "gtk-network"; - case DRIVE_CDROM : return "gtk-cdrom"; - default : return "gtk-directory"; + case DRIVE_REMOVABLE : return use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media"; + case DRIVE_FIXED : return use_symbolic ? "drive-harddisk-symbolic" : "drive-harddisk"; + case DRIVE_REMOTE : return use_symbolic ? "folder-remote-symbolic" : "folder-remote"; + case DRIVE_CDROM : return use_symbolic ? "drive-optical-symbolic" : "drive-optical"; + default : return use_symbolic ? "folder-symbolic" : "folder"; } } @@ -223,14 +228,29 @@ g_win32_mount_get_icon (GMount *mount) } else { - win32_mount->icon = g_themed_icon_new_with_default_fallbacks ( - _win32_drive_type_to_icon (win32_mount->drive_type)); + win32_mount->icon = g_themed_icon_new_with_default_fallbacks (_win32_drive_type_to_icon (win32_mount->drive_type, FALSE)); } } return g_object_ref (win32_mount->icon); } +static GIcon * +g_win32_mount_get_symbolic_icon (GMount *mount) +{ + GWin32Mount *win32_mount = G_WIN32_MOUNT (mount); + + g_return_val_if_fail (win32_mount->mount_path != NULL, NULL); + + /* lazy creation */ + if (!win32_mount->symbolic_icon) + { + win32_mount->symbolic_icon = g_themed_icon_new_with_default_fallbacks (_win32_drive_type_to_icon (win32_mount->drive_type, TRUE)); + } + + return g_object_ref (win32_mount->symbolic_icon); +} + static char * g_win32_mount_get_uuid (GMount *mount) { @@ -292,102 +312,36 @@ typedef struct { GString *error_string; } UnmountEjectOp; -static void -eject_unmount_cb (GPid pid, gint status, gpointer user_data) -{ - UnmountEjectOp *data = user_data; - GSimpleAsyncResult *simple; - -#if 0 - if (WEXITSTATUS (status) != 0) - { - GError *error; - error = g_error_new_literal (G_IO_ERROR, - G_IO_ERROR_FAILED, - data->error_string->str); - simple = g_simple_async_result_new_from_error (G_OBJECT (data->win32_mount), - data->callback, - data->user_data, - error); - g_error_free (error); - } - else - { - simple = g_simple_async_result_new (G_OBJECT (data->win32_mount), - data->callback, - data->user_data, - NULL); - } - - g_simple_async_result_complete (simple); - g_object_unref (simple); - - g_source_remove (data->error_channel_source_id); - g_io_channel_unref (data->error_channel); - g_string_free (data->error_string, TRUE); - close (data->error_fd); - g_spawn_close_pid (pid); - g_free (data); -#endif -} - -static gboolean -eject_unmount_read_error (GIOChannel *channel, - GIOCondition condition, - gpointer user_data) -{ - char *str; - gsize str_len; - UnmountEjectOp *data = user_data; - - g_io_channel_read_to_end (channel, &str, &str_len, NULL); - g_string_append (data->error_string, str); - g_free (str); - return TRUE; -} - static void -eject_unmount_do (GMount *mount, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data, - char **argv) +g_win32_mount_unmount (GMount *mount, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { - GWin32Mount *win32_mount = G_WIN32_MOUNT (mount); -} - -static void -g_win32_mount_unmount (GMount *mount, - GMountUnmountFlags flags, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GWin32Mount *win32_mount = G_WIN32_MOUNT (mount); } static gboolean -g_win32_mount_unmount_finish (GMount *mount, - GAsyncResult *result, - GError **error) +g_win32_mount_unmount_finish (GMount *mount, + GAsyncResult *result, + GError **error) { return FALSE; } static void -g_win32_mount_eject (GMount *mount, - GMountUnmountFlags flags, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +g_win32_mount_eject (GMount *mount, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { - GWin32Mount *win32_mount = G_WIN32_MOUNT (mount); } static gboolean -g_win32_mount_eject_finish (GMount *mount, - GAsyncResult *result, - GError **error) +g_win32_mount_eject_finish (GMount *mount, + GAsyncResult *result, + GError **error) { return FALSE; } @@ -398,6 +352,7 @@ g_win32_mount_mount_iface_init (GMountIface *iface) iface->get_root = g_win32_mount_get_root; iface->get_name = g_win32_mount_get_name; iface->get_icon = g_win32_mount_get_icon; + iface->get_symbolic_icon = g_win32_mount_get_symbolic_icon; iface->get_uuid = g_win32_mount_get_uuid; iface->get_drive = g_win32_mount_get_drive; iface->get_volume = g_win32_mount_get_volume;