summaryrefslogtreecommitdiffstats
path: root/SidebarManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SidebarManager.cpp')
-rw-r--r--SidebarManager.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/SidebarManager.cpp b/SidebarManager.cpp
new file mode 100644
index 0000000..86e70d0
--- /dev/null
+++ b/SidebarManager.cpp
@@ -0,0 +1,46 @@
+#include "SidebarManager.h"
+
+
+SidebarManager::SidebarManager(EditManager *editor)
+ : sidebarView(editor), sidebarAdd(editor)
+{
+ this->editor = editor;
+ activeSidebar = NULL;
+
+ sidebar = gtk_scrolled_window_new(NULL, NULL);
+ g_object_ref_sink(G_OBJECT(sidebar));
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sidebar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ viewport = gtk_viewport_new(NULL, NULL);
+ gtk_container_add(GTK_CONTAINER(sidebar), viewport);
+ gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
+
+ gtk_widget_show(sidebar);
+}
+
+SidebarManager::~SidebarManager() {
+ g_object_unref(G_OBJECT(sidebar));
+}
+
+void SidebarManager::update() {
+ Sidebar *newSidebar = activeSidebar;
+
+ switch(editor->getMode()) {
+ case EditManager::VIEW:
+ newSidebar = &sidebarView;
+ break;
+ case EditManager::ADD:
+ newSidebar = &sidebarAdd;
+ }
+
+ if(activeSidebar != newSidebar) {
+ if(activeSidebar)
+ gtk_container_remove(GTK_CONTAINER(viewport), gtk_bin_get_child(GTK_BIN(viewport)));
+
+ gtk_container_add(GTK_CONTAINER(viewport), newSidebar->getWidget());
+
+ activeSidebar = newSidebar;
+ }
+
+ activeSidebar->update();
+}