[libgd] Add MainViewGeneric::view-selection-changed signal



commit 43134a3534f0468a7de992e11e236989a7c86357
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Oct 25 04:36:22 2012 +0300

    Add MainViewGeneric::view-selection-changed signal
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686832

 libgd/gd-main-view-generic.c |   15 ++++++++++++++-
 libgd/gd-main-view.c         |   11 +++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/libgd/gd-main-view-generic.c b/libgd/gd-main-view-generic.c
index 6459b80..6e11cf8 100644
--- a/libgd/gd-main-view-generic.c
+++ b/libgd/gd-main-view-generic.c
@@ -21,13 +21,25 @@
 
 #include "gd-main-view-generic.h"
 
+enum {
+  VIEW_SELECTION_CHANGED,
+  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)
 {
-  /* nothing */
+  signals[VIEW_SELECTION_CHANGED] =
+    g_signal_new ("view-selection-changed",
+                  GD_TYPE_MAIN_VIEW_GENERIC,
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL, NULL,
+                  G_TYPE_NONE, 0);
 }
 
 /**
@@ -162,6 +174,7 @@ set_all_selection (GdMainViewGeneric *self,
   gtk_tree_model_foreach (actual_model,
                           set_selection_foreach,
                           GINT_TO_POINTER (selection));
+  g_signal_emit (self, signals[VIEW_SELECTION_CHANGED], 0);
 }
 
 void
diff --git a/libgd/gd-main-view.c b/libgd/gd-main-view.c
index c9244c1..d22bd7e 100644
--- a/libgd/gd-main-view.c
+++ b/libgd/gd-main-view.c
@@ -662,6 +662,15 @@ on_icon_view_item_activated (GtkIconView *icon_view,
 }
 
 static void
+on_view_selection_changed (GtkWidget *view,
+                           gpointer user_data)
+{
+  GdMainView *self = user_data;
+
+  g_signal_emit (self, signals[VIEW_SELECTION_CHANGED], 0);
+}
+
+static void
 gd_main_view_apply_model (GdMainView *self)
 {
   GdMainViewGeneric *generic = get_generic (self);
@@ -712,6 +721,8 @@ gd_main_view_rebuild (GdMainView *self)
                     G_CALLBACK (on_button_release_event), self);
   g_signal_connect_after (self->priv->current_view, "drag-begin",
                           G_CALLBACK (on_drag_begin), self);
+  g_signal_connect (self->priv->current_view, "view-selection-changed",
+                    G_CALLBACK (on_view_selection_changed), self);
 
   gd_main_view_apply_selection_mode (self);
   gd_main_view_apply_model (self);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]