[Xfce4-commits] <design:master> Add entry completion.
Nick Schermer
noreply at xfce.org
Sat Jun 4 18:38:01 CEST 2011
Updating branch refs/heads/master
to 29617ffd374b19089bf74bf6fdb735ceb185d45e (commit)
from f022175679338adec51c4ad4bbeedc303cae5c6a (commit)
commit 29617ffd374b19089bf74bf6fdb735ceb185d45e
Author: Nick Schermer <nick at xfce.org>
Date: Sat Jun 4 18:36:21 2011 +0200
Add entry completion.
.../merge-with-xfrun/demo-code/c/appfinder-model.c | 27 +++++++++++++++++++-
.../merge-with-xfrun/demo-code/c/appfinder-model.h | 1 +
.../demo-code/c/appfinder-window.c | 10 +++++++
3 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-model.c b/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-model.c
index 7883df7..b04acc2 100644
--- a/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-model.c
+++ b/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-model.c
@@ -215,6 +215,7 @@ xfce_appfinder_model_get_column_type (GtkTreeModel *tree_model,
{
case XFCE_APPFINDER_MODEL_COLUMN_ABSTRACT:
case XFCE_APPFINDER_MODEL_COLUMN_URI:
+ case XFCE_APPFINDER_MODEL_COLUMN_COMMAND:
return G_TYPE_STRING;
case XFCE_APPFINDER_MODEL_COLUMN_ICON:
@@ -278,7 +279,9 @@ xfce_appfinder_model_get_value (GtkTreeModel *tree_model,
{
XfceAppfinderModel *model = XFCE_APPFINDER_MODEL (tree_model);
ModelItem *item;
- const gchar *name, *comment;
+ const gchar *name;
+ const gchar *comment;
+ const gchar *command, *p;
g_return_if_fail (XFCE_IS_APPFINDER_MODEL (model));
g_return_if_fail (iter->stamp == model->stamp);
@@ -317,6 +320,27 @@ xfce_appfinder_model_get_value (GtkTreeModel *tree_model,
g_value_set_static_string (value, item->abstract);
break;
+ case XFCE_APPFINDER_MODEL_COLUMN_COMMAND:
+ if (item->command == NULL
+ && item->item != NULL)
+ {
+ command = garcon_menu_item_get_command (item->item);
+ if (command != NULL)
+ {
+ /* only add first part of the command */
+ p = strchr (command, ' ');
+ if (p != NULL)
+ item->command = g_strndup (command, p - command);
+ else
+ item->command = g_strdup (command);
+ }
+ }
+
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_static_string (value, item->command);
+ break;
+
+
case XFCE_APPFINDER_MODEL_COLUMN_ICON:
if (item->pixbuf == NULL)
{
@@ -841,6 +865,7 @@ xfce_appfinder_model_filter_idle_destroyed (gpointer data)
}
+
static void
xfce_appfinder_model_filter (XfceAppfinderModel *model)
{
diff --git a/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-model.h b/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-model.h
index 6ee91d6..bca36d9 100644
--- a/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-model.h
+++ b/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-model.h
@@ -28,6 +28,7 @@ enum
XFCE_APPFINDER_MODEL_COLUMN_ICON,
XFCE_APPFINDER_MODEL_COLUMN_ICON_LARGE,
XFCE_APPFINDER_MODEL_COLUMN_VISIBLE,
+ XFCE_APPFINDER_MODEL_COLUMN_COMMAND,
XFCE_APPFINDER_MODEL_COLUMN_URI,
XFCE_APPFINDER_MODEL_N_COLUMNS,
};
diff --git a/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-window.c b/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-window.c
index 5a6dcf2..0a51a4b 100644
--- a/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-window.c
+++ b/xfce4-appfinder/merge-with-xfrun/demo-code/c/appfinder-window.c
@@ -119,6 +119,7 @@ xfce_appfinder_window_init (XfceAppfinderWindow *window)
GtkWidget *bbox;
GtkWidget *button;
GtkTreePath *path;
+ GtkEntryCompletion *completion;
window->last_window_height = 400;
@@ -167,6 +168,15 @@ xfce_appfinder_window_init (XfceAppfinderWindow *window)
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (window->entry), GTK_ENTRY_ICON_SECONDARY, _("Toggle view mode"));
gtk_widget_show (entry);
+ completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (window->model));
+ gtk_entry_completion_set_text_column (completion, XFCE_APPFINDER_MODEL_COLUMN_COMMAND);
+ gtk_entry_completion_set_popup_completion (completion, TRUE);
+ gtk_entry_completion_set_popup_single_match (completion, FALSE);
+ gtk_entry_completion_set_inline_completion (completion, TRUE);
+ gtk_entry_set_completion (GTK_ENTRY (entry), completion);
+ g_object_unref (G_OBJECT (completion));
+
window->bin_collapsed = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
gtk_box_pack_start (GTK_BOX (vbox2), window->bin_collapsed, FALSE, TRUE, 0);
gtk_widget_show (window->bin_collapsed);
More information about the Xfce4-commits
mailing list