Revision: 388 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=388&view=rev Author: frlan Date: 2009-01-20 00:15:12 +0000 (Tue, 20 Jan 2009)
Log Message: ----------- GeanyLipsum: Added support for config files and custom Lorem Ipsum text snippets
Modified Paths: -------------- trunk/geanylipsum/src/geanylipsum.c
Modified: trunk/geanylipsum/src/geanylipsum.c =================================================================== --- trunk/geanylipsum/src/geanylipsum.c 2009-01-20 00:14:26 UTC (rev 387) +++ trunk/geanylipsum/src/geanylipsum.c 2009-01-20 00:15:12 UTC (rev 388) @@ -63,8 +63,9 @@ PLUGIN_SET_INFO(_("Lipsum"), _("Creating dummy text with Geany"), VERSION, _("Frank Lanitz frank@frank.uvena.de"));
static GtkWidget *main_menu_item = NULL; +static gchar *config_file = NULL; +static gchar *lipsum = NULL;
- /* Doing some basic keybinding stuff */ enum { @@ -89,7 +90,6 @@ } }
-/* Only inserts a default tet. So dialog is some kind of useless at the moment ;) */ void lipsum_activated(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata) { @@ -136,7 +136,7 @@
gtk_widget_destroy(dialog);
- insert_string(LOREMIPSUM); + insert_string(lipsum); } else { @@ -156,11 +156,27 @@ plugin_init(G_GNUC_UNUSED GeanyData *data) { GtkWidget *menu_lipsum = NULL; + GKeyFile *config = g_key_file_new(); GtkTooltips *tooltips = NULL; tooltips = gtk_tooltips_new();
main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
+ config_file = g_strconcat(geany->app->configdir, + G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, + "geanylipsum", G_DIR_SEPARATOR_S, "lipsum.conf", NULL); + + /* Initialising options from config file */ + g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); + lipsum = g_key_file_get_string(config, "snippets", "lipsumtext", NULL); + + /* Setting default value */ + if (lipsum == NULL) + { + lipsum = g_strdup(LOREMIPSUM); + } + g_key_file_free(config); + menu_lipsum = gtk_image_menu_item_new_with_mnemonic(_("_Lipsum")); gtk_tooltips_set_tip(tooltips, menu_lipsum, _("Include Pseudotext to your code"), NULL); @@ -170,7 +186,6 @@ gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_lipsum);
/* init keybindins */ - keybindings_set_item(plugin_key_group, LIPSUM_KB_INSERT, kblipsum_insert, 0, 0, "inster_lipsum", _("Insert Lipsum tex"), menu_lipsum);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.