[nautilus/refactor: 20/26] window: remove nautilus_window_get_selection[_count]
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/refactor: 20/26] window: remove nautilus_window_get_selection[_count]
- Date: Wed, 29 Dec 2010 17:59:08 +0000 (UTC)
commit 65db0cf05c0a2c13cecebf2371d3eeab8b72606c
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Dec 29 15:04:38 2010 +0100
window: remove nautilus_window_get_selection[_count]
No need to duplicate selection handling between view and window.
src/nautilus-trash-bar.c | 40 +++++++++++++++++-----------------
src/nautilus-trash-bar.h | 4 +-
src/nautilus-view.c | 11 ++++++++-
src/nautilus-view.h | 1 +
src/nautilus-window-manage-views.c | 19 ++++------------
src/nautilus-window.c | 41 ------------------------------------
src/nautilus-window.h | 3 --
7 files changed, 38 insertions(+), 81 deletions(-)
---
diff --git a/src/nautilus-trash-bar.c b/src/nautilus-trash-bar.c
index 81d9a31..08b43a6 100644
--- a/src/nautilus-trash-bar.c
+++ b/src/nautilus-trash-bar.c
@@ -27,7 +27,7 @@
#include "nautilus-trash-bar.h"
-#include "nautilus-window.h"
+#include "nautilus-view.h"
#include <libnautilus-private/nautilus-file-operations.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-file.h>
@@ -37,7 +37,7 @@
(G_TYPE_INSTANCE_GET_PRIVATE ((o), NAUTILUS_TYPE_TRASH_BAR, NautilusTrashBarPrivate))
enum {
- PROP_WINDOW = 1,
+ PROP_VIEW = 1,
NUM_PROPERTIES
};
@@ -46,7 +46,7 @@ struct NautilusTrashBarPrivate
GtkWidget *empty_button;
GtkWidget *restore_button;
- NautilusWindow *window;
+ NautilusView *view;
gulong selection_handler_id;
};
@@ -58,7 +58,7 @@ restore_button_clicked_cb (GtkWidget *button,
{
GList *locations, *files, *l;
- locations = nautilus_window_get_selection (bar->priv->window);
+ locations = nautilus_view_get_selection (bar->priv->view);
files = NULL;
for (l = locations; l != NULL; l = l->next) {
@@ -72,24 +72,24 @@ restore_button_clicked_cb (GtkWidget *button,
}
static void
-selection_changed_cb (NautilusWindow *window,
+selection_changed_cb (NautilusView *view,
NautilusTrashBar *bar)
{
int count;
- count = nautilus_window_get_selection_count (window);
+ count = nautilus_view_get_selection_count (view);
gtk_widget_set_sensitive (bar->priv->restore_button, (count > 0));
}
static void
-connect_window_and_update_button (NautilusTrashBar *bar)
+connect_view_and_update_button (NautilusTrashBar *bar)
{
bar->priv->selection_handler_id =
- g_signal_connect (bar->priv->window, "selection_changed",
+ g_signal_connect (bar->priv->view, "selection-changed",
G_CALLBACK (selection_changed_cb), bar);
- selection_changed_cb (bar->priv->window, bar);
+ selection_changed_cb (bar->priv->view, bar);
}
static void
@@ -103,9 +103,9 @@ nautilus_trash_bar_set_property (GObject *object,
bar = NAUTILUS_TRASH_BAR (object);
switch (prop_id) {
- case PROP_WINDOW:
- bar->priv->window = g_value_get_object (value);
- connect_window_and_update_button (bar);
+ case PROP_VIEW:
+ bar->priv->view = g_value_get_object (value);
+ connect_view_and_update_button (bar);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -121,7 +121,7 @@ nautilus_trash_bar_finalize (GObject *obj)
bar = NAUTILUS_TRASH_BAR (obj);
if (bar->priv->selection_handler_id) {
- g_signal_handler_disconnect (bar->priv->window, bar->priv->selection_handler_id);
+ g_signal_handler_disconnect (bar->priv->view, bar->priv->selection_handler_id);
}
G_OBJECT_CLASS (nautilus_trash_bar_parent_class)->finalize (obj);
@@ -151,11 +151,11 @@ nautilus_trash_bar_class_init (NautilusTrashBarClass *klass)
object_class->finalize = nautilus_trash_bar_finalize;
g_object_class_install_property (object_class,
- PROP_WINDOW,
- g_param_spec_object ("window",
- "window",
- "the NautilusWindow",
- NAUTILUS_TYPE_WINDOW,
+ PROP_VIEW,
+ g_param_spec_object ("view",
+ "view",
+ "the NautilusView",
+ NAUTILUS_TYPE_VIEW,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
@@ -222,11 +222,11 @@ nautilus_trash_bar_init (NautilusTrashBar *bar)
}
GtkWidget *
-nautilus_trash_bar_new (NautilusWindow *window)
+nautilus_trash_bar_new (NautilusView *view)
{
GObject *bar;
- bar = g_object_new (NAUTILUS_TYPE_TRASH_BAR, "window", window, NULL);
+ bar = g_object_new (NAUTILUS_TYPE_TRASH_BAR, "view", view, NULL);
return GTK_WIDGET (bar);
}
diff --git a/src/nautilus-trash-bar.h b/src/nautilus-trash-bar.h
index fe8770c..b18445f 100644
--- a/src/nautilus-trash-bar.h
+++ b/src/nautilus-trash-bar.h
@@ -23,7 +23,7 @@
#ifndef __NAUTILUS_TRASH_BAR_H
#define __NAUTILUS_TRASH_BAR_H
-#include "nautilus-window.h"
+#include "nautilus-view.h"
#include <gtk/gtk.h>
@@ -52,7 +52,7 @@ typedef struct
GType nautilus_trash_bar_get_type (void) G_GNUC_CONST;
-GtkWidget *nautilus_trash_bar_new (NautilusWindow *window);
+GtkWidget *nautilus_trash_bar_new (NautilusView *view);
G_END_DECLS
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 1bac03e..5ab7361 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -137,6 +137,7 @@ enum {
MOVE_COPY_ITEMS,
REMOVE_FILE,
ZOOM_LEVEL_CHANGED,
+ SELECTION_CHANGED,
TRASH,
DELETE,
LAST_SIGNAL
@@ -2313,7 +2314,7 @@ fm_directory_view_display_selection_info (FMDirectoryView *view)
void
fm_directory_view_send_selection_change (FMDirectoryView *view)
{
- nautilus_window_report_selection_changed (view->details->window);
+ g_signal_emit (view, signals[SELECTION_CHANGED], 0);
view->details->send_selection_change_to_shell = FALSE;
}
@@ -10707,6 +10708,14 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[SELECTION_CHANGED] =
+ g_signal_new ("selection-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
klass->accepts_dragged_files = real_accepts_dragged_files;
klass->file_still_belongs = real_file_still_belongs;
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index 224b8a8..2c03196 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -56,6 +56,7 @@ typedef FMDirectoryView NautilusView;
#define FM_DIRECTORY_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), FM_TYPE_DIRECTORY_VIEW, FMDirectoryViewClass))
+#define NAUTILUS_TYPE_VIEW FM_TYPE_DIRECTORY_VIEW
#define NAUTILUS_VIEW(obj) FM_DIRECTORY_VIEW(obj)
#define NAUTILUS_IS_VIEW(obj) FM_IS_DIRECTORY_VIEW(obj)
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 92c85f0..b70f817 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -105,16 +105,6 @@ static void load_new_location (NautilusWindowSlot
static void location_has_really_changed (NautilusWindowSlot *slot);
static void update_for_new_location (NautilusWindowSlot *slot);
-void
-nautilus_window_report_selection_changed (NautilusWindow *window)
-{
- if (window->details->temporarily_ignore_view_signals) {
- return;
- }
-
- g_signal_emit_by_name (window, "selection_changed");
-}
-
/* set_displayed_location:
*/
static void
@@ -1425,12 +1415,13 @@ nautilus_window_slot_show_x_content_bar (NautilusWindowSlot *slot, GMount *mount
}
static void
-nautilus_window_slot_show_trash_bar (NautilusWindowSlot *slot,
- NautilusWindow *window)
+nautilus_window_slot_show_trash_bar (NautilusWindowSlot *slot)
{
GtkWidget *bar;
+ NautilusView *view;
- bar = nautilus_trash_bar_new (window);
+ view = nautilus_window_slot_get_current_view (slot);
+ bar = nautilus_trash_bar_new (view);
gtk_widget_show (bar);
nautilus_window_slot_add_extra_location_widget (slot, bar);
@@ -1565,7 +1556,7 @@ update_for_new_location (NautilusWindowSlot *slot)
nautilus_window_slot_update_query_editor (slot);
if (nautilus_directory_is_in_trash (directory)) {
- nautilus_window_slot_show_trash_bar (slot, window);
+ nautilus_window_slot_show_trash_bar (slot);
}
/* need the mount to determine if we should put up the x-content cluebar */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 9f3420b..2acafb2 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -91,7 +91,6 @@ enum {
ZOOM_CHANGED,
VIEW_AS_CHANGED,
LOADING_URI,
- SELECTION_CHANGED,
HIDDEN_FILES_MODE_CHANGED,
LAST_SIGNAL
};
@@ -1716,37 +1715,6 @@ nautilus_window_get_window_type (NautilusWindow *window)
return NAUTILUS_WINDOW_GET_CLASS (window)->window_type;
}
-int
-nautilus_window_get_selection_count (NautilusWindow *window)
-{
- NautilusWindowSlot *slot;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- slot = window->details->active_pane->active_slot;
-
- if (slot->content_view != NULL) {
- return nautilus_view_get_selection_count (slot->content_view);
- }
-
- return 0;
-}
-
-GList *
-nautilus_window_get_selection (NautilusWindow *window)
-{
- NautilusWindowSlot *slot;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- slot = window->details->active_pane->active_slot;
-
- if (slot->content_view != NULL) {
- return nautilus_view_get_selection (slot->content_view);
- }
- return NULL;
-}
-
NautilusWindowShowHiddenFilesMode
nautilus_window_get_hidden_files_mode (NautilusWindow *window)
{
@@ -1921,15 +1889,6 @@ nautilus_window_class_init (NautilusWindowClass *class)
G_TYPE_NONE, 1,
G_TYPE_STRING);
- signals[SELECTION_CHANGED] =
- g_signal_new ("selection_changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0,
"go_up", 1,
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 8028d79..db79fb8 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -148,7 +148,6 @@ void nautilus_window_allow_up (NautilusWindow *window
GtkUIManager * nautilus_window_get_ui_manager (NautilusWindow *window);
-void nautilus_window_report_selection_changed (NautilusWindow *window);
void nautilus_window_report_load_complete (NautilusWindow *window,
NautilusView *view);
@@ -167,7 +166,5 @@ void nautilus_window_set_initiated_unmount (NautilusWindow *wind
NautilusWindowSlot * nautilus_window_get_active_slot (NautilusWindow *window);
void nautilus_window_push_status (NautilusWindow *window,
const char *text);
-int nautilus_window_get_selection_count (NautilusWindow *window);
-GList * nautilus_window_get_selection (NautilusWindow *window);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]