[anjuta] snippet-manager: Basic export feature done.



commit 1b1167dbf13c3af457f5d066ea2a2fd719a4e63d
Author: Dragos Dena <dragos dena gmail com>
Date:   Sat Aug 14 01:44:29 2010 +0300

    snippet-manager: Basic export feature done.

 plugins/snippets-manager/snippets-db.c            |   22 +++++++++++++++-
 plugins/snippets-manager/snippets-db.h            |    1 +
 plugins/snippets-manager/snippets-import-export.c |   29 +++++++++++++++++++++
 3 files changed, 51 insertions(+), 1 deletions(-)
---
diff --git a/plugins/snippets-manager/snippets-db.c b/plugins/snippets-manager/snippets-db.c
index f64a5e0..25067af 100644
--- a/plugins/snippets-manager/snippets-db.c
+++ b/plugins/snippets-manager/snippets-db.c
@@ -1132,7 +1132,6 @@ snippets_db_get_snippets_group (SnippetsDB* snippets_db,
 	return NULL;
 }
 
-
 void
 snippets_db_set_snippets_group_name (SnippetsDB *snippets_db,
                                      const gchar *old_group_name,
@@ -1167,6 +1166,27 @@ snippets_db_has_snippets_group_name (SnippetsDB *snippets_db,
 }
 
 /**
+ * snippets_db_get_snippets_groups:
+ * @snippets_db: A #SnippetsDB object.
+ *
+ * The returned list is owned by the snippets database and should not be 
+ * modified in any way.
+ *
+ * Returns: A #GList with all the snippets groups in the database.
+ */
+GList*
+snippets_db_get_snippets_groups (SnippetsDB *snippets_db)
+{
+	SnippetsDBPrivate *priv = NULL;
+
+	/* Assertions */
+	g_return_val_if_fail (ANJUTA_IS_SNIPPETS_DB (snippets_db), NULL);
+	priv = ANJUTA_SNIPPETS_DB_GET_PRIVATE (snippets_db);
+
+	return priv->snippets_groups;
+}
+
+/**
  * snippets_db_get_global_variable_text:
  * @snippets_db: A #SnippetsDB object.
  * @variable_name: The variable name.
diff --git a/plugins/snippets-manager/snippets-db.h b/plugins/snippets-manager/snippets-db.h
index 9be254a..5e7d8ba 100644
--- a/plugins/snippets-manager/snippets-db.h
+++ b/plugins/snippets-manager/snippets-db.h
@@ -133,6 +133,7 @@ void                       snippets_db_set_snippets_group_name (SnippetsDB *snip
                                                                 const gchar *new_group_name);
 gboolean                   snippets_db_has_snippets_group_name (SnippetsDB *snippets_db,
                                                                 const gchar *group_name);
+GList*                     snippets_db_get_snippets_groups     (SnippetsDB *snippets_db);
 
 /* Global variables handling methods */
 gboolean                   snippets_db_add_global_variable       (SnippetsDB* snippets_db,
diff --git a/plugins/snippets-manager/snippets-import-export.c b/plugins/snippets-manager/snippets-import-export.c
index 36c4a46..7773fc3 100644
--- a/plugins/snippets-manager/snippets-import-export.c
+++ b/plugins/snippets-manager/snippets-import-export.c
@@ -181,8 +181,37 @@ snippets_manager_import_snippets (SnippetsDB *snippets_db,
 void snippets_manager_export_snippets (SnippetsDB *snippets_db,
                                        AnjutaShell *anjuta_shell)
 {
+	GtkWidget *file_chooser = NULL;
+	GtkFileFilter *filter = NULL;
 
 	/* Assertions */
 	g_return_if_fail (ANJUTA_IS_SNIPPETS_DB (snippets_db));
 
+	file_chooser = gtk_file_chooser_dialog_new (_("Export Snippets"),
+	                                            GTK_WINDOW (anjuta_shell),
+	                                            GTK_FILE_CHOOSER_ACTION_SAVE,
+	                                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+	                                            GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+	                                            NULL);
+
+	/* Set up the filter */
+	filter = gtk_file_filter_new ();
+	gtk_file_filter_set_name (filter, "Native format");
+	gtk_file_filter_add_pattern (filter, "*.anjuta-snippets");
+	gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_chooser), filter);
+
+	if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT)
+	{
+		gchar *uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (file_chooser)),
+		      *path = anjuta_util_get_local_path_from_uri (uri);
+
+		snippets_manager_save_snippets_xml_file (NATIVE_FORMAT,
+		                                         snippets_db_get_snippets_groups (snippets_db),
+		                                         path);
+		g_free (path);
+		g_free (uri);
+	}
+	
+	gtk_widget_destroy (file_chooser);
+
 }



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