Revision: 1182 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1182&view=re... Author: frlan Date: 2010-03-19 23:59:47 +0000 (Fri, 19 Mar 2010)
Log Message: ----------- GeanyLaTeX: Add dialog and keybinding for insert \usepackage{} function
Modified Paths: -------------- trunk/geanylatex/src/geanylatex.c trunk/geanylatex/src/latexkeybindings.c trunk/geanylatex/src/latexkeybindings.h
Modified: trunk/geanylatex/src/geanylatex.c =================================================================== --- trunk/geanylatex/src/geanylatex.c 2010-03-19 23:59:21 UTC (rev 1181) +++ trunk/geanylatex/src/geanylatex.c 2010-03-19 23:59:47 UTC (rev 1182) @@ -1016,6 +1016,51 @@ } }
+void glatex_insert_usepackage_dialog(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + GtkWidget *dialog = NULL; + GtkWidget *vbox = NULL; + GtkWidget *label = NULL; + GtkWidget *textbox = NULL; + GtkWidget *table = NULL; + + dialog = gtk_dialog_new_with_buttons(_("Add additional package"), + GTK_WINDOW(geany->main_widgets->window), + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog)); + gtk_widget_set_name(dialog, "GeanyDialog"); + gtk_box_set_spacing(GTK_BOX(vbox), 10); + + table = gtk_table_new(1, 2, FALSE); + gtk_table_set_col_spacings(GTK_TABLE(table), 6); + gtk_table_set_row_spacings(GTK_TABLE(table), 6); + + label = gtk_label_new(_("Package name:")); + textbox = gtk_entry_new(); + + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), textbox, 1, 2, 0, 1); + gtk_container_add(GTK_CONTAINER(vbox), table); + + gtk_widget_show_all(vbox); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + { + const gchar *pkg; + pkg = gtk_entry_get_text(GTK_ENTRY(textbox)); + glatex_usepackage(pkg); + + } + + gtk_widget_destroy(dialog); + +} + void glatex_wizard_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata) @@ -1626,6 +1671,9 @@ keybindings_set_item(plugin_key_group, KB_LATEX_STRUCTURE_LVLDOWN, glatex_kb_structure_lvldown, 0, 0, "structure_lvl_down", _("Set selection one level down"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_USEPACKAGE_DIALOG, + glatex_kb_usepackage_dialog, 0, 0, "usepackage_dialog", + _("Insert \usepackage{}"), NULL); }
void plugin_help()
Modified: trunk/geanylatex/src/latexkeybindings.c =================================================================== --- trunk/geanylatex/src/latexkeybindings.c 2010-03-19 23:59:21 UTC (rev 1181) +++ trunk/geanylatex/src/latexkeybindings.c 2010-03-19 23:59:47 UTC (rev 1182) @@ -145,3 +145,10 @@ return; glatex_structure_lvldown(); } + +void glatex_kb_usepackage_dialog(G_GNUC_UNUSED guint key_id) +{ + if (NULL == document_get_current()) + return; + glatex_insert_usepackage_dialog(NULL, NULL); +}
Modified: trunk/geanylatex/src/latexkeybindings.h =================================================================== --- trunk/geanylatex/src/latexkeybindings.h 2010-03-19 23:59:21 UTC (rev 1181) +++ trunk/geanylatex/src/latexkeybindings.h 2010-03-19 23:59:47 UTC (rev 1182) @@ -46,6 +46,7 @@ KB_LATEX_ENVIRONMENT_INSERT_ENUMERATE, KB_LATEX_STRUCTURE_LVLUP, KB_LATEX_STRUCTURE_LVLDOWN, + KB_LATEX_USEPACKAGE_DIALOG, COUNT_KB };
@@ -68,5 +69,6 @@ void glatex_kb_insert_enumerate_list(G_GNUC_UNUSED guint key_id); void glatex_kb_structure_lvlup(G_GNUC_UNUSED guint key_id); void glatex_kb_structure_lvldown(G_GNUC_UNUSED guint key_id); +void glatex_kb_usepackage_dialog(G_GNUC_UNUSED guint key_id);
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.