[Xfce4-commits] <xfce4-settings:nick/mime-settings> Don't permit selection on non-app rows in chooser.
Nick Schermer
noreply at xfce.org
Sat Jan 21 22:02:02 CET 2012
Updating branch refs/heads/nick/mime-settings
to 3b1816cee4272e89a15268d515c4fb5d70bbd00b (commit)
from be02842662466f890869111bb826f21a363a83b8 (commit)
commit 3b1816cee4272e89a15268d515c4fb5d70bbd00b
Author: Nick Schermer <nick at xfce.org>
Date: Sat Jan 21 21:59:46 2012 +0100
Don't permit selection on non-app rows in chooser.
dialogs/mime-settings/xfce-mime-chooser.c | 33 +++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/dialogs/mime-settings/xfce-mime-chooser.c b/dialogs/mime-settings/xfce-mime-chooser.c
index a2d5fb1..07e24d9 100644
--- a/dialogs/mime-settings/xfce-mime-chooser.c
+++ b/dialogs/mime-settings/xfce-mime-chooser.c
@@ -43,6 +43,11 @@ static void xfce_mime_chooser_row_activated (GtkTreeView *tree_vie
GtkTreePath *path,
GtkTreeViewColumn *column,
XfceMimeChooser *chooser);
+static gboolean xfce_mime_chooser_row_can_select (GtkTreeSelection *selection,
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean path_currently_selected,
+ gpointer data);
static void xfce_mime_chooser_update_accept (XfceMimeChooser *chooser);
static void xfce_mime_chooser_notify_expanded (GtkExpander *expander,
GParamSpec *pspec,
@@ -172,6 +177,8 @@ xfce_mime_chooser_init (XfceMimeChooser *chooser)
chooser->treeview = treeview;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+ gtk_tree_selection_set_select_function (selection,
+ xfce_mime_chooser_row_can_select, NULL, NULL);
g_signal_connect_swapped (G_OBJECT (selection), "changed",
G_CALLBACK (xfce_mime_chooser_update_accept), chooser);
@@ -268,6 +275,32 @@ xfce_mime_chooser_row_activated (GtkTreeView *tree_view,
+static gboolean
+xfce_mime_chooser_row_can_select (GtkTreeSelection *selection,
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean path_currently_selected,
+ gpointer data)
+{
+ gboolean permitted = TRUE;
+ GtkTreeIter iter;
+ GValue value = { 0, };
+
+ /* we can always change the selection if the path is already selected */
+ if (G_UNLIKELY (!path_currently_selected))
+ {
+ /* check if there's an application for the path */
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get_value (model, &iter, CHOOSER_COLUMN_APP_INFO, &value);
+ permitted = (g_value_get_object (&value) != NULL);
+ g_value_unset (&value);
+ }
+
+ return permitted;
+}
+
+
+
static void
xfce_mime_chooser_update_accept (XfceMimeChooser *chooser)
{
More information about the Xfce4-commits
mailing list