diff options
author | neoraider <devnull@localhost> | 2007-10-19 00:07:02 +0200 |
---|---|---|
committer | neoraider <devnull@localhost> | 2007-10-19 00:07:02 +0200 |
commit | ddebc59336b71accc9887004b0f5c9a4bb17eb6b (patch) | |
tree | f6fec8577a50e536167c1352e8148a18c2e2f0b7 /UIManager.cpp | |
parent | 2bc9bb15dcc9691f6946eaa7a03370814bad0b8e (diff) | |
download | zoomedit-ddebc59336b71accc9887004b0f5c9a4bb17eb6b.tar zoomedit-ddebc59336b71accc9887004b0f5c9a4bb17eb6b.zip |
zoomedit: UIManager gekapselt + einige kleine Fixes.
Diffstat (limited to 'UIManager.cpp')
-rw-r--r-- | UIManager.cpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/UIManager.cpp b/UIManager.cpp new file mode 100644 index 0000000..e78898b --- /dev/null +++ b/UIManager.cpp @@ -0,0 +1,82 @@ +#include "UIManager.h" + + +const gchar* const 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, "zoomIn")) + zoomInCentered(1.2f); + else if(!strcmp(name, "zoomOut")) + zoomOutCentered(1.2f);*/ +} + +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); + + action = gtk_action_new("toolbar1", "Toolbar", NULL, NULL); + gtk_action_group_add_action(actionGroup, action); + + action = gtk_action_new("new", "_New", NULL, GTK_STOCK_NEW); + gtk_action_group_add_action_with_accel(actionGroup, action, NULL); + + action = gtk_action_new("open", "_Open", NULL, GTK_STOCK_OPEN); + gtk_action_group_add_action_with_accel(actionGroup, action, NULL); + + action = gtk_action_new("save", "_Save", NULL, GTK_STOCK_SAVE); + gtk_action_group_add_action_with_accel(actionGroup, action, NULL); + + action = gtk_action_new("saveAs", "Save _As", NULL, NULL); + gtk_action_group_add_action(actionGroup, 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); + + 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); + + 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); + + return actionGroup; +} + +UIManager::UIManager() { + uiManager = gtk_ui_manager_new(); + + gtk_ui_manager_add_ui_from_string(uiManager, uiData, -1, NULL); + + gtk_ui_manager_insert_action_group(uiManager, createActions(), 0); + + gtk_ui_manager_ensure_update(uiManager); +} + +UIManager::~UIManager() { + g_object_unref(G_OBJECT(uiManager)); +} |