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



Author: jhs
Date: Wed Mar 26 09:24:01 2008
New Revision: 1471
URL: http://svn.gnome.org/viewvc/glom?rev=1471&view=rev

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

	* glom/mode_data/flowtablewithfields.cc:
	* glom/utility_widgets/dialog_layoutitem_properties.cc:
	* glom/utility_widgets/labelglom.cc:
	* glom/utility_widgets/labelglom.h:	
	Added popup menu for LabelGlom
	
	* glom/utility_widgets/dragbutton.h:
	Make a method const

Modified:
   trunk/ChangeLog
   trunk/glom/mode_data/flowtablewithfields.cc
   trunk/glom/utility_widgets/dialog_layoutitem_properties.cc
   trunk/glom/utility_widgets/dragbutton.h
   trunk/glom/utility_widgets/labelglom.cc
   trunk/glom/utility_widgets/labelglom.h

Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc	(original)
+++ trunk/glom/mode_data/flowtablewithfields.cc	Wed Mar 26 09:24:01 2008
@@ -515,8 +515,9 @@
   Gtk::Alignment* alignment_label = Gtk::manage(new Gtk::Alignment());
   alignment_label->set(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   alignment_label->show();
-
-  LabelGlom* label = Gtk::manage(new LabelGlom(layoutitem_text->get_text(), 0.0 /* xalign */, 0.5 /* yalign */)); //The alignment here seems to be necessary as well (or instead of) the parent Gtk::Alignment.
+  
+  const Glib::ustring text = layoutitem_text->get_text();
+  LabelGlom* label = Gtk::manage(new LabelGlom(text, 0.0 /* xalign */, 0.5 /* yalign */)); //The alignment here seems to be necessary as well (or instead of) the parent Gtk::Alignment.
   label->set_layout_item (layoutitem_text, table_name);
   label->show();
   alignment_label->add(*label);
@@ -541,7 +542,8 @@
     alignment_title->set(Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
     alignment_title->show();
 
-    Gtk::Label* title_label = Gtk::manage(new Gtk::Label(title));
+    LabelGlom* title_label = Gtk::manage(new LabelGlom(title, 0, 0, false, true));
+    title_label->set_layout_item (layoutitem_text, table_name);
     title_label->show();
     alignment_title->add(*title_label);
 

Modified: trunk/glom/utility_widgets/dialog_layoutitem_properties.cc
==============================================================================
--- trunk/glom/utility_widgets/dialog_layoutitem_properties.cc	(original)
+++ trunk/glom/utility_widgets/dialog_layoutitem_properties.cc	Wed Mar 26 09:24:01 2008
@@ -43,8 +43,8 @@
 
 Glib::ustring Dialog_LayoutItem_Properties::get_label() const
 {
-  return m_pEntryLabel->get_text();  
+  return m_pEntryLabel->get_text();
 }
 
-} // namespace Glom
+} // Glom
 

Modified: trunk/glom/utility_widgets/dragbutton.h
==============================================================================
--- trunk/glom/utility_widgets/dragbutton.h	(original)
+++ trunk/glom/utility_widgets/dragbutton.h	Wed Mar 26 09:24:01 2008
@@ -37,7 +37,7 @@
     ~DragButton();
 
   
-    static gchar* get_target() {return "flowtable";};
+    static const gchar* get_target() {return "flowtable";};
   protected:
 		virtual void on_drag_begin(const Glib::RefPtr<Gdk::DragContext>& drag_context);
     virtual void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, 

Modified: trunk/glom/utility_widgets/labelglom.cc
==============================================================================
--- trunk/glom/utility_widgets/labelglom.cc	(original)
+++ trunk/glom/utility_widgets/labelglom.cc	Wed Mar 26 09:24:01 2008
@@ -22,21 +22,12 @@
 #include <gtkmm/messagedialog.h>
 #include "../application.h"
 #include <glibmm/i18n.h>
+#include "dialog_layoutitem_properties.h"
 //#include <sstream> //For stringstream
 
 namespace Glom
 {
 
-LabelGlom::LabelGlom(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& /* refGlade */)
-: Gtk::Label(cobject)
-{
-#ifndef GLOM_ENABLE_CLIENT_ONLY
-  setup_menu();
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
-  init();
-}
-
 LabelGlom::LabelGlom()
 {
 #ifndef GLOM_ENABLE_CLIENT_ONLY
@@ -46,8 +37,9 @@
   init();
 }
 
-LabelGlom::LabelGlom(const Glib::ustring& label, float xalign, float yalign, bool mnemonic)
-: Gtk::Label(label, xalign, yalign, mnemonic)
+LabelGlom::LabelGlom(const Glib::ustring& label, float xalign, float yalign, bool mnemonic, bool title)
+: m_label(label, xalign, yalign, mnemonic),
+  m_title(title)
 {
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   setup_menu();
@@ -62,7 +54,10 @@
 
 void LabelGlom::init()
 {
-
+  add(m_label);
+  m_label.show();
+  set_events (Gdk::BUTTON_PRESS_MASK);
+  m_refUtilDetails->set_visible(false);
 }
 
 App_Glom* LabelGlom::get_application()
@@ -73,5 +68,62 @@
   return dynamic_cast<App_Glom*>(pWindow);
 }
 
+void LabelGlom::on_menu_properties_activate()
+{
+  try
+  {
+    Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(GLOM_GLADEDIR "glom_developer.glade", "dialog_layoutitem_properties");
+    
+    Dialog_LayoutItem_Properties* dialog = new Dialog_LayoutItem_Properties (0, refXml);
+    refXml->get_widget_derived("dialog_layoutitem_properties", dialog);
+    
+    if (dialog)
+    {
+      dialog->set_label (m_label.get_label());
+      if (dialog->run() == Gtk::RESPONSE_APPLY)
+      {
+        Glib::ustring label(dialog->get_label());
+        sharedptr<LayoutItem_Text> layoutitem_text = sharedptr<LayoutItem_Text>::cast_dynamic(m_pLayoutItem);
+        if (layoutitem_text)
+        {
+          // We could just set the title of the layout item but than
+          // we would need to redraw the whole layout.
+          m_label.set_label (label);
+          if (m_title)
+          {
+            std::cout << "label: " << label << std::endl;
+            layoutitem_text->set_title (label);
+          }
+          else
+          {
+            layoutitem_text->set_text (label);
+          }
+        }
+      }
+      delete dialog;
+    }
+  }
+  catch(const Gnome::Glade::XmlError& ex)
+  {
+    std::cerr << ex.what() << std::endl;
+  }
+}
+
+bool LabelGlom::on_button_press_event(GdkEventButton *event)
+{
+  App_Glom* pApp = get_application();
+  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_pPopupMenuUtils->popup(event->button, event->time);
+      return true; //We handled this event.
+    }
+  }
+  return Gtk::EventBox::on_button_press_event(event);
+}
 
 } //namespace Glom

Modified: trunk/glom/utility_widgets/labelglom.h
==============================================================================
--- trunk/glom/utility_widgets/labelglom.h	(original)
+++ trunk/glom/utility_widgets/labelglom.h	Wed Mar 26 09:24:01 2008
@@ -23,6 +23,7 @@
 
 #include <gtkmm.h>
 #include "layoutwidgetbase.h"
+#include "layoutwidgetutils.h"
 #include <glom/libglom/data_structure/layout/layoutitem_button.h>
 #include <libglademm.h>
 
@@ -32,14 +33,13 @@
 class App_Glom;
 
 class LabelGlom
-: public Gtk::Label,
-  public LayoutWidgetBase
-  //public LayoutWidgetUtils
+: public Gtk::EventBox,
+  public LayoutWidgetBase,
+  public LayoutWidgetUtils
 {
 public:
-  explicit LabelGlom(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
   explicit LabelGlom();
-  explicit LabelGlom(const Glib::ustring& label, float xalign, float yalign, bool mnemonic = false);
+  explicit LabelGlom(const Glib::ustring& label, float xalign, float yalign, bool mnemonic = false, bool title = false);
   virtual ~LabelGlom();
 
 protected:
@@ -47,7 +47,12 @@
 
   virtual App_Glom* get_application();
     
-  //virtual void on_menu_properties_activate();
+  Gtk::Label m_label;
+  bool m_title;
+    
+  virtual bool on_button_press_event(GdkEventButton *event);
+  virtual void on_menu_properties_activate();
+    
 };
 
 } //namespace Glom



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