Revision: 1206 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1206&view=re... Author: frlan Date: 2010-03-27 01:36:53 +0000 (Sat, 27 Mar 2010)
Log Message: ----------- GeanyLaTeX: Adding a menu entry for easy inserting font sizes into LaTeX document
Modified Paths: -------------- trunk/geanylatex/src/formatpatterns.c trunk/geanylatex/src/formatutils.c trunk/geanylatex/src/formatutils.h trunk/geanylatex/src/geanylatex.c
Modified: trunk/geanylatex/src/formatpatterns.c =================================================================== --- trunk/geanylatex/src/formatpatterns.c 2010-03-27 01:36:25 UTC (rev 1205) +++ trunk/geanylatex/src/formatpatterns.c 2010-03-27 01:36:53 UTC (rev 1206) @@ -1,7 +1,7 @@ /* * formatpatterns.c * - * Copyright 2009-2010 Frank Lanitz frank@Jupiter + * Copyright 2009-2010 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 @@ -46,3 +46,29 @@ N_("Left side oriented"), N_("Right side oriented") }; + +gchar *glatex_fontsize_pattern[] = { + "\tiny", + "\scriptsize", + "\footnotesize", + "\small", + "\normalsize", + "\large", + "\Large", + "\LARGE", + "\huge", + "\Huge" +}; + +const gchar *glatex_fontsize_labels[] = { + N_("tiny"), + N_("scriptsize"), + N_("footnotesize"), + N_("small"), + N_("normalsize"), + N_("large"), + N_("Large"), + N_("LARGE"), + N_("huge"), + N_("Huge") +};
Modified: trunk/geanylatex/src/formatutils.c =================================================================== --- trunk/geanylatex/src/formatutils.c 2010-03-27 01:36:25 UTC (rev 1205) +++ trunk/geanylatex/src/formatutils.c 2010-03-27 01:36:53 UTC (rev 1206) @@ -1,59 +1,76 @@ /* - * formatutils.c + * formatutils.c * - * Copyright 2009-2010 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * Copyright 2009-2010 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 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. + * 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. + * 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. */
#include "formatutils.h"
void glatex_insert_latex_format(G_GNUC_UNUSED GtkMenuItem * menuitem, - G_GNUC_UNUSED gpointer gdata) + G_GNUC_UNUSED gpointer gdata) { - gint format = GPOINTER_TO_INT(gdata); - GeanyDocument *doc = NULL; + gint format = GPOINTER_TO_INT(gdata); + GeanyDocument *doc = NULL; doc = document_get_current();
if (doc != NULL) { - if (sci_has_selection(doc->editor->sci)) - { - gchar *selection; - gchar *replacement = NULL; + if (sci_has_selection(doc->editor->sci)) + { + gchar *selection; + gchar *replacement = NULL;
- selection = sci_get_selection_contents(doc->editor->sci); + selection = sci_get_selection_contents(doc->editor->sci);
- replacement = g_strconcat(glatex_format_pattern[format],"{", - selection, "}", NULL); + replacement = g_strconcat(glatex_format_pattern[format],"{", + selection, "}", NULL);
- sci_replace_sel(doc->editor->sci, replacement); - g_free(selection); + sci_replace_sel(doc->editor->sci, replacement); + g_free(selection); g_free(replacement); - } - else - { + } + else + { sci_start_undo_action(doc->editor->sci); - glatex_insert_string(glatex_format_pattern[format], TRUE); - glatex_insert_string("{", TRUE); - glatex_insert_string("}", FALSE); + glatex_insert_string(glatex_format_pattern[format], TRUE); + glatex_insert_string("{", TRUE); + glatex_insert_string("}", FALSE); sci_end_undo_action(doc->editor->sci); } - } + } }
+void glatex_insert_latex_fontsize(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + gint size = GPOINTER_TO_INT(gdata); + GeanyDocument *doc = NULL; + doc = document_get_current(); + + if (doc != NULL) + { + sci_start_undo_action(doc->editor->sci); + glatex_insert_string(glatex_fontsize_pattern[size], TRUE); + glatex_insert_string(" ", TRUE); + sci_end_undo_action(doc->editor->sci); + } +} + +
Modified: trunk/geanylatex/src/formatutils.h =================================================================== --- trunk/geanylatex/src/formatutils.h 2010-03-27 01:36:25 UTC (rev 1205) +++ trunk/geanylatex/src/formatutils.h 2010-03-27 01:36:53 UTC (rev 1206) @@ -1,22 +1,22 @@ /* - * formatutils.h + * formatutils.h * - * Copyright 2009-2010 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * Copyright 2009-2010 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 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. + * 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. + * 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. */
#ifndef LATEXFORMATUTILS_H @@ -25,21 +25,44 @@ #include "geanylatex.h"
enum { - LATEX_ITALIC = 0, - LATEX_BOLD, - LATEX_UNDERLINE, - LATEX_SLANTED, - LATEX_TYPEWRITER, - LATEX_SMALLCAPS, - LATEX_EMPHASIS, - LATEX_CENTER, - LATEX_LEFT, - LATEX_RIGHT, + LATEX_ITALIC = 0, + LATEX_BOLD, + LATEX_UNDERLINE, + LATEX_SLANTED, + LATEX_TYPEWRITER, + LATEX_SMALLCAPS, + LATEX_EMPHASIS, + LATEX_CENTER, + LATEX_LEFT, + LATEX_RIGHT, LATEX_STYLES_END };
+/* Couting from smalles on up to biggest default font size. Keep in mind: + * LATEX_FONTSIZE_LARGE1 -> large + * LATEX_FONTSIZE_LARGE2 -> Large + * LATEX_FONTSIZE_LARGE3 -> LARGE + * LATEX_FONTSIZE_HUGE1 -> huge + * LATEX_FONTSIZE_HUGE2 -> Huge */ +enum { + LATEX_FONTSIZE_TINY = 0, + LATEX_FONTSIZE_SCRIPTSIZE, + LATEX_FONTSIZE_FOOTNOTESIZE, + LATEX_FONTSIZE_SMALL, + LATEX_FONTSIZE_NORMALSIZE, + LATEX_FONTSIZE_LARGE1, + LATEX_FONTSIZE_LARGE2, + LATEX_FONTSIZE_LARGE3, + LATEX_FONTSIZE_HUGE1, + LATEX_FONTSIZE_HUGE2, + LATEX_FONTSIZE_END +}; + extern gchar* glatex_format_pattern[]; extern const gchar *glatex_format_labels[]; +extern const gchar *glatex_fontsize_labels[]; +extern gchar *glatex_fontsize_pattern[]; void glatex_insert_latex_format(GtkMenuItem * menuitem, gpointer gdata); +void glatex_insert_latex_fontsize(GtkMenuItem * menuitem, gpointer gdata);
#endif
Modified: trunk/geanylatex/src/geanylatex.c =================================================================== --- trunk/geanylatex/src/geanylatex.c 2010-03-27 01:36:25 UTC (rev 1205) +++ trunk/geanylatex/src/geanylatex.c 2010-03-27 01:36:53 UTC (rev 1206) @@ -49,6 +49,8 @@ static GtkWidget *menu_latex_bibtex_submenu = NULL; static GtkWidget *menu_latex_format_insert = NULL; static GtkWidget *menu_latex_format_insert_submenu = NULL; +static GtkWidget *menu_latex_fontsize = NULL; +static GtkWidget *menu_latex_fontsize_submenu = NULL; static GtkWidget *menu_latex_insert_environment = NULL; static GtkWidget *menu_latex_insert_usepackage = NULL; static GtkWidget *menu_latex_replacement = NULL; @@ -1852,6 +1854,23 @@ G_CALLBACK(glatex_insert_latex_format), GINT_TO_POINTER(i)); }
+ /* Add font size menu */ + menu_latex_fontsize = gtk_menu_item_new_with_mnemonic(_("_Font size")); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), menu_latex_fontsize); + + menu_latex_fontsize_submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_latex_fontsize), + menu_latex_fontsize_submenu); + + for (i = 0; i < LATEX_FONTSIZE_END; i++) + { + tmp = NULL; + tmp = gtk_menu_item_new_with_mnemonic(_(glatex_fontsize_labels[i])); + gtk_container_add(GTK_CONTAINER(menu_latex_fontsize_submenu), tmp); + g_signal_connect(tmp, "activate", + G_CALLBACK(glatex_insert_latex_fontsize), GINT_TO_POINTER(i)); + } + /* Add menuitem for LaTeX replacement functions*/ menu_latex_replacement = gtk_menu_item_new_with_mnemonic( _("_Special Character Replacement"));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.