Commit 2c9b478c authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

scripts: disable execution when there is no file selected

parent da58e6cc
......@@ -58,24 +58,6 @@ browser_data_free (BrowserData *data)
static void
list_tools__gth_browser_update_sensitivity_cb (GthBrowser *browser)
{
BrowserData *data;
int n_selected;
gboolean sensitive;
data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
g_return_if_fail (data != NULL);
n_selected = gth_file_selection_get_n_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
sensitive = (n_selected > 0);
gth_window_enable_action (GTH_WINDOW (browser), "exec-script", sensitive);
}
static void
update_scripts_menu (BrowserData *data)
update_scripts (BrowserData *data)
{
GthMenuManager *menu_manager;
......@@ -116,8 +98,6 @@ update_scripts (BrowserData *data)
gth_shortcut_free (shortcut);
}
list_tools__gth_browser_update_sensitivity_cb (data->browser);
_g_object_list_unref (script_list);
}
......@@ -183,7 +163,14 @@ list_tools__gth_browser_construct_cb (GthBrowser *browser)
}
void
list_tools__gth_browser_file_list_selection_changed (GthBrowser *browser,
int n_selected)
{
BrowserData *data;
data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
g_return_if_fail (data != NULL);
gth_window_enable_action (GTH_WINDOW (browser), "exec-script", n_selected > 0);
}
......@@ -24,6 +24,8 @@
#include <gthumb.h>
void list_tools__gth_browser_construct_cb (GthBrowser *browser);
void list_tools__gth_browser_construct_cb (GthBrowser *browser);
void list_tools__gth_browser_file_list_selection_changed (GthBrowser *browser,
int n_selected);
#endif /* CALLBACKS_H */
......@@ -30,6 +30,7 @@ G_MODULE_EXPORT void
gthumb_extension_activate (void)
{
gth_hook_add_callback ("gth-browser-construct", 5, G_CALLBACK (list_tools__gth_browser_construct_cb), NULL);
gth_hook_add_callback ("gth-browser-file-list-selection-changed", 5, G_CALLBACK (list_tools__gth_browser_file_list_selection_changed), NULL);
}
......
......@@ -3634,10 +3634,12 @@ update_selection_cb (gpointer user_data)
gth_browser_update_sensitivity (browser);
_gth_browser_update_statusbar_list_info (browser);
n_selected = gth_file_selection_get_n_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
gth_hook_invoke ("gth-browser-file-list-selection-changed", browser, n_selected);
if (gth_window_get_current_page (GTH_WINDOW (browser)) != GTH_BROWSER_PAGE_BROWSER)
return FALSE;
n_selected = gth_file_selection_get_n_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
if (n_selected == 1) {
GList *items;
GList *file_list;
......
......@@ -89,6 +89,14 @@ gth_main_register_default_hooks (void)
**/
gth_hook_register ("gth-browser-update-sensitivity", 1);
/**
* Called when the file list selection changes
*
* @browser (GthBrowser*): the relative window.
* @n_selected (int): number of selected files.
*/
gth_hook_register ("gth-browser-file-list-selection-changed", 2);
/**
* Called when the current page changes.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment