Esempio n. 1
0
/* simple file print using an external tool */
static void print_external(GeanyDocument *doc)
{
	gchar *cmdline;

	if (doc->file_name == NULL)
		return;

	if (! NZV(printing_prefs.external_print_cmd))
	{
		dialogs_show_msgbox(GTK_MESSAGE_ERROR,
			_("Please set a print command in the preferences dialog first."));
		return;
	}

	cmdline = g_strdup(printing_prefs.external_print_cmd);
	utils_str_replace_all(&cmdline, "%f", doc->file_name);

	if (dialogs_show_question(
			_("The file \"%s\" will be printed with the following command:\n\n%s"),
			doc->file_name, cmdline))
	{
		GError *error = NULL;

#ifdef G_OS_WIN32
		gchar *tmp_cmdline = g_strdup(cmdline);
#else
		/* /bin/sh -c emulates the system() call and makes complex commands possible
		 * but only needed on non-win32 systems due to the lack of win32's shell capabilities */
		gchar *tmp_cmdline = g_strconcat("/bin/sh -c \"", cmdline, "\"", NULL);
#endif

		if (! g_spawn_command_line_async(tmp_cmdline, &error))
		{
			dialogs_show_msgbox(GTK_MESSAGE_ERROR,
				_("Printing of \"%s\" failed (return code: %s)."),
				doc->file_name, error->message);
			g_error_free(error);
		}
		else
		{
			msgwin_status_add(_("File %s printed."), doc->file_name);
		}
		g_free(tmp_cmdline);
	}
	g_free(cmdline);
}
Esempio n. 2
0
static void on_command_send_button_clicked(G_GNUC_UNUSED GtkButton *button,
	G_GNUC_UNUSED gpointer gdata)
{
	gchar *text = utils_text_buffer_get_text(command_text, -1);
	const gchar *start;
	char *locale;

	thread_synchronize();
	utils_str_replace_all(&text, "\n", " ");
	start = utils_skip_spaces(text);
	locale = gtk_toggle_button_get_active(command_locale) ?
		utils_get_locale_from_utf8(start) : strdup(start);
	debug_send_command(N, locale);
	g_free(locale);
	gtk_widget_hide(command_dialog);

	if (*start)
	{
		GtkTreePath *path;
		GtkTreeIter iter;
		gchar *display = strdup(start);

		/* from ui_combo_box_add_to_history() */
		if (model_find(command_model, &iter, COMMAND_TEXT, start))
			gtk_list_store_remove(command_store, &iter);

		if (strlen(display) >= 273)
			strcpy(display + 270, _("\342\200\246"));  /* For translators: ellipsis */

		gtk_list_store_prepend(command_store, &iter);
		gtk_list_store_set(command_store, &iter, COMMAND_DISPLAY, display, COMMAND_TEXT,
			start, COMMAND_LOCALE, gtk_toggle_button_get_active(command_locale), -1);
		g_free(display);

		path = gtk_tree_path_new_from_indices(15, -1);
		if (gtk_tree_model_get_iter(command_model, &iter, path))
			gtk_list_store_remove(command_store, &iter);
		gtk_tree_path_free(path);
	}

	g_free(text);
}
Esempio n. 3
0
void view_display_edited(GtkTreeModel *model, gboolean condition, const gchar *path_str,
	const char *format, gchar *new_text)
{
	if (validate_column(new_text, TRUE))
	{
		if (condition)
		{
			GtkTreeIter iter;
			const char *name;
			gint hb_mode;
			char *locale;

			gtk_tree_model_get_iter_from_string(model, &iter, path_str);
			gtk_tree_model_get(model, &iter, COLUMN_NAME, &name, COLUMN_HB_MODE,
				&hb_mode, -1);
			locale = utils_get_locale_from_display(new_text, hb_mode);
			utils_str_replace_all(&locale, "\n", " ");
			debug_send_format(F, format, name, locale);
			g_free(locale);
		}
		else
			plugin_blink();
	}
}