glom r1565 - in trunk: . glom/mode_data glom/utility_widgets
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1565 - in trunk: . glom/mode_data glom/utility_widgets
- Date: Tue, 15 Apr 2008 16:01:25 +0100 (BST)
Author: jhs
Date: Tue Apr 15 16:01:24 2008
New Revision: 1565
URL: http://svn.gnome.org/viewvc/glom?rev=1565&view=rev
Log:
2008-04-15 Johannes Schmid <johannes schmid openismus com>
* glom/mode_data/flowtablewithfields.cc
(add_layout_notebook_at_position):
Set layout item for notebook and use notebooklabelglom
* glom/utility_widgets/notebookglom.cc
(delete_from_layout):
* glom/utility_widgets/notebookglom.h
(GLOM_UTILITY_WIDGETS_NOTEBOOK_GLOM_H):
Fixed typo in header and added delete method
* glom/utility_widgets/Makefile.am:
* glom/utility_widgets/notebooklabelglom.cc:
* glom/utility_widgets/notelabelbookglom.h:
Added new tab widget for notebook to be able to attach a popupmenu
Summary: Added popup-menu to notebook tabs to add new groups and delete
the notebook.
Added:
trunk/glom/utility_widgets/notebooklabelglom.cc
trunk/glom/utility_widgets/notebooklabelglom.h
Modified:
trunk/ChangeLog
trunk/glom/mode_data/flowtablewithfields.cc
trunk/glom/utility_widgets/Makefile.am
trunk/glom/utility_widgets/notebookglom.cc
trunk/glom/utility_widgets/notebookglom.h
Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc (original)
+++ trunk/glom/mode_data/flowtablewithfields.cc Tue Apr 15 16:01:24 2008
@@ -22,6 +22,7 @@
#include <glom/utility_widgets/datawidget.h>
#include <glom/utility_widgets/buttonglom.h>
#include <glom/utility_widgets/notebookglom.h>
+#include <glom/utility_widgets/notebooklabelglom.h>
#include <glom/utility_widgets/imageglom.h>
#include <glom/utility_widgets/labelglom.h>
#include <glom/utility_widgets/dialog_flowtable.h>
@@ -290,15 +291,20 @@
NotebookGlom* notebook_widget = Gtk::manage(new NotebookGlom());
notebook_widget->show();
+ notebook_widget->set_layout_item (notebook, m_table_name);
for(LayoutGroup::type_list_items::iterator iter = notebook->m_list_items.begin(); iter != notebook->m_list_items.end(); ++iter)
{
sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::cast_dynamic(*iter);
if(group)
{
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ NotebookLabelGlom* tab_label = Gtk::manage(new NotebookLabelGlom(notebook_widget));
+ tab_label->show();
+#else
Gtk::Label* tab_label = Gtk::manage(new Gtk::Label());
tab_label->show();
-
+#endif
sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::cast_dynamic(group);
if(portal)
{
@@ -328,13 +334,20 @@
flow_table->set_columns_count(group->m_columns_count);
flow_table->set_padding(Utils::DEFAULT_SPACING_SMALL);
flow_table->show();
-
+
+ // Put the new flowtable in an event box to catch events
+ Gtk::EventBox* event_box = Gtk::manage( new Gtk::EventBox() ); //TODO_Leak: Valgrind says this is possibly leaked.
+ event_box->add(*flow_table);
+ event_box->set_visible_window(false);
+ event_box->signal_button_press_event().connect (sigc::mem_fun (*flow_table,
+ &FlowTableWithFields::on_button_press_event));
+ event_box->show();
//This doesn't work (probably because we haven't implmented it in our custom container),
//so we put the flowtable in an alignment and give that a border instead.
//flow_table->set_border_width(Glom::Utils::DEFAULT_SPACING_SMALL); //Put some space between the page child and the page edges.
Gtk::Alignment* alignment = Gtk::manage(new Gtk::Alignment());
alignment->set_border_width(Glom::Utils::DEFAULT_SPACING_SMALL);
- alignment->add(*flow_table);
+ alignment->add(*event_box);
alignment->show();
notebook_widget->append_page(*alignment, *tab_label);
Modified: trunk/glom/utility_widgets/Makefile.am
==============================================================================
--- trunk/glom/utility_widgets/Makefile.am (original)
+++ trunk/glom/utility_widgets/Makefile.am Tue Apr 15 16:01:24 2008
@@ -45,7 +45,8 @@
dragbutton.cc dragbutton.h \
dragbar.cc dragbar.h \
sidebar.h sidebar.cc \
- flowtable_dnd.h flowtable_dnd.cc
+ flowtable_dnd.h flowtable_dnd.cc \
+ notebooklabelglom.h notebooklabelglom.cc
endif
Modified: trunk/glom/utility_widgets/notebookglom.cc
==============================================================================
--- trunk/glom/utility_widgets/notebookglom.cc (original)
+++ trunk/glom/utility_widgets/notebookglom.cc Tue Apr 15 16:01:24 2008
@@ -67,5 +67,10 @@
return dynamic_cast<App_Glom*>(pWindow);
}
+void NotebookGlom::delete_from_layout()
+{
+ on_menupopup_activate_delete();
+}
+
} //namespace Glom
Modified: trunk/glom/utility_widgets/notebookglom.h
==============================================================================
--- trunk/glom/utility_widgets/notebookglom.h (original)
+++ trunk/glom/utility_widgets/notebookglom.h Tue Apr 15 16:01:24 2008
@@ -19,7 +19,7 @@
*/
#ifndef GLOM_UTILITY_WIDGETS_NOTEBOOK_GLOM_H
-#define GLOM_UTILITY_WIDGETS_BUTTON_GLOM_H
+#define GLOM_UTILITY_WIDGETS_NOTEBOOK_GLOM_H
#include <gtkmm.h>
#include "layoutwidgetmenu.h"
@@ -40,6 +40,8 @@
explicit NotebookGlom();
virtual ~NotebookGlom();
+ void delete_from_layout();
+
protected:
void init();
@@ -48,5 +50,5 @@
} //namespace Glom
-#endif //GLOM_UTILITY_WIDGETS_BUTTON_GLOM_H
+#endif //GLOM_UTILITY_WIDGETS_NOTEBOOK_GLOM_H
Added: trunk/glom/utility_widgets/notebooklabelglom.cc
==============================================================================
--- (empty file)
+++ trunk/glom/utility_widgets/notebooklabelglom.cc Tue Apr 15 16:01:24 2008
@@ -0,0 +1,163 @@
+/* Glom
+ *
+ * Copyright (C) 2001-2004 Murray Cumming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "notebooklabelglom.h"
+#include "../application.h"
+#include <glibmm/i18n.h>
+
+namespace Glom
+{
+
+NotebookLabelGlom::NotebookLabelGlom(NotebookGlom* notebook)
+: m_notebook(notebook),
+ m_pPopupMenu(0)
+{
+ init();
+}
+
+NotebookLabelGlom::NotebookLabelGlom(const Glib::ustring& label, NotebookGlom* notebook)
+: m_label(label),
+ m_notebook (notebook),
+ m_pPopupMenu(0)
+{
+ init();
+}
+
+NotebookLabelGlom::~NotebookLabelGlom()
+{
+
+}
+
+void NotebookLabelGlom::init()
+{
+ add(m_label);
+ m_label.show();
+ set_events (Gdk::ALL_EVENTS_MASK);
+ set_visible_window (false);
+ setup_menu();
+}
+
+void NotebookLabelGlom::set_label (const Glib::ustring& title)
+{
+ m_label.set_label (title);
+}
+
+App_Glom* NotebookLabelGlom::get_application()
+{
+ Gtk::Container* pWindow = get_toplevel();
+ //TODO: This only works when the child widget is already in its parent.
+
+ return dynamic_cast<App_Glom*>(pWindow);
+}
+
+void NotebookLabelGlom::on_menu_new_group_activate()
+{
+ sharedptr<LayoutGroup> group(new LayoutGroup());
+ group->set_title(_("New Group"));
+ group->set_name (_("Group"));
+
+ sharedptr<LayoutGroup> notebook_group = sharedptr<LayoutGroup>::cast_dynamic (m_notebook->get_layout_item());
+ notebook_group->add_item (group);
+
+ m_notebook->signal_layout_changed().emit();
+}
+
+void NotebookLabelGlom::on_menu_delete_activate()
+{
+ Glib::ustring message;
+ if (!m_notebook->get_layout_item()->get_title().empty())
+ {
+ message = Glib::ustring::compose (_("Delete whole notebook \"%1\"?"),
+ m_notebook->get_layout_item()->get_title());
+ }
+ else
+ {
+ message = _("Delete whole notebook?");
+ }
+ Gtk::MessageDialog dlg (message, false, Gtk::MESSAGE_QUESTION,
+ Gtk::BUTTONS_YES_NO, true);
+ switch (dlg.run())
+ {
+ case Gtk::RESPONSE_YES:
+ m_notebook->delete_from_layout();
+ break;
+ default:
+ return;
+ }
+}
+
+void NotebookLabelGlom::setup_menu()
+{
+ m_refUIManager = Gtk::UIManager::create();
+ m_refActionGroup = Gtk::ActionGroup::create();
+
+ m_refActionGroup->add(Gtk::Action::create("NotebookMenu", "Notebook Menu") );
+ m_refNewGroup = Gtk::Action::create("NewGroup", _("New Group"));
+ m_refDelete = Gtk::Action::create("Delete", _("Delete"));
+
+ m_refActionGroup->add(m_refNewGroup,
+ sigc::mem_fun(*this, &NotebookLabelGlom::on_menu_new_group_activate) );
+ m_refActionGroup->add(m_refDelete,
+ sigc::mem_fun(*this, &NotebookLabelGlom::on_menu_delete_activate) );
+
+ m_refUIManager->insert_action_group(m_refActionGroup);
+
+ try
+ {
+ Glib::ustring ui_info =
+ "<ui>"
+ " <popup name='NotebookMenu'>"
+ " <menuitem action='NewGroup'/>"
+ " <separator />"
+ " <menuitem action='Delete' />"
+ " </popup>"
+ "</ui>";
+
+ m_refUIManager->add_ui_from_string(ui_info);
+ }
+ catch(const Glib::Error& ex)
+ {
+ std::cerr << "building menus failed: " << ex.what();
+ }
+
+ //Get the menu:
+ m_pPopupMenu = dynamic_cast<Gtk::Menu*>( m_refUIManager->get_widget("/NotebookMenu") );
+ if(!m_pPopupMenu)
+ g_warning("menu not found");
+}
+
+bool NotebookLabelGlom::on_button_press_event(GdkEventButton *event)
+{
+ App_Glom* pApp = get_application();
+ if(pApp && pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ {
+ GdkModifierType mods;
+ gdk_window_get_pointer( Gtk::Widget::gobj()->window, 0, 0, &mods );
+ if(mods & GDK_BUTTON3_MASK)
+ {
+ //Give user choices of actions on this item:
+ m_pPopupMenu->popup(event->button, event->time);
+ return true; //We handled this event.
+ }
+ }
+ return Gtk::EventBox::on_button_press_event(event);
+}
+
+} //namespace Glom
Added: trunk/glom/utility_widgets/notebooklabelglom.h
==============================================================================
--- (empty file)
+++ trunk/glom/utility_widgets/notebooklabelglom.h Tue Apr 15 16:01:24 2008
@@ -0,0 +1,68 @@
+/* Glom
+ *
+ * Copyright (C) 2001-2004 Murray Cumming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GLOM_UTILITY_WIDGETS_NOTEBOOK_LABEL_GLOM_H
+#define GLOM_UTILITY_WIDGETS_NOTEBOOK_LABEL_GLOM_H
+
+#include <gtkmm.h>
+#include "notebookglom.h"
+#include <libglademm.h>
+
+namespace Glom
+{
+
+class App_Glom;
+
+class NotebookLabelGlom
+: public Gtk::EventBox
+{
+public:
+ explicit NotebookLabelGlom(NotebookGlom* notebook);
+ explicit NotebookLabelGlom(const Glib::ustring& label, NotebookGlom* notebook);
+ virtual ~NotebookLabelGlom();
+
+ void set_label (const Glib::ustring& title);
+
+protected:
+ void init();
+
+ virtual App_Glom* get_application();
+
+ Gtk::Label m_label;
+ NotebookGlom* m_notebook;
+
+ void setup_menu();
+ Gtk::Menu* m_pPopupMenu;
+
+ void on_menu_new_group_activate();
+ void on_menu_delete_activate();
+
+ virtual bool on_button_press_event(GdkEventButton *event);
+
+ Glib::RefPtr<Gtk::Action> m_refNewGroup;
+ Glib::RefPtr<Gtk::Action> m_refDelete;
+ Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
+ Glib::RefPtr<Gtk::UIManager> m_refUIManager;
+};
+
+} //namespace Glom
+
+#endif //GLOM_UTILITY_WIDGETS_NOTEBOOK_LABEL_GLOM_H
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]