[geany/geany-plugins] 6f48da: Merge pull request #2 from kugel-/autoclose-v0.2
RPG
git-noreply at xxxxx
Thu Nov 14 10:07:27 UTC 2013
Branch: refs/heads/master
Author: RPG <rpg at scriptumplus.ru>
Committer: RPG <rpg at scriptumplus.ru>
Date: Thu, 14 Nov 2013 10:07:27 UTC
Commit: 6f48dac8b2e9d83b3b0ec782458ebb3916ad0708
https://github.com/geany/geany-plugins/commit/6f48dac8b2e9d83b3b0ec782458ebb3916ad0708
Log Message:
-----------
Merge pull request #2 from kugel-/autoclose-v0.2
Autoclose v0.2
Modified Paths:
--------------
addons/src/ao_xmltagging.c
autoclose/src/autoclose.c
geanylatex/src/geanylatex.c
geanylatex/src/templates.c
geanysendmail/src/geanysendmail.c
updatechecker/src/updatechecker.c
Modified: addons/src/ao_xmltagging.c
28 files changed, 14 insertions(+), 14 deletions(-)
===================================================================
@@ -44,8 +44,6 @@ void ao_xmltagging(void)
if (sci_has_selection(doc->editor->sci) == TRUE)
{
- gchar *selection = NULL;
- gchar *replacement = NULL;
GtkWidget *dialog = NULL;
GtkWidget *vbox = NULL;
GtkWidget *hbox = NULL;
@@ -84,38 +82,40 @@ void ao_xmltagging(void)
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
{
- gchar *tag = NULL;
+ GString *tag = NULL;
+ gchar *selection = NULL;
+ gchar *replacement = NULL;
+ /* Getting the selection and setting the undo flag */
selection = sci_get_selection_contents(doc->editor->sci);
sci_start_undo_action(doc->editor->sci);
- tag = g_strdup(gtk_entry_get_text(GTK_ENTRY(textbox)));
- if (NZV(tag))
+ /* Getting the tag */
+ tag = g_string_new(gtk_entry_get_text(GTK_ENTRY(textbox)));
+
+ if (tag->len > 0)
{
gsize end = 0;
- GString *tmp = NULL;
gchar *end_tag;
/* First we check for %s and replace it with selection*/
- tmp = g_string_new(tag);
- utils_string_replace_all(tmp, "%s", selection);
- tag = g_string_free(tmp, FALSE);
+ utils_string_replace_all(tag, "%s", selection);
/* We try to find a space inside the inserted tag as we
* only need to close the tag with part until first space.
* */
- while (!g_ascii_isspace(tag[end]) && tag[end] != '\0')
+ while (end < tag->len && !g_ascii_isspace(tag->str[end]) )
end++;
if (end > 0)
{
- end_tag = g_strndup(tag, end);
+ end_tag = g_strndup(tag->str, end);
}
else
{
- end_tag = tag;
+ end_tag = tag->str;
}
- replacement = g_strconcat("<", tag, ">",
+ replacement = g_strconcat("<", tag->str, ">",
selection, "</", end_tag, ">", NULL);
g_free(end_tag);
}
@@ -124,7 +124,7 @@ void ao_xmltagging(void)
sci_end_undo_action(doc->editor->sci);
g_free(selection);
g_free(replacement);
- g_free(tag);
+ g_string_free(tag, TRUE);
}
gtk_widget_destroy(dialog);
}
Modified: autoclose/src/autoclose.c
26 files changed, 6 insertions(+), 20 deletions(-)
===================================================================
@@ -410,7 +410,7 @@
if (char_is_curly_bracket(ch))
{
if (line_start == line_end)
- return AC_CONTINUE_ACTION;
+ goto final;
if (line_start > line_end)
{
line = line_end;
@@ -433,6 +433,7 @@
unindent_line(sci, i, indent_width);
}
}
+final:
sci_end_undo_action(sci);
return AC_STOP_ACTION;
}
@@ -779,9 +780,8 @@ struct_semicolon(
if (!ac_info->jump_on_tab)
return;
g_return_if_fail(data);
- g_return_if_fail(DOC_VALID(data->doc));
- ScintillaObject *sci = data->doc->editor->sci;
+ ScintillaObject *sci = SCINTILLA(obj);
/* reset jump_on_tab state when user clicked away */
gboolean updated_sel = nt->updated & SC_UPDATE_SELECTION;
gboolean updated_text = nt->updated & SC_UPDATE_CONTENT;
@@ -800,8 +800,6 @@ struct_semicolon(
data->last_line = new_line;
}
-#define AC_GOBJECT_KEY "autoclose-userdata"
-
static void
on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data)
{
@@ -813,29 +811,17 @@ struct_semicolon(
data = g_new0(AutocloseUserData, 1);
data->doc = doc;
plugin_signal_connect(geany_plugin, G_OBJECT(sci), "sci-notify",
- FALSE, G_CALLBACK(on_sci_notify), data);
+ FALSE, G_CALLBACK(on_sci_notify), data);
plugin_signal_connect(geany_plugin, G_OBJECT(sci), "key-press-event",
FALSE, G_CALLBACK(on_key_press), data);
- /* save data pointer via GObject too for on_document_close() */
- g_object_set_data(G_OBJECT(sci), AC_GOBJECT_KEY, data);
-}
-
-static void
-on_document_close(GObject *obj, GeanyDocument *doc, gpointer user_data)
-{
- /* free the AutocloseUserData instance and disconnect the handler */
- ScintillaObject *sci = doc->editor->sci;
- AutocloseUserData *data = g_object_steal_data(G_OBJECT(sci), AC_GOBJECT_KEY);
- /* no plugin_signal_disconnect() ?? */
- g_signal_handlers_disconnect_by_func(G_OBJECT(sci), G_CALLBACK(on_sci_notify), data);
- g_free(data);
+ /* This will free the data when the sci is destroyed */
+ g_object_set_data_full(G_OBJECT(sci), "autoclose-userdata", data, g_free);
}
PluginCallback plugin_callbacks[] =
{
{ "document-open", (GCallback) &on_document_open, FALSE, NULL },
{ "document-new", (GCallback) &on_document_open, FALSE, NULL },
- { "document-close", (GCallback) &on_document_close, FALSE, NULL },
{ NULL, NULL, FALSE, NULL }
};
Modified: geanylatex/src/geanylatex.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -1,7 +1,7 @@
/*
* geanylatex.c - Plugin to let Geany better work together with LaTeX
*
- * Copyright 2007-2012 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ * Copyright 2007-2013 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
* Copyright 2005-2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Copyright 2006-2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
*
@@ -971,7 +971,7 @@ static void glatex_kblatex_toggle(G_GNUC_UNUSED guint key_id)
if (ref_string != NULL)
g_free(ref_string);
if (template_string != NULL)
- g_free(template_string);
+ g_string_free(template_string, TRUE);
}
}
Modified: geanylatex/src/templates.c
4 files changed, 3 insertions(+), 1 deletions(-)
===================================================================
@@ -1,7 +1,7 @@
/*
* templates.c
*
- * Copyright 2009-2012 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ * Copyright 2009-2013 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -81,6 +81,8 @@ GPtrArray* glatex_init_custom_templates(void)
g_slist_foreach(file_list, (GFunc)glatex_init_cutom_template_item, templates);
g_slist_foreach(file_list, (GFunc) g_free, NULL);
g_slist_free(file_list);
+
+ g_free(tmp_basedir);
return templates;
}
Modified: geanysendmail/src/geanysendmail.c
6 files changed, 5 insertions(+), 1 deletions(-)
===================================================================
@@ -1,7 +1,7 @@
/*
* geanysendmail.c
*
- * Copyright 2007-2011 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ * Copyright 2007-2011, 2013 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
* Copyright 2007 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Copyright 2007, 2008 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* Copyright 2008, 2009 Timothy Boronczyk <tboronczyk(at)gmail(dot)com>
@@ -111,6 +111,8 @@ enum
}
else
{
+ g_free(cmd_str);
+ g_free(locale_filename);
return;
}
@@ -170,6 +172,8 @@ enum
{
ui_set_statusbar(FALSE, _("File has to be saved before sending."));
}
+
+ g_free(config);
}
static void key_send_as_attachment(G_GNUC_UNUSED guint key_id)
Modified: updatechecker/src/updatechecker.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -143,7 +143,7 @@ static void parse_version_string(const gchar *ver, gint *major, gint *minor,
}
else
{
- major = 0;
+ *major = 0;
}
g_strfreev(vers);
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list