[glom] Disables the Open button next to ID fields if the field is empty.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Subject: [glom] Disables the Open button next to ID fields if the field is empty.
- Date: Sun, 10 May 2009 15:51:53 -0400 (EDT)
commit 4cbeb70ae5acdd9e7772e3dc30ddbcb9a99df1d2
Author: Murray Cumming <murrayc murrayc com>
Date: Sun May 10 17:19:48 2009 +0200
Disables the Open button next to ID fields if the field is empty.
* glom/utility_widgets/datawidget.[h|cc]:
Added private update_go_to_details_button_sensitivity() method and
called it whenever the value is changed by the user or set via
set_value(). Fixes bug #565023.
---
ChangeLog | 9 +++++++++
glom/utility_widgets/datawidget.cc | 25 +++++++++++++++++++++----
glom/utility_widgets/datawidget.h | 5 +++++
3 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5c66131..5e40619 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-05-10 Murray Cumming <murrayc murrayc-x61>
+
+ Disables the Open button next to ID fields if the field is empty.
+
+ * glom/utility_widgets/datawidget.[h|cc]:
+ Added private update_go_to_details_button_sensitivity() method and
+ called it whenever the value is changed by the user or set via
+ set_value(). Fixes bug #565023.
+
2009-05-07 Murray Cumming <murrayc murrayc-x61>
Allow non-network-shared connections when using IPv6.
diff --git a/glom/utility_widgets/datawidget.cc b/glom/utility_widgets/datawidget.cc
index ee285bb..111f496 100644
--- a/glom/utility_widgets/datawidget.cc
+++ b/glom/utility_widgets/datawidget.cc
@@ -46,6 +46,8 @@ DataWidget::DataWidget(Field::glom_field_type glom_type, const Glib::ustring& ti
*/
DataWidget::DataWidget(const sharedptr<LayoutItem_Field>& field, const Glib::ustring& table_name, const Document* document)
+: m_child(0),
+ m_button_go_to_details(0)
{
const Field::glom_field_type glom_type = field->get_glom_type();
set_layout_item(field, table_name);
@@ -240,10 +242,10 @@ DataWidget::DataWidget(const sharedptr<LayoutItem_Field>& field, const Glib::ust
if((field_used_in_relationship_to_one || field_is_related_primary_key) && hbox_parent)
{
//Add a button for related record navigation:
- Gtk::Button* button_go_to_details = Gtk::manage(new Gtk::Button(Gtk::Stock::OPEN));
- button_go_to_details->set_tooltip_text(_("Open the record identified by this ID, in the other table."));
- hbox_parent->pack_start(*button_go_to_details);
- button_go_to_details->signal_clicked().connect(sigc::mem_fun(*this, &DataWidget::on_button_open_details));
+ m_button_go_to_details = Gtk::manage(new Gtk::Button(Gtk::Stock::OPEN));
+ m_button_go_to_details->set_tooltip_text(_("Open the record identified by this ID, in the other table."));
+ hbox_parent->pack_start(*m_button_go_to_details);
+ m_button_go_to_details->signal_clicked().connect(sigc::mem_fun(*this, &DataWidget::on_button_open_details));
//Add a button to make it easier to choose an ID for this field.
//Don't add this for simple related primary key fields, because they
@@ -276,6 +278,7 @@ DataWidget::~DataWidget()
void DataWidget::on_widget_edited()
{
m_signal_edited.emit(get_value());
+ update_go_to_details_button_sensitivity();
}
DataWidget::type_signal_edited DataWidget::signal_edited()
@@ -307,6 +310,20 @@ void DataWidget::set_value(const Gnome::Gda::Value& value)
checkbutton->set_active( bValue );
}
}
+
+ update_go_to_details_button_sensitivity();
+}
+
+void DataWidget::update_go_to_details_button_sensitivity()
+{
+ //If there is a Go-To-Details "Open" button, only enable it if there is
+ //an ID:
+ if(m_button_go_to_details)
+ {
+ const Gnome::Gda::Value value = get_value();
+ const bool enabled = !Conversions::value_is_empty(value);
+ m_button_go_to_details->set_sensitive(enabled);
+ }
}
Gnome::Gda::Value DataWidget::get_value() const
diff --git a/glom/utility_widgets/datawidget.h b/glom/utility_widgets/datawidget.h
index 6e6cfc7..27be179 100644
--- a/glom/utility_widgets/datawidget.h
+++ b/glom/utility_widgets/datawidget.h
@@ -113,11 +113,16 @@ private:
*/
bool offer_related_record_id_find(Gnome::Gda::Value& chosen_id);
+private:
+ void update_go_to_details_button_sensitivity();
+
+protected:
type_signal_edited m_signal_edited;
type_signal_open_details_requested m_signal_open_details_requested;
Gtk::Label m_label;
Gtk::Widget* m_child;
+ Gtk::Button* m_button_go_to_details;
};
} //namespace Glom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]