From ddebc59336b71accc9887004b0f5c9a4bb17eb6b Mon Sep 17 00:00:00 2001 From: neoraider Date: Thu, 18 Oct 2007 22:07:02 +0000 Subject: zoomedit: UIManager gekapselt + einige kleine Fixes. --- UIManager.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 UIManager.cpp (limited to 'UIManager.cpp') 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*) +"" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" +""; + +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)); +} -- cgit v1.2.3