Revision: 59 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=59&view=rev Author: eht16 Date: 2008-06-03 09:06:14 -0700 (Tue, 03 Jun 2008)
Log Message: ----------- Compilation fixes. Version bump.
Modified Paths: -------------- trunk/instantsave/ChangeLog trunk/instantsave/configure.in trunk/instantsave/src/instantsave.c
Modified: trunk/instantsave/ChangeLog =================================================================== --- trunk/instantsave/ChangeLog 2008-06-02 22:36:11 UTC (rev 58) +++ trunk/instantsave/ChangeLog 2008-06-03 16:06:14 UTC (rev 59) @@ -1,3 +1,11 @@ +2008-06-03 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * src/instantsave.c: + Compilation fixes. + * configure.in: + Version bump. + + 2008-05-20 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/instantsave.c:
Modified: trunk/instantsave/configure.in =================================================================== --- trunk/instantsave/configure.in 2008-06-02 22:36:11 UTC (rev 58) +++ trunk/instantsave/configure.in 2008-06-03 16:06:14 UTC (rev 59) @@ -2,7 +2,7 @@ # $Id$
AC_INIT(configure.in) -AM_INIT_AUTOMAKE(instantsave, 0.1) +AM_INIT_AUTOMAKE(instantsave, 0.2)
AM_CONFIG_HEADER(config.h)
Modified: trunk/instantsave/src/instantsave.c =================================================================== --- trunk/instantsave/src/instantsave.c 2008-06-02 22:36:11 UTC (rev 58) +++ trunk/instantsave/src/instantsave.c 2008-06-03 16:06:14 UTC (rev 59) @@ -25,7 +25,7 @@ #include <config.h> #include <unistd.h>
-#if HAVE_LOCALE_H +#ifdef HAVE_LOCALE_H # include <locale.h> #endif
@@ -44,10 +44,10 @@ GeanyFunctions *geany_functions;
-PLUGIN_VERSION_CHECK(60) +PLUGIN_VERSION_CHECK(67)
-PLUGIN_INFO(_("Instant Save"), _("Save instantly new files without an explicit Save As dialog."), - "0.1", "Enrico Tröger") +PLUGIN_SET_INFO(_("Instant Save"), _("Save instantly new files without an explicit Save As dialog."), + "0.2", "Enrico Tröger")
static gchar *config_file; @@ -56,7 +56,7 @@
static void on_document_new(GObject *obj, gint idx, gpointer user_data) { - if (doc_list[idx].file_name == NULL) + if (documents[idx]->file_name == NULL) { gchar *new_filename; gint fd; @@ -70,9 +70,9 @@ /* add the filetype's default extension to the new filename */ setptr(new_filename, g_strconcat(new_filename, ".", ft->extension, NULL)); - doc_list[idx].file_name = new_filename; + documents[idx]->file_name = new_filename;
- if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_NONE) + if (FILETYPE_ID(documents[idx]->file_type) == GEANY_FILETYPES_NONE) p_document->set_filetype(idx, p_filetypes->lookup_by_name(default_ft));
/* force saving the file to enable all the related actions(tab name, filetype, etc.) */ @@ -81,7 +81,7 @@ }
-GeanyCallback geany_callbacks[] = +PluginCallback plugin_callbacks[] = { { "document-new", (GCallback) &on_document_new, FALSE, NULL }, { NULL, NULL, FALSE, NULL } @@ -93,7 +93,7 @@ #ifdef ENABLE_NLS gchar *locale_dir = NULL;
-#if HAVE_LOCALE_H +#ifdef HAVE_LOCALE_H setlocale(LC_ALL, ""); #endif
@@ -114,8 +114,42 @@ }
-void init(GeanyData *data) +static void on_configure_response(GtkDialog *dialog, gint response, gpointer user_data) { + if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) + { + GKeyFile *config = g_key_file_new(); + gchar *data; + gchar *config_dir = g_path_get_dirname(config_file); + + g_free(default_ft); + default_ft = gtk_combo_box_get_active_text(GTK_COMBO_BOX( + g_object_get_data(G_OBJECT(dialog), "combo"))); + + g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); + g_key_file_set_string(config, "instantsave", "default_ft", default_ft); + + if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && p_utils->mkdir(config_dir, TRUE) != 0) + { + p_dialogs->show_msgbox(GTK_MESSAGE_ERROR, + _("Plugin configuration directory could not be created.")); + } + else + { + /* write config to file */ + data = g_key_file_to_data(config, NULL, NULL); + p_utils->write_file(config_file, data); + g_free(data); + } + + g_free(config_dir); + g_key_file_free(config); + } +} + + +void plugin_init(GeanyData *data) +{ GKeyFile *config = g_key_file_new(); config_file = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "instantsave", G_DIR_SEPARATOR_S, "instantsave.conf", NULL); @@ -130,17 +164,12 @@ }
-void configure(GtkWidget *parent) +GtkWidget *plugin_configure(GtkDialog *dialog) { - GtkWidget *dialog, *label, *vbox, *combo; + GtkWidget *label, *vbox, *combo; gint i;
- dialog = gtk_dialog_new_with_buttons(_("Instant Save"), - GTK_WINDOW(parent), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); - vbox = p_ui->dialog_vbox_new(GTK_DIALOG(dialog)); - gtk_widget_set_name(dialog, "GeanyDialog"); - gtk_box_set_spacing(GTK_BOX(vbox), 6); + vbox = gtk_vbox_new(FALSE, 6);
label = gtk_label_new(_("Filetype to use for newly opened files:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); @@ -159,40 +188,14 @@
gtk_widget_show_all(vbox);
- /* run the dialog and check for the response code */ - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) - { - GKeyFile *config = g_key_file_new(); - gchar *data; - gchar *config_dir = g_path_get_dirname(config_file); - - g_free(default_ft); - default_ft = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); - - g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); - g_key_file_set_string(config, "instantsave", "default_ft", default_ft); - - if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && p_utils->mkdir(config_dir, TRUE) != 0) - { - p_dialogs->show_msgbox(GTK_MESSAGE_ERROR, - _("Plugin configuration directory could not be created.")); - } - else - { - /* write config to file */ - data = g_key_file_to_data(config, NULL, NULL); - p_utils->write_file(config_file, data); - g_free(data); - } - - g_free(config_dir); - g_key_file_free(config); - } - gtk_widget_destroy(dialog); + g_object_set_data(G_OBJECT(dialog), "combo", combo); + g_signal_connect(dialog, "response", G_CALLBACK(on_configure_response), NULL); + + return vbox; }
-void cleanup(void) +void plugin_cleanup(void) { g_free(config_file); g_free(default_ft);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.