コード例 #1
0
ファイル: callbacks.c プロジェクト: cristiklein/gthumb
static void
update_scripts_menu (BrowserData *data)
{
	GthMenuManager	*menu_manager;
	GList		*script_list;
	GList		*scan;

	menu_manager = gth_browser_get_menu_manager (data->browser, GTH_BROWSER_MENU_MANAGER_TOOLS3);
	if (data->menu_merge_id != 0)
		gth_menu_manager_remove_entries (menu_manager, data->menu_merge_id);
	data->menu_merge_id = gth_menu_manager_new_merge_id (menu_manager);

	script_list = gth_script_file_get_scripts (gth_script_file_get ());
	for (scan = script_list; scan; scan = scan->next) {
		GthScript *script = scan->data;
		char      *detailed_action;

		if (! gth_script_is_visible (script))
			continue;

		detailed_action = g_strdup_printf ("win.exec-script('%s')", gth_script_get_id (script));
		gth_menu_manager_append_entry (menu_manager,
					       data->menu_merge_id,
					       gth_script_get_display_name (script),
					       detailed_action,
					       NULL,
					       NULL);

		g_free (detailed_action);
	}

	list_tools__gth_browser_update_sensitivity_cb (data->browser);

	_g_object_list_unref (script_list);
}
コード例 #2
0
static void
set_script_list (DialogData *data,
		 GList      *script_list)
{
	GList *scan;

	g_signal_handlers_block_by_func (data->list_store, row_inserted_cb, data);

	for (scan = script_list; scan; scan = scan->next) {
		GthScript   *script = scan->data;
		char        *shortcut;
		GtkTreeIter  iter;

		shortcut = get_script_shortcut (script);

		gtk_list_store_append (data->list_store, &iter);
		gtk_list_store_set (data->list_store, &iter,
				    COLUMN_SCRIPT, script,
				    COLUMN_NAME, gth_script_get_display_name (script),
				    COLUMN_SHORTCUT, shortcut,
				    COLUMN_VISIBLE, gth_script_is_visible (script),
				   -1);

		g_free (shortcut);
	}

	g_signal_handlers_unblock_by_func (data->list_store, row_inserted_cb, data);
}
コード例 #3
0
static void
script_editor_dialog__response_cb (GtkDialog *dialog,
			           int        response,
			           gpointer   user_data)
{
	DialogData    *data = user_data;
	GthScript     *script;
	GError        *error = NULL;
	GthScriptFile *script_file;
	gboolean       new_script;
	GtkTreeIter    iter;
	gboolean       change_list = TRUE;


	if (response == GTK_RESPONSE_HELP) {
		/* FIXME: show help dialog */
		return;
	}

	if (response != GTK_RESPONSE_OK) {
		gtk_widget_destroy (GTK_WIDGET (dialog));
		return;
	}

	script = gth_script_editor_dialog_get_script (GTH_SCRIPT_EDITOR_DIALOG (dialog), &error);
	if (script == NULL) {
		_gtk_error_dialog_from_gerror_show (GTK_WINDOW (dialog), _("Could not save the script"), error);
		g_clear_error (&error);
		return;
	}

	/* update the script file */

	script_file = gth_script_file_get ();
	new_script = ! gth_script_file_has_script (script_file, script);

	g_signal_handlers_block_by_func (script_file, scripts_changed_cb, data);
	gth_script_file_add (script_file, script);
	gth_script_file_save (script_file, NULL); /* FIXME: handle errors */
	g_signal_handlers_unblock_by_func (script_file, scripts_changed_cb, data);

	/* update the script list */

	if (new_script) {
		g_signal_handlers_block_by_func (data->list_store, row_inserted_cb, data);
		gtk_list_store_append (data->list_store, &iter);
		g_signal_handlers_unblock_by_func (data->list_store, row_inserted_cb, data);
	}
	else
		change_list = get_script_iter (data, script, &iter);

	if (change_list) {
		char *shortcut;

		shortcut = get_script_shortcut (script);
		gtk_list_store_set (data->list_store, &iter,
				    COLUMN_SCRIPT, script,
				    COLUMN_NAME, gth_script_get_display_name (script),
				    COLUMN_SHORTCUT, shortcut,
				    COLUMN_VISIBLE, gth_script_is_visible (script),
				    -1);

		g_free (shortcut);
	}

	gtk_widget_destroy (GTK_WIDGET (dialog));

	g_object_unref (script);
}