Hi list, I'm trying to get an icon in the toolbar from an extension (nautilus-sendto) and to get it to behave properly. It means that it should be sensitive when I select files and not in a list of already defined case. All of this logic is already implemented in the nautilus_nste_get_file_items callback. However since I want a toolbar item, I've created a new callback : nautilus_nste_get_toolbar_items My first problem was that writing the sensitive attribute didn't do anything since the attribute is only read once to create the button. Attached is a patch that allows the NautilusMenuItem to notify the button of the sensitivity change. nautilus-ui-utilities.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) Now I want to get the list of files in order to set a sensible value for the sensitivity. I've connected a callback to the selection_changed signal but it seems that from an extension, there is no way to get the list of selected files in order to accomplish that. It is not a problem for a get_file_items type callback because it's used each time the right-click menu is shown (afaiu). The data is available but buried in class depending on libnautilus-private so my question is, am I just a fool to want to access this data and if not, what is the best course to fix this problem ? Thanks in advance, -- Gilles Dartiguelongue <gilles dartiguelongue esiee org>
Index: libnautilus-private/nautilus-ui-utilities.c
===================================================================
--- libnautilus-private/nautilus-ui-utilities.c (révision 13570)
+++ libnautilus-private/nautilus-ui-utilities.c (copie de travail)
@@ -113,6 +113,19 @@
nautilus_menu_item_activate (NAUTILUS_MENU_ITEM (callback_data));
}
+static void
+extension_action_sensitive_callback (NautilusMenuItem *item,
+ GParamSpec *arg1,
+ gpointer user_data)
+{
+ gboolean value;
+ g_object_get (G_OBJECT (item),
+ "sensitive", &value,
+ NULL);
+
+ gtk_action_set_sensitive (GTK_ACTION (user_data), value);
+}
+
GtkAction *
nautilus_action_from_menu_item (NautilusMenuItem *item)
{
@@ -207,6 +220,11 @@
g_object_ref (item),
(GClosureNotify)g_object_unref, 0);
+ g_signal_connect_data (item, "notify::sensitive",
+ G_CALLBACK (extension_action_sensitive_callback),
+ g_object_ref (action),
+ (GClosureNotify)g_object_unref, 0);
+
g_free (name);
g_free (label);
g_free (tip);
Attachment:
signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=