[gtk+/places-sidebar] New signal populate-popup



commit e00498fcd8d5a006c0016bce6e2f77e5c78cfc82
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Dec 14 11:57:49 2012 -0600

    New signal populate-popup
    
    Instead of conditionally creating contextual menu items like 'Show file properties',
    we'll instead let the caller populate the popup menu, as is done for GtkEntry.
    
    Signed-off-by: Federico Mena Quintero <federico gnome org>

 gtk/gtkplacessidebar.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index a59da60..033fda0 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -148,6 +148,9 @@ struct _GtkPlacesSidebarClass {
 	void (* open_location)         (GtkPlacesSidebar *sidebar,
 				        GFile            *location,
 				        GtkPlacesOpenMode open_mode);
+	void (* populate_popup)        (GtkPlacesSidebar *sidebar,
+					GtkMenu          *menu,
+					GFile            *selected_item);
 	void (* show_file_properties)  (GtkPlacesSidebar *sidebar,
 					GFile            *file);
 	void (* empty_trash_requested) (GtkPlacesSidebar *sidebar);
@@ -203,6 +206,7 @@ typedef enum {
 
 enum {
 	OPEN_LOCATION,
+	POPULATE_POPUP,
 	SHOW_FILE_PROPERTIES,
 	EMPTY_TRASH_REQUESTED,
 	SHOW_ERROR_MESSAGE,
@@ -309,6 +313,13 @@ emit_open_location (GtkPlacesSidebar *sidebar, GFile *location, GtkPlacesOpenMod
 }
 
 static void
+emit_populate_popup (GtkPlacesSidebar *sidebar, GtkMenu *menu, GFile *selected_item)
+{
+	g_signal_emit (sidebar, places_sidebar_signals[POPULATE_POPUP], 0,
+		       menu, selected_item);
+}
+
+static void
 emit_show_file_properties (GtkPlacesSidebar *sidebar, GFile *file)
 {
 	g_signal_emit (sidebar, places_sidebar_signals[SHOW_FILE_PROPERTIES], 0,
@@ -3704,6 +3715,17 @@ gtk_places_sidebar_class_init (GtkPlacesSidebarClass *class)
 			      G_TYPE_OBJECT,
 			      GTK_TYPE_PLACES_OPEN_MODE);
 
+	places_sidebar_signals [POPULATE_POPUP] =
+		g_signal_new (I_("populate-popup"),
+			      G_OBJECT_CLASS_TYPE (gobject_class),
+			      G_SIGNAL_RUN_FIRST,
+			      G_STRUCT_OFFSET (GtkPlacesSidebarClass, populate_popup),
+			      NULL, NULL,
+			      _gtk_marshal_VOID__OBJECT_OBJECT,
+			      G_TYPE_NONE, 2,
+			      G_TYPE_OBJECT,
+			      G_TYPE_OBJECT);
+
 	places_sidebar_signals [SHOW_FILE_PROPERTIES] =
 		g_signal_new (I_("show-file-properties"),
 			      G_OBJECT_CLASS_TYPE (gobject_class),



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