[glom] Allow editing of formatting for static text items.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom] Allow editing of formatting for static text items.
- Date: Fri, 22 Jan 2010 14:54:09 +0000 (UTC)
commit 38cb58d1e1692858a04884af81dd367641664138
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Jan 22 15:30:03 2010 +0100
Allow editing of formatting for static text items.
* glom/mode_design/layout/layout_item_dialogs/dialog_formatting.[h|cc]:
Added generic formatting (not choices, not default/custom) dialog
for static text items and maybe others.
* glom/mode_design/layout/layout_item_dialogs/box_formatting.[h|cc]:
set_formatting(): Add optional bool paramters to hide numeric formatting
and choices.
* glom/base_db.[h|cc]: Added offer_item_formatting() to use this dialog.
* glom/mode_design/layout/dialog_layout_details.cc(): Allow editing of
the formatting for static text items instead of just fields.
* glom/utility_widgets/db_adddel/db_adddel.cc:
construct_specified_columns_cellrenderer(): Apply the formatting to
any LayoutItem_WithFormatting, not just fields.
* glom/mode_data/flowtablewithfields.cc: add_textobject_at_position():
Try to apply the formatting to the label, but it doesn't seem to work.
ChangeLog | 20 +++++
Makefile_glom.am | 2 +
glom/base_db.cc | 36 ++++++++
glom/base_db.h | 6 ++
glom/mode_data/flowtablewithfields.cc | 3 +
glom/mode_design/layout/dialog_layout_details.cc | 30 +++++--
glom/mode_design/layout/dialog_layout_details.h | 4 +-
.../layout/layout_item_dialogs/box_formatting.cc | 41 +++++----
.../layout/layout_item_dialogs/box_formatting.h | 5 +-
.../layout_item_dialogs/dialog_formatting.cc | 89 ++++++++++++++++++++
.../layout/layout_item_dialogs/dialog_formatting.h | 62 ++++++++++++++
.../dialog_groupby_secondaryfields.cc | 4 +-
.../dialog_groupby_secondaryfields.h | 2 +-
glom/utility_widgets/datawidget.cc | 74 ----------------
glom/utility_widgets/db_adddel/db_adddel.cc | 25 ++----
glom/utility_widgets/labelglom.cc | 1 +
glom/utility_widgets/layoutwidgetbase.cc | 3 +
17 files changed, 285 insertions(+), 122 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d778e10..fd0b4af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2010-01-22 Murray Cumming <murrayc murrayc com>>
+
+ Allow editing of formatting for static text items.
+
+ * glom/mode_design/layout/layout_item_dialogs/dialog_formatting.[h|cc]:
+ Added generic formatting (not choices, not default/custom) dialog
+ for static text items and maybe others.
+ * glom/mode_design/layout/layout_item_dialogs/box_formatting.[h|cc]:
+ set_formatting(): Add optional bool paramters to hide numeric formatting
+ and choices.
+ * glom/base_db.[h|cc]: Added offer_item_formatting() to use this dialog.
+ * glom/mode_design/layout/dialog_layout_details.cc(): Allow editing of
+ the formatting for static text items instead of just fields.
+
+ * glom/utility_widgets/db_adddel/db_adddel.cc:
+ construct_specified_columns_cellrenderer(): Apply the formatting to
+ any LayoutItem_WithFormatting, not just fields.
+ * glom/mode_data/flowtablewithfields.cc: add_textobject_at_position():
+ Try to apply the formatting to the label, but it doesn't seem to work.
+
2010-01-22 Murray Cumming <murrayc murrayc com>
Add LayoutItem_WithFormatting as a Field/StaticText common base class.
diff --git a/Makefile_glom.am b/Makefile_glom.am
index 2ca7136..ece08cd 100644
--- a/Makefile_glom.am
+++ b/Makefile_glom.am
@@ -265,6 +265,8 @@ glom_glom_SOURCES += \
glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.h \
glom/mode_design/layout/layout_item_dialogs/dialog_field_summary.cc \
glom/mode_design/layout/layout_item_dialogs/dialog_field_summary.h \
+ glom/mode_design/layout/layout_item_dialogs/dialog_formatting.cc \
+ glom/mode_design/layout/layout_item_dialogs/dialog_formatting.h \
glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc \
glom/mode_design/layout/layout_item_dialogs/dialog_group_by.h \
glom/mode_design/layout/layout_item_dialogs/dialog_groupby_secondaryfields.cc \
diff --git a/glom/base_db.cc b/glom/base_db.cc
index e011682..317076b 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -30,6 +30,7 @@
//#ifndef GLOM_ENABLE_CLIENT_ONLY
#include <glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.h>
+#include <glom/mode_design/layout/layout_item_dialogs/dialog_formatting.h>
#include <glom/mode_design/layout/layout_item_dialogs/dialog_notebook.h>
#include <glom/mode_design/layout/layout_item_dialogs/dialog_textobject.h>
#include <glom/mode_design/layout/layout_item_dialogs/dialog_imageobject.h>
@@ -1908,6 +1909,41 @@ Base_DB::type_list_field_items Base_DB::offer_field_list(const Glib::ustring& ta
return result;
}
+bool Base_DB::offer_item_formatting(const sharedptr<LayoutItem_WithFormatting>& layout_item, Gtk::Window* transient_for)
+{
+ bool result = false;
+
+ try
+ {
+ Glib::RefPtr<Gtk::Builder> refXml = Gtk::Builder::create_from_file(Utils::get_glade_file_path("glom_developer.glade"), "dialog_layout_field_properties");
+
+ Dialog_Formatting dialog;
+ if(transient_for)
+ dialog.set_transient_for(*transient_for);
+
+ add_view(&dialog);
+
+ dialog.set_item(layout_item);
+
+ const int response = dialog.run();
+ if(response == Gtk::RESPONSE_OK)
+ {
+ //Get the chosen formatting:
+ dialog.use_item_chosen(layout_item);
+ result = true;
+ }
+ //Cancel means use the old one:
+
+ remove_view(&dialog);
+ }
+ catch(const Gtk::BuilderError& ex)
+ {
+ std::cerr << ex.what() << std::endl;
+ }
+
+ return result;
+}
+
sharedptr<LayoutItem_Field> Base_DB::offer_field_formatting(const sharedptr<const LayoutItem_Field>& start_field, const Glib::ustring& table_name, Gtk::Window* transient_for)
{
sharedptr<LayoutItem_Field> result;
diff --git a/glom/base_db.h b/glom/base_db.h
index a2939bc..6fce311 100644
--- a/glom/base_db.h
+++ b/glom/base_db.h
@@ -146,6 +146,12 @@ protected:
sharedptr<LayoutItem_Field> offer_field_formatting(const sharedptr<const LayoutItem_Field>& start_field, const Glib::ustring& table_name, Gtk::Window* transient_for = 0);
+
+ /** Offer generic formatting for a @a layout_item, starting with its current options.
+ * @result true if the user changed some formatting for the items.
+ */
+ bool offer_item_formatting(const sharedptr<LayoutItem_WithFormatting>& layout_item, Gtk::Window* transient_for = 0);
+
sharedptr<LayoutItem_Text> offer_textobject(const sharedptr<LayoutItem_Text>& start_textobject, Gtk::Window* transient_for = 0, bool show_title = true);
sharedptr<LayoutItem_Image> offer_imageobject(const sharedptr<LayoutItem_Image>& start_imageobject, Gtk::Window* transient_for = 0, bool show_title = true);
sharedptr<LayoutItem_Notebook> offer_notebook(const sharedptr<LayoutItem_Notebook>& start_notebook, Gtk::Window* transient_for = 0);
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index edbff0b..02bf365 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -615,6 +615,9 @@ void FlowTableWithFields::add_textobject_at_position(const sharedptr<LayoutItem_
label->show();
alignment_label->add(*label);
+ //TODO: Why isn't this formatting used?
+ //std::cout << "DEBUG: Applying formatting for text item: " << text << std::endl;
+ //std::cout << " DEBUG: font: " << layoutitem_text->get_formatting_used().get_text_format_font() << std::endl;
apply_formatting(*label, layoutitem_text);
add_layoutwidgetbase(label, add_before);
diff --git a/glom/mode_design/layout/dialog_layout_details.cc b/glom/mode_design/layout/dialog_layout_details.cc
index cc56422..eeef0ca 100644
--- a/glom/mode_design/layout/dialog_layout_details.cc
+++ b/glom/mode_design/layout/dialog_layout_details.cc
@@ -52,7 +52,7 @@ Dialog_Layout_Details::Dialog_Layout_Details(BaseObjectType* cobject, const Glib
m_button_add_text(0),
m_button_add_image(0),
m_button_field_delete(0),
- m_button_field_formatting(0),
+ m_button_formatting(0),
m_button_edit(0),
m_label_table_name(0)
{
@@ -158,8 +158,8 @@ Dialog_Layout_Details::Dialog_Layout_Details(BaseObjectType* cobject, const Glib
builder->get_widget("button_field_delete", m_button_field_delete);
m_button_field_delete->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_field_delete) );
- builder->get_widget("button_formatting", m_button_field_formatting);
- m_button_field_formatting->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_field_formatting) );
+ builder->get_widget("button_formatting", m_button_formatting);
+ m_button_formatting->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_formatting) );
builder->get_widget("button_add_field", m_button_add_field);
m_button_add_field->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_add_field) );
@@ -415,11 +415,11 @@ void Dialog_Layout_Details::enable_buttons()
m_button_field_delete->set_sensitive(true);
- //Only fields have formatting:
+ //Only some items have formatting:
sharedptr<LayoutItem> layout_item = (*iter)[m_model_items->m_columns.m_col_layout_item];
- sharedptr<LayoutItem_Field> layout_item_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
- const bool is_field = layout_item_field;
- m_button_field_formatting->set_sensitive(is_field);
+ sharedptr<LayoutItem_WithFormatting> layoutitem_withformatting = sharedptr<LayoutItem_WithFormatting>::cast_dynamic(layout_item);
+ const bool is_field = layoutitem_withformatting;
+ m_button_formatting->set_sensitive(is_field);
}
else
{
@@ -427,7 +427,7 @@ void Dialog_Layout_Details::enable_buttons()
m_button_down->set_sensitive(false);
m_button_up->set_sensitive(false);
m_button_field_delete->set_sensitive(false);
- m_button_field_formatting->set_sensitive(false);
+ m_button_formatting->set_sensitive(false);
}
}
@@ -927,7 +927,7 @@ void Dialog_Layout_Details::on_button_add_group()
enable_buttons();
}
-void Dialog_Layout_Details::on_button_field_formatting()
+void Dialog_Layout_Details::on_button_formatting()
{
//TODO: Abstract this into the base class:
@@ -944,6 +944,7 @@ void Dialog_Layout_Details::on_button_field_formatting()
sharedptr<LayoutItem_Field> field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
if(field)
{
+ //Handle field formatting, which includes more than the generic formatting stuff:
sharedptr<LayoutItem_Field> chosenitem = offer_field_formatting(field, get_fields_table(), this);
if(chosenitem)
{
@@ -952,6 +953,17 @@ void Dialog_Layout_Details::on_button_field_formatting()
//m_model_parts->row_changed(Gtk::TreeModel::Path(iter), iter); //TODO: Add row_changed(iter) to gtkmm?
}
}
+ else
+ {
+ //Handle any other items that can have formatting:
+ sharedptr<LayoutItem_WithFormatting> withformatting = sharedptr<LayoutItem_WithFormatting>::cast_dynamic(layout_item);
+ if(withformatting)
+ {
+ const bool changed = offer_item_formatting(withformatting, this);
+ if(changed)
+ m_modified = true;
+ }
+ }
}
}
}
diff --git a/glom/mode_design/layout/dialog_layout_details.h b/glom/mode_design/layout/dialog_layout_details.h
index 2515572..7fa7a6b 100644
--- a/glom/mode_design/layout/dialog_layout_details.h
+++ b/glom/mode_design/layout/dialog_layout_details.h
@@ -77,7 +77,7 @@ protected:
void on_button_add_button();
void on_button_add_text();
void on_button_add_image();
- void on_button_field_formatting();
+ void on_button_formatting();
virtual void on_button_edit(); //overridden in derived class
void on_treeview_fields_selection_changed();
@@ -114,7 +114,7 @@ protected:
Gtk::Button* m_button_add_text;
Gtk::Button* m_button_add_image;
Gtk::Button* m_button_field_delete;
- Gtk::Button* m_button_field_formatting;
+ Gtk::Button* m_button_formatting;
Gtk::Button* m_button_edit;
Gtk::Label* m_label_table_name;
diff --git a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
index 38d3bf5..51ba6d0 100644
--- a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
@@ -53,7 +53,9 @@ Box_Formatting::Box_Formatting(BaseObjectType* cobject, const Glib::RefPtr<Gtk::
m_checkbutton_choices_restricted(0),
m_adddel_choices_custom(0),
m_col_index_custom_choices(0),
- m_for_print_layout(false)
+ m_for_print_layout(false),
+ m_show_numeric(true),
+ m_show_choices(true)
{
//Numeric formatting:
builder->get_widget("vbox_numeric_format", m_vbox_numeric_format);
@@ -133,6 +135,7 @@ Box_Formatting::~Box_Formatting()
void Box_Formatting::set_is_for_print_layout()
{
m_for_print_layout = true;
+ m_show_choices = false;
//Add labels (because we will hide the checkboxes):
Gtk::Label* label = Gtk::manage(new Gtk::Label(_("Font")));
@@ -157,10 +160,13 @@ void Box_Formatting::set_formatting(const FieldFormatting& format, const Glib::u
set_formatting(format);
}
-void Box_Formatting::set_formatting(const FieldFormatting& format)
+void Box_Formatting::set_formatting(const FieldFormatting& format, bool show_numeric, bool show_choices)
{
m_format = format;
+ m_show_numeric = show_numeric;
+ m_show_choices = show_choices;
+
//Numeric formatting:
m_checkbox_format_use_thousands->set_active( format.m_numeric_format.m_use_thousands_separator );
m_checkbox_format_use_decimal_places->set_active( format.m_numeric_format.m_decimal_places_restricted );
@@ -342,22 +348,19 @@ void Box_Formatting::on_combo_choices_relationship_changed()
void Box_Formatting::enforce_constraints()
{
//Hide inappropriate UI:
- bool is_numeric = false;
- if(m_field && (m_field->get_glom_type() == Field::TYPE_NUMERIC))
- is_numeric = true;
-
- if(is_numeric)
- m_vbox_numeric_format->show();
- else
- m_vbox_numeric_format->hide();
-
- bool show_text = false;
- if(m_field && (m_field->get_glom_type() != Field::TYPE_BOOLEAN) && (m_field->get_glom_type() != Field::TYPE_IMAGE)) //TODO: Allow text options when showing booleans as Yes/No on print layouts.
- show_text = true;
+ bool show_text = true;
+ if(m_field)
+ {
+ m_show_numeric = false;
+ if(m_field->get_glom_type() == Field::TYPE_NUMERIC)
+ m_show_numeric = true;
- if(m_for_print_layout)
- show_text = true;
+ if((m_field->get_glom_type() == Field::TYPE_BOOLEAN) || (m_field->get_glom_type() == Field::TYPE_IMAGE)) //TODO: Allow text options when showing booleans as Yes/No on print layouts.
+ {
+ show_text = false;
+ }
+ }
if(show_text)
{
@@ -398,8 +401,12 @@ void Box_Formatting::enforce_constraints()
m_colorbutton_foreground->set_sensitive( m_for_print_layout || m_checkbox_format_text_color_foreground->get_active() );
m_colorbutton_background->set_sensitive( m_for_print_layout || m_checkbox_format_text_color_background->get_active() );
+ if(m_show_numeric)
+ m_vbox_numeric_format->show();
+ else
+ m_vbox_numeric_format->hide();
- if(!m_for_print_layout)
+ if(m_show_choices)
m_vbox_choices->show();
else
m_vbox_choices->hide();
diff --git a/glom/mode_design/layout/layout_item_dialogs/box_formatting.h b/glom/mode_design/layout/layout_item_dialogs/box_formatting.h
index 090da52..de83a7d 100644
--- a/glom/mode_design/layout/layout_item_dialogs/box_formatting.h
+++ b/glom/mode_design/layout/layout_item_dialogs/box_formatting.h
@@ -43,7 +43,7 @@ public:
/**
* @param format The starting information.
*/
- void set_formatting(const FieldFormatting& format);
+ void set_formatting(const FieldFormatting& format, bool show_numeric = true, bool show_choices = true);
/**
* @param format The starting information.
@@ -105,6 +105,9 @@ private:
//showing this on a print layout.
bool m_for_print_layout;
+ bool m_show_numeric;
+ bool m_show_choices;
+
class AlignmentColumns: public Gtk::TreeModelColumnRecord
{
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_formatting.cc b/glom/mode_design/layout/layout_item_dialogs/dialog_formatting.cc
new file mode 100644
index 0000000..8feffcb
--- /dev/null
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_formatting.cc
@@ -0,0 +1,89 @@
+/* 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 "dialog_formatting.h"
+#include <libglom/data_structure/glomconversions.h>
+#include <glom/glade_utils.h>
+#include <glibmm/i18n.h>
+
+namespace Glom
+{
+
+Dialog_Formatting::Dialog_Formatting()
+: m_box_formatting(0)
+{
+ set_title(_("Formatting"));
+ set_border_width(6);
+
+ //GtkBuilder can't find top-level objects (GtkAdjustments in this case),
+ //that one top-level object references.
+ //See http://bugzilla.gnome.org/show_bug.cgi?id=575714
+ //so we need to this silliness. murrayc.
+ std::list<Glib::ustring> builder_ids;
+ builder_ids.push_back("box_formatting");
+ builder_ids.push_back("adjustment2");
+
+ //Get the formatting stuff:
+ try
+ {
+ Glib::RefPtr<Gtk::Builder> refXmlFormatting = Gtk::Builder::create_from_file(Utils::get_glade_file_path("glom_developer.glade"), builder_ids);
+ refXmlFormatting->get_widget_derived("box_formatting", m_box_formatting);
+ }
+ catch(const Gtk::BuilderError& ex)
+ {
+ std::cerr << ex.what() << std::endl;
+ }
+
+ get_vbox()->pack_start(*m_box_formatting, Gtk::PACK_EXPAND_WIDGET);
+ add_view(m_box_formatting);
+
+ add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
+
+ show_all_children();
+}
+
+Dialog_Formatting::~Dialog_Formatting()
+{
+ remove_view(m_box_formatting);
+}
+
+void Dialog_Formatting::set_item(const sharedptr<const LayoutItem_WithFormatting>& layout_item)
+{
+ m_box_formatting->set_formatting(layout_item->m_formatting, false, false);
+
+ enforce_constraints();
+}
+
+void Dialog_Formatting::use_item_chosen(const sharedptr<LayoutItem_WithFormatting>& layout_item)
+{
+ if(!layout_item)
+ return;
+
+ m_box_formatting->get_formatting(layout_item->m_formatting);
+}
+
+void Dialog_Formatting::enforce_constraints()
+{
+}
+
+} //namespace Glom
+
+
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_formatting.h b/glom/mode_design/layout/layout_item_dialogs/dialog_formatting.h
new file mode 100644
index 0000000..7c36c63
--- /dev/null
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_formatting.h
@@ -0,0 +1,62 @@
+/* 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_MODE_DATA_DIALOG_FORMATTING_H
+#define GLOM_MODE_DATA_DIALOG_FORMATTING_H
+
+#include <gtkmm.h>
+#include <glom/utility_widgets/dialog_properties.h>
+#include <libglom/document/view.h>
+#include <glom/box_withbuttons.h>
+#include <glom/utility_widgets/combo_textglade.h>
+#include <glom/mode_design/comboentry_currency.h>
+#include "box_formatting.h"
+
+namespace Glom
+{
+
+class Dialog_Formatting
+ : public Gtk::Dialog,
+ public View_Composite_Glom //Give it access to the document.
+{
+public:
+ Dialog_Formatting();
+ virtual ~Dialog_Formatting();
+
+ /**
+ * @param document The document, so that the dialog can load the previous layout, and save changes.
+ * @param field The starting item information.
+ */
+ void set_item(const sharedptr<const LayoutItem_WithFormatting>& field);
+
+ /** Set the @a layout_item's formatting to the formatting specified in the
+ * dialog by the user.
+ */
+ void use_item_chosen(const sharedptr<LayoutItem_WithFormatting>& layout_item);
+
+private:
+ void enforce_constraints();
+
+ Box_Formatting* m_box_formatting;
+};
+
+} //namespace Glom
+
+#endif //GLOM_MODE_DATA_DIALOG_FORMATTING_H
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_groupby_secondaryfields.cc b/glom/mode_design/layout/layout_item_dialogs/dialog_groupby_secondaryfields.cc
index 5f09ab7..68fc288 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_groupby_secondaryfields.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_groupby_secondaryfields.cc
@@ -86,7 +86,7 @@ Dialog_GroupBy_SecondaryFields::Dialog_GroupBy_SecondaryFields(BaseObjectType* c
m_button_field_edit->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_GroupBy_SecondaryFields::on_button_edit_field) );
builder->get_widget("button_field_formatting", m_button_field_formatting);
- m_button_field_formatting->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_GroupBy_SecondaryFields::on_button_field_formatting) );
+ m_button_field_formatting->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_GroupBy_SecondaryFields::on_button_formatting) );
show_all_children();
}
@@ -312,7 +312,7 @@ void Dialog_GroupBy_SecondaryFields::on_button_edit_field()
}
}
-void Dialog_GroupBy_SecondaryFields::on_button_field_formatting()
+void Dialog_GroupBy_SecondaryFields::on_button_formatting()
{
Glib::RefPtr<Gtk::TreeView::Selection> refTreeSelection = m_treeview_fields->get_selection();
if(refTreeSelection)
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_groupby_secondaryfields.h b/glom/mode_design/layout/layout_item_dialogs/dialog_groupby_secondaryfields.h
index aa69835..61c3f4b 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_groupby_secondaryfields.h
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_groupby_secondaryfields.h
@@ -50,7 +50,7 @@ private:
virtual void on_button_add_field();
virtual void on_button_delete();
virtual void on_button_edit_field();
- virtual void on_button_field_formatting();
+ virtual void on_button_formatting();
virtual void on_treeview_fields_selection_changed();
virtual void on_cell_data_name(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter);
diff --git a/glom/utility_widgets/datawidget.cc b/glom/utility_widgets/datawidget.cc
index 6674974..4dff5b5 100644
--- a/glom/utility_widgets/datawidget.cc
+++ b/glom/utility_widgets/datawidget.cc
@@ -446,80 +446,6 @@ void DataWidget::set_editable(bool editable)
}
}
-/*
-void DataWidget::setup_menu()
-{
- m_refActionGroup->add(m_refContextLayout,
- sigc::mem_fun(*this, &DataWidget::on_menupopup_activate_layout) );
-
- m_refActionGroup->add(m_refContextLayoutProperties,
- sigc::mem_fun(*this, &DataWidget::on_menupopup_activate_layout_properties) );
-
- m_refActionGroup->add(m_refContextAddField,
- sigc::bind( sigc::mem_fun(*this, &DataWidget::on_menupopup_add_item), LayoutWidgetBase::TYPE_FIELD ) );
-
- m_refActionGroup->add(m_refContextAddRelatedRecords,
- sigc::bind( sigc::mem_fun(*this, &DataWidget::on_menupopup_add_item), LayoutWidgetBase::TYPE_PORTAL ) );
-
- m_refActionGroup->add(m_refContextAddGroup,
- sigc::bind( sigc::mem_fun(*this, &DataWidget::on_menupopup_add_item), LayoutWidgetBase::TYPE_GROUP ) );
-
- //TODO: This does not work until this widget is in a container in the window:s
- App_Glom* pApp = get_application();
- if(pApp)
- {
- pApp->add_developer_action(m_refContextLayout); //So that it can be disabled when not in developer mode.
- pApp->add_developer_action(m_refContextLayoutProperties); //So that it can be disabled when not in developer mode.
- pApp->add_developer_action(m_refContextAddField);
- pApp->add_developer_action(m_refContextAddRelatedRecords);
- pApp->add_developer_action(m_refContextAddGroup);
-
- pApp->update_userlevel_ui(); //Update our action's sensitivity.
- }
-
- m_refUIManager = Gtk::UIManager::create();
-
- m_refUIManager->insert_action_group(m_refActionGroup);
-
- //TODO: add_accel_group(m_refUIManager->get_accel_group());
-
- try
- {
- Glib::ustring ui_info =
- "<ui>"
- " <popup name='ContextMenu'>"
- " <menuitem action='ContextLayout'/>"
- " <menuitem action='ContextLayoutProperties'/>"
- " <menuitem action='ContextAddField'/>"
- " <menuitem action='ContextAddRelatedRecords'/>"
- " <menuitem action='ContextAddGroup'/>"
- " </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_pMenuPopup = dynamic_cast<Gtk::Menu*>( m_refUIManager->get_widget("/ContextMenu") );
- if(!m_pMenuPopup)
- g_warning("menu not found");
-
-
- if(pApp)
- {
- const bool sensitive = pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER;
- m_refContextLayout->set_sensitive(sensitive);
- m_refContextAddField->set_sensitive(sensitive);
- m_refContextAddRelatedRecords->set_sensitive(sensitive);
- m_refContextAddGroup->set_sensitive(sensitive);
- }
-}
-*/
-
#ifndef GLOM_ENABLE_CLIENT_ONLY
bool DataWidget::on_button_press_event(GdkEventButton *event)
{
diff --git a/glom/utility_widgets/db_adddel/db_adddel.cc b/glom/utility_widgets/db_adddel/db_adddel.cc
index 1480871..279b729 100644
--- a/glom/utility_widgets/db_adddel/db_adddel.cc
+++ b/glom/utility_widgets/db_adddel/db_adddel.cc
@@ -669,21 +669,12 @@ int DbAddDel::get_fixed_cell_height()
{
Glib::ustring font_name;
- sharedptr<LayoutItem_Field> item_field = sharedptr<LayoutItem_Field>::cast_dynamic(iter->m_item);
- if(item_field)
+ sharedptr<LayoutItem_WithFormatting> item_withformatting = sharedptr<LayoutItem_WithFormatting>::cast_dynamic(iter->m_item);
+ if(item_withformatting)
{
- const FieldFormatting& formatting = item_field->get_formatting_used();
+ const FieldFormatting& formatting = item_withformatting->get_formatting_used();
font_name = formatting.get_text_format_font();
}
- else
- {
- sharedptr<LayoutItem_Text> item_text = sharedptr<LayoutItem_Text>::cast_dynamic(iter->m_item);
- if(item_text)
- {
- const FieldFormatting& formatting = item_text->get_formatting_used();
- font_name = formatting.get_text_format_font();
- }
- }
if(font_name.empty())
continue;
@@ -746,10 +737,6 @@ Gtk::CellRenderer* DbAddDel::construct_specified_columns_cellrenderer(const shar
break;
}
} //switch
-
- //Set font and colors:
- if(pCellRenderer)
- apply_formatting(pCellRenderer, item_field);
}
else
{
@@ -798,6 +785,12 @@ Gtk::CellRenderer* DbAddDel::construct_specified_columns_cellrenderer(const shar
}
}
+ //Use formatting:
+ sharedptr<LayoutItem_WithFormatting> item_withformatting = sharedptr<LayoutItem_WithFormatting>::cast_dynamic(layout_item);
+ if(item_withformatting && pCellRenderer)
+ {
+ apply_formatting(pCellRenderer, item_withformatting);
+ }
//Set extra cellrenderer attributes, depending on the type used:
Gtk::CellRendererText* pCellRendererText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
diff --git a/glom/utility_widgets/labelglom.cc b/glom/utility_widgets/labelglom.cc
index 8c072ed..e4a7ab8 100644
--- a/glom/utility_widgets/labelglom.cc
+++ b/glom/utility_widgets/labelglom.cc
@@ -110,6 +110,7 @@ bool LabelGlom::on_button_press_event(GdkEventButton *event)
return true; //We handled this event.
}
}
+
return Gtk::EventBox::on_button_press_event(event);
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
diff --git a/glom/utility_widgets/layoutwidgetbase.cc b/glom/utility_widgets/layoutwidgetbase.cc
index a6ba905..491d90b 100644
--- a/glom/utility_widgets/layoutwidgetbase.cc
+++ b/glom/utility_widgets/layoutwidgetbase.cc
@@ -86,6 +86,9 @@ void LayoutWidgetBase::set_read_only(bool /* read_only */)
void LayoutWidgetBase::apply_formatting(Gtk::Widget& widget, const sharedptr<const LayoutItem_WithFormatting>& layout_item)
{
+ if(!layout_item)
+ return;
+
//Horizontal alignment:
const FieldFormatting::HorizontalAlignment alignment =
layout_item->get_formatting_used_horizontal_alignment();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]