glom r1467 - in trunk: . glom glom/layout_item_dialogs glom/utility_widgets
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1467 - in trunk: . glom glom/layout_item_dialogs glom/utility_widgets
- Date: Sat, 22 Mar 2008 16:09:38 +0000 (GMT)
Author: jhs
Date: Sat Mar 22 16:09:38 2008
New Revision: 1467
URL: http://svn.gnome.org/viewvc/glom?rev=1467&view=rev
Log:
2008-03-22 Johannes Schmid <johannes schmid openismus com>
* glom/glom_developer.glade:
* glom/utility_widgets/Makefile.am:
* glom/utility_widgets/buttonglom.cc:
* glom/utility_widgets/buttonglom.h:
* glom/utility_widgets/dialog_buttonscript.cc:
* glom/utility_widgets/dialog_buttonscript.h:
* glom/utility_widgets/dialog_layoutitem_properties.cc:
* glom/utility_widgets/dialog_layoutitem_properties.h:
* glom/utility_widgets/labelglom.h:
* glom/utility_widgets/layoutwidgetutils.h:
Added popup-menu for buttons (and so refactoring to make it easier for other
widgets)
Added:
trunk/glom/utility_widgets/dialog_layoutitem_properties.cc
trunk/glom/utility_widgets/dialog_layoutitem_properties.h
trunk/glom/utility_widgets/layoutwidgetutils.h
Modified:
trunk/ChangeLog
trunk/glom/glom_developer.glade
trunk/glom/layout_item_dialogs/dialog_buttonscript.cc
trunk/glom/layout_item_dialogs/dialog_buttonscript.h
trunk/glom/utility_widgets/Makefile.am
trunk/glom/utility_widgets/buttonglom.cc
trunk/glom/utility_widgets/buttonglom.h
trunk/glom/utility_widgets/labelglom.h
Modified: trunk/glom/glom_developer.glade
==============================================================================
--- trunk/glom/glom_developer.glade (original)
+++ trunk/glom/glom_developer.glade Sat Mar 22 16:09:38 2008
@@ -14211,5 +14211,82 @@
</widget>
</child>
</widget>
-
+ <widget class="GtkDialog" id="dialog_layoutitem_properties">
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Properties</property>
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox29">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"><b>Label:</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="entry_label">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area29">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="button3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="button2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-apply</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-10</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>
Modified: trunk/glom/layout_item_dialogs/dialog_buttonscript.cc
==============================================================================
--- trunk/glom/layout_item_dialogs/dialog_buttonscript.cc (original)
+++ trunk/glom/layout_item_dialogs/dialog_buttonscript.cc Sat Mar 22 16:09:38 2008
@@ -87,6 +87,11 @@
return result;
}
+void Dialog_ButtonScript::get_script (const sharedptr<LayoutItem_Button>& script)
+{
+ script->set_script (m_text_view->get_buffer()->get_text() );
+}
+
void Dialog_ButtonScript::on_button_test()
{
const Glib::ustring calculation = m_text_view->get_buffer()->get_text();
Modified: trunk/glom/layout_item_dialogs/dialog_buttonscript.h
==============================================================================
--- trunk/glom/layout_item_dialogs/dialog_buttonscript.h (original)
+++ trunk/glom/layout_item_dialogs/dialog_buttonscript.h Sat Mar 22 16:09:38 2008
@@ -41,6 +41,7 @@
void set_script(const sharedptr<const LayoutItem_Button>& script, const Glib::ustring& table_name);
sharedptr<LayoutItem_Button> get_script() const;
+ void get_script (const sharedptr<LayoutItem_Button>& script);
protected:
void on_button_test();
Modified: trunk/glom/utility_widgets/Makefile.am
==============================================================================
--- trunk/glom/utility_widgets/Makefile.am (original)
+++ trunk/glom/utility_widgets/Makefile.am Sat Mar 22 16:09:38 2008
@@ -34,13 +34,16 @@
labelglom.h labelglom.cc \
dialog_choose_id.cc dialog_choose_id.h \
dialog_choose_date.cc dialog_choose_date.h \
- checkglom.h checkglom.cc
+ checkglom.h checkglom.cc \
+ layoutwidgetutils.h layoutwidgetutils.cc \
+ dialog_layoutitem_properties.cc dialog_layoutitem_properties.h
if !GLOM_ENABLE_CLIENT_ONLY
libutility_widgets_a_SOURCES += filechooserdialog_saveextras.cc filechooserdialog_saveextras.h \
dragbutton.cc dragbutton.h \
dragbar.cc dragbar.h \
sidebar.h sidebar.cc
+
endif
Modified: trunk/glom/utility_widgets/buttonglom.cc
==============================================================================
--- trunk/glom/utility_widgets/buttonglom.cc (original)
+++ trunk/glom/utility_widgets/buttonglom.cc Sat Mar 22 16:09:38 2008
@@ -21,6 +21,9 @@
#include "buttonglom.h"
#include <gtkmm/messagedialog.h>
#include "../application.h"
+#include "../libglom/glade_utils.h"
+#include "dialog_layoutitem_properties.h"
+#include "../layout_item_dialogs/dialog_buttonscript.h"
#include <glibmm/i18n.h>
//#include <sstream> //For stringstream
@@ -62,4 +65,79 @@
return dynamic_cast<App_Glom*>(pWindow);
}
+void ButtonGlom::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 (get_label());
+ if (dialog->run() == Gtk::RESPONSE_APPLY)
+ {
+ // We could just set the title of the layout item but than
+ // we would need to redraw the whole layout.
+ set_label (dialog->get_label());
+ m_pLayoutItem->set_title (dialog->get_label());
+ }
+ delete dialog;
+ }
+ }
+ catch(const Gnome::Glade::XmlError& ex)
+ {
+ std::cerr << ex.what() << std::endl;
+ }
+}
+
+void ButtonGlom::on_menu_details_activate()
+{
+ try
+ {
+ Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "window_button_script");
+
+ Dialog_ButtonScript* dialog = 0;
+ refXml->get_widget_derived("window_button_script", dialog);
+
+ if(dialog)
+ {
+ sharedptr<LayoutItem_Button> layout_item =
+ sharedptr<LayoutItem_Button>::cast_dynamic(get_layout_item());
+ dialog->set_script(layout_item, m_table_name);
+ int response = Glom::Utils::dialog_run_with_help(dialog, "window_button_script");
+ dialog->hide();
+ if(response == Gtk::RESPONSE_OK)
+ {
+ dialog->get_script(layout_item);
+ }
+
+ delete dialog;
+ }
+ }
+ catch(const Gnome::Glade::XmlError& ex)
+ {
+ std::cerr << ex.what() << std::endl;
+ }
+}
+
+bool ButtonGlom::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::Button::on_button_press_event(event);
+}
+
} //namespace Glom
Modified: trunk/glom/utility_widgets/buttonglom.h
==============================================================================
--- trunk/glom/utility_widgets/buttonglom.h (original)
+++ trunk/glom/utility_widgets/buttonglom.h Sat Mar 22 16:09:38 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>
@@ -33,7 +34,8 @@
class ButtonGlom
: public Gtk::Button,
- public LayoutWidgetBase
+ public LayoutWidgetBase,
+ public LayoutWidgetUtils
{
public:
explicit ButtonGlom(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
@@ -44,6 +46,10 @@
void init();
virtual App_Glom* get_application();
+
+ virtual void on_menu_properties_activate();
+ virtual void on_menu_details_activate();
+ virtual bool on_button_press_event(GdkEventButton *event);
};
} //namespace Glom
Added: trunk/glom/utility_widgets/dialog_layoutitem_properties.cc
==============================================================================
--- (empty file)
+++ trunk/glom/utility_widgets/dialog_layoutitem_properties.cc Sat Mar 22 16:09:38 2008
@@ -0,0 +1,50 @@
+/* Glom
+ *
+ * Copyright (C) 2001-2004 Murray Cumming
+ *
+ * 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 "dialog_layoutitem_properties.h"
+
+namespace Glom
+{
+
+Dialog_LayoutItem_Properties::Dialog_LayoutItem_Properties(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade)
+: Gtk::Dialog(cobject)
+{
+ refGlade->get_widget("entry_label", m_pEntryLabel);
+ show_all_children ();
+}
+
+#if 0
+Dialog_LayoutItem_Properties::~Dialog_LayoutItem_Properties()
+{
+}
+#endif
+
+void Dialog_LayoutItem_Properties::set_label (Glib::ustring label)
+{
+ m_pEntryLabel->set_text(label);
+}
+
+Glib::ustring Dialog_LayoutItem_Properties::get_label() const
+{
+ return m_pEntryLabel->get_text();
+}
+
+} // namespace Glom
+
Added: trunk/glom/utility_widgets/dialog_layoutitem_properties.h
==============================================================================
--- (empty file)
+++ trunk/glom/utility_widgets/dialog_layoutitem_properties.h Sat Mar 22 16:09:38 2008
@@ -0,0 +1,45 @@
+/* Glom
+ *
+ * Copyright (C) 2001-2004 Murray Cumming
+ *
+ * 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 DIALOG_LAYOUTITEM_PROPERTIES_H
+#define DIALOG_LAYOUTITEM_PROPERTIES_H
+
+#include <gtkmm.h>
+#include <libglademm.h>
+
+namespace Glom
+{
+
+class Dialog_LayoutItem_Properties : public Gtk::Dialog
+{
+public:
+ Dialog_LayoutItem_Properties(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
+ //virtual ~Dialog_LayoutItem_Properties();
+
+ Glib::ustring get_label() const;
+ void set_label (Glib::ustring label);
+
+protected:
+ Gtk::Entry* m_pEntryLabel;
+};
+
+} //namespace Glom
+
+#endif //DIALOG_LAYOUTITEM_PROPERTIES_H
Modified: trunk/glom/utility_widgets/labelglom.h
==============================================================================
--- trunk/glom/utility_widgets/labelglom.h (original)
+++ trunk/glom/utility_widgets/labelglom.h Sat Mar 22 16:09:38 2008
@@ -34,6 +34,7 @@
class LabelGlom
: public Gtk::Label,
public LayoutWidgetBase
+ //public LayoutWidgetUtils
{
public:
explicit LabelGlom(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
@@ -45,6 +46,8 @@
void init();
virtual App_Glom* get_application();
+
+ //virtual void on_menu_properties_activate();
};
} //namespace Glom
Added: trunk/glom/utility_widgets/layoutwidgetutils.h
==============================================================================
--- (empty file)
+++ trunk/glom/utility_widgets/layoutwidgetutils.h Sat Mar 22 16:09:38 2008
@@ -0,0 +1,54 @@
+/*
+ * glom
+ *
+ * glom is free software.
+ *
+ * You may 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.
+ *
+ * glom 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 glom. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _GLOM_LAYOUT_WIDGET_UTILS_H_
+#define _GLOM_LAYOUT_WIDGET_UTILS_H_
+
+#include <gtkmm.h>
+
+namespace Glom
+{
+
+class LayoutWidgetUtils: public sigc::trackable
+{
+ public:
+ LayoutWidgetUtils();
+ virtual ~LayoutWidgetUtils();
+
+ protected:
+ void setup_util_menu();
+ Gtk::Menu* m_pPopupMenuUtils;
+
+ virtual void on_menu_properties_activate() = 0;
+ // It's not really important to implement this though you should deactivate
+ // the menu item then
+ virtual void on_menu_details_activate() {};
+
+ Glib::RefPtr<Gtk::Action> m_refUtilProperties;
+ Glib::RefPtr<Gtk::Action> m_refUtilDetails;
+ Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
+ Glib::RefPtr<Gtk::UIManager> m_refUIManager;
+};
+
+} // namespace Glom
+
+#endif // _GLOM_LAYOUT_WIDGET_UTILS_H_
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]