[geany/geany-plugins] f0fc46: commander: Fix sorting when using a type prefix
Colomban Wendling
git-noreply at xxxxx
Sat Aug 4 15:08:40 UTC 2012
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sat, 04 Aug 2012 15:08:40
Commit: f0fc46d785593f4ddc208fa4592e3a9c4f53b4c8
https://github.com/geany/geany-plugins/commit/f0fc46d785593f4ddc208fa4592e3a9c4f53b4c8
Log Message:
-----------
commander: Fix sorting when using a type prefix
Modified Paths:
--------------
commander/src/commander-plugin.c
Modified: commander/src/commander-plugin.c
42 files changed, 29 insertions(+), 13 deletions(-)
===================================================================
@@ -64,8 +64,9 @@ struct {
};
typedef enum {
- COL_TYPE_MENU_ITEM,
- COL_TYPE_FILE
+ COL_TYPE_MENU_ITEM = 1 << 0,
+ COL_TYPE_FILE = 1 << 1,
+ COL_TYPE_ANY = 0xffff
} ColType;
enum {
@@ -160,6 +161,27 @@ enum {
return dist;
}
+static const gchar *
+get_key (gint *type_)
+{
+ gint type = COL_TYPE_ANY;
+ const gchar *key = gtk_entry_get_text (GTK_ENTRY (plugin_data.entry));
+
+ if (g_str_has_prefix (key, "f:")) {
+ key += 2;
+ type = COL_TYPE_FILE;
+ } else if (g_str_has_prefix (key, "c:")) {
+ key += 2;
+ type = COL_TYPE_MENU_ITEM;
+ }
+
+ if (type_) {
+ *type_ = type;
+ }
+
+ return key;
+}
+
static gint
sort_func (GtkTreeModel *model,
GtkTreeIter *a,
@@ -170,7 +192,7 @@ enum {
gint distb;
gchar *patha;
gchar *pathb;
- const gchar *key = gtk_entry_get_text (GTK_ENTRY (plugin_data.entry));
+ const gchar *key = get_key (NULL);
gtk_tree_model_get (model, a, COL_PATH, &patha, -1);
gtk_tree_model_get (model, b, COL_PATH, &pathb, -1);
@@ -189,20 +211,14 @@ enum {
GtkTreeIter *iter,
gpointer dummy)
{
- gboolean visible = TRUE;
+ gboolean visible = FALSE;
gchar *text;
gint type;
- const gchar *key = gtk_entry_get_text (GTK_ENTRY (plugin_data.entry));
+ gint key_type;
+ const gchar *key = get_key (&key_type);
gtk_tree_model_get (model, iter, COL_PATH, &text, COL_TYPE, &type, -1);
- if (g_str_has_prefix (key, "f:")) {
- key += 2;
- visible = type == COL_TYPE_FILE;
- } else if (g_str_has_prefix (key, "c:")) {
- key += 2;
- visible = type == COL_TYPE_MENU_ITEM;
- }
- if (visible) {
+ if (type & key_type) {
visible = key_matches (key, text);
}
g_free (text);
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
More information about the Plugins-Commits
mailing list