[glom/glom-1-18] List view and Related Records: Disable buttons when appropriate.



commit 04f8683d46c19e6cd6fd30475980311e61a2766b
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Nov 11 10:16:19 2011 +0100

    List view and Related Records: Disable buttons when appropriate.
    
    * glom/mode_data/db_adddel/db_adddel.[h|cc]: Handle the
    Gtk::TreeView::Selection::signal_changed() signal and call a
    new virtual on_selection_changed() method.
    * glom/mode_data/db_adddel/db_adddel_withbuttons.[h|cc]:
    Disable the Edit/Open and Delete buttons when there is no selection.
    Bug #663812 (Andrà Klapper)
    
    Conflicts:
    
    	glom/utility_widgets/db_adddel/db_adddel.h
    	glom/utility_widgets/db_adddel/db_adddel_withbuttons.h

 ChangeLog                                          |   11 +++++++++
 glom/utility_widgets/db_adddel/db_adddel.cc        |   23 ++++++++++++++++++++
 glom/utility_widgets/db_adddel/db_adddel.h         |    8 +++++++
 .../db_adddel/db_adddel_withbuttons.cc             |    5 ++++
 .../db_adddel/db_adddel_withbuttons.h              |    2 +
 5 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5b94fb4..72f4414 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-11-11  Murray Cumming  <murrayc murrayc com>
+
+	List view and Related Records: Disable buttons when appropriate.
+
+	* glom/mode_data/db_adddel/db_adddel.[h|cc]: Handle the 
+	Gtk::TreeView::Selection::signal_changed() signal and call a 
+	new virtual on_selection_changed() method.
+	* glom/mode_data/db_adddel/db_adddel_withbuttons.[h|cc]:
+	Disable the Edit/Open and Delete buttons when there is no selection.
+	Bug #663812 (Andrà Klapper)
+
 2011-11-09  Murray Cumming  <murrayc murrayc com>
 
 	PostgreSQL backend: Use g_shell_quote().
diff --git a/glom/utility_widgets/db_adddel/db_adddel.cc b/glom/utility_widgets/db_adddel/db_adddel.cc
index 2ffa8aa..03b5661 100644
--- a/glom/utility_widgets/db_adddel/db_adddel.cc
+++ b/glom/utility_widgets/db_adddel/db_adddel.cc
@@ -160,6 +160,13 @@ DbAddDel::DbAddDel()
 
   signal_style_changed().connect(sigc::mem_fun(*this, &DbAddDel::on_self_style_changed));
 #endif // !GLOM_ENABLE_CLIENT_ONLY
+
+  Glib::RefPtr<Gtk::TreeView::Selection> refSelection = m_TreeView.get_selection();
+  if(refSelection)
+  {
+    refSelection->signal_changed().connect(
+      sigc::mem_fun(*this, &DbAddDel::on_treeview_selection_changed));
+  }
 }
 
 DbAddDel::~DbAddDel()
@@ -2930,4 +2937,20 @@ Gtk::TreeModel::iterator DbAddDel::get_row_selected()
   return get_item_selected();
 }
 
+void DbAddDel::on_treeview_selection_changed()
+{
+  Glib::RefPtr<Gtk::TreeView::Selection> refSelection = m_TreeView.get_selection();
+  if(!refSelection)
+    return;
+
+  const bool one_selected = (refSelection->count_selected_rows() > 0);
+  on_selection_changed(one_selected);
+}
+
+void DbAddDel::on_selection_changed(bool selection)
+{
+  m_refContextDel->set_sensitive(selection);
+  m_refContextAdd->set_sensitive(selection);
+}
+
 } //namespace Glom
diff --git a/glom/utility_widgets/db_adddel/db_adddel.h b/glom/utility_widgets/db_adddel/db_adddel.h
index 104d27a..a405cd1 100644
--- a/glom/utility_widgets/db_adddel/db_adddel.h
+++ b/glom/utility_widgets/db_adddel/db_adddel.h
@@ -306,6 +306,8 @@ protected:
   /// A common handler for the edit button, the context menu, etc.
   void do_user_requested_edit();
 
+  virtual void on_selection_changed(bool selection);
+
 private:
   virtual Gnome::Gda::Value treeview_get_key(const Gtk::TreeModel::iterator& row) const;
 
@@ -333,6 +335,7 @@ private:
 
   virtual bool on_button_press_event_Popup(GdkEventButton* event);
   virtual void on_treeview_button_press_event(GdkEventButton* event);
+  void on_treeview_selection_changed();
 
 protected:
   void on_MenuPopup_activate_Edit();
@@ -411,12 +414,17 @@ private:
   Gtk::TreeView m_TreeView;
   #endif
 
+<<<<<<< HEAD
 
   Gtk::TreeModel::ColumnRecord m_ColumnRecord;
 
   //typedef Gtk::ListStore type_model_store;
   typedef DbTreeModel type_model_store;
   Glib::RefPtr<type_model_store> m_refListStore;
+=======
+private:
+  Glib::RefPtr<DbTreeModel> m_refListStore;
+>>>>>>> edc483a... List view and Related Records: Disable buttons when appropriate.
 
   //Columns, not including the hidden internal columns:
   typedef std::vector<DbAddDelColumnInfo> type_ColumnTypes;
diff --git a/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc b/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc
index d3d289e..0e7a731 100644
--- a/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc
+++ b/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc
@@ -157,5 +157,10 @@ void DbAddDel_WithButtons::set_allow_view_details(bool val)
   setup_buttons();
 }
 
+void DbAddDel_WithButtons::on_selection_changed(bool selection)
+{
+  m_Button_Edit.set_sensitive(selection);
+  m_Button_Del.set_sensitive(selection);
+}
 
 } //namespace Glom
diff --git a/glom/utility_widgets/db_adddel/db_adddel_withbuttons.h b/glom/utility_widgets/db_adddel/db_adddel_withbuttons.h
index e3e8b5a..a2e1968 100644
--- a/glom/utility_widgets/db_adddel/db_adddel_withbuttons.h
+++ b/glom/utility_widgets/db_adddel/db_adddel_withbuttons.h
@@ -53,6 +53,8 @@ private:
   void on_button_edit();
   #endif //GLOM_ENABLE_MAEMO
 
+  virtual void on_selection_changed(bool selection);
+
   virtual void show_all_vfunc();
 
   //member widgets:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]