commit
a071b52ca6
23 changed files with 768 additions and 22 deletions
@ -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(); |
||||
} |
||||
} |
||||
@ -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<PluginDialogEntry*> plugins; |
||||
}; |
||||
@ -0,0 +1,73 @@ |
||||
#include "PluginDialogEntry.h" |
||||
|
||||
#include "plugin/Plugin.h" |
||||
|
||||
#include <i18n.h> |
||||
|
||||
|
||||
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(); |
||||
} |
||||
} |
||||
|
||||
@ -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; |
||||
}; |
||||
@ -0,0 +1,137 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- Generated with glade 3.22.1 --> |
||||
<interface> |
||||
<requires lib="gtk+" version="3.0"/> |
||||
<object class="GtkAdjustment" id="adjustment1"> |
||||
<property name="upper">100</property> |
||||
<property name="step_increment">1</property> |
||||
<property name="page_increment">1</property> |
||||
</object> |
||||
<object class="GtkDialog" id="pluginDialog"> |
||||
<property name="can_focus">False</property> |
||||
<property name="border_width">5</property> |
||||
<property name="title" translatable="yes">Plugin Manager</property> |
||||
<property name="modal">True</property> |
||||
<property name="destroy_with_parent">True</property> |
||||
<property name="type_hint">dialog</property> |
||||
<child> |
||||
<placeholder/> |
||||
</child> |
||||
<child internal-child="vbox"> |
||||
<object class="GtkBox" id="dialog-vbox2"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="orientation">vertical</property> |
||||
<property name="spacing">2</property> |
||||
<child internal-child="action_area"> |
||||
<object class="GtkButtonBox" id="dialog-action_area2"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="layout_style">end</property> |
||||
<child> |
||||
<object class="GtkButton" id="button1"> |
||||
<property name="label">gtk-close</property> |
||||
<property name="use_action_appearance">False</property> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">True</property> |
||||
<property name="receives_default">True</property> |
||||
<property name="use_stock">True</property> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">False</property> |
||||
<property name="position">0</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkButton" id="button2"> |
||||
<property name="label">gtk-ok</property> |
||||
<property name="use_action_appearance">False</property> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">True</property> |
||||
<property name="receives_default">True</property> |
||||
<property name="use_stock">True</property> |
||||
<accelerator key="Return" signal="activate"/> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">False</property> |
||||
<property name="position">1</property> |
||||
</packing> |
||||
</child> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="pack_type">end</property> |
||||
<property name="position">0</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkBox"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="orientation">vertical</property> |
||||
<child> |
||||
<object class="GtkScrolledWindow"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">True</property> |
||||
<property name="shadow_type">in</property> |
||||
<property name="min_content_height">300</property> |
||||
<child> |
||||
<object class="GtkViewport"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<child> |
||||
<object class="GtkBox" id="pluginBox"> |
||||
<property name="name">pluginBox</property> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="orientation">vertical</property> |
||||
<child> |
||||
<placeholder/> |
||||
</child> |
||||
<child> |
||||
<placeholder/> |
||||
</child> |
||||
<child> |
||||
<placeholder/> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">True</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">0</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkLabel"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="label" translatable="yes">Plugin changes are only applied after Xournal++ restart</property> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">1</property> |
||||
</packing> |
||||
</child> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">True</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">1</property> |
||||
</packing> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
<action-widgets> |
||||
<action-widget response="1">button1</action-widget> |
||||
<action-widget response="2">button2</action-widget> |
||||
</action-widgets> |
||||
</object> |
||||
</interface> |
||||
@ -0,0 +1,155 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- Generated with glade 3.22.1 --> |
||||
<interface> |
||||
<requires lib="gtk+" version="3.20"/> |
||||
<object class="GtkOffscreenWindow" id="offscreenwindow"> |
||||
<property name="can_focus">False</property> |
||||
<child> |
||||
<placeholder/> |
||||
</child> |
||||
<child> |
||||
<object class="GtkBox" id="pluginMainBox"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="orientation">vertical</property> |
||||
<child> |
||||
<object class="GtkLabel" id="pluginName"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="label" translatable="yes">pluginName</property> |
||||
<attributes> |
||||
<attribute name="weight" value="bold"/> |
||||
</attributes> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">0</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkBox"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="halign">center</property> |
||||
<child> |
||||
<object class="GtkLabel"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="label" translatable="yes">Author: </property> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">0</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkLabel" id="lbAuthor"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="label" translatable="yes">Author</property> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">1</property> |
||||
</packing> |
||||
</child> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">False</property> |
||||
<property name="position">1</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkBox"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="halign">center</property> |
||||
<child> |
||||
<object class="GtkLabel"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="label" translatable="yes">Version: </property> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">0</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkLabel" id="lbVersion"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="label" translatable="yes">1.2.3</property> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">1</property> |
||||
</packing> |
||||
</child> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">False</property> |
||||
<property name="position">2</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkBox"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="halign">center</property> |
||||
<child> |
||||
<object class="GtkCheckButton" id="cbEnabled"> |
||||
<property name="label" translatable="yes">enabled,</property> |
||||
<property name="name">cbEnabled</property> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">True</property> |
||||
<property name="receives_default">False</property> |
||||
<property name="draw_indicator">True</property> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">0</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkLabel" id="lbDefaultText"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
<property name="label" translatable="yes">default enabled / disabled</property> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">1</property> |
||||
</packing> |
||||
</child> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">False</property> |
||||
<property name="position">3</property> |
||||
</packing> |
||||
</child> |
||||
<child> |
||||
<object class="GtkSeparator"> |
||||
<property name="visible">True</property> |
||||
<property name="can_focus">False</property> |
||||
</object> |
||||
<packing> |
||||
<property name="expand">False</property> |
||||
<property name="fill">True</property> |
||||
<property name="position">4</property> |
||||
</packing> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</interface> |
||||
Loading…
Reference in new issue