[nautilus] progress-info: add NautilusProgressUIHandler
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] progress-info: add NautilusProgressUIHandler
- Date: Fri, 4 Feb 2011 00:39:07 +0000 (UTC)
commit adab8f5fe5681dcb06be4d6fbaa674624b49b6b5
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Feb 2 11:53:14 2011 -0500
progress-info: add NautilusProgressUIHandler
It will take care of the various states of file operation progress' user
interface.
src/Makefile.am | 2 +
src/nautilus-application.c | 23 ++------
src/nautilus-progress-ui-handler.c | 115 ++++++++++++++++++++++++++++++++++++
src/nautilus-progress-ui-handler.h | 65 ++++++++++++++++++++
4 files changed, 187 insertions(+), 18 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 52f4204..a21da0f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -109,6 +109,8 @@ nautilus_SOURCES = \
nautilus-pathbar.h \
nautilus-places-sidebar.c \
nautilus-places-sidebar.h \
+ nautilus-progress-ui-handler.c \
+ nautilus-progress-ui-handler.h \
nautilus-properties-window.c \
nautilus-properties-window.h \
nautilus-query-editor.c \
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 4bfc63a..de6aaf3 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -41,7 +41,7 @@
#include "nautilus-list-view.h"
#include "nautilus-navigation-window.h"
#include "nautilus-navigation-window-slot.h"
-#include "nautilus-progress-info-manager.h"
+#include "nautilus-progress-ui-handler.h"
#include "nautilus-self-check-functions.h"
#include "nautilus-spatial-window.h"
#include "nautilus-window-bookmarks.h"
@@ -110,7 +110,7 @@ struct _NautilusApplicationPriv {
GVolumeMonitor *volume_monitor;
GDBusProxy *ck_proxy;
gboolean session_is_active;
- NautilusProgressInfoManager *progress_manager;
+ NautilusProgressUIHandler *progress_handler;
gboolean initialized;
};
@@ -473,18 +473,6 @@ do_upgrades_once (NautilusApplication *application,
}
static void
-new_progress_info_cb (NautilusProgressInfoManager *manager,
- NautilusProgressInfo *info,
- NautilusApplication *self)
-{
- /* hold/release application while there are file operations in progress */
- g_signal_connect_swapped (info, "started",
- G_CALLBACK (g_application_hold), self);
- g_signal_connect_swapped (info, "finished",
- G_CALLBACK (g_application_release), self);
-}
-
-static void
finish_startup (NautilusApplication *application,
gboolean no_desktop)
{
@@ -502,9 +490,8 @@ finish_startup (NautilusApplication *application,
/* Initialize the ConsoleKit listener for active session */
do_initialize_consolekit (application);
- application->priv->progress_manager = nautilus_progress_info_manager_new ();
- g_signal_connect (application->priv->progress_manager, "new-progress-info",
- G_CALLBACK (new_progress_info_cb), application);
+ /* Initialize the UI handler singleton for file operations */
+ application->priv->progress_handler = nautilus_progress_ui_handler_new ();
/* Watch for unmounts so we can close open windows */
/* TODO-gio: This should be using the UNMOUNTED feature of GFileMonitor instead */
@@ -1281,7 +1268,7 @@ nautilus_application_finalize (GObject *object)
g_clear_object (&application->priv->volume_monitor);
g_clear_object (&application->priv->ck_proxy);
- g_clear_object (&application->priv->progress_manager);
+ g_clear_object (&application->priv->progress_handler);
nautilus_dbus_manager_stop ();
diff --git a/src/nautilus-progress-ui-handler.c b/src/nautilus-progress-ui-handler.c
new file mode 100644
index 0000000..9ab8f03
--- /dev/null
+++ b/src/nautilus-progress-ui-handler.c
@@ -0,0 +1,115 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * nautilus-progress-ui-handler.c: file operation progress user interface.
+ *
+ * Copyright (C) 2007, 2011 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Alexander Larsson <alexl redhat com>
+ * Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#include <config.h>
+
+#include "nautilus-progress-ui-handler.h"
+
+#include "nautilus-application.h"
+
+#include <libnautilus-private/nautilus-progress-info.h>
+#include <libnautilus-private/nautilus-progress-info-manager.h>
+
+struct _NautilusProgressUIHandlerPriv {
+ NautilusProgressInfoManager *manager;
+};
+
+G_DEFINE_TYPE (NautilusProgressUIHandler, nautilus_progress_ui_handler, G_TYPE_OBJECT);
+
+static void
+progress_info_finished_cb (NautilusProgressInfo *info,
+ NautilusProgressUIHandler *self)
+{
+ NautilusApplication *app;
+
+ app = nautilus_application_dup_singleton ();
+ g_application_release (G_APPLICATION (app));
+
+ g_object_unref (app);
+}
+
+static void
+progress_info_started_cb (NautilusProgressInfo *info,
+ NautilusProgressUIHandler *self)
+{
+ NautilusApplication *app;
+
+ app = nautilus_application_dup_singleton ();
+ g_application_hold (G_APPLICATION (app));
+
+ g_signal_connect (info, "finished",
+ G_CALLBACK (progress_info_finished_cb), self);
+
+ g_object_unref (app);
+}
+
+static void
+new_progress_info_cb (NautilusProgressInfoManager *manager,
+ NautilusProgressInfo *info,
+ NautilusProgressUIHandler *self)
+{
+ g_signal_connect (info, "started",
+ G_CALLBACK (progress_info_started_cb), self);
+}
+
+static void
+nautilus_progress_ui_handler_dispose (GObject *obj)
+{
+ NautilusProgressUIHandler *self = NAUTILUS_PROGRESS_UI_HANDLER (obj);
+
+ g_clear_object (&self->priv->manager);
+
+ G_OBJECT_CLASS (nautilus_progress_ui_handler_parent_class)->dispose (obj);
+}
+
+static void
+nautilus_progress_ui_handler_init (NautilusProgressUIHandler *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_PROGRESS_UI_HANDLER,
+ NautilusProgressUIHandlerPriv);
+
+ self->priv->manager = nautilus_progress_info_manager_new ();
+
+ g_signal_connect (self->priv->manager, "new-progress-info",
+ G_CALLBACK (new_progress_info_cb), self);
+}
+
+static void
+nautilus_progress_ui_handler_class_init (NautilusProgressUIHandlerClass *klass)
+{
+ GObjectClass *oclass;
+
+ oclass = G_OBJECT_CLASS (klass);
+ oclass->dispose = nautilus_progress_ui_handler_dispose;
+
+ g_type_class_add_private (klass, sizeof (NautilusProgressUIHandlerPriv));
+}
+
+NautilusProgressUIHandler *
+nautilus_progress_ui_handler_new (void)
+{
+ return g_object_new (NAUTILUS_TYPE_PROGRESS_UI_HANDLER, NULL);
+}
diff --git a/src/nautilus-progress-ui-handler.h b/src/nautilus-progress-ui-handler.h
new file mode 100644
index 0000000..f09c2ea
--- /dev/null
+++ b/src/nautilus-progress-ui-handler.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * nautilus-progress-ui-handler.h: file operation progress user interface.
+ *
+ * Copyright (C) 2007, 2011 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Alexander Larsson <alexl redhat com>
+ * Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#ifndef __NAUTILUS_PROGRESS_UI_HANDLER_H__
+#define __NAUTILUS_PROGRESS_UI_HANDLER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_PROGRESS_UI_HANDLER nautilus_progress_ui_handler_get_type()
+#define NAUTILUS_PROGRESS_UI_HANDLER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_PROGRESS_UI_HANDLER, NautilusProgressUIHandler))
+#define NAUTILUS_PROGRESS_UI_HANDLER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PROGRESS_UI_HANDLER, NautilusProgressUIHandlerClass))
+#define NAUTILUS_IS_PROGRESS_UI_HANDLER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_PROGRESS_UI_HANDLER))
+#define NAUTILUS_IS_PROGRESS_UI_HANDLER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PROGRESS_UI_HANDLER))
+#define NAUTILUS_PROGRESS_UI_HANDLER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_PROGRESS_UI_HANDLER, NautilusProgressUIHandlerClass))
+
+typedef struct _NautilusProgressUIHandlerPriv NautilusProgressUIHandlerPriv;
+
+typedef struct {
+ GObject parent;
+
+ /* private */
+ NautilusProgressUIHandlerPriv *priv;
+} NautilusProgressUIHandler;
+
+typedef struct {
+ GObjectClass parent_class;
+} NautilusProgressUIHandlerClass;
+
+GType nautilus_progress_ui_handler_get_type (void);
+
+NautilusProgressUIHandler * nautilus_progress_ui_handler_new (void);
+
+G_END_DECLS
+
+#endif /* __NAUTILUS_PROGRESS_UI_HANDLER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]