glom r1445 - in trunk: . glom/mode_data glom/utility_widgets



Author: jhs
Date: Tue Mar  4 11:17:14 2008
New Revision: 1445
URL: http://svn.gnome.org/viewvc/glom?rev=1445&view=rev

Log:
2008-03-04  Johannes Schmid  <jhs gnome org>

	* glom/mode_data/box_data_details.cc:
	Fixed a crasher (probably related to an empty table)
	
	* glom/utility_widgets/Makefile.am:
	* glom/utility_widgets/datawidget.cc:
	* glom/utility_widgets/checkglom.h: (added)
	* glom/utility_widgets/checkglom.cc: (added)
	Add a popup menu to checkbutton fields


Added:
   trunk/glom/utility_widgets/checkglom.cc
   trunk/glom/utility_widgets/checkglom.h
Modified:
   trunk/ChangeLog
   trunk/glom/mode_data/box_data_details.cc
   trunk/glom/utility_widgets/Makefile.am
   trunk/glom/utility_widgets/datawidget.cc

Modified: trunk/glom/mode_data/box_data_details.cc
==============================================================================
--- trunk/glom/mode_data/box_data_details.cc	(original)
+++ trunk/glom/mode_data/box_data_details.cc	Tue Mar  4 11:17:14 2008
@@ -794,7 +794,7 @@
     {
       //It is not auto-generated:
 
-      if(strFieldName == m_field_primary_key->get_name()) //if it is the primary key that is being edited.
+      if(m_field_primary_key && strFieldName == m_field_primary_key->get_name()) //if it is the primary key that is being edited.
       {
         if(!check_entered_value_for_uniqueness(m_table_name, layout_field, field_value, window))
         {

Modified: trunk/glom/utility_widgets/Makefile.am
==============================================================================
--- trunk/glom/utility_widgets/Makefile.am	(original)
+++ trunk/glom/utility_widgets/Makefile.am	Tue Mar  4 11:17:14 2008
@@ -33,7 +33,8 @@
                                imageglom.h imageglom.cc \
                                labelglom.h labelglom.cc \
                                dialog_choose_id.cc dialog_choose_id.h \
-                               dialog_choose_date.cc dialog_choose_date.h
+                               dialog_choose_date.cc dialog_choose_date.h \
+                               checkglom.h checkglom.cc
 
 if !GLOM_ENABLE_CLIENT_ONLY
 libutility_widgets_a_SOURCES += filechooserdialog_saveextras.cc filechooserdialog_saveextras.h \

Added: trunk/glom/utility_widgets/checkglom.cc
==============================================================================
--- (empty file)
+++ trunk/glom/utility_widgets/checkglom.cc	Tue Mar  4 11:17:14 2008
@@ -0,0 +1,102 @@
+/* Glom
+ *
+ * Copyright (C) 2008 Johannes Schmid
+ *
+ * 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 "checkglom.h"
+#include <gtkmm/messagedialog.h>
+#include "../dialog_invalid_data.h"
+#include "../application.h"
+#include <glibmm/i18n.h>
+
+#include <iostream>   // for cout, endl
+
+namespace Glom
+{
+
+CheckGlom::CheckGlom(Glib::ustring title)
+  : Gtk::CheckButton(title)
+{
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+  setup_menu();
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
+  init();
+}
+
+CheckGlom::~CheckGlom()
+{
+}
+
+void CheckGlom::init()
+{
+
+}
+
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+bool CheckGlom::on_button_press_event(GdkEventButton *event)
+{
+  //Enable/Disable items.
+  //We did this earlier, but get_application is more likely to work now:
+  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_refContextAddField);
+    pApp->add_developer_action(m_refContextAddRelatedRecords);
+    pApp->add_developer_action(m_refContextAddGroup);
+
+    pApp->update_userlevel_ui(); //Update our action's sensitivity. 
+
+    //Only show this popup in developer mode, so operators still see the default GtkCheck context menu.
+    //TODO: It would be better to add it somehow to the standard context menu.
+    if(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+    {
+      GdkModifierType mods;
+      gdk_window_get_pointer( Gtk::Widget::gobj()->window, 0, 0, &mods );
+      if(mods & GDK_BUTTON3_MASK)
+      {
+        //Give user choices of actions on this item:
+        m_pMenuPopup->popup(event->button, event->time);
+        return true; //We handled this event.
+      }
+    }
+  }
+  return Gtk::CheckButton::on_button_press_event(event);
+}
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
+App_Glom* CheckGlom::get_application()
+{
+  Gtk::Container* pWindow = get_toplevel();
+  //TODO: This only works when the child widget is already in its parent.
+
+  return dynamic_cast<App_Glom*>(pWindow);
+}
+
+void CheckGlom::set_value(const Gnome::Gda::Value& value)
+{
+  set_active (value.get_boolean());
+}
+
+Gnome::Gda::Value CheckGlom::get_value() const
+{
+  return Gnome::Gda::Value(get_active());
+}
+
+} //namespace Glom

Added: trunk/glom/utility_widgets/checkglom.h
==============================================================================
--- (empty file)
+++ trunk/glom/utility_widgets/checkglom.h	Tue Mar  4 11:17:14 2008
@@ -0,0 +1,60 @@
+/* Glom
+ *
+ * Copyright (C) 2008 Johannes Schmid
+ *
+ * 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_UTILITY_WIDGETS_CHECK_GLOM_H
+#define GLOM_UTILITY_WIDGETS_CHECK_GLOM_H
+
+#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY
+
+#include <gtkmm.h>
+#include <glom/libglom/data_structure/field.h>
+#include "layoutwidgetfield.h"
+#include <libglademm.h>
+
+namespace Glom
+{
+
+class App_Glom;
+
+class CheckGlom
+: public Gtk::CheckButton,
+  public LayoutWidgetField
+{
+public:
+  explicit CheckGlom(Glib::ustring title);
+  virtual ~CheckGlom();
+
+  virtual void set_value(const Gnome::Gda::Value& value);
+  virtual Gnome::Gda::Value get_value() const;    
+
+protected:
+  void init();
+
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+  virtual bool on_button_press_event(GdkEventButton *event); //override
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
+  virtual App_Glom* get_application();
+};
+
+} //namespace Glom
+
+#endif //GLOM_UTILITY_WIDGETS_CHECK_GLOM_H
+

Modified: trunk/glom/utility_widgets/datawidget.cc
==============================================================================
--- trunk/glom/utility_widgets/datawidget.cc	(original)
+++ trunk/glom/utility_widgets/datawidget.cc	Tue Mar  4 11:17:14 2008
@@ -20,6 +20,7 @@
 
 #include "datawidget.h"
 #include "entryglom.h"
+#include "checkglom.h"
 #include "labelglom.h"
 #include "comboentryglom.h"
 #include "comboglom.h"
@@ -54,13 +55,14 @@
   const Glib::ustring title = field->get_title_or_name();
   if(glom_type == Field::TYPE_BOOLEAN)
   {
-    Gtk::CheckButton* checkbutton = Gtk::manage( new Gtk::CheckButton( title ) );
+    CheckGlom* checkbutton = Gtk::manage( new CheckGlom( title ) );
     checkbutton->show();
     checkbutton->signal_toggled().connect( sigc::mem_fun(*this, &DataWidget::on_widget_edited)  );
 
     //TODO: entry->signal_user_requested_layout().connect( sigc::mem_fun(*this, &DataWidget::on_child_user_requested_layout );
 
     m_child = checkbutton;
+    pFieldWidget = checkbutton;
 
     m_label.set_text( Glib::ustring() ); //It is not used.
   }



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