[glom] Avoid some copy/pasting of code.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Avoid some copy/pasting of code.
- Date: Tue, 18 Oct 2011 18:40:14 +0000 (UTC)
commit baa0549cc910dc747497e228638e9155e5a508a1
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Oct 17 23:12:33 2011 +0200
Avoid some copy/pasting of code.
* glom/mode_design/print_layouts/print_layout_toolbar_button.cc:
* glom/utility_widgets/layouttoolbar.cc:
* glom/utility_widgets/layouttoolbarbutton.cc: Moved get_icon_path() to:
* glom/utils_ui.[h|cc]
ChangeLog | 61 +++++++++++--------
.../print_layouts/print_layout_toolbar_button.cc | 22 +-------
glom/utility_widgets/layouttoolbar.cc | 18 ------
glom/utility_widgets/layouttoolbarbutton.cc | 22 +-------
glom/utils_ui.cc | 13 ++++
glom/utils_ui.h | 2 +
6 files changed, 54 insertions(+), 84 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 78ecbf5..1825330 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2011-10-17 Murray Cumming <murrayc murrayc com>
+
+ Avoid some copy/pasting of code.
+
+ * glom/mode_design/print_layouts/print_layout_toolbar_button.cc:
+ * glom/utility_widgets/layouttoolbar.cc:
+ * glom/utility_widgets/layouttoolbarbutton.cc: Moved get_icon_path() to:
+ * glom/utils_ui.[h|cc]
+
+2011-10-17 Murray Cumming <murrayc murrayc com>
+
+ Test report contents.
+
+ * glom/libglom/xsl_utils.[h|cc]: transform(): Return the contents,
+ not a filepath.
+ * glom/libglom/report_builder.[h|cc]: report_build(): return the
+ contents, not the path. Add report_build_and_save() to get a temporary
+ filepath.
+ * glom/mode_data/box_data_manyrecords.cc:
+ * glom/frame_glom.cc: Adapted.
+ * tests/test_selfhosting_new_then_report.cc: Check that some expected
+ text is in the generated HTML.
+
+2011-10-17 Murray Cumming <murrayc murrayc com>
+
+ Test report building.
+
+ * tests/test_selfhosting_new_from_example.cc: Move most code into
+ utility functions in:
+ * tests/test_selfhosting_utils.[h|cc]:
+ * tests/test_selfhosting_new_then_report.cc: Add a new test that also
+ generates a HTML report.
+ * Makefile_tests: Mention the new files.
+
2011-10-18 Murray Cumming <murrayc murrayc com>
Film Manager example: Change default table.
@@ -48,32 +82,7 @@
Correct the pkg-config file.
* glom/libglom/glom.pc.in: Depend on libgdamm-5.0, not ligdamm-4.0.
- And depend on libxslt, because we just moved the xslt stuff into libglom.
-
-2011-10-17 Murray Cumming <murrayc murrayc com>
-
- Test report contents.
-
- * glom/libglom/xsl_utils.[h|cc]: transform(): Return the contents,
- not a filepath.
- * glom/libglom/report_builder.[h|cc]: report_build(): return the
- contents, not the path. Add report_build_and_save() to get a temporary
- filepath.
- * glom/mode_data/box_data_manyrecords.cc:
- * glom/frame_glom.cc: Adapted.
- * tests/test_selfhosting_new_then_report.cc: Check that some expected
- text is in the generated HTML.
-
-2011-10-17 Murray Cumming <murrayc murrayc com>
-
- Test report building.
-
- * tests/test_selfhosting_new_from_example.cc: Move most code into
- utility functions in:
- * tests/test_selfhosting_utils.[h|cc]:
- * tests/test_selfhosting_new_then_report.cc: Add a new test that also
- generates a HTML report.
- * Makefile_tests: Mention the new files.
+ And depend on libxslt, because we just moved the xslt stuff into libglom.
2011-10-17 Murray Cumming <murrayc murrayc com>
diff --git a/glom/mode_design/print_layouts/print_layout_toolbar_button.cc b/glom/mode_design/print_layouts/print_layout_toolbar_button.cc
index c797750..0ce2830 100644
--- a/glom/mode_design/print_layouts/print_layout_toolbar_button.cc
+++ b/glom/mode_design/print_layouts/print_layout_toolbar_button.cc
@@ -19,34 +19,16 @@
*/
#include "print_layout_toolbar_button.h"
+#include <glom/utils_ui.h>
#include <gtkmm/toolpalette.h>
#include <iostream>
-namespace
-{
-
-std::string get_icon_path(const std::string& filename)
-{
-#ifdef G_OS_WIN32
- gchar* basepath = g_win32_get_package_installation_directory_of_module(0);
- const std::string result = Glib::build_filename(Glib::build_filename(basepath,
- "share" G_DIR_SEPARATOR_S "glom" G_DIR_SEPARATOR_S "pixmaps"), filename);
- g_free(basepath);
- return result;
-#else
- return Glib::build_filename(GLOM_PKGDATADIR G_DIR_SEPARATOR_S "pixmaps", filename);
-#endif
-}
-
-} //anonymous namespace
-
-
namespace Glom
{
PrintLayoutToolbarButton::PrintLayoutToolbarButton(const std::string& icon_name, enumItems type,
const Glib::ustring& title, const Glib::ustring& tooltip)
-: Gtk::ToolButton( *(Gtk::manage (new Gtk::Image(get_icon_path(icon_name)))) )
+: Gtk::ToolButton( *(Gtk::manage (new Gtk::Image(Utils::get_icon_path(icon_name)))) )
{
m_type = type;
g_object_set_data(G_OBJECT(gobj()), "glom-type", GINT_TO_POINTER(type));
diff --git a/glom/utility_widgets/layouttoolbar.cc b/glom/utility_widgets/layouttoolbar.cc
index 16ad936..f9db400 100644
--- a/glom/utility_widgets/layouttoolbar.cc
+++ b/glom/utility_widgets/layouttoolbar.cc
@@ -25,24 +25,6 @@
#include "layoutwidgetbase.h"
-namespace
-{
-
-Glib::ustring get_icon_path(const Glib::ustring& filename)
-{
-#ifdef G_OS_WIN32
- gchar* basepath = g_win32_get_package_installation_directory_of_module(0);
- Glib::ustring result = Glib::build_filename(Glib::build_filename(basepath,
- "share" G_DIR_SEPARATOR_S "glom" G_DIR_SEPARATOR_S "pixmaps"), filename);
- g_free(basepath);
- return result;
-#else
- return Glib::build_filename(GLOM_PKGDATADIR G_DIR_SEPARATOR_S "pixmaps", filename);
-#endif
-}
-
-} //anonymous namespace
-
namespace Glom
{
diff --git a/glom/utility_widgets/layouttoolbarbutton.cc b/glom/utility_widgets/layouttoolbarbutton.cc
index d8f374e..9032147 100644
--- a/glom/utility_widgets/layouttoolbarbutton.cc
+++ b/glom/utility_widgets/layouttoolbarbutton.cc
@@ -20,32 +20,14 @@
#include <gtkmm.h>
#include "layouttoolbarbutton.h"
-
-namespace
-{
-
-std::string get_icon_path(const std::string& filename)
-{
-#ifdef G_OS_WIN32
- gchar* basepath = g_win32_get_package_installation_directory_of_module(0);
- const std::string result = Glib::build_filename(Glib::build_filename(basepath,
- "share" G_DIR_SEPARATOR_S "glom" G_DIR_SEPARATOR_S "pixmaps"), filename);
- g_free(basepath);
- return result;
-#else
- return Glib::build_filename(GLOM_PKGDATADIR G_DIR_SEPARATOR_S "pixmaps", filename);
-#endif
-}
-
-} //anonymous namespace
-
+#include <glom/utils_ui.h>
namespace Glom
{
LayoutToolbarButton::LayoutToolbarButton(const std::string& icon_name, LayoutWidgetBase::enumType type,
const Glib::ustring& title, const Glib::ustring& tooltip)
-: Gtk::ToolButton( *(Gtk::manage (new Gtk::Image(get_icon_path(icon_name)))) )
+: Gtk::ToolButton( *(Gtk::manage (new Gtk::Image(Utils::get_icon_path(icon_name)))) )
{
m_type = type;
g_object_set_data(G_OBJECT(gobj()), "glom-type", GINT_TO_POINTER(type));
diff --git a/glom/utils_ui.cc b/glom/utils_ui.cc
index 8ea3384..5cdb0c2 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -517,4 +517,17 @@ void Utils::show_report_in_browser(const std::string& filepath, Gtk::Window* par
#endif //G_OS_WIN32
}
+std::string Utils::get_icon_path(const Glib::ustring& filename)
+{
+#ifdef G_OS_WIN32
+ gchar* basepath = g_win32_get_package_installation_directory_of_module(0);
+ const std::string result = Glib::build_filename(Glib::build_filename(basepath,
+ "share" G_DIR_SEPARATOR_S "glom" G_DIR_SEPARATOR_S "pixmaps"), filename);
+ g_free(basepath);
+ return result;
+#else
+ return Glib::build_filename(GLOM_PKGDATADIR G_DIR_SEPARATOR_S "pixmaps", filename);
+#endif
+}
+
} //namespace Glom
diff --git a/glom/utils_ui.h b/glom/utils_ui.h
index c13fb6e..5febc5e 100644
--- a/glom/utils_ui.h
+++ b/glom/utils_ui.h
@@ -96,6 +96,8 @@ bool show_warning_no_records_found(Gtk::Window& transient_for);
void show_report_in_browser(const std::string& filepath, Gtk::Window* parent_window);
+std::string get_icon_path(const Glib::ustring& filename);
+
} //namespace Utils
} //namespace Glom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]