summaryrefslogtreecommitdiff
path: root/plugins/sort
diff options
context:
space:
mode:
authorPerberos <[email protected]>2011-11-07 16:46:58 -0300
committerPerberos <[email protected]>2011-11-07 16:46:58 -0300
commit528c1e5ff51e213936e800fc5a9a25da99c0bdf2 (patch)
tree77f8aa456b09367ba81f04d4562fc935f898a951 /plugins/sort
downloadpluma-528c1e5ff51e213936e800fc5a9a25da99c0bdf2.tar.bz2
pluma-528c1e5ff51e213936e800fc5a9a25da99c0bdf2.tar.xz
initial
Diffstat (limited to 'plugins/sort')
-rwxr-xr-xplugins/sort/Makefile.am34
-rwxr-xr-xplugins/sort/gedit-sort-plugin.c588
-rwxr-xr-xplugins/sort/gedit-sort-plugin.h73
-rwxr-xr-xplugins/sort/sort.gedit-plugin.desktop.in9
-rwxr-xr-xplugins/sort/sort.ui275
5 files changed, 979 insertions, 0 deletions
diff --git a/plugins/sort/Makefile.am b/plugins/sort/Makefile.am
new file mode 100755
index 00000000..8fa39143
--- /dev/null
+++ b/plugins/sort/Makefile.am
@@ -0,0 +1,34 @@
+# sort plugin
+plugindir = $(GEDIT_PLUGINS_LIBS_DIR)
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ $(GEDIT_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS)
+
+plugin_LTLIBRARIES = libsort.la
+
+libsort_la_SOURCES = \
+ gedit-sort-plugin.h \
+ gedit-sort-plugin.c
+
+libsort_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
+libsort_la_LIBADD = $(GEDIT_LIBS)
+
+uidir = $(GEDIT_PLUGINS_DATA_DIR)/sort
+ui_DATA = sort.ui
+
+plugin_in_files = sort.gedit-plugin.desktop.in
+
+%.gedit-plugin: %.gedit-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.gedit-plugin.desktop.in=.gedit-plugin)
+
+EXTRA_DIST = $(ui_DATA) $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
+
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/sort/gedit-sort-plugin.c b/plugins/sort/gedit-sort-plugin.c
new file mode 100755
index 00000000..8fc6c959
--- /dev/null
+++ b/plugins/sort/gedit-sort-plugin.c
@@ -0,0 +1,588 @@
+/*
+ * gedit-sort-plugin.c
+ *
+ * Original author: Carlo Borreo <[email protected]>
+ * Ported to Gedit2 by Lee Mallabone <[email protected]>
+ *
+ * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gedit-sort-plugin.h"
+
+#include <string.h>
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include <gedit/gedit-debug.h>
+#include <gedit/gedit-utils.h>
+#include <gedit/gedit-help.h>
+
+#define GEDIT_SORT_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_SORT_PLUGIN, GeditSortPluginPrivate))
+
+/* Key in case the plugin ever needs any settings. */
+#define SORT_BASE_KEY "/apps/gedit-2/plugins/sort"
+
+#define WINDOW_DATA_KEY "GeditSortPluginWindowData"
+#define MENU_PATH "/MenuBar/EditMenu/EditOps_6"
+
+GEDIT_PLUGIN_REGISTER_TYPE(GeditSortPlugin, gedit_sort_plugin)
+
+typedef struct
+{
+ GtkWidget *dialog;
+ GtkWidget *col_num_spinbutton;
+ GtkWidget *reverse_order_checkbutton;
+ GtkWidget *ignore_case_checkbutton;
+ GtkWidget *remove_dups_checkbutton;
+
+ GeditDocument *doc;
+
+ GtkTextIter start, end; /* selection */
+} SortDialog;
+
+typedef struct
+{
+ GtkActionGroup *ui_action_group;
+ guint ui_id;
+} WindowData;
+
+typedef struct
+{
+ GeditPlugin *plugin;
+ GeditWindow *window;
+} ActionData;
+
+typedef struct
+{
+ gboolean ignore_case;
+ gboolean reverse_order;
+ gboolean remove_duplicates;
+ gint starting_column;
+} SortInfo;
+
+static void sort_cb (GtkAction *action, ActionData *action_data);
+static void sort_real (SortDialog *dialog);
+
+static const GtkActionEntry action_entries[] =
+{
+ { "Sort",
+ GTK_STOCK_SORT_ASCENDING,
+ N_("S_ort..."),
+ NULL,
+ N_("Sort the current document or selection"),
+ G_CALLBACK (sort_cb) }
+};
+
+static void
+sort_dialog_destroy (GtkObject *obj,
+ gpointer dialog_pointer)
+{
+ gedit_debug (DEBUG_PLUGINS);
+
+ g_slice_free (SortDialog, dialog_pointer);
+}
+
+static void
+sort_dialog_response_handler (GtkDialog *widget,
+ gint res_id,
+ SortDialog *dialog)
+{
+ gedit_debug (DEBUG_PLUGINS);
+
+ switch (res_id)
+ {
+ case GTK_RESPONSE_OK:
+ sort_real (dialog);
+ gtk_widget_destroy (dialog->dialog);
+ break;
+
+ case GTK_RESPONSE_HELP:
+ gedit_help_display (GTK_WINDOW (widget),
+ NULL,
+ "gedit-sort-plugin");
+ break;
+
+ case GTK_RESPONSE_CANCEL:
+ gtk_widget_destroy (dialog->dialog);
+ break;
+ }
+}
+
+/* NOTE: we store the current selection in the dialog since focusing
+ * the text field (like the combo box) looses the documnent selection.
+ * Storing the selection ONLY works because the dialog is modal */
+static void
+get_current_selection (GeditWindow *window, SortDialog *dialog)
+{
+ GeditDocument *doc;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ doc = gedit_window_get_active_document (window);
+
+ if (!gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
+ &dialog->start,
+ &dialog->end))
+ {
+ /* No selection, get the whole document. */
+ gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc),
+ &dialog->start,
+ &dialog->end);
+ }
+}
+
+static SortDialog *
+get_sort_dialog (ActionData *action_data)
+{
+ SortDialog *dialog;
+ GtkWidget *error_widget;
+ gboolean ret;
+ gchar *data_dir;
+ gchar *ui_file;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ dialog = g_slice_new (SortDialog);
+
+ data_dir = gedit_plugin_get_data_dir (action_data->plugin);
+ ui_file = g_build_filename (data_dir, "sort.ui", NULL);
+ g_free (data_dir);
+ ret = gedit_utils_get_ui_objects (ui_file,
+ NULL,
+ &error_widget,
+ "sort_dialog", &dialog->dialog,
+ "reverse_order_checkbutton", &dialog->reverse_order_checkbutton,
+ "col_num_spinbutton", &dialog->col_num_spinbutton,
+ "ignore_case_checkbutton", &dialog->ignore_case_checkbutton,
+ "remove_dups_checkbutton", &dialog->remove_dups_checkbutton,
+ NULL);
+ g_free (ui_file);
+
+ if (!ret)
+ {
+ const gchar *err_message;
+
+ err_message = gtk_label_get_label (GTK_LABEL (error_widget));
+ gedit_warning (GTK_WINDOW (action_data->window),
+ "%s", err_message);
+
+ g_free (dialog);
+ gtk_widget_destroy (error_widget);
+
+ return NULL;
+ }
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog),
+ GTK_RESPONSE_OK);
+
+ g_signal_connect (dialog->dialog,
+ "destroy",
+ G_CALLBACK (sort_dialog_destroy),
+ dialog);
+
+ g_signal_connect (dialog->dialog,
+ "response",
+ G_CALLBACK (sort_dialog_response_handler),
+ dialog);
+
+ get_current_selection (action_data->window, dialog);
+
+ return dialog;
+}
+
+static void
+sort_cb (GtkAction *action,
+ ActionData *action_data)
+{
+ GeditDocument *doc;
+ GtkWindowGroup *wg;
+ SortDialog *dialog;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ doc = gedit_window_get_active_document (action_data->window);
+ g_return_if_fail (doc != NULL);
+
+ dialog = get_sort_dialog (action_data);
+ g_return_if_fail (dialog != NULL);
+
+ wg = gedit_window_get_group (action_data->window);
+ gtk_window_group_add_window (wg,
+ GTK_WINDOW (dialog->dialog));
+
+ dialog->doc = doc;
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog),
+ GTK_WINDOW (action_data->window));
+
+ gtk_window_set_modal (GTK_WINDOW (dialog->dialog),
+ TRUE);
+
+ gtk_widget_show (GTK_WIDGET (dialog->dialog));
+}
+
+/* Compares two strings for the sorting algorithm. Uses the UTF-8 processing
+ * functions in GLib to be as correct as possible.*/
+static gint
+compare_algorithm (gconstpointer s1,
+ gconstpointer s2,
+ gpointer data)
+{
+ gint length1, length2;
+ gint ret;
+ gchar *string1, *string2;
+ gchar *substring1, *substring2;
+ gchar *key1, *key2;
+ SortInfo *sort_info;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ sort_info = (SortInfo *) data;
+ g_return_val_if_fail (sort_info != NULL, -1);
+
+ if (!sort_info->ignore_case)
+ {
+ string1 = *((gchar **) s1);
+ string2 = *((gchar **) s2);
+ }
+ else
+ {
+ string1 = g_utf8_casefold (*((gchar **) s1), -1);
+ string2 = g_utf8_casefold (*((gchar **) s2), -1);
+ }
+
+ length1 = g_utf8_strlen (string1, -1);
+ length2 = g_utf8_strlen (string2, -1);
+
+ if ((length1 < sort_info->starting_column) &&
+ (length2 < sort_info->starting_column))
+ {
+ ret = 0;
+ }
+ else if (length1 < sort_info->starting_column)
+ {
+ ret = -1;
+ }
+ else if (length2 < sort_info->starting_column)
+ {
+ ret = 1;
+ }
+ else if (sort_info->starting_column < 1)
+ {
+ key1 = g_utf8_collate_key (string1, -1);
+ key2 = g_utf8_collate_key (string2, -1);
+ ret = strcmp (key1, key2);
+
+ g_free (key1);
+ g_free (key2);
+ }
+ else
+ {
+ /* A character column offset is required, so figure out
+ * the correct offset into the UTF-8 string. */
+ substring1 = g_utf8_offset_to_pointer (string1, sort_info->starting_column);
+ substring2 = g_utf8_offset_to_pointer (string2, sort_info->starting_column);
+
+ key1 = g_utf8_collate_key (substring1, -1);
+ key2 = g_utf8_collate_key (substring2, -1);
+ ret = strcmp (key1, key2);
+
+ g_free (key1);
+ g_free (key2);
+ }
+
+ /* Do the necessary cleanup. */
+ if (sort_info->ignore_case)
+ {
+ g_free (string1);
+ g_free (string2);
+ }
+
+ if (sort_info->reverse_order)
+ {
+ ret = -1 * ret;
+ }
+
+ return ret;
+}
+
+static gchar *
+get_line_slice (GtkTextBuffer *buf,
+ gint line)
+{
+ GtkTextIter start, end;
+ char *ret;
+
+ gtk_text_buffer_get_iter_at_line (buf, &start, line);
+ end = start;
+
+ if (!gtk_text_iter_ends_line (&start))
+ gtk_text_iter_forward_to_line_end (&end);
+
+ ret= gtk_text_buffer_get_slice (buf,
+ &start,
+ &end,
+ TRUE);
+
+ g_assert (ret != NULL);
+
+ return ret;
+}
+
+static void
+sort_real (SortDialog *dialog)
+{
+ GeditDocument *doc;
+ GtkTextIter start, end;
+ gint start_line, end_line;
+ gint i;
+ gchar *last_row = NULL;
+ gint num_lines;
+ gchar **lines;
+ SortInfo *sort_info;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ doc = dialog->doc;
+ g_return_if_fail (doc != NULL);
+
+ sort_info = g_new0 (SortInfo, 1);
+ sort_info->ignore_case = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->ignore_case_checkbutton));
+ sort_info->reverse_order = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->reverse_order_checkbutton));
+ sort_info->remove_duplicates = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->remove_dups_checkbutton));
+ sort_info->starting_column = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dialog->col_num_spinbutton)) - 1;
+
+ start = dialog->start;
+ end = dialog->end;
+ start_line = gtk_text_iter_get_line (&start);
+ end_line = gtk_text_iter_get_line (&end);
+
+ /* if we are at line start our last line is the previus one.
+ * Otherwise the last line is the current one but we try to
+ * move the iter after the line terminator */
+ if (gtk_text_iter_get_line_offset (&end) == 0)
+ end_line = MAX (start_line, end_line - 1);
+ else
+ gtk_text_iter_forward_line (&end);
+
+ num_lines = end_line - start_line + 1;
+ lines = g_new0 (gchar *, num_lines + 1);
+
+ gedit_debug_message (DEBUG_PLUGINS, "Building list...");
+
+ for (i = 0; i < num_lines; i++)
+ {
+ lines[i] = get_line_slice (GTK_TEXT_BUFFER (doc), start_line + i);
+ }
+
+ lines[num_lines] = NULL;
+
+ gedit_debug_message (DEBUG_PLUGINS, "Sort list...");
+
+ g_qsort_with_data (lines,
+ num_lines,
+ sizeof (gpointer),
+ compare_algorithm,
+ sort_info);
+
+ gedit_debug_message (DEBUG_PLUGINS, "Rebuilding document...");
+
+ gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER (doc));
+
+ gtk_text_buffer_delete (GTK_TEXT_BUFFER (doc),
+ &start,
+ &end);
+
+ for (i = 0; i < num_lines; i++)
+ {
+ if (sort_info->remove_duplicates &&
+ last_row != NULL &&
+ (strcmp (last_row, lines[i]) == 0))
+ continue;
+
+ gtk_text_buffer_insert (GTK_TEXT_BUFFER (doc),
+ &start,
+ lines[i],
+ -1);
+ gtk_text_buffer_insert (GTK_TEXT_BUFFER (doc),
+ &start,
+ "\n",
+ -1);
+
+ last_row = lines[i];
+ }
+
+ gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (doc));
+
+ g_strfreev (lines);
+ g_free (sort_info);
+
+ gedit_debug_message (DEBUG_PLUGINS, "Done.");
+}
+
+static void
+free_window_data (WindowData *data)
+{
+ g_return_if_fail (data != NULL);
+
+ g_object_unref (data->ui_action_group);
+ g_slice_free (WindowData, data);
+}
+
+static void
+free_action_data (ActionData *data)
+{
+ g_return_if_fail (data != NULL);
+
+ g_slice_free (ActionData, data);
+}
+
+static void
+update_ui_real (GeditWindow *window,
+ WindowData *data)
+{
+ GeditView *view;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ view = gedit_window_get_active_view (window);
+
+ gtk_action_group_set_sensitive (data->ui_action_group,
+ (view != NULL) &&
+ gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
+}
+
+static void
+impl_activate (GeditPlugin *plugin,
+ GeditWindow *window)
+{
+ GtkUIManager *manager;
+ WindowData *data;
+ ActionData *action_data;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ data = g_slice_new (WindowData);
+ action_data = g_slice_new (ActionData);
+ action_data->window = window;
+ action_data->plugin = plugin;
+
+ manager = gedit_window_get_ui_manager (window);
+
+ data->ui_action_group = gtk_action_group_new ("GeditSortPluginActions");
+ gtk_action_group_set_translation_domain (data->ui_action_group,
+ GETTEXT_PACKAGE);
+ gtk_action_group_add_actions_full (data->ui_action_group,
+ action_entries,
+ G_N_ELEMENTS (action_entries),
+ action_data,
+ (GDestroyNotify) free_action_data);
+
+ gtk_ui_manager_insert_action_group (manager,
+ data->ui_action_group,
+ -1);
+
+ data->ui_id = gtk_ui_manager_new_merge_id (manager);
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data,
+ (GDestroyNotify) free_window_data);
+
+ gtk_ui_manager_add_ui (manager,
+ data->ui_id,
+ MENU_PATH,
+ "Sort",
+ "Sort",
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+
+ update_ui_real (window,
+ data);
+}
+
+static void
+impl_deactivate (GeditPlugin *plugin,
+ GeditWindow *window)
+{
+ GtkUIManager *manager;
+ WindowData *data;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ manager = gedit_window_get_ui_manager (window);
+
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ gtk_ui_manager_remove_ui (manager,
+ data->ui_id);
+ gtk_ui_manager_remove_action_group (manager,
+ data->ui_action_group);
+
+ g_object_set_data (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ NULL);
+}
+
+static void
+impl_update_ui (GeditPlugin *plugin,
+ GeditWindow *window)
+{
+ WindowData *data;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ update_ui_real (window,
+ data);
+}
+
+static void
+gedit_sort_plugin_init (GeditSortPlugin *plugin)
+{
+ gedit_debug_message (DEBUG_PLUGINS, "GeditSortPlugin initializing");
+}
+
+static void
+gedit_sort_plugin_finalize (GObject *object)
+{
+ gedit_debug_message (DEBUG_PLUGINS, "GeditSortPlugin finalizing");
+
+ G_OBJECT_CLASS (gedit_sort_plugin_parent_class)->finalize (object);
+}
+
+static void
+gedit_sort_plugin_class_init (GeditSortPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GeditPluginClass *plugin_class = GEDIT_PLUGIN_CLASS (klass);
+
+ object_class->finalize = gedit_sort_plugin_finalize;
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+ plugin_class->update_ui = impl_update_ui;
+}
diff --git a/plugins/sort/gedit-sort-plugin.h b/plugins/sort/gedit-sort-plugin.h
new file mode 100755
index 00000000..c10280bf
--- /dev/null
+++ b/plugins/sort/gedit-sort-plugin.h
@@ -0,0 +1,73 @@
+/*
+ * gedit-sort-plugin.h
+ *
+ * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef __GEDIT_SORT_PLUGIN_H__
+#define __GEDIT_SORT_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gedit/gedit-plugin.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GEDIT_TYPE_SORT_PLUGIN (gedit_sort_plugin_get_type ())
+#define GEDIT_SORT_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GEDIT_TYPE_SORT_PLUGIN, GeditSortPlugin))
+#define GEDIT_SORT_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GEDIT_TYPE_SORT_PLUGIN, GeditSortPluginClass))
+#define GEDIT_IS_SORT_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GEDIT_TYPE_SORT_PLUGIN))
+#define GEDIT_IS_SORT_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GEDIT_TYPE_SORT_PLUGIN))
+#define GEDIT_SORT_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GEDIT_TYPE_SORT_PLUGIN, GeditSortPluginClass))
+
+/* Private structure type */
+typedef struct _GeditSortPluginPrivate GeditSortPluginPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GeditSortPlugin GeditSortPlugin;
+
+struct _GeditSortPlugin
+{
+ GeditPlugin parent_instance;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GeditSortPluginClass GeditSortPluginClass;
+
+struct _GeditSortPluginClass
+{
+ GeditPluginClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gedit_sort_plugin_get_type (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gedit_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GEDIT_SORT_PLUGIN_H__ */
diff --git a/plugins/sort/sort.gedit-plugin.desktop.in b/plugins/sort/sort.gedit-plugin.desktop.in
new file mode 100755
index 00000000..9ee9634a
--- /dev/null
+++ b/plugins/sort/sort.gedit-plugin.desktop.in
@@ -0,0 +1,9 @@
+[Gedit Plugin]
+Module=sort
+IAge=2
+_Name=Sort
+_Description=Sorts a document or selected text.
+Icon=gtk-sort-ascending
+Authors=Carlo Borreo <[email protected]>;Lee Mallabone <[email protected]>;Paolo Maggi <[email protected]>;Jorge Alberto Torres H. <[email protected]>
+Copyright=Copyright © 2001 Carlo Borreo\nCopyright © 2002-2003 Lee Mallabone, Paolo Maggi\nCopyright © 2004-2005 Paolo Maggi
+Website=http://www.gedit.org
diff --git a/plugins/sort/sort.ui b/plugins/sort/sort.ui
new file mode 100755
index 00000000..4d1fe091
--- /dev/null
+++ b/plugins/sort/sort.ui
@@ -0,0 +1,275 @@
+<?xml version="1.0"?>
+<!--*- mode: xml -*-->
+<interface>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
+ <property name="lower">1</property>
+ <property name="page_increment">10</property>
+ <property name="step_increment">1</property>
+ <property name="page_size">0</property>
+ <property name="value">1</property>
+ </object>
+ <object class="GtkImage" id="sort_image">
+ <property name="stock">gtk-sort-ascending</property>
+ <property name="icon_size">4</property>
+ </object>
+ <object class="GtkDialog" id="sort_dialog">
+ <property name="title" translatable="yes">Sort</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog_action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="button2">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="image">sort_image</property>
+ <property name="label" translatable="yes">_Sort</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="button3">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-help</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="border_width">10</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkCheckButton" id="reverse_order_checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Reverse order</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="remove_dups_checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">R_emove duplicates</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="ignore_case_checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Ignore case</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox13">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label18">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">S_tart at column:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">col_num_spinbutton</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="col_num_spinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
+ <property name="digits">0</property>
+ <property name="numeric">True</property>
+ <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+ <property name="snap_to_ticks">False</property>
+ <property name="wrap">False</property>
+ <property name="adjustment">adjustment1</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox14">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkImage" id="image7">
+ <property name="visible">True</property>
+ <property name="stock">gtk-dialog-warning</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label17">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">You cannot undo a sort operation</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">True</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">button1</action-widget>
+ <action-widget response="-5">button2</action-widget>
+ <action-widget response="-11">button3</action-widget>
+ </action-widgets>
+ </object>
+</interface>