[nautilus-actions] Define a new maintainer menu option 'Dump the clipboard'



commit 10cdc219c611eb478aa9ad5ccfa21ba111f4de91
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Dec 3 19:16:27 2009 +0100

    Define a new maintainer menu option 'Dump the clipboard'

 ChangeLog                                          |   12 ++++
 TODO                                               |    6 ++-
 nautilus-actions/nact/nact-clipboard.c             |   62 ++++++++++++++++++++
 nautilus-actions/nact/nact-clipboard.h             |    2 +
 nautilus-actions/nact/nact-main-menubar.c          |   11 ++++
 .../nact/nautilus-actions-maintainer.actions       |    2 +
 6 files changed, 94 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 194de10..a2db3b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-12-03 Pierre Wieser <pwieser trychlos org>
+
+	Add a maintainer menu option to dump the clipboard.
+
+	* nautilus-actions/nact/nact-clipboard.c:
+	* nautilus-actions/nact/nact-clipboard.h (nact_clipboard_dump):
+	New function.
+
+	* nautilus-actions/nact/nact-main-menubar.c:
+	* nautilus-actions/nact/nautilus-actions-maintainer.actions:
+	Define the a new 'Dump the clipboard' option.
+
 2009-12-02 Pierre Wieser <pwieser trychlos org>
 
 	* nautilus-actions/nact/nact-iaction-tab.c
diff --git a/TODO b/TODO
index dfdefc4..1727519 100644
--- a/TODO
+++ b/TODO
@@ -97,4 +97,8 @@
 
 - nact: new action assistant
 
-- check that having an id which is not a UUID is supported
+- nact: copy/paste: only the action is copied without its profiles
+
+- nact: shouldn't be able to paste into a read-only item
+
+- nact: when pasting an item, should reset provider and read-only flag
diff --git a/nautilus-actions/nact/nact-clipboard.c b/nautilus-actions/nact/nact-clipboard.c
index 8f00eaf..afdf091 100644
--- a/nautilus-actions/nact/nact-clipboard.c
+++ b/nautilus-actions/nact/nact-clipboard.c
@@ -122,6 +122,8 @@ static gchar *export_row_object( NactClipboard *clipboard, NAObject *object, con
 static void   get_from_primary_clipboard_callback( GtkClipboard *gtk_clipboard, GtkSelectionData *selection_data, guint info, NactClipboard *clipboard );
 static void   clear_primary_clipboard_callback( GtkClipboard *gtk_clipboard, NactClipboard *clipboard );
 
+static gchar *clipboard_mode_to_string( gint mode );
+
 GType
 nact_clipboard_get_type( void )
 {
@@ -760,3 +762,63 @@ clear_primary_clipboard_callback( GtkClipboard *gtk_clipboard, NactClipboard *cl
 	g_free( data );
 	clipboard->private->primary_data = NULL;
 }
+
+/**
+ * nact_clipboard_dump:
+ * @clipboard: this #NactClipboard instance.
+ *
+ * Dumps the content of the primary clipboard.
+ */
+void
+nact_clipboard_dump( NactClipboard *clipboard )
+{
+	static const gchar *thisfn = "nact_clipboard_dump";
+	gchar *mode;
+	GList *it;
+
+	g_return_if_fail( NACT_IS_CLIPBOARD( clipboard ));
+
+	if( !clipboard->private->dispose_has_run ){
+
+		g_debug( "%s:       window=%p (%s)", thisfn, ( void * ) clipboard->private->window, G_OBJECT_TYPE_NAME( clipboard->private->window ));
+		g_debug( "%s:          dnd=%p", thisfn, ( void * ) clipboard->private->dnd );
+		g_debug( "%s:      primary=%p", thisfn, ( void * ) clipboard->private->primary );
+		g_debug( "%s: primary_data=%p", thisfn, ( void * ) clipboard->private->primary_data );
+		g_debug( "%s:  primary_data->nb_actions=%d", thisfn, clipboard->private->primary_data->nb_actions );
+		g_debug( "%s: primary_data->nb_profiles=%d", thisfn, clipboard->private->primary_data->nb_profiles );
+		g_debug( "%s:    primary_data->nb_menus=%d", thisfn, clipboard->private->primary_data->nb_menus );
+		g_debug( "%s:       primary_data->items=%p (count=%d)",
+				thisfn,
+				( void * ) clipboard->private->primary_data->items,
+				clipboard->private->primary_data->items ? g_list_length( clipboard->private->primary_data->items ) : 0 );
+		mode = clipboard_mode_to_string( clipboard->private->primary_data->mode );
+		g_debug( "%s:       primary_data->mode=%d (%s)", thisfn, clipboard->private->primary_data->mode, mode );
+		g_free( mode );
+		g_debug( "%s:  primary_got=%s", thisfn, ( void * ) clipboard->private->primary_got ? "True":"False" );
+		for( it = clipboard->private->primary_data->items ; it ; it = it->next ){
+			na_object_object_dump( NA_OBJECT( it->data ));
+		}
+	}
+}
+
+static gchar *
+clipboard_mode_to_string( gint mode )
+{
+	gchar *mode_str;
+
+	switch( mode ){
+		case CLIPBOARD_MODE_CUT:
+			mode_str = g_strdup( "CutMode" );
+			break;
+
+		case CLIPBOARD_MODE_COPY:
+			mode_str = g_strdup( "CopyMode" );
+			break;
+
+		default:
+			mode_str = g_strdup( "unknown mode" );
+			break;
+	}
+
+	return( mode_str );
+}
diff --git a/nautilus-actions/nact/nact-clipboard.h b/nautilus-actions/nact/nact-clipboard.h
index c816e1b..572ebd3 100644
--- a/nautilus-actions/nact/nact-clipboard.h
+++ b/nautilus-actions/nact/nact-clipboard.h
@@ -101,6 +101,8 @@ void           nact_clipboard_primary_set( NactClipboard *clipboard, GList *item
 GList         *nact_clipboard_primary_get( NactClipboard *clipboard, gboolean *relabel );
 void           nact_clipboard_primary_counts( NactClipboard *clipboard, guint *actions, guint *profiles, guint *menus );
 
+void           nact_clipboard_dump( NactClipboard *clipboard );
+
 G_END_DECLS
 
 #endif /* __NACT_CLIPBOARD_H__ */
diff --git a/nautilus-actions/nact/nact-main-menubar.c b/nautilus-actions/nact/nact-main-menubar.c
index 94d7949..b644ed0 100644
--- a/nautilus-actions/nact/nact-main-menubar.c
+++ b/nautilus-actions/nact/nact-main-menubar.c
@@ -135,6 +135,7 @@ static void     on_export_activated( GtkAction *action, NactMainWindow *window )
 static void     on_dump_selection_activated( GtkAction *action, NactMainWindow *window );
 static void     on_brief_tree_store_dump_activated( GtkAction *action, NactMainWindow *window );
 static void     on_list_modified_items_activated( GtkAction *action, NactMainWindow *window );
+static void     on_dump_clipboard_activated( GtkAction *action, NactMainWindow *window );
 
 static void     on_help_activated( GtkAction *action, NactMainWindow *window );
 static void     on_about_activated( GtkAction *action, NactMainWindow *window );
@@ -240,6 +241,10 @@ static const GtkActionEntry entries[] = {
 				/* i18n: tooltip displayed in the status bar when selecting the ListModifiedItems item */
 				N_( "List the modified items" ),
 				G_CALLBACK( on_list_modified_items_activated ) },
+		{ "DumpClipboard", NULL, N_( "_Dump the clipboard" ), NULL,
+				/* i18n: tooltip displayed in the status bar when selecting the DumpClipboard item */
+				N_( "Dump the content of the clipboard object" ),
+				G_CALLBACK( on_dump_clipboard_activated ) },
 		{ "HelpItem" , GTK_STOCK_HELP, NULL, NULL,
 				/* i18n: tooltip displayed in the status bar when selecting the Help item */
 				N_( "Display help about this program" ),
@@ -1260,6 +1265,12 @@ on_list_modified_items_activated( GtkAction *action, NactMainWindow *window )
 }
 
 static void
+on_dump_clipboard_activated( GtkAction *action, NactMainWindow *window )
+{
+	nact_clipboard_dump( nact_main_window_get_clipboard( window ));
+}
+
+static void
 on_help_activated( GtkAction *gtk_action, NactMainWindow *window )
 {
 }
diff --git a/nautilus-actions/nact/nautilus-actions-maintainer.actions b/nautilus-actions/nact/nautilus-actions-maintainer.actions
index 9077381..9dca50e 100644
--- a/nautilus-actions/nact/nautilus-actions-maintainer.actions
+++ b/nautilus-actions/nact/nautilus-actions-maintainer.actions
@@ -6,6 +6,7 @@
                 <menuitem action="DumpSelectionItem" />
                 <menuitem action="BriefTreeStoreDumpItem" />
                 <menuitem action="ListModifiedItems" />
+                <menuitem action="DumpClipboard" />
             </menu>
         </placeholder>
     </menubar>
@@ -14,5 +15,6 @@
                 <toolitem action="DumpSelectionItem" />
                 <toolitem action="BriefTreeStoreDumpItem" />
                 <toolitem action="ListModifiedItems" />
+                <toolitem action="DumpClipboard" />
     </toolbar>
 </ui>



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