SF.net SVN: geany-plugins:[1358] trunk/geany-plugins
frlan at users.sourceforge.net
frlan at xxxxx
Sat May 15 21:26:52 UTC 2010
Revision: 1358
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1358&view=rev
Author: frlan
Date: 2010-05-15 21:26:52 +0000 (Sat, 15 May 2010)
Log Message:
-----------
Added a function to put XML tags around a selection
Modified Paths:
--------------
trunk/geany-plugins/addons/AUTHORS
trunk/geany-plugins/addons/ChangeLog
trunk/geany-plugins/addons/README
trunk/geany-plugins/addons/src/addons.c
trunk/geany-plugins/po/POTFILES.in
Added Paths:
-----------
trunk/geany-plugins/addons/src/ao_xmltagging.c
trunk/geany-plugins/addons/src/ao_xmltagging.h
Modified: trunk/geany-plugins/addons/AUTHORS
===================================================================
--- trunk/geany-plugins/addons/AUTHORS 2010-05-15 21:26:05 UTC (rev 1357)
+++ trunk/geany-plugins/addons/AUTHORS 2010-05-15 21:26:52 UTC (rev 1358)
@@ -1,3 +1,4 @@
Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Bert Vermeulen <bert(at)biot(dot)com>
Eugene Arshinov <earshinov(at)gmail(dot)com>
+Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
Modified: trunk/geany-plugins/addons/ChangeLog
===================================================================
--- trunk/geany-plugins/addons/ChangeLog 2010-05-15 21:26:05 UTC (rev 1357)
+++ trunk/geany-plugins/addons/ChangeLog 2010-05-15 21:26:52 UTC (rev 1358)
@@ -1,3 +1,9 @@
+2010-05-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+
+ * src/ao_xmltagging.[c|h]:
+ Add function for setting tags around a selection.
+
+
2010-01-17 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/addons.c, src/ao_tasks.c, src/ao_tasks.h:
Modified: trunk/geany-plugins/addons/README
===================================================================
--- trunk/geany-plugins/addons/README 2010-05-15 21:26:05 UTC (rev 1357)
+++ trunk/geany-plugins/addons/README 2010-05-15 21:26:52 UTC (rev 1358)
@@ -51,6 +51,11 @@
saved. If you have 'Ensure new line at file end' option checked in Preferences,
one trailing newline will be left.
+XMLtagging
+^^^^^^^^^^
+XMLtagging allows to easy tag a selected text, by checking for a
+selection, offering a little dialog for inserting a tag and
+replacing a selection.
Downloads
---------
Modified: trunk/geany-plugins/addons/src/addons.c
===================================================================
--- trunk/geany-plugins/addons/src/addons.c 2010-05-15 21:26:05 UTC (rev 1357)
+++ trunk/geany-plugins/addons/src/addons.c 2010-05-15 21:26:52 UTC (rev 1358)
@@ -31,6 +31,7 @@
#include "ao_bookmarklist.h"
#include "ao_markword.h"
#include "ao_tasks.h"
+#include "ao_xmltagging.h"
@@ -50,6 +51,7 @@
KB_FOCUS_BOOKMARK_LIST,
KB_FOCUS_TASKS,
KB_UPDATE_TASKS,
+ KB_XMLTAGGING,
KB_COUNT
};
@@ -65,6 +67,7 @@
gboolean enable_systray;
gboolean enable_bookmarklist;
gboolean enable_markword;
+ gboolean enable_xmltagging;
gboolean strip_trailing_blank_lines;
gchar *tasks_token_list;
@@ -90,6 +93,7 @@
static void ao_document_before_save_cb(GObject *obj, GeanyDocument *doc, gpointer data);
static void ao_document_close_cb(GObject *obj, GeanyDocument *doc, gpointer data);
static void ao_startup_complete_cb(GObject *obj, gpointer data);
+
gboolean ao_editor_notify_cb(GObject *object, GeanyEditor *editor,
SCNotification *nt, gpointer data);
@@ -133,6 +137,10 @@
ao_tasks_update(ao_info->tasks, NULL);
}
+static void kb_ao_xmltagging(guint key_id)
+{
+ ao_xmltagging(NULL, NULL);
+}
gboolean ao_editor_notify_cb(GObject *object, GeanyEditor *editor,
SCNotification *nt, gpointer data)
@@ -234,6 +242,8 @@
"addons", "enable_markword", FALSE);
ao_info->strip_trailing_blank_lines = utils_get_setting_boolean(config,
"addons", "strip_trailing_blank_lines", FALSE);
+ ao_info->enable_xmltagging = utils_get_setting_boolean(config, "addons",
+ "enable_xmltagging", FALSE);
main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
plugin_module_make_resident(geany_plugin);
@@ -256,6 +266,8 @@
0, 0, "focus_tasks", _("Focus Tasks List"), NULL);
keybindings_set_item(key_group, KB_UPDATE_TASKS, kb_tasks_update,
0, 0, "update_tasks", _("Update Tasks List"), NULL);
+ keybindings_set_item(key_group, KB_XMLTAGGING, kb_ao_xmltagging,
+ 0, 0, "xml_tagging", _("Run XML tagging"), NULL);
}
@@ -295,6 +307,8 @@
g_object_get_data(G_OBJECT(dialog), "check_markword"))));
ao_info->strip_trailing_blank_lines = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
g_object_get_data(G_OBJECT(dialog), "check_blanklines"))));
+ ao_info->enable_xmltagging = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ g_object_get_data(G_OBJECT(dialog), "check_xmltagging"))));
g_key_file_load_from_file(config, ao_info->config_file, G_KEY_FILE_NONE, NULL);
g_key_file_set_boolean(config, "addons",
@@ -310,6 +324,8 @@
g_key_file_set_boolean(config, "addons", "enable_markword", ao_info->enable_markword);
g_key_file_set_boolean(config, "addons", "strip_trailing_blank_lines",
ao_info->strip_trailing_blank_lines);
+ g_key_file_set_boolean(config, "addons", "enable_xmltagging",
+ ao_info->enable_xmltagging);
g_object_set(ao_info->doclist, "enable-doclist", ao_info->show_toolbar_doclist_item, NULL);
g_object_set(ao_info->openuri, "enable-openuri", ao_info->enable_openuri, NULL);
@@ -347,7 +363,7 @@
GtkWidget *vbox, *check_doclist, *check_openuri, *check_tasks, *check_systray;
GtkWidget *check_bookmarklist, *check_markword, *frame_tasks, *vbox_tasks;
GtkWidget *check_tasks_scan_mode, *entry_tasks_tokens, *label_tasks_tokens, *tokens_hbox;
- GtkWidget *check_blanklines;
+ GtkWidget *check_blanklines, *check_xmltagging;
vbox = gtk_vbox_new(FALSE, 6);
@@ -424,6 +440,12 @@
ao_info->strip_trailing_blank_lines);
gtk_box_pack_start(GTK_BOX(vbox), check_blanklines, FALSE, FALSE, 3);
+ check_xmltagging = gtk_check_button_new_with_label(
+ _("XML tagging for selection"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_xmltagging),
+ ao_info->enable_xmltagging);
+ gtk_box_pack_start(GTK_BOX(vbox), check_xmltagging, FALSE, FALSE, 3);
+
g_object_set_data(G_OBJECT(dialog), "check_doclist", check_doclist);
g_object_set_data(G_OBJECT(dialog), "check_openuri", check_openuri);
g_object_set_data(G_OBJECT(dialog), "check_tasks", check_tasks);
@@ -433,6 +455,7 @@
g_object_set_data(G_OBJECT(dialog), "check_bookmarklist", check_bookmarklist);
g_object_set_data(G_OBJECT(dialog), "check_markword", check_markword);
g_object_set_data(G_OBJECT(dialog), "check_blanklines", check_blanklines);
+ g_object_set_data(G_OBJECT(dialog), "check_xmltagging", check_xmltagging);
g_signal_connect(dialog, "response", G_CALLBACK(ao_configure_response_cb), NULL);
ao_configure_tasks_toggled_cb(GTK_TOGGLE_BUTTON(check_tasks), dialog);
Added: trunk/geany-plugins/addons/src/ao_xmltagging.c
===================================================================
--- trunk/geany-plugins/addons/src/ao_xmltagging.c (rev 0)
+++ trunk/geany-plugins/addons/src/ao_xmltagging.c 2010-05-15 21:26:52 UTC (rev 1358)
@@ -0,0 +1,100 @@
+/*
+ * ao_xmltagging.c
+ *
+ * Copyright 2010 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#include "geanyplugin.h"
+#include "addons.h"
+#include "ao_xmltagging.h"
+
+
+static void enter_key_pressed_in_entry(G_GNUC_UNUSED GtkWidget *widget, gpointer dialog)
+{
+ gtk_dialog_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+}
+
+
+void ao_xmltagging()
+{
+ GeanyDocument *doc = NULL;
+
+ doc = document_get_current();
+
+ g_return_if_fail(doc != NULL);
+
+ if (sci_has_selection(doc->editor->sci) == TRUE)
+ {
+ gchar *selection = NULL;
+ gchar *replacement = NULL;
+ GtkWidget *dialog = NULL;
+ GtkWidget *vbox = NULL;
+ GtkWidget *label = NULL;
+ GtkWidget *textbox = NULL;
+ GtkWidget *table = NULL;
+
+ dialog = gtk_dialog_new_with_buttons(_("XML tagging"),
+ GTK_WINDOW(geany->main_widgets->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ NULL);
+ vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog));
+ gtk_widget_set_name(dialog, "GeanyDialog");
+ gtk_box_set_spacing(GTK_BOX(vbox), 10);
+
+ table = gtk_table_new(1, 2, FALSE);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 6);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 6);
+
+ label = gtk_label_new(_("Tag name to be inserted:"));
+ textbox = gtk_entry_new();
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
+ gtk_table_attach_defaults(GTK_TABLE(table), textbox, 1, 2, 0, 1);
+ gtk_container_add(GTK_CONTAINER(vbox), table);
+
+ g_signal_connect(G_OBJECT(textbox), "activate",
+ G_CALLBACK(enter_key_pressed_in_entry), dialog);
+
+ gtk_widget_show_all(vbox);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
+ {
+ const gchar *tag = NULL;
+
+ selection = sci_get_selection_contents(doc->editor->sci);
+ sci_start_undo_action(doc->editor->sci);
+
+ tag = g_strdup(gtk_entry_get_text(GTK_ENTRY(textbox)));
+ if (NZV(tag))
+ {
+ replacement = g_strconcat("<", tag, ">",
+ selection, "</", tag, ">", NULL);
+ }
+
+ sci_replace_sel(doc->editor->sci, replacement);
+ sci_end_undo_action(doc->editor->sci);
+ g_free(selection);
+ g_free(replacement);
+ }
+
+ gtk_widget_destroy(dialog);
+ }
+}
Added: trunk/geany-plugins/addons/src/ao_xmltagging.h
===================================================================
--- trunk/geany-plugins/addons/src/ao_xmltagging.h (rev 0)
+++ trunk/geany-plugins/addons/src/ao_xmltagging.h 2010-05-15 21:26:52 UTC (rev 1358)
@@ -0,0 +1,22 @@
+/*
+ * ao_xmltagging.h
+ *
+ * Copyright 2010 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+void ao_xmltagging();
Modified: trunk/geany-plugins/po/POTFILES.in
===================================================================
--- trunk/geany-plugins/po/POTFILES.in 2010-05-15 21:26:05 UTC (rev 1357)
+++ trunk/geany-plugins/po/POTFILES.in 2010-05-15 21:26:52 UTC (rev 1358)
@@ -9,6 +9,7 @@
addons/src/ao_bookmarklist.c
addons/src/ao_markword.c
addons/src/ao_blanklines.c
+addons/src/ao_xmltagging.c
#codenav
codenav/src/codenavigation.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Plugins-Commits
mailing list