[gnome-documents] main-view: move view-selection-changed to GdMainView
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] main-view: move view-selection-changed to GdMainView
- Date: Mon, 12 Mar 2012 20:18:28 +0000 (UTC)
commit 29e356a68045e7a1b6b9ca0fb98d55f616849129
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Mar 12 16:15:23 2012 -0400
main-view: move view-selection-changed to GdMainView
Doesn't make sense for this to stay on the generic widget now that we
track selections in the model.
src/lib/gd-main-view-generic.c | 15 +--------------
src/lib/gd-main-view.c | 11 +++++++++--
src/view.js | 16 +++-------------
3 files changed, 13 insertions(+), 29 deletions(-)
---
diff --git a/src/lib/gd-main-view-generic.c b/src/lib/gd-main-view-generic.c
index 9b69391..9744a48 100644
--- a/src/lib/gd-main-view-generic.c
+++ b/src/lib/gd-main-view-generic.c
@@ -22,26 +22,13 @@
#include "gd-main-view.h"
#include "gd-main-view-generic.h"
-enum {
- VIEW_SELECTION_CHANGED = 1,
- NUM_SIGNALS
-};
-
-static guint signals[NUM_SIGNALS] = { 0, };
-
typedef GdMainViewGenericIface GdMainViewGenericInterface;
G_DEFINE_INTERFACE (GdMainViewGeneric, gd_main_view_generic, GTK_TYPE_WIDGET)
static void
gd_main_view_generic_default_init (GdMainViewGenericInterface *iface)
{
- signals[VIEW_SELECTION_CHANGED] =
- g_signal_new ("view-selection-changed",
- GD_TYPE_MAIN_VIEW_GENERIC,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdMainViewGenericIface, selection_changed),
- NULL, NULL, NULL,
- G_TYPE_NONE, 0);
+ /* nothing */
}
/**
diff --git a/src/lib/gd-main-view.c b/src/lib/gd-main-view.c
index 8aa7c0e..c82cf3c 100644
--- a/src/lib/gd-main-view.c
+++ b/src/lib/gd-main-view.c
@@ -49,6 +49,7 @@ enum {
enum {
ITEM_ACTIVATED = 1,
SELECTION_MODE_REQUEST,
+ VIEW_SELECTION_CHANGED,
NUM_SIGNALS
};
@@ -191,6 +192,13 @@ gd_main_view_class_init (GdMainViewClass *klass)
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
+ signals[VIEW_SELECTION_CHANGED] =
+ g_signal_new ("view-selection-changed",
+ GD_TYPE_MAIN_VIEW,
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
g_type_class_add_private (klass, sizeof (GdMainViewPrivate));
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
}
@@ -304,7 +312,6 @@ on_button_release_selection_mode (GdMainView *self,
gboolean entered_mode,
GtkTreePath *path)
{
- GdMainViewGeneric *generic = get_generic (self);
gboolean selected;
GtkTreeIter iter;
@@ -324,7 +331,7 @@ on_button_release_selection_mode (GdMainView *self,
GD_MAIN_COLUMN_SELECTED, TRUE,
-1);
- g_signal_emit_by_name (generic, "view-selection-changed");
+ g_signal_emit (self, signals[VIEW_SELECTION_CHANGED], 0);
return FALSE;
}
diff --git a/src/view.js b/src/view.js
index 2022252..3f3fcae 100644
--- a/src/view.js
+++ b/src/view.js
@@ -120,6 +120,8 @@ View.prototype = {
Lang.bind(this, this._onItemActivated));
this.widget.connect('selection-mode-request',
Lang.bind(this, this._onSelectionModeRequest));
+ this.widget.connect('view-selection-changed',
+ Lang.bind(this, this._onViewSelectionChanged));
this.widget.connect('notify::view-type',
Lang.bind(this, this._onViewTypeChanged));
@@ -223,18 +225,6 @@ View.prototype = {
_onViewTypeChanged: function() {
if (this.widget.get_view_type() == Gd.MainViewType.LIST)
this._addListRenderers();
-
- // setup selections view => controller
- let generic = this.widget.get_generic_view();
- generic.connect('view-selection-changed', Lang.bind(this, this._onSelectionChanged));
-
- Global.selectionController.freezeSelection(false);
-
- generic.connect('destroy', Lang.bind(this,
- function() {
- // save selection when the view is destroyed
- Global.selectionController.freezeSelection(true);
- }));
},
_onSelectionModeRequest: function() {
@@ -305,7 +295,7 @@ View.prototype = {
this.widget.set_selection_mode(selectionMode);
},
- _onSelectionChanged: function() {
+ _onViewSelectionChanged: function() {
// update the selection on the controller when the view signals a change
let selectedURNs = Utils.getURNsFromPaths(this.widget.get_selection(),
this._treeModel);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]