Revision: 1105 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1105&view=re... Author: frlan Date: 2010-01-03 21:50:42 +0000 (Sun, 03 Jan 2010)
Log Message: ----------- Make text for inserting a reference configurable via a hidden pref.
Modified Paths: -------------- trunk/geanylatex/doc/geanylatex.tex trunk/geanylatex/src/geanylatex.c
Modified: trunk/geanylatex/doc/geanylatex.tex =================================================================== --- trunk/geanylatex/doc/geanylatex.tex 2010-01-02 22:53:35 UTC (rev 1104) +++ trunk/geanylatex/doc/geanylatex.tex 2010-01-03 21:50:42 UTC (rev 1105) @@ -572,6 +572,35 @@
Please ensure, you reload the plugin once this option has been changed.
+\subsubsection{Customized reference strings} + +Geany\LaTeX{} is able to insert references to a label where its +using some default value. As this value is not always optimal, it +can be changed using a hidden preference by setting +\texttt{glatex_reference_page}, \texttt{glatex_reference_chapter} or +\texttt{glatex_reference_all} inside configuration file as shown inside +the example configuration snippet. + +\begin{lstlisting} +[general] +glatex_set_koma_active=true +glatex_set_toolbar_active=true + +[reference] +glatex_reference_page=\textbf{\pageref{{{reference}}}} +glatex_reference_chapter=\textbf{\ref{{{reference}}}} +glatex_reference_all=\textbf{\ref{{{reference}}}, page \pageref{{{reference}}}}\end{lstlisting} + +Please take care in this case \texttt{{{reference}}} will be +replace by label name. + +Also \texttt{\textbackslash{}t}, \texttt{\textbackslash{}r}, +\texttt{\textbackslash{}n} will be handled as known from C so you will +need to add a second \textbackslash{} in front of in such cases. Even +this seems to be annyoing on the first hand, it allows you to insert some +more complicated constructs over here which might require a new line inside. + + \section{Contribution to the plugin} If you like the plugin, there are a number of ways, how to contribute to the development of the plugin.
Modified: trunk/geanylatex/src/geanylatex.c =================================================================== --- trunk/geanylatex/src/geanylatex.c 2010-01-02 22:53:35 UTC (rev 1104) +++ trunk/geanylatex/src/geanylatex.c 2010-01-03 21:50:42 UTC (rev 1105) @@ -54,6 +54,9 @@ /* Options for plugin */ static gboolean glatex_set_koma_active = FALSE; static gboolean glatex_deactivate_toolbaritems_with_non_latex = TRUE; +static gchar *glatex_ref_chapter_string = NULL; +static gchar *glatex_ref_page_string = NULL; +static gchar *glatex_ref_all_string = NULL; static gboolean glatex_set_toolbar_active = FALSE;
/* Function will be deactivated, when only loaded */ @@ -554,29 +557,40 @@ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { gchar *ref_string = NULL; - + GString *template_string = NULL; + ref_string = g_strdup(gtk_combo_box_get_active_text( GTK_COMBO_BOX(textbox_ref)));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio1)) == TRUE) { - ref_string = g_strconcat("\ref{", ref_string, "}", NULL); + template_string = g_string_new(glatex_ref_chapter_string); } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio2))== TRUE) { - ref_string = g_strconcat("\pageref{", ref_string, "}", NULL); + template_string = g_string_new(glatex_ref_page_string); } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio3))== TRUE) { - ref_string = g_strconcat("\ref{", ref_string, "}, ", _("page"), - " \pageref{", ref_string, "}", NULL); + template_string = g_string_new(glatex_ref_all_string); }
- if (ref_string != NULL) + if (ref_string != NULL && template_string != NULL) { - glatex_insert_string(ref_string, TRUE); + gchar *tmp; + utils_string_replace_all(template_string, "{{reference}}", ref_string); + tmp = g_string_free(template_string, FALSE); + glatex_insert_string(tmp, TRUE); g_free(ref_string); + g_free(tmp); } + else + { + if (ref_string != NULL) + g_free(ref_string); + if (template_string != NULL) + g_free(template_string); + } }
gtk_widget_destroy(dialog); @@ -1321,6 +1335,13 @@ glatex_deactivate_toolbaritems_with_non_latex = utils_get_setting_boolean(config, "toolbar", "glatex_deactivate_toolbaritems_with_non_latex", TRUE);
+ glatex_ref_page_string = utils_get_setting_string(config, "reference", + "glatex_reference_page", _("page \pageref{{{reference}}}")); + glatex_ref_chapter_string = utils_get_setting_string(config, "reference", + "glatex_reference_chapter", "\ref{{{reference}}}"); + glatex_ref_all_string = utils_get_setting_string(config, "reference", + "glatex_reference_all", _("\ref{{{reference}}}, page \pageref{{{reference}}}")); + main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
g_key_file_free(config); @@ -1462,4 +1483,7 @@ gtk_widget_destroy(glatex_toolbar);
g_free(config_file); + g_free(glatex_ref_chapter_string); + g_free(glatex_ref_page_string); + g_free(glatex_ref_all_string); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org