Commit 4c20fa07 authored by Cosimo Cecchi's avatar Cosimo Cecchi

window: remove nautilus_window_get_selection[_count]

No need to duplicate selection handling between view and window.
parent dedd9e11
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "nautilus-trash-bar.h" #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-operations.h>
#include <libnautilus-private/nautilus-file-utilities.h> #include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-file.h> #include <libnautilus-private/nautilus-file.h>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
(G_TYPE_INSTANCE_GET_PRIVATE ((o), NAUTILUS_TYPE_TRASH_BAR, NautilusTrashBarPrivate)) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NAUTILUS_TYPE_TRASH_BAR, NautilusTrashBarPrivate))
enum { enum {
PROP_WINDOW = 1, PROP_VIEW = 1,
NUM_PROPERTIES NUM_PROPERTIES
}; };
...@@ -46,7 +46,7 @@ struct NautilusTrashBarPrivate ...@@ -46,7 +46,7 @@ struct NautilusTrashBarPrivate
GtkWidget *empty_button; GtkWidget *empty_button;
GtkWidget *restore_button; GtkWidget *restore_button;
NautilusWindow *window; NautilusView *view;
gulong selection_handler_id; gulong selection_handler_id;
}; };
...@@ -58,7 +58,7 @@ restore_button_clicked_cb (GtkWidget *button, ...@@ -58,7 +58,7 @@ restore_button_clicked_cb (GtkWidget *button,
{ {
GList *locations, *files, *l; GList *locations, *files, *l;
locations = nautilus_window_get_selection (bar->priv->window); locations = nautilus_view_get_selection (bar->priv->view);
files = NULL; files = NULL;
for (l = locations; l != NULL; l = l->next) { for (l = locations; l != NULL; l = l->next) {
...@@ -72,24 +72,24 @@ restore_button_clicked_cb (GtkWidget *button, ...@@ -72,24 +72,24 @@ restore_button_clicked_cb (GtkWidget *button,
} }
static void static void
selection_changed_cb (NautilusWindow *window, selection_changed_cb (NautilusView *view,
NautilusTrashBar *bar) NautilusTrashBar *bar)
{ {
int count; 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)); gtk_widget_set_sensitive (bar->priv->restore_button, (count > 0));
} }
static void static void
connect_window_and_update_button (NautilusTrashBar *bar) connect_view_and_update_button (NautilusTrashBar *bar)
{ {
bar->priv->selection_handler_id = 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); G_CALLBACK (selection_changed_cb), bar);
selection_changed_cb (bar->priv->window, bar); selection_changed_cb (bar->priv->view, bar);
} }
static void static void
...@@ -103,9 +103,9 @@ nautilus_trash_bar_set_property (GObject *object, ...@@ -103,9 +103,9 @@ nautilus_trash_bar_set_property (GObject *object,
bar = NAUTILUS_TRASH_BAR (object); bar = NAUTILUS_TRASH_BAR (object);
switch (prop_id) { switch (prop_id) {
case PROP_WINDOW: case PROP_VIEW:
bar->priv->window = g_value_get_object (value); bar->priv->view = g_value_get_object (value);
connect_window_and_update_button (bar); connect_view_and_update_button (bar);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -121,7 +121,7 @@ nautilus_trash_bar_finalize (GObject *obj) ...@@ -121,7 +121,7 @@ nautilus_trash_bar_finalize (GObject *obj)
bar = NAUTILUS_TRASH_BAR (obj); bar = NAUTILUS_TRASH_BAR (obj);
if (bar->priv->selection_handler_id) { 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); G_OBJECT_CLASS (nautilus_trash_bar_parent_class)->finalize (obj);
...@@ -151,11 +151,11 @@ nautilus_trash_bar_class_init (NautilusTrashBarClass *klass) ...@@ -151,11 +151,11 @@ nautilus_trash_bar_class_init (NautilusTrashBarClass *klass)
object_class->finalize = nautilus_trash_bar_finalize; object_class->finalize = nautilus_trash_bar_finalize;
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_WINDOW, PROP_VIEW,
g_param_spec_object ("window", g_param_spec_object ("view",
"window", "view",
"the NautilusWindow", "the NautilusView",
NAUTILUS_TYPE_WINDOW, NAUTILUS_TYPE_VIEW,
G_PARAM_WRITABLE | G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
...@@ -222,11 +222,11 @@ nautilus_trash_bar_init (NautilusTrashBar *bar) ...@@ -222,11 +222,11 @@ nautilus_trash_bar_init (NautilusTrashBar *bar)
} }
GtkWidget * GtkWidget *
nautilus_trash_bar_new (NautilusWindow *window) nautilus_trash_bar_new (NautilusView *view)
{ {
GObject *bar; 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); return GTK_WIDGET (bar);
} }
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#ifndef __NAUTILUS_TRASH_BAR_H #ifndef __NAUTILUS_TRASH_BAR_H
#define __NAUTILUS_TRASH_BAR_H #define __NAUTILUS_TRASH_BAR_H
#include "nautilus-window.h" #include "nautilus-view.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
...@@ -52,7 +52,7 @@ typedef struct ...@@ -52,7 +52,7 @@ typedef struct
GType nautilus_trash_bar_get_type (void) G_GNUC_CONST; 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 G_END_DECLS
......
...@@ -137,6 +137,7 @@ enum { ...@@ -137,6 +137,7 @@ enum {
MOVE_COPY_ITEMS, MOVE_COPY_ITEMS,
REMOVE_FILE, REMOVE_FILE,
ZOOM_LEVEL_CHANGED, ZOOM_LEVEL_CHANGED,
SELECTION_CHANGED,
TRASH, TRASH,
DELETE, DELETE,
LAST_SIGNAL LAST_SIGNAL
...@@ -2313,7 +2314,7 @@ fm_directory_view_display_selection_info (FMDirectoryView *view) ...@@ -2313,7 +2314,7 @@ fm_directory_view_display_selection_info (FMDirectoryView *view)
void void
fm_directory_view_send_selection_change (FMDirectoryView *view) 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; view->details->send_selection_change_to_shell = FALSE;
} }
...@@ -10707,6 +10708,14 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) ...@@ -10707,6 +10708,14 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
0, NULL, NULL, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); 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->accepts_dragged_files = real_accepts_dragged_files;
klass->file_still_belongs = real_file_still_belongs; klass->file_still_belongs = real_file_still_belongs;
......
...@@ -56,6 +56,7 @@ typedef FMDirectoryView NautilusView; ...@@ -56,6 +56,7 @@ typedef FMDirectoryView NautilusView;
#define FM_DIRECTORY_VIEW_GET_CLASS(obj) \ #define FM_DIRECTORY_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), FM_TYPE_DIRECTORY_VIEW, FMDirectoryViewClass)) (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_VIEW(obj) FM_DIRECTORY_VIEW(obj)
#define NAUTILUS_IS_VIEW(obj) FM_IS_DIRECTORY_VIEW(obj) #define NAUTILUS_IS_VIEW(obj) FM_IS_DIRECTORY_VIEW(obj)
......
...@@ -105,16 +105,6 @@ static void load_new_location (NautilusWindowSlot ...@@ -105,16 +105,6 @@ static void load_new_location (NautilusWindowSlot
static void location_has_really_changed (NautilusWindowSlot *slot); static void location_has_really_changed (NautilusWindowSlot *slot);
static void update_for_new_location (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: /* set_displayed_location:
*/ */
static void static void
...@@ -1425,12 +1415,13 @@ nautilus_window_slot_show_x_content_bar (NautilusWindowSlot *slot, GMount *mount ...@@ -1425,12 +1415,13 @@ nautilus_window_slot_show_x_content_bar (NautilusWindowSlot *slot, GMount *mount
} }
static void static void
nautilus_window_slot_show_trash_bar (NautilusWindowSlot *slot, nautilus_window_slot_show_trash_bar (NautilusWindowSlot *slot)
NautilusWindow *window)
{ {
GtkWidget *bar; 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); gtk_widget_show (bar);
nautilus_window_slot_add_extra_location_widget (slot, bar); nautilus_window_slot_add_extra_location_widget (slot, bar);
...@@ -1565,7 +1556,7 @@ update_for_new_location (NautilusWindowSlot *slot) ...@@ -1565,7 +1556,7 @@ update_for_new_location (NautilusWindowSlot *slot)
nautilus_window_slot_update_query_editor (slot); nautilus_window_slot_update_query_editor (slot);
if (nautilus_directory_is_in_trash (directory)) { 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 */ /* need the mount to determine if we should put up the x-content cluebar */
......
...@@ -91,7 +91,6 @@ enum { ...@@ -91,7 +91,6 @@ enum {
ZOOM_CHANGED, ZOOM_CHANGED,
VIEW_AS_CHANGED, VIEW_AS_CHANGED,
LOADING_URI, LOADING_URI,
SELECTION_CHANGED,
HIDDEN_FILES_MODE_CHANGED, HIDDEN_FILES_MODE_CHANGED,
LAST_SIGNAL LAST_SIGNAL
}; };
...@@ -1686,37 +1685,6 @@ nautilus_window_get_window_type (NautilusWindow *window) ...@@ -1686,37 +1685,6 @@ nautilus_window_get_window_type (NautilusWindow *window)
return NAUTILUS_WINDOW_GET_CLASS (window)->window_type; 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 NautilusWindowShowHiddenFilesMode
nautilus_window_get_hidden_files_mode (NautilusWindow *window) nautilus_window_get_hidden_files_mode (NautilusWindow *window)
{ {
...@@ -1891,15 +1859,6 @@ nautilus_window_class_init (NautilusWindowClass *class) ...@@ -1891,15 +1859,6 @@ nautilus_window_class_init (NautilusWindowClass *class)
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
G_TYPE_STRING); 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); binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0, gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0,
"go_up", 1, "go_up", 1,
......
...@@ -148,7 +148,6 @@ void nautilus_window_allow_up (NautilusWindow *window ...@@ -148,7 +148,6 @@ void nautilus_window_allow_up (NautilusWindow *window
GtkUIManager * nautilus_window_get_ui_manager (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, void nautilus_window_report_load_complete (NautilusWindow *window,
NautilusView *view); NautilusView *view);
...@@ -167,7 +166,5 @@ void nautilus_window_set_initiated_unmount (NautilusWindow *wind ...@@ -167,7 +166,5 @@ void nautilus_window_set_initiated_unmount (NautilusWindow *wind
NautilusWindowSlot * nautilus_window_get_active_slot (NautilusWindow *window); NautilusWindowSlot * nautilus_window_get_active_slot (NautilusWindow *window);
void nautilus_window_push_status (NautilusWindow *window, void nautilus_window_push_status (NautilusWindow *window,
const char *text); const char *text);
int nautilus_window_get_selection_count (NautilusWindow *window);
GList * nautilus_window_get_selection (NautilusWindow *window);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment