Ejemplo n.º 1
0
static void
on_message_treeview_clear_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	gint tabnum = GPOINTER_TO_INT(user_data);

	msgwin_clear_tab(tabnum);
}
Ejemplo n.º 2
0
static void find_file(GtkTreeIter *iter)
{
	gchar *pattern_str = NULL;
	gboolean case_sensitive, full_path;
	gchar *path;

	path = build_path(iter);

	if (show_dialog_find_file(iter ? path : NULL, &pattern_str, &case_sensitive, &full_path) == GTK_RESPONSE_ACCEPT)
	{
		GPatternSpec *pattern;

		if (!case_sensitive)
			SETPTR(pattern_str, g_utf8_strdown(pattern_str, -1));

		pattern = g_pattern_spec_new(pattern_str);

		msgwin_clear_tab(MSG_MESSAGE);
		msgwin_set_messages_dir(get_project_base_path());
		find_file_recursive(iter, case_sensitive, full_path, pattern);
		msgwin_switch_tab(MSG_MESSAGE, TRUE);
	}

	g_free(pattern_str);
	g_free(path);
}
Ejemplo n.º 3
0
static void spawn_cmd(const gchar *cmd, const gchar *dir)
{
	GError *error = NULL;
	gchar **argv = NULL;
	gchar *working_dir;
	gchar *utf8_working_dir;
	gchar *utf8_cmd_string;
	gchar *out;
	gint exitcode;
	gboolean success;
	GString *output;

#ifndef G_OS_WIN32
	/* run within shell so we can use pipes */
	argv = g_new0(gchar *, 4);
	argv[0] = g_strdup("/bin/sh");
	argv[1] = g_strdup("-c");
	argv[2] = g_strdup(cmd);
	argv[3] = NULL;
#endif

	utf8_cmd_string = utils_get_utf8_from_locale(cmd);
	utf8_working_dir = g_strdup(dir);
	working_dir = utils_get_locale_from_utf8(utf8_working_dir);

	msgwin_clear_tab(MSG_MESSAGE);
	msgwin_switch_tab(MSG_MESSAGE, TRUE);
	msgwin_msg_add(COLOR_BLUE, -1, NULL, _("%s (in directory: %s)"), utf8_cmd_string, utf8_working_dir);
	g_free(utf8_working_dir);
	g_free(utf8_cmd_string);

	output = g_string_new(NULL);
#ifndef G_OS_WIN32
	success = spawn_sync(working_dir, NULL, argv, NULL,
			NULL, NULL, output, &exitcode, &error);
#else
	success = spawn_sync(working_dir, cmd, NULL, NULL,
			NULL, output, NULL, &exitcode, &error);
#endif
	out = g_string_free(output, FALSE);
	if (!success || exitcode != 0)
	{
		if (error != NULL)
		{
			msgwin_msg_add(COLOR_RED, -1, NULL, _("Process execution failed (%s)"), error->message);
			g_error_free(error);
		}
		msgwin_msg_add(COLOR_RED, -1, NULL, "%s", out);
	}
	else
	{
		msgwin_msg_add(COLOR_BLACK, -1, NULL, "%s", out);
	}

	g_strfreev(argv);
	g_free(working_dir);
	g_free(out);
}
Ejemplo n.º 4
0
static void perform_check(GeanyDocument *doc)
{
    clear_spellcheck_error_markers(doc);

    if (sc_info->use_msgwin)
    {
        msgwin_clear_tab(MSG_MESSAGE);
        msgwin_switch_tab(MSG_MESSAGE, FALSE);
    }

    sc_speller_check_document(doc);
}
Ejemplo n.º 5
0
static void find_tags(const gchar *name, gboolean declaration, gboolean case_sensitive, MatchType match_type, gchar *utf8_path)
{
	gchar *utf8_base_path = get_project_base_path();
	gchar *locale_base_path = utils_get_locale_from_utf8(utf8_base_path);
	GPtrArray *tags_array = geany_data->app->tm_workspace->tags_array;
	guint i;
	gchar *name_case;
	GPatternSpec *pspec;

	if (case_sensitive)
		name_case = g_strdup(name);
	else
		name_case = g_utf8_strdown(name, -1);

	pspec = g_pattern_spec_new(name_case);

	msgwin_set_messages_dir(locale_base_path);
	msgwin_clear_tab(MSG_MESSAGE);
	for (i = 0; i < tags_array->len; i++) /* TODO: binary search */
	{
		TMTag *tag = tags_array->pdata[i];

		if (match(tag, name_case, declaration, case_sensitive, match_type, pspec, utf8_path))
		{
			gchar *scopestr = tag->scope ? g_strconcat(tag->scope, "::", NULL) : g_strdup("");
			gchar *utf8_fname = utils_get_utf8_from_locale(tag->file->file_name);
			gchar *relpath;

			relpath = get_relative_path(utf8_base_path, utf8_fname);
			msgwin_msg_add(COLOR_BLACK, -1, NULL, "%s:%lu:\n\t[%s]\t %s%s%s", relpath ? relpath : utf8_fname,
				tag->line, tm_tag_type_name(tag), scopestr, tag->name, tag->arglist ? tag->arglist : "");
			g_free(scopestr);
			g_free(relpath);
			g_free(utf8_fname);
		}
	}
	msgwin_switch_tab(MSG_MESSAGE, TRUE);

	g_free(name_case);
	g_pattern_spec_free(pspec);
	g_free(utf8_base_path);
	g_free(locale_base_path);
}
Ejemplo n.º 6
0
static void find_tags(const gchar *name, gboolean declaration, gboolean case_sensitive, MatchType match_type)
{
	tagFile *tf;
	GeanyProject *prj;
	gchar *tag_filename = NULL;
	tagEntry entry;
	tagFileInfo info;

	prj = geany_data->app->project;
	if (!prj)
		return;

	msgwin_clear_tab(MSG_MESSAGE);
	msgwin_set_messages_dir(prj->base_path);

	tag_filename = get_tags_filename();
	tf = tagsOpen(tag_filename, &info);

	if (tf)
	{
		if (find_first(tf, &entry, name, match_type))
		{
			GPatternSpec *name_pat;
			gchar *name_case;
			gchar *path = NULL; 
			gint num = 0;

			if (case_sensitive)
				name_case = g_strdup(name);
			else
				name_case = g_utf8_strdown(name, -1);

			SETPTR(name_case, g_strconcat("*", name_case, "*", NULL));
			name_pat = g_pattern_spec_new(name_case);

			if (!filter_tag(&entry, name_pat, declaration, case_sensitive))
			{
				path = g_build_filename(prj->base_path, entry.file, NULL);
				show_entry(&entry);
				num++;
			}
			
			while (find_next(tf, &entry, match_type))
			{
				if (!filter_tag(&entry, name_pat, declaration, case_sensitive))
				{
					if (!path)
						path = g_build_filename(prj->base_path, entry.file, NULL);
					show_entry(&entry);
					num++;
				}
			}
			
			if (num == 1)
			{
				GeanyDocument *doc = document_open_file(path, FALSE, NULL, NULL);
				if (doc != NULL)
				{
					navqueue_goto_line(document_get_current(), doc, entry.address.lineNumber);
					gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));
				}
			}

			g_pattern_spec_free(name_pat);
			g_free(name_case);
			g_free(path);
		}

		tagsClose(tf);
	}

	msgwin_switch_tab(MSG_MESSAGE, TRUE);

	g_free(tag_filename);
}