/* Called by Geany to initialize the plugin */ void plugin_init(GeanyData G_GNUC_UNUSED *data) { GKeyFile *config = g_key_file_new(); gchar *kb_label = _("Send file by mail"); GtkWidget *menu_mail = NULL; GeanyKeyGroup *key_group; config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "geanysendmail", G_DIR_SEPARATOR_S, "mail.conf", NULL); /* Initialising options from config file */ g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); mailer = g_key_file_get_string(config, "tools", "mailer", NULL); address = g_key_file_get_string(config, "tools", "address", NULL); use_address_dialog = g_key_file_get_boolean(config, "tools", "address_usage", NULL); icon_in_toolbar = g_key_file_get_boolean(config, "icon", "show_icon", NULL); g_key_file_free(config); add_stock_item(); if (icon_in_toolbar == TRUE) { show_icon(); } /* Build up menu entry */ menu_mail = gtk_menu_item_new_with_mnemonic(_("_Mail document")); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_mail); gtk_widget_set_tooltip_text(menu_mail, _("Sends the opened file as unzipped attachment by any mailer from your $PATH")); g_signal_connect(G_OBJECT(menu_mail), "activate", G_CALLBACK(send_as_attachment), NULL); /* setup keybindings */ key_group = plugin_set_key_group(geany_plugin, "sendmail", COUNT_KB, NULL); keybindings_set_item(key_group, SENDMAIL_KB, key_send_as_attachment, 0, 0, "send_file_as_attachment", kb_label, menu_mail); gtk_widget_show_all(menu_mail); ui_add_document_sensitive(menu_mail); main_menu_item = menu_mail; }
/* Called by Geany to initialize the plugin */ void plugin_init(GeanyData G_GNUC_UNUSED *data) { GKeyFile *config = g_key_file_new(); gchar *config_file_old = NULL; gchar *config_dir = NULL; gchar *config_dir_old = NULL; gchar *kb_label = _("Send file by mail"); GtkWidget *menu_mail = NULL; GeanyKeyGroup *key_group; config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "sendmail", G_DIR_SEPARATOR_S, "mail.conf", NULL); #ifndef G_OS_WIN32 /* We try only to move if we are on not Windows platform */ config_file_old = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "geanysendmail", G_DIR_SEPARATOR_S, "mail.conf", NULL); config_dir = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "sendmail", NULL); config_dir_old = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "geanysendmail", NULL); if (g_file_test(config_file_old, G_FILE_TEST_EXISTS)) { if (dialogs_show_question( _("Renamed plugin detected!\n" "\n" "GeanySendMail has been renamed to sendmail -- you surely have " "already recognised it. \n" "Geany is able to migrate your old plugin configuration by " "moving the old configuration file to new location.\n" "Move now?"))) { if (g_rename(config_dir_old, config_dir) == 0) { dialogs_show_msgbox(GTK_MESSAGE_INFO, _("Your configuration directory has been " "successfully moved from \"%s\" to \"%s\"."), config_dir_old, config_dir); } else { /* If there was an error on migrating we need * to load from original one. * When saving new configuration it will go to * new folder so migration should * be implicit. */ g_free(config_file); config_file = g_strdup(config_file_old); dialogs_show_msgbox( GTK_MESSAGE_WARNING, _("Your old configuration directory \"%s\" could " "not be moved to \"%s\" (%s). " "Please move manually the directory to the new location."), config_dir_old, config_dir, g_strerror(errno)); } } } g_free(config_dir_old); g_free(config_dir); g_free(config_file_old); #endif /* Initialising options from config file */ g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); mailer = g_key_file_get_string(config, "tools", "mailer", NULL); address = g_key_file_get_string(config, "tools", "address", NULL); use_address_dialog = g_key_file_get_boolean(config, "tools", "address_usage", NULL); icon_in_toolbar = g_key_file_get_boolean(config, "icon", "show_icon", NULL); g_key_file_free(config); add_stock_item(); if (icon_in_toolbar == TRUE) { show_icon(); } /* Build up menu entry */ menu_mail = gtk_menu_item_new_with_mnemonic(_("_Mail document")); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_mail); gtk_widget_set_tooltip_text(menu_mail, _("Sends the opened file as unzipped attachment by any mailer from your $PATH")); g_signal_connect(G_OBJECT(menu_mail), "activate", G_CALLBACK(send_as_attachment), NULL); /* setup keybindings */ key_group = plugin_set_key_group(geany_plugin, "sendmail", COUNT_KB, NULL); keybindings_set_item(key_group, SENDMAIL_KB, key_send_as_attachment, 0, 0, "send_file_as_attachment", kb_label, menu_mail); gtk_widget_show_all(menu_mail); ui_add_document_sensitive(menu_mail); main_menu_item = menu_mail; }