[geany/geany-plugins] 98303e: Merge pull request #1 from frlan/geniuspaste_small_improvments
Enrico Trotta
git-noreply at xxxxx
Tue May 1 17:24:02 UTC 2012
Branch: refs/heads/master
Author: Enrico Trotta <enrico.trt at gmail.com>
Committer: Enrico Trotta <enrico.trt at gmail.com>
Date: Tue, 01 May 2012 17:24:02
Commit: 98303e9723c909bafe78e1ffa86645669cac1e3f
https://github.com/geany/geany-plugins/commit/98303e9723c909bafe78e1ffa86645669cac1e3f
Log Message:
-----------
Merge pull request #1 from frlan/geniuspaste_small_improvments
Geniuspaste small improvments
Modified Paths:
--------------
geniuspaste/src/geniuspaste.c
geniuspaste/wscript_build
geniuspaste/wscript_configure
po/POTFILES.in
Modified: geniuspaste/src/geniuspaste.c
87 files changed, 43 insertions(+), 44 deletions(-)
===================================================================
@@ -69,10 +69,9 @@
static gboolean check_button_is_checked = FALSE;
PLUGIN_VERSION_CHECK(147)
-PLUGIN_SET_INFO("GeniusPaste",
- "Paste your code on your favorite pastebin",
- "0.1",
- "Enrico Trotta");
+PLUGIN_SET_TRANSLATABLE_INFO(LOCALEDIR, GETTEXT_PACKAGE, "GeniusPaste",
+ _("Paste your code on your favorite pastebin"),
+ "0.1", "Enrico Trotta");
static gint last_indexof(gchar * string, gchar c)
@@ -90,7 +89,7 @@ static void paste(const gchar * website)
GeanyDocument *doc = document_get_current();
GeanyFiletype *ft = doc->file_type;
-
+
GError *error;
gchar *buffer_shell_command;
@@ -108,11 +107,11 @@ static void paste(const gchar * website)
"Lua", "OCaml", "PHP", "Perl", "Plain Text",
"Python", "Ruby", "Scheme", "Tcl"
};
-
+
const gchar *langs_supported_dpaste[] = { "Bash", "C", "CSS", "Diff",
- "Django/Jinja", "HTML", "IRC logs", "JavaScript", "PHP",
+ "Django/Jinja", "HTML", "IRC logs", "JavaScript", "PHP",
"Python console session", "Python Traceback", "Python",
- "Python3", "Restructured Text", "SQL", "Text only"
+ "Python3", "Restructured Text", "SQL", "Text only"
};
gint i;
@@ -120,21 +119,21 @@ static void paste(const gchar * website)
guint status;
gsize f_lenght;
gboolean result;
-
+
occ_position = last_indexof(f_name, G_DIR_SEPARATOR);
f_title = f_name + occ_position + 1;
switch (website_selected) {
-
+
case CODEPAD_ORG:
-
+
for (i = 0; i < G_N_ELEMENTS(langs_supported_codepad); i++) {
if (g_strcmp0(f_type, langs_supported_codepad[i]) == 0)
break;
else
f_type = langs_supported_codepad[8];
}
-
+
if ((result =
g_file_get_contents(f_path, &f_content, &f_lenght,
&error)) == FALSE) {
@@ -142,7 +141,7 @@ static void paste(const gchar * website)
"Unable to the the content of the file");
g_error_free(error);
}
-
+
msg = soup_message_new("POST", website);
formdata =
soup_form_encode("lang", f_type, "code", f_content, "submit",
@@ -150,7 +149,7 @@ static void paste(const gchar * website)
break;
case PASTEBIN_COM:
-
+
if ((result =
g_file_get_contents(f_path, &f_content, &f_lenght,
&error)) == FALSE) {
@@ -158,7 +157,7 @@ static void paste(const gchar * website)
"Unable to the the content of the file");
g_error_free(error);
}
-
+
msg = soup_message_new("POST", website);
formdata =
soup_form_encode("paste_code", f_content, "paste_format",
@@ -167,14 +166,14 @@ static void paste(const gchar * website)
case DPASTE_DE:
-
+
for (i = 0; i < G_N_ELEMENTS(langs_supported_dpaste); i++) {
if (g_strcmp0(f_type, langs_supported_dpaste[i]) == 0)
break;
else
f_type = langs_supported_dpaste[15]; // Text only
}
-
+
if ((result =
g_file_get_contents(f_path, &f_content, &f_lenght,
&error)) == FALSE) {
@@ -182,12 +181,12 @@ static void paste(const gchar * website)
"Unable to the the content of the file");
g_error_free(error);
}
-
+
msg = soup_message_new("POST", website);
formdata =
soup_form_encode("content", f_content, "title", f_title,
"lexer", f_type, NULL);
-
+
break;
case SPRUNGE_US:
@@ -199,15 +198,15 @@ static void paste(const gchar * website)
"Unable to the the content of the file");
g_error_free(error);
}
-
+
msg = soup_message_new("POST", website);
formdata =
soup_form_encode("sprunge", f_content, NULL);
-
+
break;
case PASTEBIN_GEANY_ORG:
-
+
if ((result =
g_file_get_contents(f_path, &f_content, &f_lenght,
&error)) == FALSE) {
@@ -215,61 +214,61 @@ static void paste(const gchar * website)
"Unable to the the content of the file");
g_error_free(error);
}
-
+
msg = soup_message_new("POST", website);
formdata =
soup_form_encode("content", f_content, "author", USERNAME,
"title", f_title, "lexer", f_type, NULL);
-
+
break;
-
+
}
soup_message_set_request(msg, "application/x-www-form-urlencoded",
SOUP_MEMORY_COPY, formdata, strlen(formdata));
-
+
status = soup_session_send_message(session, msg);
if(status == 200) {
p_url = msg->response_body->data;
-
- /*
+
+ /*
* codepad.org doesn't return only the url of the new snippet pasted
* but an html page. This minimal parser will get the bare url.
*/
-
+
if (website_selected == CODEPAD_ORG) {
temp_body = g_strdup(p_url);
tokens_array = g_strsplit(temp_body, "<a href=\"", 0);
-
+
/* copy the first 27 chars because the url is composed by 27 characters.
* codepad.org/XXXXXXXX
*/
- p_url = g_strndup(tokens_array[5], 27);
-
+ p_url = g_strndup(tokens_array[5], 27);
+
g_free(temp_body);
g_strfreev(tokens_array);
-
+
} else if(website_selected == DPASTE_DE) {
p_url = g_strndup(p_url + 1, strlen(p_url) - 2);
-
+
} else if(website_selected == SPRUNGE_US) {
-
+
/* in order to enable the syntax highlightning on sprunge.us
* it is necessary to append at the returned url a question
* mark '?' followed by the file type.
- *
+ *
* e.g. sprunge.us/xxxx?c
*/
- p_url[strlen(p_url) - 1] = '\0';
+ p_url[strlen(p_url) - 1] = '\0';
f_type[0] = g_ascii_tolower(f_type[0]);
temp_body = g_strdup_printf("?%s", f_type);
g_strlcat(p_url + 1, temp_body, -1);
p_url = g_strchomp(p_url);
free(temp_body);
}
-
+
if (check_button_is_checked) {
buffer_shell_command = g_malloc(100 * sizeof(gchar));
sprintf(buffer_shell_command, "%s %s", OPEN_BROWSER, p_url);
@@ -278,18 +277,18 @@ static void paste(const gchar * website)
} else {
dialogs_show_msgbox(GTK_MESSAGE_INFO, "%s", p_url);
}
-
+
if(website_selected == CODEPAD_ORG || website_selected == DPASTE_DE) {
g_free(p_url);
}
-
+
} else {
dialogs_show_msgbox(GTK_MESSAGE_INFO, "Unable to paste the code. Check your connection and retry.\n"
"Error code: %d\n", status);
}
-
+
g_free(f_content);
-
+
}
static void item_activate(GtkMenuItem * menuitem, gpointer gdata)
@@ -300,8 +299,8 @@ static void item_activate(GtkMenuItem * menuitem, gpointer gdata)
static void on_configure_response(GtkDialog * dialog, gint response, gpointer * user_data)
{
if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) {
-
- website_selected =
+
+ website_selected =
gtk_combo_box_get_active
(GTK_COMBO_BOX(widgets.combo));
Modified: geniuspaste/wscript_build
31 files changed, 31 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+#
+# WAF build script for geany-plugins - Update Checker
+#
+# Copyright 2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+# Copyright 2011-2012 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# $Id$
+
+from build.wafutils import build_plugin
+
+
+name = 'geniuspaste'
+includes = ['geniuspaste/src']
+libraries = ['LIBSOUP']
+
+build_plugin(bld, name, includes=includes, libraries=libraries)
Modified: geniuspaste/wscript_configure
36 files changed, 36 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+#
+# WAF build script for geany-plugins - GeniusPaste
+#
+# Copyright 2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+# Copyright 2011-2012 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# $Id$
+
+from build.wafutils import check_cfg_cached
+
+packages = [
+ ('libsoup-2.4', '2.4.0', 'LIBSOUP')
+ ]
+
+for package_name, package_version, uselib_store in packages:
+ check_cfg_cached(conf,
+ package=package_name,
+ atleast_version=package_version,
+ uselib_store=uselib_store,
+ mandatory=True,
+ args='--cflags --libs')
Modified: po/POTFILES.in
3 files changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -208,6 +208,9 @@ geanyvc/src/vc_svk.c
geanyvc/src/vc_svn.c
geanyvc/src/utils.c
+# GeniusPaste
+geniuspaste/src/geniuspaste.c
+
# GProject
gproject/src/gproject-main.c
gproject/src/gproject-menu.c
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
More information about the Plugins-Commits
mailing list