[glom/glom-1-20] Details: Really make non-editable multiline text fields non-editable.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-20] Details: Really make non-editable multiline text fields non-editable.
- Date: Fri, 30 Dec 2011 08:55:24 +0000 (UTC)
commit f9a9e46e115a75693a78aaf59295ea6b0d193fa4
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Dec 30 09:46:52 2011 +0100
Details: Really make non-editable multiline text fields non-editable.
* glom/mode_data/datawidget/textview.[h|cc]: Override set_read_only(),
so that multiline text fields are really non-editable when the formatting
specifies that.
ChangeLog | 8 ++++++
glom/mode_data/datawidget/datawidget.cc | 41 +++++++++++++++++++++----------
glom/mode_data/datawidget/textview.cc | 5 ++++
glom/mode_data/datawidget/textview.h | 2 +
4 files changed, 43 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 67f5940..353a3db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-12-30 Murray Cumming <murrayc murrayc com>
+
+ Details: Really make non-editable multiline text fields non-editable.
+
+ * glom/mode_data/datawidget/textview.[h|cc]: Override set_read_only(),
+ so that multiline text fields are really non-editable when the formatting
+ specifies that.
+
2011-12-29 Murray Cumming <murrayc murrayc com>
App_WithDoc_Gtk: Simple clipboard menu handlers: Handle GtkTextView
diff --git a/glom/mode_data/datawidget/datawidget.cc b/glom/mode_data/datawidget/datawidget.cc
index 39fbd7b..5dff30a 100644
--- a/glom/mode_data/datawidget/datawidget.cc
+++ b/glom/mode_data/datawidget/datawidget.cc
@@ -376,21 +376,36 @@ void DataWidget::set_viewable(bool viewable)
void DataWidget::set_editable(bool editable)
{
Gtk::Widget* child = get_data_child_widget();
- Gtk::Entry* entry = dynamic_cast<Gtk::Entry*>(child);
- if(entry)
- entry->set_editable(editable);
- else
+ Gtk::Editable* gtkeditable = dynamic_cast<Gtk::Editable*>(child);
+ if(gtkeditable)
{
- LayoutWidgetBase* base = dynamic_cast<LayoutWidgetBase*>(child);
- if(base)
- base->set_read_only(!editable);
- else
- {
- Gtk::CheckButton* checkbutton = dynamic_cast<Gtk::CheckButton*>(child);
- if(checkbutton)
- checkbutton->set_sensitive(editable);
- }
+ gtkeditable->set_editable(editable);
+ return;
}
+
+ //GtkTextView does not implement GtkEditable:
+ //See https://bugzilla.gnome.org/show_bug.cgi?id=667008
+ //and our TextView class actually derives from ScrolledView anyway,
+ //and out LayoutWidgetBase::set_read_only() override takes care of it instead.
+ //But let's leave this here just in case:
+ Gtk::TextView* textview =
+ dynamic_cast<Gtk::TextView*>(child);
+ if(textview)
+ {
+ textview->set_editable(editable);
+ return;
+ }
+
+ LayoutWidgetBase* base = dynamic_cast<LayoutWidgetBase*>(child);
+ if(base)
+ {
+ base->set_read_only(!editable);
+ return;
+ }
+
+ Gtk::CheckButton* checkbutton = dynamic_cast<Gtk::CheckButton*>(child);
+ if(checkbutton)
+ checkbutton->set_sensitive(editable);
}
#ifndef GLOM_ENABLE_CLIENT_ONLY
diff --git a/glom/mode_data/datawidget/textview.cc b/glom/mode_data/datawidget/textview.cc
index 603546f..2f92a78 100644
--- a/glom/mode_data/datawidget/textview.cc
+++ b/glom/mode_data/datawidget/textview.cc
@@ -221,5 +221,10 @@ TextView::type_text_view* TextView::get_textview()
return &m_TextView;
}
+void TextView::set_read_only(bool read_only)
+{
+ m_TextView.set_editable(!read_only);
+}
+
} //namespace DataWidetChildren
} //namespace Glom
diff --git a/glom/mode_data/datawidget/textview.h b/glom/mode_data/datawidget/textview.h
index f6caa3c..d9c051b 100644
--- a/glom/mode_data/datawidget/textview.h
+++ b/glom/mode_data/datawidget/textview.h
@@ -61,6 +61,8 @@ public:
typedef Gtk::TextView type_text_view;
type_text_view* get_textview();
+
+ void set_read_only(bool read_only = true);
private:
void init();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]