[glom] Use a custom Notebook-like widget instead of Gtk::Notebook.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Use a custom Notebook-like widget instead of Gtk::Notebook.
- Date: Tue, 8 Mar 2011 11:49:38 +0000 (UTC)
commit 65c72e4e16f41d73fa7827d7e53a1464d6055888
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Mar 7 23:35:23 2011 +0100
Use a custom Notebook-like widget instead of Gtk::Notebook.
* glom/utility_widgets/notebook_noframe.[h|cc]: A new class with an API that
is as much like the Gtk::Notebook API as we need it to be.
Unlike GtkNotebook, this has no frame around the page at the bottom.
That was wasting space because the extra division was unnecessary when it
fills almost the whole window anyway.
* Makefile_glom.am: Mention the new files.
* glom/mode_data/notebook_data.cc: Derive from the new class instead of
Gtk::Notebook.
ChangeLog | 119 ++++++++++--------
Makefile_glom.am | 2 +
glom/mode_data/notebook_data.cc | 27 ++++
glom/notebook_glom.cc | 4 +-
glom/notebook_glom.h | 3 +-
glom/utility_widgets/notebook_noframe.cc | 201 ++++++++++++++++++++++++++++++
glom/utility_widgets/notebook_noframe.h | 77 ++++++++++++
7 files changed, 377 insertions(+), 56 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8ca4a5a..c1d1f47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-03-08 Murray Cumming <murrayc murrayc com>
+
+ Use a custom Notebook-like widget instead of Gtk::Notebook.
+
+ * glom/utility_widgets/notebook_noframe.[h|cc]: A new class with an API that
+ is as much like the Gtk::Notebook API as we need it to be.
+ Unlike GtkNotebook, this has no frame around the "page" at the bottom.
+ That was wasting space because the extra division was unnecessary when it
+ fills almost the whole window anyway.
+ * Makefile_glom.am: Mention the new files.
+ * glom/mode_data/notebook_data.cc: Derive from the new class instead of
+ Gtk::Notebook.
+
2011-02-26 Murray Cumming <murrayc murrayc com>
Fix the CSV import test.
@@ -9,19 +22,19 @@
CSV Import: Fix quoted-newline detection, so we don't drop rows.
- * glom/import_csv/csv_parser.[h|cc]: on_idle_parse(): Make in_quotes a
- member variable, initialized in clear(), so we remember it across calls to
- on_idle_parse(), instead of thinking that we are in quotes just because we
+ * glom/import_csv/csv_parser.[h|cc]: on_idle_parse(): Make in_quotes a
+ member variable, initialized in clear(), so we remember it across calls to
+ on_idle_parse(), instead of thinking that we are in quotes just because we
are parsing arbitrary chunks of bytes that look that way individually.
-
- This fixes bug #637529 (Darmon Xavier), so all rows should be imported
+
+ This fixes bug #637529 (Darmon Xavier), so all rows should be imported
instead of dropping some in the middle.
2011-02-26 Murray Cumming <murrayc murrayc-x61>
Dialog_Import_CSV_Progress: Try to really show progress.
- * glom/import_csv/dialog_import_csv_progress.cc: Try to call
+ * glom/import_csv/dialog_import_csv_progress.cc: Try to call
Main::events_pending() and iterate() to really show the text in the progress
bar, though it does not seem to work.
@@ -35,16 +48,16 @@
Avoid GTK+ warning when clicking on the list button.
- * glom/mode_data/db_adddel/db_adddel.[h|cc]: on_cell_button_clicked():
- Delay the response to the click, to an idle handler, to avoid confusing
+ * glom/mode_data/db_adddel/db_adddel.[h|cc]: on_cell_button_clicked():
+ Delay the response to the click, to an idle handler, to avoid confusing
GtkTreeView, which was showing a warning with GTK+ 3 about a NULL GtkAdjustment.
2011-02-10 Murray Cumming <murrayc murrayc com>
Use the new Gtk::ComboBox CellArea API to align columns properly.
- * glom/mode_data/datawidget/combo.cc: Get the CellAreaBox and use its
- more-useful pack() method instead of the standard one, so that the columns
+ * glom/mode_data/datawidget/combo.cc: Get the CellAreaBox and use its
+ more-useful pack() method instead of the standard one, so that the columns
really align.
1.19.3:
@@ -53,7 +66,7 @@
Require the correct gtksourceviewmm version.
- * configure.ac: Use the gtksourceviewmm version with the API changes to use
+ * configure.ac: Use the gtksourceviewmm version with the API changes to use
vector.
2011-01-30 Murray Cumming <murrayc murrayc com>
@@ -61,7 +74,7 @@
Adapt to libgdamm API changes.
* glom/libglom/connectionpool.cc:
- * glom/libglom/db_utils.cc: libgdamm now uses std::vector instead of
+ * glom/libglom/db_utils.cc: libgdamm now uses std::vector instead of
*Handle, like gtkmm.
2011-01-28 Murray Cumming <murrayc murrayc com>
@@ -74,11 +87,11 @@
* glom/mode_design/print_layouts/print_layout_toolbar_button.cc:
* glom/mode_design/print_layouts/window_print_layout_edit.h:
* glom/utility_widgets/imageglom.cc:
- * glom/utility_widgets/layouttoolbarbutton.cc: Use std::vector instead of
+ * glom/utility_widgets/layouttoolbarbutton.cc: Use std::vector instead of
std::list.
- * glom/dialog_existing_or_new.cc: This one even used the intermediate type
+ * glom/dialog_existing_or_new.cc: This one even used the intermediate type
directly, showing how necessary this API change was.
-
+
2011-01-18 Murray Cumming <murrayc murrayc com>
Disable more deprecated API.
@@ -89,22 +102,22 @@
Require the appropriate gtksourceviewmm version.
- * configure.ac: Use the latest gtksourceviewmm release. Older versions would
+ * configure.ac: Use the latest gtksourceviewmm release. Older versions would
not build with the newer versions of gtkmm 3, so this is a hint.
2011-01-13 Murray Cumming <murrayc murrayc com>
Require the appropriate goocanvasmm version.
- * configure.ac: Use the latest goocanvasmm release. The code has already
+ * configure.ac: Use the latest goocanvasmm release. The code has already
been ported.
2011-01-06 Murray Cumming <murrayc murrayc com>
get_current_locale(): Handle more complex setlocale(NULL) results.
-
- * glom/libglom/utils.cc: locale_simplify(): On Ubuntu Natty,
- setlocale() has started returning a more complex string. Parse it, or the
+
+ * glom/libglom/utils.cc: locale_simplify(): On Ubuntu Natty,
+ setlocale() has started returning a more complex string. Parse it, or the
older simpler syntax.
2011-01-06 Murray Cumming <murrayc murrayc com>
@@ -113,8 +126,8 @@
* Makefile_libglom.am: Define libglom_all_libs to avoid duplication.
* Makefile_glom.am: Use libglom_all_libs instead of repeating.
- * Makefile_tests.am: Use libglom_all_libs to explicitly link against the
- dependencies of libglom. This seems to have been automatic with the linker in
+ * Makefile_tests.am: Use libglom_all_libs to explicitly link against the
+ dependencies of libglom. This seems to have been automatic with the linker in
previous versions of Ubuntu, but not with Ubuntu Natty.
2011-01-05 Murray Cumming <murrayc murrayc com>
@@ -133,9 +146,9 @@
2010-12-16 Murray Cumming <murrayc murrayc com>
- More dealing with cppcheck errors.
+ More dealing with cppcheck errors.
- * glom/libglom/data_structure/layout/layoutitem.cc: operator=(): Check for
+ * glom/libglom/data_structure/layout/layoutitem.cc: operator=(): Check for
src=this.
* glom/base_db.cc:
* glom/frame_glom.cc:
@@ -153,7 +166,7 @@
2010-12-16 Murray Cumming <murrayc murrayc com>
Remove unused methods.
-
+
* glom/libglom/data_structure/glomconversions.cc:
* glom/libglom/document/bakery/document.cc:
* glom/libglom/document/bakery/document.h:
@@ -162,7 +175,7 @@
* glom/libglom/document/document.cc:
* glom/libglom/document/document.h:
* glom/utility_widgets/canvas/test_canvas_editable.cc:
- Remove unused methods, found by cppcheck. Some other methods that cppcheck
+ Remove unused methods, found by cppcheck. Some other methods that cppcheck
mentions seem to be virtual methods that are used.
2010-12-16 Murray Cumming <murrayc murrayc com>
@@ -180,7 +193,7 @@
* glom/mode_data/box_data_portal.cc:
* glom/mode_data/datawidget/combochoiceswithtreemodel.cc:
* glom/mode_data/flowtablewithfields.cc:
- * glom/mode_data/notebook_data.cc: C++ doesn't mind if we call delete on a
+ * glom/mode_data/notebook_data.cc: C++ doesn't mind if we call delete on a
null pointer. Found by cppcheck.
2010-12-15 Ben Konrath <ben bagu org>
@@ -194,7 +207,7 @@
Fix make check when using --enable-glom-ui=no.
- * Makefile_tests.am: Correct the LDADD flags for the selfhosting tests, so
+ * Makefile_tests.am: Correct the LDADD flags for the selfhosting tests, so
that make check still works when using --enable-glom-ui=no.
2010-12-14 Murray Cumming <murrayc murrayc com>
@@ -204,68 +217,68 @@
* Makefile.am:
* Makefile_glom.am:
* Makefile_libglom.am:
- * Makefile_tests.am: Use AM_CPPFLAGS and AM_CFLAGS just to hold the
+ * Makefile_tests.am: Use AM_CPPFLAGS and AM_CFLAGS just to hold the
(optional) warning flags, as we did previously.
2010-12-14 Murray Cumming <murrayc murrayc com>
- Build: Avoid use of non-UI cflags/libs where not necessary.
+ Build: Avoid use of non-UI cflags/libs where not necessary.
* Makefile.am: Do not use AM_CPPFLAGS, AM_CFLAGS or AM_CXXFLAGS.
* Makefile_glom.am:
* Makefile_libglom.am:
- * Makefile_tests.am: Instead use individual variables for each target,
+ * Makefile_tests.am: Instead use individual variables for each target,
making sure that we use only the necessary flags.
libglom may have been linking to some unnecessary UI libraries before.
* glom/import_csv/csv_parser.h: Avoid unnecessary UI includes.
* tests/import/test_parsing.cc:
* tests/import/test_signals.cc: Avoid including gtkmm.h.
-
- As a side-effect, the build is now longer, because some files are now
- compiled again separately for the tests, presumably because they now need
+
+ As a side-effect, the build is now longer, because some files are now
+ compiled again separately for the tests, presumably because they now need
to be built with different compiler flags. But that is a better test.
2010-12-13 Murray Cumming <murrayc murrayc com>
Correct my previous commit.
- * configure.ac: Correct the no/yes test for --enable-glom-ui and add a comma
+ * configure.ac: Correct the no/yes test for --enable-glom-ui and add a comma
so it actually works.
* Makefile_tests.am: Restore the source file lists for the python tests.
2010-12-13 Murray Cumming <murrayc murrayc com>
Allow libglom to be built without building the Glom UI code too.
-
+
* configure.ac: Added an --enable-glom-ui option, defaulting to yes.
- When using --enable-glom-ui=no then only libglom will be built. This is
- useful for deployment of libglom to servers where the UI dependencies are not
+ When using --enable-glom-ui=no then only libglom will be built. This is
+ useful for deployment of libglom to servers where the UI dependencies are not
wanted.
- We still use GLOM_LIBS and GLOM_FLAGS even in libglom, instead of using
- LIBGLOM_LIBS and LIBGLOM_CFLAGS anywhere, but this does reduce duplication
+ We still use GLOM_LIBS and GLOM_FLAGS even in libglom, instead of using
+ LIBGLOM_LIBS and LIBGLOM_CFLAGS anywhere, but this does reduce duplication
of the flags in glom's UI build.
* Makefile.am: Do not include Makefile_glom.am if the UI should not be built.
* Makefile_glom.am: Move the bin_programs definition to here.
* Makefile_libglom.am: Move the LTLIBRARIES definitions to here.
- * Makefile_tests.am: Attempt, unsuccessfully, to build and run UI-dependent
- tests only when the UI was built, when running make check.
+ * Makefile_tests.am: Attempt, unsuccessfully, to build and run UI-dependent
+ tests only when the UI was built, when running make check.
2010-12-13 Murray Cumming <murrayc murrayc com>
Fix the build with latest gtkmm.
-
+
* glom/mode_design/print_layouts/window_print_layout_edit.cc:
Use Widget::render_icon_pixbuf() instead of the old render_icon() method.
-
+
2010-12-08 Murray Cumming <murrayc murrayc com>
Partial port to recent gtkmm API changes from git master.
- * glom/mode_data/datawidget/datawidget.cc: signal_style_changed was removed
+ * glom/mode_data/datawidget/datawidget.cc: signal_style_changed was removed
though it might come back later.
- * glom/mode_data/datawidget/entry.cc: Use override_color() instead of
+ * glom/mode_data/datawidget/entry.cc: Use override_color() instead of
modify_text().
- * glom/mode_data/placeholder-glom.cc: Use set_source_rgba() instead of
+ * glom/mode_data/placeholder-glom.cc: Use set_source_rgba() instead of
set_source_color(). Use get_style_context() instead of get_style().
2010-12-03 Murray Cumming <murrayc murrayc com>
@@ -285,7 +298,7 @@
* glom/mode_design/script_library/dialog_script_library.cc:
* glom/mode_design/script_library/dialog_script_library.h:
* tests/glade_toplevels_instantiation.cc:
- * tests/test_glade_derived_instantiation.cc: Change the gtksourceview
+ * tests/test_glade_derived_instantiation.cc: Change the gtksourceview
namespace to Gsv.
2010-12-03 Murray Cumming <murrayc murrayc com>
@@ -303,15 +316,15 @@
Replaced GtkRuler with GimpRuler because GtkRuler was removed from GTK 3.
- * glom/utility_widgets/gimpruler/: Added several source files from
- gimp, with small changes to make it build for us, to provide the GimpRuler
+ * glom/utility_widgets/gimpruler/: Added several source files from
+ gimp, with small changes to make it build for us, to provide the GimpRuler
widget.
- * COPYING: Switch to GPL version 3 (instead of 2), because the GIMP source
+ * COPYING: Switch to GPL version 3 (instead of 2), because the GIMP source
code uses it.
* Makefile_glom.am:
* glom/glom_developer.glade:
- * glom/mode_design/print_layouts/window_print_layout_edit.[cc|cc]: Use
- GimpRuler instead of GtkRuler, creating and adding them in code instead of
+ * glom/mode_design/print_layouts/window_print_layout_edit.[cc|cc]: Use
+ GimpRuler instead of GtkRuler, creating and adding them in code instead of
in the .glade file, to avoid Glade needing to know about that widget.
1.19.2:
diff --git a/Makefile_glom.am b/Makefile_glom.am
index 5560574..9b3517f 100644
--- a/Makefile_glom.am
+++ b/Makefile_glom.am
@@ -206,6 +206,8 @@ glom_source_files = \
glom/utility_widgets/layoutwidgetutils.h \
glom/utility_widgets/notebookglom.cc \
glom/utility_widgets/notebookglom.h \
+ glom/utility_widgets/notebook_noframe.cc \
+ glom/utility_widgets/notebook_noframe.h \
glom/utility_widgets/placeholder.cc \
glom/utility_widgets/placeholder.h \
glom/utility_widgets/adddel/adddel.cc \
diff --git a/glom/mode_data/notebook_data.cc b/glom/mode_data/notebook_data.cc
index b5d96f3..cdad49f 100644
--- a/glom/mode_data/notebook_data.cc
+++ b/glom/mode_data/notebook_data.cc
@@ -31,6 +31,9 @@
namespace Glom
{
+static const gchar gNotebookCss[] = "gtkmm__GtkNotebook#glomnotebook { padding: 0 0 0 0; }";
+
+
Notebook_Data::Notebook_Data()
:
#ifdef GLOM_ENABLE_MAEMO
@@ -38,6 +41,30 @@ Notebook_Data::Notebook_Data()
#endif
m_iPage_Details(0), m_iPage_List(0)
{
+
+ //Hide the GtkNotebook border:
+ set_name("glomnotebook");
+
+ std::cout << G_OBJECT_TYPE_NAME(gobj()) << std::endl;
+
+ GtkStyleContext *style_context;
+ GtkCssProvider *provider;
+ GError *error = NULL;
+
+ style_context = gtk_widget_get_style_context(GTK_WIDGET(gobj()));
+ provider = gtk_css_provider_new();
+ if (!gtk_css_provider_load_from_data(provider, gNotebookCss, -1,
+ &error)) {
+ g_error("%s", error->message);
+ g_error_free(error);
+ return;
+ }
+ gtk_style_context_add_provider(style_context,
+ GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref(provider);
+
+
//Add Pages:
append_page(m_Box_List, _("List"));
m_iPage_List = 0;
diff --git a/glom/notebook_glom.cc b/glom/notebook_glom.cc
index 588759b..984333f 100644
--- a/glom/notebook_glom.cc
+++ b/glom/notebook_glom.cc
@@ -43,7 +43,7 @@ Notebook_Glom::~Notebook_Glom()
void Notebook_Glom::on_show()
{
- Gtk::Notebook::on_show();
+ NotebookNoFrame::on_show();
//We do this only in on_show() because otherwise GtkNotebook emits the signal (and we catch it) during show:
if(!m_connection_switch_page)
@@ -99,7 +99,7 @@ void Notebook_Glom::on_switch_page_handler(Gtk::Widget* /* pPage */, guint uiPag
void Notebook_Glom::on_leave_page(guint uiPageNumber)
{
//Call base class:
- //Gtk::Notebook::on_leave_page(uiPageNumber);
+ //NotebookNoFrame::on_leave_page(uiPageNumber);
//Tell the page to save itself:
if(!m_destructor_in_progress)
diff --git a/glom/notebook_glom.h b/glom/notebook_glom.h
index bb6cc01..b3fd5d8 100644
--- a/glom/notebook_glom.h
+++ b/glom/notebook_glom.h
@@ -21,6 +21,7 @@
#ifndef GLOM_NOTEBOOK_GLOM_H
#define GLOM_NOTEBOOK_GLOM_H
+#include <glom/utility_widgets/notebook_noframe.h>
#include <glom/box_withbuttons.h>
#include <libglom/document/document.h>
@@ -30,7 +31,7 @@ namespace Glom
/** Notebook with document methods.
*/
class Notebook_Glom :
- public Gtk::Notebook,
+ public NotebookNoFrame,
public Base_DB
{
public:
diff --git a/glom/utility_widgets/notebook_noframe.cc b/glom/utility_widgets/notebook_noframe.cc
new file mode 100644
index 0000000..4ab81a8
--- /dev/null
+++ b/glom/utility_widgets/notebook_noframe.cc
@@ -0,0 +1,201 @@
+/* Glom
+ *
+ * Copyright (C) 2011 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 "notebook_noframe.h"
+#include <glom/utils_ui.h>
+#include <gtkmm/label.h>
+#include <gtkmm/togglebutton.h>
+#include <glibmm/i18n.h>
+//#include <sstream> //For stringstream
+
+namespace Glom
+{
+
+NotebookNoFrame::NotebookNoFrame()
+: m_current_page(0)
+{
+ set_orientation(Gtk::ORIENTATION_VERTICAL);
+ set_spacing(Utils::DEFAULT_SPACING_SMALL);
+
+ m_box_tabs.set_spacing(Utils::DEFAULT_SPACING_SMALL);
+ m_box_tabs.set_layout(Gtk::BUTTONBOX_START);
+ pack_start(m_box_tabs, Gtk::PACK_SHRINK);
+ m_box_tabs.show();
+
+ pack_start(m_box_pages);
+ m_box_pages.show();
+}
+
+NotebookNoFrame::~NotebookNoFrame()
+{
+}
+
+NotebookNoFrame::type_signal_switch_page NotebookNoFrame::signal_switch_page()
+{
+ return m_signal_switch_page;
+}
+
+Gtk::Widget* NotebookNoFrame::get_nth_page(int page_num)
+{
+ if(page_num < 0)
+ return 0;
+
+ if(page_num >= (int)m_vec_page_widgets.size())
+ return 0;
+
+ Gtk::Box* box = m_vec_page_widgets[page_num];
+ if(!box)
+ return 0;
+
+ std::vector<Gtk::Widget*> children = box->get_children();
+ if(children.empty())
+ return 0;
+
+ return children[0];
+}
+
+const Gtk::Widget* NotebookNoFrame::get_nth_page(int page_num) const
+{
+ NotebookNoFrame* unconstThis = const_cast<NotebookNoFrame*>(this);
+ return unconstThis->get_nth_page(page_num);
+}
+
+int NotebookNoFrame::get_current_page() const
+{
+ return m_current_page;
+}
+
+void NotebookNoFrame::set_current_page(int page_num)
+{
+ if(page_num < 0)
+ return;
+
+ const int size = (int)m_vec_page_widgets.size();
+ if(page_num >= size)
+ return;
+
+ m_current_page = page_num;
+
+ //TODO: Enable the tab button too.
+
+ //Show only the current page:
+ for(int i = 0; i < size; ++i)
+ {
+ Gtk::ToggleButton* tab = m_vec_tab_widgets[i];
+ if(!tab)
+ continue;
+
+ Gtk::Box* box = m_vec_page_widgets[i];
+ if(!box)
+ continue;
+
+ if(i == page_num)
+ {
+ if(!tab->get_active())
+ tab->set_active();
+
+ box->show();
+ }
+ else
+ {
+ if(tab->get_active())
+ tab->set_active(false);
+
+ box->hide();
+ }
+ }
+}
+
+int NotebookNoFrame::append_page(Gtk::Widget& child, Gtk::Widget& tab_label)
+{
+ Gtk::ToggleButton* toggle = Gtk::manage(new Gtk::ToggleButton());
+ toggle->set_active(false);
+ toggle->add(tab_label);
+ toggle->show();
+ m_box_tabs.pack_start(*toggle);
+ m_vec_tab_widgets.push_back(toggle);
+
+ //We put the child into a box so we can show or hide it regardless of
+ //whether the callers calls show() or hide() on the child widget.
+ //Note that this would make the public list of children incorrect, if we supported that anyway.
+ Gtk::Box* box = Gtk::manage(new Gtk::Box());
+ box->pack_start(child, Gtk::PACK_EXPAND_WIDGET);
+ m_box_pages.pack_start(*box, Gtk::PACK_EXPAND_WIDGET);
+ m_vec_page_widgets.push_back(box);
+
+ const int index = m_vec_page_widgets.size() - 1;
+
+ //Make sure that the first one is showing:
+ if(index == 0)
+ {
+ m_current_page = 0;
+ toggle->set_active();
+ box->show();
+ }
+ else
+ {
+ toggle->set_active(false);
+ box->hide();
+ }
+
+ set_current_page(index);
+
+ toggle->signal_toggled().connect(
+ sigc::bind(
+ sigc::mem_fun(*this, &NotebookNoFrame::on_tab_toggled),
+ index));
+
+ return index;
+}
+
+int NotebookNoFrame::append_page(Widget& child, const Glib::ustring& tab_label, bool use_mnemonic)
+{
+ Gtk::Label* pLabel = Gtk::manage( new Gtk::Label(tab_label, use_mnemonic) );
+ pLabel->show();
+ return append_page(child, *pLabel);
+}
+
+void NotebookNoFrame::on_tab_toggled(int index)
+{
+ Gtk::ToggleButton* tab = m_vec_tab_widgets[index];
+ if(!tab)
+ return;
+
+ int new_current_page = 0;
+ if(tab->get_active())
+ {
+ //A different page was selected by clicking on its tab, pressing the button down:
+ new_current_page = index;
+ }
+ else
+ {
+ //A different page was selected by clicking on another tab, raising it's button:
+ //So let's choose another one:
+ new_current_page = index + 1;
+ if(new_current_page >= (int)m_vec_tab_widgets.size())
+ new_current_page = 0;
+ }
+
+ set_current_page(new_current_page);
+ Gtk::Widget* child = get_nth_page(new_current_page);
+ m_signal_switch_page.emit(child, new_current_page);
+}
+
+} //namespace Glom
diff --git a/glom/utility_widgets/notebook_noframe.h b/glom/utility_widgets/notebook_noframe.h
new file mode 100644
index 0000000..08e63e1
--- /dev/null
+++ b/glom/utility_widgets/notebook_noframe.h
@@ -0,0 +1,77 @@
+/* Glom
+ *
+ * Copyright (C) 2011 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_NOFRAME_H
+#define GLOM_UTILITY_WIDGETS_NOTEBOOK_NOFRAME_H
+
+#include <gtkmm/box.h>
+#include <gtkmm/buttonbox.h>
+#include <gtkmm/togglebutton.h>
+
+namespace Glom
+{
+
+class Application;
+class NotebookLabel;
+
+class NotebookNoFrame
+: public Gtk::Box
+{
+public:
+ explicit NotebookNoFrame();
+ virtual ~NotebookNoFrame();
+
+ int append_page(Gtk::Widget& child, Gtk::Widget& tab_label);
+ /*
+ int append_page(Widget& child);
+ */
+ int append_page(Widget& child, const Glib::ustring& tab_label, bool use_mnemonic = false);
+
+ Widget* get_nth_page(int page_num);
+ const Widget* get_nth_page(int page_num) const;
+
+ int get_current_page() const;
+ void set_current_page(int page_num);
+
+ typedef sigc::signal<void, Gtk::Widget*, guint> type_signal_switch_page;
+
+ type_signal_switch_page signal_switch_page();
+
+protected:
+ void on_tab_toggled(int index);
+
+ Gtk::ButtonBox m_box_tabs;
+ Gtk::Box m_box_pages;
+
+ type_signal_switch_page m_signal_switch_page;
+
+ //Caching the widget pointers is nicer than repeatedly calling Gtk::Container::get_children().
+ typedef std::vector<Gtk::ToggleButton*> type_vec_togglebuttons;
+ type_vec_togglebuttons m_vec_tab_widgets;
+
+ typedef std::vector<Gtk::Box*> type_vec_widgets;
+ type_vec_widgets m_vec_page_widgets;
+
+ int m_current_page;
+};
+
+} //namespace Glom
+
+#endif //GLOM_UTILITY_WIDGETS_NOTEBOOK_NOFRAME_H
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]