summaryrefslogtreecommitdiffstats
path: root/UIManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'UIManager.cpp')
-rw-r--r--UIManager.cpp105
1 files changed, 0 insertions, 105 deletions
diff --git a/UIManager.cpp b/UIManager.cpp
deleted file mode 100644
index bec4c43..0000000
--- a/UIManager.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "UIManager.h"
-#include "Window.h"
-
-
-const gchar* UIManager::uiData = (const gchar*)
-"<ui>"
- "<menubar>"
- "<menu action=\"fileMenu\">"
- "<menuitem action=\"new\"/>"
- "<menuitem action=\"open\"/>"
- "<menuitem action=\"save\"/>"
- "<menuitem action=\"saveAs\"/>"
- "<separator/>"
- "<menuitem action=\"quit\"/>"
- "</menu>"
- "</menubar>"
- "<toolbar action=\"toolbar1\">"
- "<separator/>"
- "<toolitem action=\"zoomIn\"/>"
- "<toolitem action=\"zoomOut\"/>"
- "<separator/>"
- "</toolbar>"
-"</ui>";
-
-
-void UIManager::handleAction(GtkAction *action, UIManager *uiManager) {
- const gchar* name = gtk_action_get_name(action);
-
- if(!strcmp(name, "save"))
- uiManager->window->handleAction(SAVE);
- else if(!strcmp(name, "saveAs"))
- uiManager->window->handleAction(SAVE_AS);
- else if(!strcmp(name, "zoomIn"))
- uiManager->window->handleAction(ZOOM_IN);
- else if(!strcmp(name, "zoomOut"))
- uiManager->window->handleAction(ZOOM_OUT);
-}
-
-GtkActionGroup* UIManager::createActions() {
- GtkActionGroup *actionGroup = gtk_action_group_new("actions");
- GtkAction *action;
-
- action = gtk_action_new("fileMenu", "_File", NULL, NULL);
- gtk_action_group_add_action(actionGroup, action);
- g_object_unref(G_OBJECT(action));
-
- action = gtk_action_new("toolbar1", "Toolbar", NULL, NULL);
- gtk_action_group_add_action(actionGroup, action);
- g_object_unref(G_OBJECT(action));
-
- action = gtk_action_new("new", "_New", NULL, GTK_STOCK_NEW);
- g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), this);
- gtk_action_group_add_action_with_accel(actionGroup, action, NULL);
- g_object_unref(G_OBJECT(action));
-
- action = gtk_action_new("open", "_Open", NULL, GTK_STOCK_OPEN);
- g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), this);
- gtk_action_group_add_action_with_accel(actionGroup, action, NULL);
- g_object_unref(G_OBJECT(action));
-
- action = gtk_action_new("save", "_Save", NULL, GTK_STOCK_SAVE);
- g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), this);
- gtk_action_group_add_action_with_accel(actionGroup, action, NULL);
- g_object_unref(G_OBJECT(action));
-
- action = gtk_action_new("saveAs", "Save _As", NULL, NULL);
- g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), this);
- gtk_action_group_add_action(actionGroup, action);
- g_object_unref(G_OBJECT(action));
-
- action = gtk_action_new("zoomIn", "Zoom _in", NULL, GTK_STOCK_ZOOM_IN);
- g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), this);
- gtk_action_group_add_action_with_accel(actionGroup, action, NULL);
- g_object_unref(G_OBJECT(action));
-
- action = gtk_action_new("zoomOut", "Zoom _out", NULL, GTK_STOCK_ZOOM_OUT);
- g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), this);
- gtk_action_group_add_action_with_accel(actionGroup, action, NULL);
- g_object_unref(G_OBJECT(action));
-
- action = gtk_action_new("quit", "_Quit", NULL, GTK_STOCK_QUIT);
- g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(gtk_main_quit), NULL);
- gtk_action_group_add_action_with_accel(actionGroup, action, NULL);
- g_object_unref(G_OBJECT(action));
-
- return actionGroup;
-}
-
-UIManager::UIManager(Window *window) {
- this->window = window;
-
- uiManager = gtk_ui_manager_new();
-
- gtk_ui_manager_add_ui_from_string(uiManager, uiData, -1, NULL);
-
- GtkActionGroup *actions = createActions();
- gtk_ui_manager_insert_action_group(uiManager, actions, 0);
- g_object_unref(G_OBJECT(actions));
-
- gtk_ui_manager_ensure_update(uiManager);
-}
-
-UIManager::~UIManager() {
- g_object_unref(G_OBJECT(uiManager));
-}