Revision: 1291 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1291&view=re... Author: frlan Date: 2010-04-24 11:47:28 +0000 (Sat, 24 Apr 2010)
Log Message: ----------- GeanyLaTeX: Add a first insert command dialog
Modified Paths: -------------- trunk/geanylatex/ChangeLog trunk/geanylatex/src/geanylatex.c trunk/geanylatex/src/geanylatex.h trunk/geanylatex/src/latexkeybindings.c trunk/geanylatex/src/latexkeybindings.h
Modified: trunk/geanylatex/ChangeLog =================================================================== --- trunk/geanylatex/ChangeLog 2010-04-24 11:46:46 UTC (rev 1290) +++ trunk/geanylatex/ChangeLog 2010-04-24 11:47:28 UTC (rev 1291) @@ -1,3 +1,9 @@ +2010-04-24 Frank Lanitz frank@frank.uvena.de + + * Add a simple insert dommand dialog, which shall support inserting + commands more in future + + 2010-04-21 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
* Automatic insert {} after typing ^ or _
Modified: trunk/geanylatex/src/geanylatex.c =================================================================== --- trunk/geanylatex/src/geanylatex.c 2010-04-24 11:46:46 UTC (rev 1290) +++ trunk/geanylatex/src/geanylatex.c 2010-04-24 11:47:28 UTC (rev 1291) @@ -53,6 +53,7 @@ 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_insert_command = NULL; static GtkWidget *menu_latex_replacement = NULL; static GtkWidget *menu_latex_replacement_submenu = NULL; static GtkWidget *menu_latex_replace_selection = NULL; @@ -717,6 +718,60 @@
void +glatex_insert_command_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + GtkWidget *dialog; + GtkWidget *vbox = NULL; + GtkWidget *label_command = NULL; + GtkWidget *textbox_command = NULL; + GtkWidget *table = NULL; + + dialog = gtk_dialog_new_with_buttons(_("Insert Command"), + 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_command = gtk_label_new(_("Command name:")); + + textbox_command = gtk_entry_new(); + + gtk_misc_set_alignment(GTK_MISC(label_command), 0, 0.5); + + gtk_table_attach_defaults(GTK_TABLE(table), label_command, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), textbox_command, 1, 2, 0, 1); + gtk_container_add(GTK_CONTAINER(vbox), table); + + g_signal_connect(G_OBJECT(textbox_command), "activate", + G_CALLBACK(glatex_enter_key_pressed_in_entry), dialog); + + gtk_widget_show_all(vbox); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + { + gchar *cmd_str = NULL; + const gchar *cmd = NULL; + + cmd = gtk_entry_get_text(GTK_ENTRY(textbox_command)); + cmd_str = g_strdup_printf("\%s{}", cmd); + glatex_insert_string(cmd_str, TRUE); + g_free(cmd_str); + } + + gtk_widget_destroy(dialog); +} + + + +void glatex_insert_ref_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata) { @@ -1695,6 +1750,9 @@ 0, 0, "insert_latex_ref", _("Insert \ref"), menu_latex_ref); keybindings_set_item(plugin_key_group, KB_LATEX_INSERT_NEWLINE, glatex_kb_insert_newline, 0, 0, "insert_new_line", _("Insert linebreak \\ "), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_INSERT_COMMAND, + glatex_kb_insert_command_dialog, 0, 0, "latex_insert_command", + _("Insert command"), menu_latex_insert_command); keybindings_set_item(plugin_key_group, KB_LATEX_TOGGLE_ACTIVE, glatex_kblatex_toggle, 0, 0, "latex_toggle_status", _("Turn input replacement on/off"), menu_latex_replace_toggle); @@ -1738,6 +1796,7 @@ _("Insert \usepackage{}"), menu_latex_insert_usepackage); }
+ void plugin_help() { dialogs_show_msgbox(GTK_MESSAGE_INFO, @@ -1951,6 +2010,16 @@ g_signal_connect(menu_latex_replace_toggle, "activate", G_CALLBACK(glatex_toggle_status), NULL);
+ /* Add menu entry for inserting a command */ + menu_latex_insert_command = gtk_menu_item_new_with_mnemonic( + _("Insert _Command")); + ui_widget_set_tooltip_text(menu_latex_ref, + _("Inserting costumized command to document")); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), + menu_latex_insert_command); + g_signal_connect(menu_latex_insert_command, "activate", + G_CALLBACK(glatex_insert_command_activated), NULL); + init_keybindings();
/* Check whether the toolbar should be shown or not and do so*/ @@ -1970,6 +2039,7 @@ ui_add_document_sensitive(menu_latex_format_insert); ui_add_document_sensitive(menu_latex_insert_environment); ui_add_document_sensitive(menu_latex_insert_usepackage); + ui_add_document_sensitive(menu_latex_insert_command); ui_add_document_sensitive(menu_latex_replacement);
gtk_widget_show_all(menu_latex);
Modified: trunk/geanylatex/src/geanylatex.h =================================================================== --- trunk/geanylatex/src/geanylatex.h 2010-04-24 11:46:46 UTC (rev 1290) +++ trunk/geanylatex/src/geanylatex.h 2010-04-24 11:47:28 UTC (rev 1291) @@ -89,4 +89,6 @@ void glatex_replace_special_character(); void glatex_insert_usepackage_dialog(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata); +void glatex_insert_command_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata); #endif
Modified: trunk/geanylatex/src/latexkeybindings.c =================================================================== --- trunk/geanylatex/src/latexkeybindings.c 2010-04-24 11:46:46 UTC (rev 1290) +++ trunk/geanylatex/src/latexkeybindings.c 2010-04-24 11:47:28 UTC (rev 1291) @@ -151,3 +151,9 @@ g_return_if_fail(document_get_current != NULL); glatex_insert_usepackage_dialog(NULL, NULL); } + +void glatex_kb_insert_command_dialog(G_GNUC_UNUSED guint key_id) +{ + g_return_if_fail(document_get_current != NULL); + glatex_insert_command_activated(NULL, NULL); +}
Modified: trunk/geanylatex/src/latexkeybindings.h =================================================================== --- trunk/geanylatex/src/latexkeybindings.h 2010-04-24 11:46:46 UTC (rev 1290) +++ trunk/geanylatex/src/latexkeybindings.h 2010-04-24 11:47:28 UTC (rev 1291) @@ -47,6 +47,7 @@ KB_LATEX_STRUCTURE_LVLUP, KB_LATEX_STRUCTURE_LVLDOWN, KB_LATEX_USEPACKAGE_DIALOG, + KB_LATEX_INSERT_COMMAND, COUNT_KB };
@@ -70,5 +71,6 @@ 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); +void glatex_kb_insert_command_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.