From cc3d01aecca5c0818545d0b3f41e4df25a45ea71 Mon Sep 17 00:00:00 2001 From: Andreas Butti Date: Fri, 22 Feb 2019 22:29:12 +0100 Subject: [PATCH] Plugin configuration dialog to enable / disable plugins --- CMakeLists.txt | 8 +- debian/control | 2 +- readme/LinuxBuild.md | 4 +- src/control/Control.cpp | 7 + src/control/settings/Settings.cpp | 52 +++++++ src/control/settings/Settings.h | 15 ++ src/enums/ActionType.enum.h | 5 +- src/enums/generated/ActionType.generated.cpp | 10 ++ src/gui/dialog/ButtonConfigGui.cpp | 6 +- src/gui/dialog/ButtonConfigGui.h | 2 +- src/gui/dialog/PluginDialog.cpp | 69 +++++++++ src/gui/dialog/PluginDialog.h | 39 +++++ src/gui/dialog/PluginDialogEntry.cpp | 73 +++++++++ src/gui/dialog/PluginDialogEntry.h | 40 +++++ src/gui/dialog/SettingsDialog.cpp | 3 +- src/plugin/Plugin.cpp | 65 +++++++- src/plugin/Plugin.h | 45 +++++- src/plugin/PluginController.cpp | 39 +++++ src/plugin/PluginController.h | 10 ++ src/util/XournalTypeList.h | 3 + ui/main.glade | 3 +- ui/plugin.glade | 137 ++++++++++++++++ ui/pluginEntry.glade | 155 +++++++++++++++++++ 23 files changed, 769 insertions(+), 23 deletions(-) create mode 100644 src/gui/dialog/PluginDialog.cpp create mode 100644 src/gui/dialog/PluginDialog.h create mode 100644 src/gui/dialog/PluginDialogEntry.cpp create mode 100644 src/gui/dialog/PluginDialogEntry.h create mode 100644 ui/plugin.glade create mode 100644 ui/pluginEntry.glade diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e37bd68..e70e27ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,9 +121,7 @@ pkg_check_modules (Lua "lua5.3") if (Lua_FOUND) message("Enable Xournal++ Plugins") add_includes_ldflags ("${Lua_LDFLAGS}" "${Lua_INCLUDE_DIRS}") - -## Plugins are not yet ready - therefore disabled at the moment -# set (ENABLE_PLUGINS "true") + set (ENABLE_PLUGINS "true") endif () configure_file ( @@ -207,6 +205,10 @@ install (DIRECTORY ui DESTINATION "share/xournalpp" COMPONENT xournalpp ) +install (DIRECTORY plugins + DESTINATION "share/xournalpp" + COMPONENT xournalpp +) # Install desktop shortcuts for Linux if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") diff --git a/debian/control b/debian/control index 1a500914..e2aa55a2 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Maintainer: Andreas Butti Section: misc Priority: optional Standards-Version: 3.9.2 -Build-Depends: debhelper (>= 9), cmake, git, libgtk-3-dev, libpoppler-glib-dev, libxml2-dev, portaudio19-dev, libsndfile-dev +Build-Depends: debhelper (>= 9), cmake, git, libgtk-3-dev, libpoppler-glib-dev, libxml2-dev, portaudio19-dev, libsndfile-dev, liblua5.3-dev Homepage: https://github.com/xournalpp/xournalpp/ Package: xournalpp diff --git a/readme/LinuxBuild.md b/readme/LinuxBuild.md index c0b885e2..8429c4d9 100644 --- a/readme/LinuxBuild.md +++ b/readme/LinuxBuild.md @@ -4,6 +4,8 @@ Please create pull requests (or file issues) if you have more precise dependencies. +Lua is needed for plugins, if it is missing, the plugins will be disabled. + ### For Fedora/CentOS/RHEL: ```bash sudo dnf install cmake gtk3-devel libxml2-devel cppunit-devel portaudio-devel libsndfile-devel \ @@ -13,7 +15,7 @@ poppler-glib-devel texlive-scheme-basic texlive-dvipng 'tex(standalone.cls)' get ### For Ubuntu/Debian: ````bash sudo apt-get install cmake libgtk-3-dev libpoppler-glib-dev portaudio19-dev libsndfile-dev \ -libcppunit-dev dvipng texlive libxml2-dev +libcppunit-dev dvipng texlive libxml2-dev liblua5.3-dev ```` ### For OpenSuse: diff --git a/src/control/Control.cpp b/src/control/Control.cpp index 32315e8f..bdccf895 100644 --- a/src/control/Control.cpp +++ b/src/control/Control.cpp @@ -983,6 +983,13 @@ void Control::actionPerformed(ActionType type, ActionGroup group, GdkEvent* even // nothing to do here break; + + // Plugin menu + case ACTION_PLUGIN_MANAGER: + this->pluginController->showPluginManager(); + break; + + // Menu Help case ACTION_HELP: XojMsgBox::showHelp(getGtkWindow()); diff --git a/src/control/settings/Settings.cpp b/src/control/settings/Settings.cpp index 4eb07e4a..ffa3ee2c 100644 --- a/src/control/settings/Settings.cpp +++ b/src/control/settings/Settings.cpp @@ -131,6 +131,9 @@ void Settings::loadDefault() this->audioOutputDevice = -1; this->audioGain = 1.0; + this->pluginEnabled = ""; + this->pluginDisabled = ""; + inTransaction = false; } @@ -392,6 +395,14 @@ void Settings::parseItem(xmlDocPtr doc, xmlNodePtr cur) { this->defaultSaveName = (const char*) value; } + else if (xmlStrcmp(name, (const xmlChar*) "pluginEnabled") == 0) + { + this->pluginEnabled = (const char*) value; + } + else if (xmlStrcmp(name, (const xmlChar*) "pluginDisabled") == 0) + { + this->pluginDisabled = (const char*) value; + } else if (xmlStrcmp(name, (const xmlChar*) "pageTemplate") == 0) { this->pageTemplate = (const char*) value; @@ -858,6 +869,9 @@ void Settings::save() WRITE_DOUBLE_PROP(audioSampleRate); WRITE_DOUBLE_PROP(audioGain); + WRITE_STRING_PROP(pluginEnabled); + WRITE_STRING_PROP(pluginDisabled); + xmlNodePtr xmlFont; xmlFont = xmlNewChild(root, NULL, (const xmlChar*) "property", NULL); xmlSetProp(xmlFont, (const xmlChar*) "name", (const xmlChar*) "font"); @@ -2035,6 +2049,44 @@ void Settings::setAudioGain(double gain) save(); } +string Settings::getPluginEnabled() +{ + XOJ_CHECK_TYPE(Settings); + + return this->pluginEnabled; +} + +void Settings::setPluginEnabled(string pluginEnabled) +{ + XOJ_CHECK_TYPE(Settings); + + if (this->pluginEnabled == pluginEnabled) + { + return; + } + this->pluginEnabled = pluginEnabled; + save(); +} + +string Settings::getPluginDisabled() +{ + XOJ_CHECK_TYPE(Settings); + + return this->pluginDisabled; +} + +void Settings::setPluginDisabled(string pluginEnabled) +{ + XOJ_CHECK_TYPE(Settings); + + if (this->pluginDisabled == pluginDisabled) + { + return; + } + this->pluginDisabled = pluginDisabled; + save(); +} + ////////////////////////////////////////////////// SAttribute::SAttribute() diff --git a/src/control/settings/Settings.h b/src/control/settings/Settings.h index 46b1bbcf..4b0a3bc0 100644 --- a/src/control/settings/Settings.h +++ b/src/control/settings/Settings.h @@ -329,6 +329,12 @@ public: double getAudioGain(); void setAudioGain(double gain); + string getPluginEnabled(); + void setPluginEnabled(string pluginEnabled); + + string getPluginDisabled(); + void setPluginDisabled(string pluginEnabled); + /** * Get name, e.g. "cm" */ @@ -676,6 +682,15 @@ private: */ double audioGain; + /** + * List of enabled plugins (only the one which are not enabled by default) + */ + string pluginEnabled; + + /** + * List of disabled plugins (only the one which are not disabled by default) + */ + string pluginDisabled; /** * "Transaction" running, do not save until the end is reached diff --git a/src/enums/ActionType.enum.h b/src/enums/ActionType.enum.h index dca9e9c1..f032e40c 100644 --- a/src/enums/ActionType.enum.h +++ b/src/enums/ActionType.enum.h @@ -181,9 +181,8 @@ enum ActionType ACTION_SET_LAYOUT_T2B, ACTION_SET_LAYOUT_B2T, - - - + // Plugin Menu + ACTION_PLUGIN_MANAGER = 700, // Menu Help ACTION_ABOUT = 800, diff --git a/src/enums/generated/ActionType.generated.cpp b/src/enums/generated/ActionType.generated.cpp index 6a12e22c..51d7d803 100644 --- a/src/enums/generated/ActionType.generated.cpp +++ b/src/enums/generated/ActionType.generated.cpp @@ -642,6 +642,11 @@ ActionType ActionType_fromString(string value) return ACTION_SET_LAYOUT_B2T; } + if (value == "ACTION_PLUGIN_MANAGER") + { + return ACTION_PLUGIN_MANAGER; + } + if (value == "ACTION_ABOUT") { return ACTION_ABOUT; @@ -1305,6 +1310,11 @@ string ActionType_toString(ActionType value) return "ACTION_SET_LAYOUT_B2T"; } + if (value == ACTION_PLUGIN_MANAGER) + { + return "ACTION_PLUGIN_MANAGER"; + } + if (value == ACTION_ABOUT) { return "ACTION_ABOUT"; diff --git a/src/gui/dialog/ButtonConfigGui.cpp b/src/gui/dialog/ButtonConfigGui.cpp index be0b9039..43b355d9 100644 --- a/src/gui/dialog/ButtonConfigGui.cpp +++ b/src/gui/dialog/ButtonConfigGui.cpp @@ -22,7 +22,7 @@ void addToolToList(GtkListStore* typeModel, const char* icon, const char* name, gtk_list_store_set(typeModel, &iter, 1, name, 2, action, -1); } -ButtonConfigGui::ButtonConfigGui(SettingsDialog* dlg, GladeSearchpath* gladeSearchPath, GtkWidget* w, Settings* settings, int button, bool withDevice) +ButtonConfigGui::ButtonConfigGui(GladeSearchpath* gladeSearchPath, GtkWidget* w, Settings* settings, int button, bool withDevice) : GladeGui(gladeSearchPath, "settingsButtonConfig.glade", "offscreenwindow") { XOJ_INIT_TYPE(ButtonConfigGui); @@ -208,8 +208,6 @@ void ButtonConfigGui::loadSettings() gtk_combo_box_set_active(GTK_COMBO_BOX(cbDevice), 0); int i = 0; - - for (InputDevice& dev : this->deviceList->getDeviceList()) { if (cfg->device == dev.getName()) @@ -225,9 +223,9 @@ void ButtonConfigGui::loadSettings() } } -// Not implemented! This is not a dialog! void ButtonConfigGui::show(GtkWindow* parent) { + // Not implemented! This is not a dialog! } void ButtonConfigGui::saveSettings() diff --git a/src/gui/dialog/ButtonConfigGui.h b/src/gui/dialog/ButtonConfigGui.h index 752b06b1..0f7e8bd2 100644 --- a/src/gui/dialog/ButtonConfigGui.h +++ b/src/gui/dialog/ButtonConfigGui.h @@ -23,7 +23,7 @@ class SettingsDialog; class ButtonConfigGui : public GladeGui { public: - ButtonConfigGui(SettingsDialog* dlg, GladeSearchpath* gladeSearchPath, GtkWidget* w, Settings* settings, int button, bool withDevice); + ButtonConfigGui(GladeSearchpath* gladeSearchPath, GtkWidget* w, Settings* settings, int button, bool withDevice); virtual ~ButtonConfigGui(); public: diff --git a/src/gui/dialog/PluginDialog.cpp b/src/gui/dialog/PluginDialog.cpp new file mode 100644 index 00000000..24384960 --- /dev/null +++ b/src/gui/dialog/PluginDialog.cpp @@ -0,0 +1,69 @@ +#include "PluginDialog.h" +#include "PluginDialogEntry.h" + +#include "control/settings/Settings.h" +#include "plugin/PluginController.h" + + +PluginDialog::PluginDialog(GladeSearchpath* gladeSearchPath, Settings* settings) + : GladeGui(gladeSearchPath, "plugin.glade", "pluginDialog"), + settings(settings) +{ + XOJ_INIT_TYPE(PluginDialog); +} + +PluginDialog::~PluginDialog() +{ + XOJ_CHECK_TYPE(PluginDialog); + + for (PluginDialogEntry* p : this->plugins) + { + delete p; + } + this->plugins.clear(); + + XOJ_RELEASE_TYPE(PluginDialog); +} + +void PluginDialog::loadPluginList(PluginController* pc) +{ + XOJ_CHECK_TYPE(PluginDialog); + + GtkWidget* pluginBox = get("pluginBox"); + + for (Plugin* p : pc->getPlugins()) + { + this->plugins.push_back(new PluginDialogEntry(p, getGladeSearchPath(), pluginBox)); + } +} + +void PluginDialog::saveSettings() +{ + XOJ_CHECK_TYPE(PluginDialog); + + string pluginEnabled; + string pluginDisabled; + + // Save plugin settings + for (PluginDialogEntry* bcg : this->plugins) + { + bcg->saveSettings(pluginEnabled, pluginDisabled); + } + + settings->setPluginEnabled(pluginEnabled); + settings->setPluginDisabled(pluginDisabled); +} + +void PluginDialog::show(GtkWindow* parent) +{ + XOJ_CHECK_TYPE(PluginDialog); + + gtk_window_set_transient_for(GTK_WINDOW(this->window), parent); + int returnCode = gtk_dialog_run(GTK_DIALOG(this->window)); + gtk_widget_hide(this->window); + + if (returnCode == 2) + { + saveSettings(); + } +} diff --git a/src/gui/dialog/PluginDialog.h b/src/gui/dialog/PluginDialog.h new file mode 100644 index 00000000..4c880a30 --- /dev/null +++ b/src/gui/dialog/PluginDialog.h @@ -0,0 +1,39 @@ +/* + * Xournal++ + * + * Plugin manage dialog + * + * @author Xournal++ Team + * https://github.com/xournalpp/xournalpp + * + * @license GNU GPLv2 or later + */ + +#pragma once + +#include "gui/GladeGui.h" + +class PluginController; +class PluginDialogEntry; +class Settings; + +class PluginDialog : public GladeGui +{ +public: + PluginDialog(GladeSearchpath* gladeSearchPath, Settings* settings); + virtual ~PluginDialog(); + +public: + void loadPluginList(PluginController* pc); + virtual void show(GtkWindow* parent); + +private: + void saveSettings(); + +private: + XOJ_TYPE_ATTRIB; + + Settings* settings; + + vector plugins; +}; diff --git a/src/gui/dialog/PluginDialogEntry.cpp b/src/gui/dialog/PluginDialogEntry.cpp new file mode 100644 index 00000000..9e68cf50 --- /dev/null +++ b/src/gui/dialog/PluginDialogEntry.cpp @@ -0,0 +1,73 @@ +#include "PluginDialogEntry.h" + +#include "plugin/Plugin.h" + +#include + + +PluginDialogEntry::PluginDialogEntry(Plugin* plugin, GladeSearchpath* gladeSearchPath, GtkWidget* w) + : GladeGui(gladeSearchPath, "pluginEntry.glade", "offscreenwindow"), + plugin(plugin) +{ + XOJ_INIT_TYPE(PluginDialogEntry); + + GtkWidget* pluginMainBox = get("pluginMainBox"); + gtk_container_remove(GTK_CONTAINER(getWindow()), pluginMainBox); + gtk_container_add(GTK_CONTAINER(w), pluginMainBox); + gtk_widget_show_all(pluginMainBox); + + loadSettings(); +} + +PluginDialogEntry::~PluginDialogEntry() +{ + XOJ_CHECK_TYPE(PluginDialogEntry); + XOJ_RELEASE_TYPE(PluginDialogEntry); +} + +void PluginDialogEntry::loadSettings() +{ + XOJ_CHECK_TYPE(PluginDialogEntry); + + gtk_label_set_text(GTK_LABEL(get("pluginName")), plugin->getName().c_str()); + gtk_label_set_text(GTK_LABEL(get("lbAuthor")), plugin->getAuthor().c_str()); + gtk_label_set_text(GTK_LABEL(get("lbVersion")), plugin->getVersion().c_str()); + + gtk_label_set_text(GTK_LABEL(get("lbDefaultText")), plugin->isDefaultEnabled() ? _("default enabled") : _("default disabled")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(get("cbEnabled")), plugin->isEnabled()); +} + +void PluginDialogEntry::show(GtkWindow* parent) +{ + // Not implemented! This is not a dialog! +} + +void PluginDialogEntry::saveSettings(string& pluginEnabled, string& pluginDisabled) +{ + XOJ_CHECK_TYPE(PluginDialogEntry); + + bool state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(get("cbEnabled"))); + + if (state == plugin->isDefaultEnabled()) + { + return; + } + + if (state) + { + if (!pluginEnabled.empty()) + { + pluginEnabled += ","; + } + pluginEnabled += plugin->getName(); + } + else + { + if (!pluginDisabled.empty()) + { + pluginDisabled += ","; + } + pluginDisabled += plugin->getName(); + } +} + diff --git a/src/gui/dialog/PluginDialogEntry.h b/src/gui/dialog/PluginDialogEntry.h new file mode 100644 index 00000000..c68eb4c7 --- /dev/null +++ b/src/gui/dialog/PluginDialogEntry.h @@ -0,0 +1,40 @@ +/* + * Xournal++ + * + * Configuration of a single plugin + * + * @author Xournal++ Team + * https://github.com/xournalpp/xournalpp + * + * @license GNU GPLv2 or later + */ + +#pragma once + +#include "gui/GladeGui.h" + +class Settings; +class Plugin; +class PluginDialog; + +class PluginDialogEntry : public GladeGui +{ +public: + PluginDialogEntry(Plugin* plugin, GladeSearchpath* gladeSearchPath, GtkWidget* w); + virtual ~PluginDialogEntry(); + +public: + void loadSettings(); + void saveSettings(string& pluginEnabled, string& pluginDisabled); + + // Not implemented! This is not a dialog! + virtual void show(GtkWindow* parent); + +private: + XOJ_TYPE_ATTRIB; + + /** + * Plugin instance + */ + Plugin* plugin; +}; diff --git a/src/gui/dialog/SettingsDialog.cpp b/src/gui/dialog/SettingsDialog.cpp index 81749765..9839dc55 100644 --- a/src/gui/dialog/SettingsDialog.cpp +++ b/src/gui/dialog/SettingsDialog.cpp @@ -65,6 +65,7 @@ SettingsDialog::~SettingsDialog() { delete bcg; } + this->buttonConfigs.clear(); // DO NOT delete settings! this->settings = NULL; @@ -76,7 +77,7 @@ void SettingsDialog::initMouseButtonEvents(const char* hbox, int button, bool wi { XOJ_CHECK_TYPE(SettingsDialog); - this->buttonConfigs.push_back(new ButtonConfigGui(this, getGladeSearchPath(), get(hbox), settings, button, withDevice)); + this->buttonConfigs.push_back(new ButtonConfigGui(getGladeSearchPath(), get(hbox), settings, button, withDevice)); } void SettingsDialog::initMouseButtonEvents() diff --git a/src/plugin/Plugin.cpp b/src/plugin/Plugin.cpp index 9d2c3c22..4cdb1fe1 100644 --- a/src/plugin/Plugin.cpp +++ b/src/plugin/Plugin.cpp @@ -39,7 +39,6 @@ Plugin::Plugin(Control* control, string name, string path) XOJ_INIT_TYPE(Plugin); loadIni(); - loadScript(); } Plugin::~Plugin() @@ -89,7 +88,7 @@ void Plugin::registerToolbar() { XOJ_CHECK_TYPE(Plugin); - if (!this->valid) + if (!this->valid || !this->enabled) { return; } @@ -124,7 +123,7 @@ void Plugin::registerMenu(GtkWindow* mainWindow, GtkWidget* menu) { XOJ_CHECK_TYPE(Plugin); - if (menuEntries.empty()) + if (menuEntries.empty() || !this->enabled) { // No entries - nothing to do return; @@ -180,6 +179,54 @@ string Plugin::getName() return name; } +/** + * Author of the plugin + */ +string Plugin::getAuthor() +{ + XOJ_CHECK_TYPE(Plugin); + + return author; +} + +/** + * Plugin version + */ +string Plugin::getVersion() +{ + XOJ_CHECK_TYPE(Plugin); + + return version; +} + +/** + * The plugin is enabled + */ +bool Plugin::isEnabled() +{ + XOJ_CHECK_TYPE(Plugin); + + return enabled; +} + +/** + * The plugin is enabled + */ +void Plugin::setEnabled(bool enabled) +{ + this->enabled = enabled; +} + +/** + * The plugin is default enabled + */ +bool Plugin::isDefaultEnabled() +{ + XOJ_CHECK_TYPE(Plugin); + + return defaultEnabled; +} + /** * @return Flag to check if init ui is currently running */ @@ -243,6 +290,12 @@ void Plugin::loadIni() LOAD_FROM_INI(mainfile, "plugin", "mainfile"); + string defaultEnabledStr; + LOAD_FROM_INI(defaultEnabledStr, "default", "enabled"); + + defaultEnabled = defaultEnabledStr == "true"; + enabled = defaultEnabled; + g_key_file_free(config); this->valid = true; @@ -313,6 +366,12 @@ void Plugin::loadScript() return; } + if (!this->enabled) + { + return; + } + + // Create Lua state variable lua = luaL_newstate(); diff --git a/src/plugin/Plugin.h b/src/plugin/Plugin.h index 9e73e895..e915807e 100644 --- a/src/plugin/Plugin.h +++ b/src/plugin/Plugin.h @@ -75,6 +75,11 @@ public: virtual ~Plugin(); public: + /** + * Load the plugin script + */ + void loadScript(); + /** * Check if this plugin is valid */ @@ -100,6 +105,31 @@ public: */ string getName(); + /** + * Author of the plugin + */ + string getAuthor(); + + /** + * Plugin version + */ + string getVersion(); + + /** + * The plugin is enabled + */ + bool isEnabled(); + + /** + * The plugin is enabled + */ + void setEnabled(bool enabled); + + /** + * The plugin is default enabled + */ + bool isDefaultEnabled(); + /** * @return Flag to check if init ui is currently running */ @@ -123,11 +153,6 @@ private: */ void loadIni(); - /** - * Load the plugin script - */ - void loadScript(); - /** * Execute lua function */ @@ -177,6 +202,16 @@ private: */ string mainfile; + /** + * The plugin is enabled + */ + bool enabled = false; + + /** + * The plugin is default enabled + */ + bool defaultEnabled = false; + /** * Lua engine */ diff --git a/src/plugin/PluginController.cpp b/src/plugin/PluginController.cpp index cf438a23..6e370b03 100644 --- a/src/plugin/PluginController.cpp +++ b/src/plugin/PluginController.cpp @@ -2,12 +2,15 @@ #include "Plugin.h" #include "control/Control.h" +#include "gui/dialog/PluginDialog.h" #include "gui/GladeSearchpath.h" #include #include +#include + PluginController::PluginController(Control* control) : control(control) @@ -62,6 +65,10 @@ void PluginController::loadPluginsFrom(string path) return; } + Settings* settings = control->getSettings(); + vector pluginEnabled = StringUtils::split(settings->getPluginEnabled(), ','); + vector pluginDisabled = StringUtils::split(settings->getPluginDisabled(), ','); + const gchar* file; while ((file = g_dir_read_name(dir)) != NULL) { @@ -77,6 +84,17 @@ void PluginController::loadPluginsFrom(string path) continue; } + if (p->isDefaultEnabled()) + { + p->setEnabled(!(std::find(pluginDisabled.begin(), pluginDisabled.end(), p->getName()) != pluginDisabled.end())); + } + else + { + p->setEnabled(std::find(pluginEnabled.begin(), pluginEnabled.end(), p->getName()) != pluginEnabled.end()); + } + + p->loadScript(); + this->plugins.push_back(p); } g_dir_close(dir); @@ -98,6 +116,18 @@ void PluginController::registerToolbar() #endif } +/** + * Show Plugin manager Dialog + */ +void PluginController::showPluginManager() +{ + XOJ_CHECK_TYPE(PluginController); + + PluginDialog dlg(control->getGladeSearchPath(), control->getSettings()); + dlg.loadPluginList(this); + dlg.show(control->getGtkWindow()); +} + /** * Register menu stuff */ @@ -121,4 +151,13 @@ void PluginController::registerMenu() #endif } +/** + * Return the plugin list + */ +vector& PluginController::getPlugins() +{ + XOJ_CHECK_TYPE(PluginController); + + return plugins; +} diff --git a/src/plugin/PluginController.h b/src/plugin/PluginController.h index 1119c212..f0923414 100644 --- a/src/plugin/PluginController.h +++ b/src/plugin/PluginController.h @@ -35,11 +35,21 @@ public: */ void registerToolbar(); + /** + * Show Plugin manager Dialog + */ + void showPluginManager(); + /** * Register menu stuff */ void registerMenu(); + /** + * Return the plugin list + */ + vector& getPlugins(); + private: XOJ_TYPE_ATTRIB; diff --git a/src/util/XournalTypeList.h b/src/util/XournalTypeList.h index ad67fbc1..2094f4b9 100644 --- a/src/util/XournalTypeList.h +++ b/src/util/XournalTypeList.h @@ -283,6 +283,9 @@ XOJ_DECLARE_TYPE(LayoutMapper, 273); XOJ_DECLARE_TYPE(PluginController, 274); XOJ_DECLARE_TYPE(Plugin, 275); XOJ_DECLARE_TYPE(MenuEntry, 276); +XOJ_DECLARE_TYPE(PluginDialog, 277); +XOJ_DECLARE_TYPE(PluginDialogEntry, 278); + diff --git a/ui/main.glade b/ui/main.glade index 08df807f..001c7812 100644 --- a/ui/main.glade +++ b/ui/main.glade @@ -1,5 +1,5 @@ - + @@ -1550,6 +1550,7 @@ False Plugin _Manager True + diff --git a/ui/plugin.glade b/ui/plugin.glade new file mode 100644 index 00000000..84661f57 --- /dev/null +++ b/ui/plugin.glade @@ -0,0 +1,137 @@ + + + + + + 100 + 1 + 1 + + + False + 5 + Plugin Manager + True + True + dialog + + + + + + True + False + vertical + 2 + + + True + False + end + + + gtk-close + False + True + True + True + True + + + False + False + 0 + + + + + gtk-ok + False + True + True + True + True + + + + False + False + 1 + + + + + False + True + end + 0 + + + + + True + False + vertical + + + True + True + in + 300 + + + True + False + + + pluginBox + True + False + vertical + + + + + + + + + + + + + + + + True + True + 0 + + + + + True + False + Plugin changes are only applied after Xournal++ restart + + + False + True + 1 + + + + + True + True + 1 + + + + + + button1 + button2 + + + diff --git a/ui/pluginEntry.glade b/ui/pluginEntry.glade new file mode 100644 index 00000000..72b14db1 --- /dev/null +++ b/ui/pluginEntry.glade @@ -0,0 +1,155 @@ + + + + + + False + + + + + + True + False + vertical + + + True + False + pluginName + + + + + + False + True + 0 + + + + + True + False + center + + + True + False + Author: + + + False + True + 0 + + + + + True + False + Author + + + False + True + 1 + + + + + False + False + 1 + + + + + True + False + center + + + True + False + Version: + + + False + True + 0 + + + + + True + False + 1.2.3 + + + False + True + 1 + + + + + False + False + 2 + + + + + True + False + center + + + enabled, + cbEnabled + True + True + False + True + + + False + True + 0 + + + + + True + False + default enabled / disabled + + + False + True + 1 + + + + + False + False + 3 + + + + + True + False + + + False + True + 4 + + + + + +