[nautilus-actions] Let the user be asked for export format in drag and drop opes
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Let the user be asked for export format in drag and drop opes
- Date: Sat, 17 Oct 2009 23:48:59 +0000 (UTC)
commit 4388779c0d595d514195aa5bf6f2d031eaf286e4
Author: Pierre Wieser <pwieser trychlos org>
Date: Sat Oct 17 18:28:04 2009 +0200
Let the user be asked for export format in drag and drop opes
ChangeLog | 5 +
src/nact/nact-clipboard.c | 183 +++++++++++++++++++----------------------
src/nact/nact-iactions-list.c | 3 +-
src/runtime/na-object.c | 2 +
4 files changed, 95 insertions(+), 98 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2bb618f..4e57472 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,16 @@
2009-10-17 Pierre Wieser <pwieser trychlos org>
Make clipboard have an access to preferences.
+ Let the user be asked for the export format in drag and drop operations.
* src/nact/nact-clipboard.c:
* src/nact/nact-clipboard.h (nact_clipboard_new):
Now pass the BaseWindow as an argument.
+ * src/nact/nact-clipboard.c
+ (nact_clipboard_dnd_get_text, nact_clipboard_dnd_drag_end):
+ Ask the user if needed.
+
* src/nact/nact-main-window.c:
* src/nact/nact-tree-model.c: Updated accordingly.
diff --git a/src/nact/nact-clipboard.c b/src/nact/nact-clipboard.c
index 3c0fd6f..2add2e4 100644
--- a/src/nact/nact-clipboard.c
+++ b/src/nact/nact-clipboard.c
@@ -35,12 +35,16 @@
#include <gtk/gtk.h>
#include <string.h>
+#include <runtime/na-pivot.h>
+
#include <common/na-iprefs.h>
#include <common/na-object-api.h>
#include <common/na-xml-names.h>
#include <common/na-xml-writer.h>
#include <common/na-utils.h>
+#include "nact-application.h"
+#include "nact-assistant-export-ask.h"
#include "nact-tree-model.h"
#include "nact-clipboard.h"
@@ -54,6 +58,7 @@ struct NactClipboardClassPrivate {
*/
struct NactClipboardPrivate {
gboolean dispose_has_run;
+ BaseWindow *window;
GtkClipboard *dnd;
GtkClipboard *primary;
gboolean primary_got;
@@ -109,8 +114,8 @@ static void instance_finalize( GObject *application );
static void get_from_dnd_clipboard_callback( GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, guchar *data );
static void clear_dnd_clipboard_callback( GtkClipboard *clipboard, NactClipboardDndData *data );
-static gchar *get_action_xml_buffer( const NAObject *object, GList **exported, NAObjectAction **action );
-static void export_rows( NactClipboard *clipboard, NactClipboardDndData *data );
+static gchar *export_rows( NactClipboard *clipboard, GList *rows, const gchar *dest_folder );
+static gchar *export_row_object( NactClipboard *clipboard, NAObject *object, const gchar *dest_folder, GList **exported );
static void get_from_primary_clipboard_callback( GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, guchar *data );
static void clear_primary_clipboard_callback( GtkClipboard *clipboard, NactClipboardPrimaryData *data );
@@ -241,8 +246,12 @@ nact_clipboard_new( BaseWindow *window )
{
NactClipboard *clipboard;
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
clipboard = g_object_new( NACT_CLIPBOARD_TYPE, NULL );
+ clipboard->private->window = window;
+
return( clipboard );
}
@@ -361,57 +370,17 @@ nact_clipboard_dnd_get_data( NactClipboard *clipboard, gboolean *copy_data )
gchar *
nact_clipboard_dnd_get_text( NactClipboard *clipboard, GList *rows )
{
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- NAObject *object;
- NAObjectAction *action;
- GList *it;
- GList *exported;
- GString *data;
- gchar *chunk;
+ gchar *buffer;
g_return_val_if_fail( NACT_IS_CLIPBOARD( clipboard ), NULL );
- g_return_val_if_fail( rows && g_list_length( rows ), NULL );
- data = g_string_new( "" );
+ buffer = NULL;
if( !clipboard->private->dispose_has_run ){
-
- exported = NULL;
- model = gtk_tree_row_reference_get_model(( GtkTreeRowReference * ) rows->data );
-
- for( it = rows ; it ; it = it->next ){
-
- path = gtk_tree_row_reference_get_path(( GtkTreeRowReference * ) it->data );
- if( path ){
- gtk_tree_model_get_iter( model, &iter, path );
- gtk_tree_path_free( path );
-
- gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
- chunk = NULL;
-
- if( NA_IS_OBJECT_ACTION( object )){
- chunk = get_action_xml_buffer( object, &exported, &action );
-
- } else if( NA_IS_OBJECT_PROFILE( object )){
- chunk = get_action_xml_buffer( object, &exported, &action );
- }
-
- if( chunk ){
- g_assert( strlen( chunk ));
- data = g_string_append( data, chunk );
- g_free( chunk );
- }
-
- g_object_unref( object );
- }
- }
-
- g_list_free( exported );
+ buffer = export_rows( clipboard, rows, NULL );
}
- return( g_string_free( data, FALSE ));
+ return( buffer );
}
/**
@@ -437,7 +406,7 @@ nact_clipboard_dnd_drag_end( NactClipboard *clipboard )
data = ( NactClipboardDndData * ) selection->data;
if( data->target == NACT_XCHANGE_FORMAT_XDS ){
- export_rows( clipboard, data );
+ export_rows( clipboard, data->rows, data->folder );
}
}
}
@@ -483,80 +452,100 @@ clear_dnd_clipboard_callback( GtkClipboard *clipboard, NactClipboardDndData *dat
}
static gchar *
-get_action_xml_buffer( const NAObject *object, GList **exported, NAObjectAction **action )
+export_rows( NactClipboard *clipboard, GList *rows, const gchar *dest_folder )
{
- gchar *buffer = NULL;
- gint index;
-
- g_return_val_if_fail( action, NULL );
-
- *action = NULL;
+ GString *data;
+ GtkTreeModel *model;
+ GList *exported, *irow;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ NAObject *object;
+ gchar *buffer;
- if( NA_IS_OBJECT_ACTION( object )){
- *action = NA_OBJECT_ACTION( object );
- }
- if( NA_IS_OBJECT_PROFILE( object )){
- *action = NA_OBJECT_ACTION( na_object_get_parent( NA_OBJECT_PROFILE( object )));
- }
+ buffer = NULL;
+ exported = NULL;
+ data = g_string_new( "" );
+ model = gtk_tree_row_reference_get_model(( GtkTreeRowReference * ) rows->data );
- if( *action ){
- index = g_list_index( *exported, ( gconstpointer ) *action );
- if( index == -1 ){
- buffer = na_xml_writer_get_xml_buffer( *action, IPREFS_EXPORT_FORMAT_GCONF_ENTRY );
- *exported = g_list_prepend( *exported, ( gpointer ) *action );
+ for( irow = rows ; irow ; irow = irow->next ){
+ path = gtk_tree_row_reference_get_path(( GtkTreeRowReference * ) irow->data );
+ if( path ){
+ gtk_tree_model_get_iter( model, &iter, path );
+ gtk_tree_path_free( path );
+ gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
+ buffer = export_row_object( clipboard, object, dest_folder, &exported );
+ if( buffer && strlen( buffer )){
+ data = g_string_append( data, buffer );
+ g_free( buffer );
+ }
+ g_object_unref( object );
}
}
- return( buffer );
+ g_list_free( exported );
+ return( g_string_free( data, FALSE ));
}
-/*
- * Exports selected actions.
- *
- * This is called when we drop or paste a selection onto an application
- * willing to deal with XdndDirectSave (XDS) protocol.
- *
- * Selected items may include menus, actions and profiles.
- * For now, we only exports actions as XML files.
- */
-static void
-export_rows( NactClipboard *clipboard, NactClipboardDndData *data )
+static gchar *
+export_row_object( NactClipboard *clipboard, NAObject *object, const gchar *dest_folder, GList **exported )
{
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- NAObject *object;
+ GList *subitems, *isub;
NAObjectAction *action;
- GList *it;
- GList *exported;
+ gint index;
+ GString *data;
gchar *buffer;
+ NactApplication *application;
+ NAPivot *pivot;
+ gint format;
gchar *fname;
- exported = NULL;
- model = gtk_tree_row_reference_get_model(( GtkTreeRowReference * ) data->rows->data );
+ if( NA_IS_OBJECT_MENU( object )){
+ subitems = na_object_get_items_list( object );
+ data = g_string_new( "" );
- for( it = data->rows ; it ; it = it->next ){
+ for( isub = subitems ; isub ; isub = isub->next ){
+ buffer = export_row_object( clipboard, isub->data, dest_folder, exported );
+ if( buffer && strlen( buffer )){
+ data = g_string_append( data, buffer );
+ g_free( buffer );
+ }
+ }
- path = gtk_tree_row_reference_get_path(( GtkTreeRowReference * ) it->data );
- if( path ){
- gtk_tree_model_get_iter( model, &iter, path );
- gtk_tree_path_free( path );
- gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
+ return( g_string_free( data, FALSE ));
+ }
- buffer = get_action_xml_buffer( object, &exported, &action );
- if( buffer ){
+ buffer = NULL;
+ action = ( NAObjectAction * ) object;
+ if( NA_IS_OBJECT_PROFILE( object )){
+ action = NA_OBJECT_ACTION( na_object_get_parent( object ));
+ }
+
+ index = g_list_index( *exported, ( gconstpointer ) action );
+ if( index == -1 ){
+ *exported = g_list_prepend( *exported, ( gpointer ) action );
+
+ application = NACT_APPLICATION( base_window_get_application( clipboard->private->window ));
+ pivot = nact_application_get_pivot( application );
+ format = na_iprefs_get_export_format( NA_IPREFS( pivot ), IPREFS_EXPORT_FORMAT );
+
+ if( format == IPREFS_EXPORT_FORMAT_ASK ){
+ format = nact_assistant_export_ask_user( clipboard->private->window, action );
+ }
- fname = na_xml_writer_get_output_fname( NA_OBJECT_ACTION( action ), data->folder, IPREFS_EXPORT_FORMAT_GCONF_ENTRY );
+ if( format != IPREFS_EXPORT_NO_EXPORT ){
+ buffer = na_xml_writer_get_xml_buffer( action, format );
+
+ if( buffer && dest_folder ){
+ fname = na_xml_writer_get_output_fname( action, dest_folder, format );
na_xml_writer_output_xml( buffer, fname );
g_free( fname );
g_free( buffer );
+ buffer = NULL;
}
-
- g_object_unref( object );
}
}
- g_list_free( exported );
+ return( buffer );
}
/**
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index ab2323d..9e116c9 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -624,10 +624,11 @@ nact_iactions_list_dispose( NactIActionsList *instance )
treeview = get_actions_list_treeview( instance );
model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ ialid = get_instance_data( instance );
+ ialid->selection_changed_send_allowed = FALSE;
nact_tree_model_dispose( model );
- ialid = get_instance_data( instance );
g_free( ialid );
}
}
diff --git a/src/runtime/na-object.c b/src/runtime/na-object.c
index 6776112..8d76431 100644
--- a/src/runtime/na-object.c
+++ b/src/runtime/na-object.c
@@ -476,6 +476,8 @@ na_object_object_ref( NAObject *object )
{
NAObject *ref = NULL;
+ g_debug( "na_object_object_ref: object=%p (%s, ref_count=%d)",
+ ( void * ) object, G_OBJECT_TYPE_NAME( object ), G_OBJECT( object )->ref_count );
g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
if( !object->private->dispose_has_run ){
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]