[niepce] * Add headers to dialogs.



commit eed87940a6210796aaa12f9b989f0aa94835c991
Author: Hubert Figuiere <hub figuiere net>
Date:   Sun Apr 12 04:04:48 2009 -0400

    	* Add headers to dialogs.
---
 ChangeLog                                   |    4 +
 configure.ac                                |    1 +
 src/ext/Makefile.am                         |    2 +-
 src/ext/libview/Makefile.am                 |    8 ++
 src/ext/libview/header.cc                   |  168 +++++++++++++++++++++++++++
 src/ext/libview/header.hh                   |   63 ++++++++++
 src/fwk/toolkit/dialog.cpp                  |   12 ++
 src/fwk/toolkit/dialog.hpp                  |    5 +
 src/niepce/Makefile.am                      |    1 +
 src/niepce/ui/dialogs/editlabels.cpp        |    4 +
 src/niepce/ui/dialogs/editlabels.ui         |   24 ++---
 src/niepce/ui/dialogs/importdialog.cpp      |    4 +
 src/niepce/ui/dialogs/importdialog.ui       |   12 ++-
 src/niepce/ui/dialogs/preferences.ui        |    8 +-
 src/niepce/ui/dialogs/preferencesdialog.cpp |    2 +
 15 files changed, 298 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e0092b5..ed669bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-04-12  Hubert Figuiere  <hub figuiere net>
+
+	* Add headers to dialogs.
+
 2009-04-11  Hubert Figuiere  <hub figuiere net>
 
 	* Remove boost::signal
diff --git a/configure.ac b/configure.ac
index bda62af..a7eaba3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,6 +168,7 @@ data/themes/Makefile
 src/Makefile
 src/ext/Makefile
 src/ext/libgdl/Makefile
+src/ext/libview/Makefile
 src/niepce/ui/Makefile
 src/niepce/ui/dialogs/Makefile
 src/niepce/ui/thumb-view/Makefile
diff --git a/src/ext/Makefile.am b/src/ext/Makefile.am
index 75709c1..4f515f6 100644
--- a/src/ext/Makefile.am
+++ b/src/ext/Makefile.am
@@ -1,5 +1,5 @@
 
 EXTRA_DIST = README
 
-SUBDIRS = libgdl
+SUBDIRS = libgdl libview
 # DIST_SUBDIRS = 
diff --git a/src/ext/libview/Makefile.am b/src/ext/libview/Makefile.am
new file mode 100644
index 0000000..11f830c
--- /dev/null
+++ b/src/ext/libview/Makefile.am
@@ -0,0 +1,8 @@
+
+
+INCLUDES = -I$(top_srcdir)/src/ext/ @LIBGTKMM_CFLAGS@
+
+noinst_LIBRARIES = libview.a
+
+
+libview_a_SOURCES = header.hh header.cc
\ No newline at end of file
diff --git a/src/ext/libview/header.cc b/src/ext/libview/header.cc
new file mode 100644
index 0000000..46a620d
--- /dev/null
+++ b/src/ext/libview/header.cc
@@ -0,0 +1,168 @@
+/* *************************************************************************
+ * Copyright (c) 2005 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * *************************************************************************/
+
+/*
+ * header.cc --
+ *
+ *      Header widget. Draw text inside a (hopefully) attractive frame.
+ */
+
+#include <gtkmm/settings.h>
+
+#include <gtk/gtkwidget.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkrc.h>
+
+#include <libview/header.hh>
+
+
+namespace view {
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * view::Header::Header --
+ *
+ *      Constructor.
+ *
+ * Results:
+ *      None
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Header::Header(const Glib::ustring &markup, // IN: Markup text
+               Alignment align)             // IN: Default alignment
+   : Gtk::MenuItem(),
+     mLabel()
+{
+   mLabel.show();
+   add(mLabel);
+
+   SetMarkup(markup);
+   SetAlignment(align);
+
+   select();
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * view::Header::SetMarkup --
+ *
+ *      Set the markup text of the header.
+ *
+ * Results:
+ *      None
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+Header::SetMarkup(const Glib::ustring& markup) // IN: The markup text
+{
+   mLabel.set_markup(markup);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * view::Header::SetAlignment --
+ *
+ *      Sets the alignment of the text inside the header.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+Header::SetAlignment(Alignment align) // IN: The new alignment
+{
+   switch (align) {
+   case LEFT:
+      mLabel.set_alignment(0, 0.5);
+      mLabel.set_justify(Gtk::JUSTIFY_LEFT);
+      break;
+
+   case CENTER:
+      mLabel.set_alignment(0.5, 0.5);
+      mLabel.set_justify(Gtk::JUSTIFY_CENTER);
+      break;
+
+   case RIGHT:
+      mLabel.set_alignment(1, 0.5);
+      mLabel.set_justify(Gtk::JUSTIFY_RIGHT);
+      break;
+
+   default:
+      g_assert_not_reached();
+   }
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * view::Header::on_style_changed --
+ *
+ *      Override method to handle style changes. Simply apply our style to
+ *      the child label.
+ *
+ *      This method should not be necessary but many theme engines are broken
+ *      so that a menu item in an unexpected place is not drawn correctly.
+ *      Examples include Bluecurve and Industrial. The Mist theme is so broken
+ *      that this workaround won't fix it. Such is life.
+ *
+ * Results:
+ *      None
+ *
+ * Side effects:
+ *      Label may redraw/resize.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+Header::on_style_changed(const Glib::RefPtr<Gtk::Style> &oldStyle) // IN
+{
+   Gtk::MenuItem::on_style_changed(oldStyle);
+
+   mLabel.set_style(get_style());
+}
+
+
+} // namespace view
diff --git a/src/ext/libview/header.hh b/src/ext/libview/header.hh
new file mode 100644
index 0000000..df04c1e
--- /dev/null
+++ b/src/ext/libview/header.hh
@@ -0,0 +1,63 @@
+/* *************************************************************************
+ * Copyright (c) 2005 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * *************************************************************************/
+
+/*
+ * header.hh --
+ *
+ *      Header widget. Draw text inside a (hopefully) attractive frame.
+ */
+
+#ifndef LIBVIEW_HEADER_HH
+#define LIBVIEW_HEADER_HH
+
+
+#include <gtkmm/menuitem.h>
+#include <gtkmm/label.h>
+
+
+namespace view {
+
+
+class Header
+   : public Gtk::MenuItem
+{
+public:
+   enum Alignment { LEFT, CENTER, RIGHT };
+
+   Header(const Glib::ustring &markup, Alignment align = LEFT);
+
+   void SetMarkup(const Glib::ustring &markup);
+   void SetAlignment(Alignment align);
+
+protected:
+   void on_style_changed(const Glib::RefPtr<Gtk::Style> &oldStyle);
+
+private:
+   Gtk::Label mLabel;
+};
+
+
+} // namespace view
+
+
+#endif // LIBVIEW_HEADER_HH
diff --git a/src/fwk/toolkit/dialog.cpp b/src/fwk/toolkit/dialog.cpp
index 7fd12c4..a8fc185 100644
--- a/src/fwk/toolkit/dialog.cpp
+++ b/src/fwk/toolkit/dialog.cpp
@@ -17,6 +17,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "libview/header.hh"
+
 #include "dialog.hpp"
 
 
@@ -24,6 +26,16 @@ namespace fwk {
 
 
 
+void Dialog::add_header(const Glib::ustring & label)
+{
+    Gtk::VBox * vbox;
+
+    builder()->get_widget("dialog-vbox1", vbox);
+    view::Header * header = manage(new view::Header(label));
+    header->show();
+    vbox->pack_start(*header, false, true);
+}
+
 int Dialog::run_modal(const Frame::Ptr & parent)
 {
     int result;
diff --git a/src/fwk/toolkit/dialog.hpp b/src/fwk/toolkit/dialog.hpp
index e13d5b4..6afe079 100644
--- a/src/fwk/toolkit/dialog.hpp
+++ b/src/fwk/toolkit/dialog.hpp
@@ -49,6 +49,11 @@ public:
     virtual void setup_widget() = 0;
     Gtk::Dialog & gtkDialog()
         { return static_cast<Gtk::Dialog&>(gtkWindow()); }
+
+    /** add a header widget at the top of the "dialog-vbox1"
+     */
+    void add_header(const Glib::ustring & label);
+
     int run_modal();
     int run_modal(const Frame::Ptr & parent);
 protected:
diff --git a/src/niepce/Makefile.am b/src/niepce/Makefile.am
index f9e06bc..d431a3f 100644
--- a/src/niepce/Makefile.am
+++ b/src/niepce/Makefile.am
@@ -22,6 +22,7 @@ niepce_LDADD = \
 	$(top_builddir)/src/fwk/utils/libniepceutils.a \
 	$(top_builddir)/src/ncr/libncr.a \
 	$(top_builddir)/src/ext/libgdl/libgdl.a \
+	$(top_builddir)/src/ext/libview/libview.a \
 	@LIBGLIBMM_LIBS@ \
 	@LIBGTKMM_LIBS@ @SQLITE3_LIBS@ \
 	@GNOMEVFS_LIBS@ @GCONF_LIBS@ @BOOST_THREAD_LIBS@ \
diff --git a/src/niepce/ui/dialogs/editlabels.cpp b/src/niepce/ui/dialogs/editlabels.cpp
index 74cc14a..4d29626 100644
--- a/src/niepce/ui/dialogs/editlabels.cpp
+++ b/src/niepce/ui/dialogs/editlabels.cpp
@@ -20,6 +20,7 @@
 
 #include <boost/format.hpp>
 
+#include <glibmm/i18n.h>
 #include <gtkmm/entry.h>
 #include <gtkmm/label.h>
 
@@ -38,6 +39,9 @@ EditLabels::EditLabels(const eng::Label::List & labels)
 void EditLabels::setup_widget()
 {
     Glib::RefPtr<Gtk::Builder> _builder = builder();
+
+    add_header(_("<b>Edit Labels</b>"));
+
     const char * color_fmt = "color%1%";
     const char * value_fmt = "value%1%";
     for(size_t i = 0; i < 5; i++) {
diff --git a/src/niepce/ui/dialogs/editlabels.ui b/src/niepce/ui/dialogs/editlabels.ui
index 7adc31f..8ba01d7 100644
--- a/src/niepce/ui/dialogs/editlabels.ui
+++ b/src/niepce/ui/dialogs/editlabels.ui
@@ -12,6 +12,9 @@
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
         <child>
+          <placeholder/>
+        </child>
+        <child>
           <object class="GtkFrame" id="frame1">
             <property name="visible">True</property>
             <property name="label_xalign">0</property>
@@ -212,14 +215,15 @@
             <child type="label">
               <object class="GtkLabel" id="dialog_title">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">&lt;b&gt;Edit Labels&lt;/b&gt;</property>
+                <property name="label" translatable="yes">&lt;b&gt;Labels&lt;/b&gt;</property>
                 <property name="use_markup">True</property>
               </object>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="position">1</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
           </packing>
         </child>
         <child internal-child="action_area">
@@ -227,22 +231,11 @@
             <property name="visible">True</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="button2">
-                <property name="label" translatable="yes">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
+              <placeholder/>
             </child>
             <child>
               <object class="GtkButton" id="button1">
-                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="label" translatable="yes">gtk-close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -264,7 +257,6 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="1">button2</action-widget>
       <action-widget response="0">button1</action-widget>
     </action-widgets>
   </object>
diff --git a/src/niepce/ui/dialogs/importdialog.cpp b/src/niepce/ui/dialogs/importdialog.cpp
index 2ef1844..3e62a79 100644
--- a/src/niepce/ui/dialogs/importdialog.cpp
+++ b/src/niepce/ui/dialogs/importdialog.cpp
@@ -54,8 +54,12 @@ void ImportDialog::setup_widget()
     if(m_is_setup) {
         return;
     }
+
+    add_header(_("Import"));
+
     Glib::RefPtr<Gtk::Builder> _builder = builder();
     Gtk::Button *select_directories = NULL;
+
     _builder->get_widget("select_directories", select_directories);
     select_directories->signal_clicked().connect(
         sigc::mem_fun(*this, &ImportDialog::do_select_directories));
diff --git a/src/niepce/ui/dialogs/importdialog.ui b/src/niepce/ui/dialogs/importdialog.ui
index 63089a6..910a99d 100644
--- a/src/niepce/ui/dialogs/importdialog.ui
+++ b/src/niepce/ui/dialogs/importdialog.ui
@@ -26,11 +26,14 @@
     <property name="type_hint">dialog</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox2">
+      <object class="GtkVBox" id="dialog-vbox1">
         <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>
+          <placeholder/>
+        </child>
+        <child>
           <object class="GtkVBox" id="vbox2">
             <property name="visible">True</property>
             <property name="spacing">8</property>
@@ -222,7 +225,8 @@
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="position">1</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
           </packing>
         </child>
         <child internal-child="action_area">
@@ -240,6 +244,8 @@
                 <property name="use_stock">True</property>
               </object>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -253,6 +259,8 @@
                 <property name="use_underline">True</property>
               </object>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
diff --git a/src/niepce/ui/dialogs/preferences.ui b/src/niepce/ui/dialogs/preferences.ui
index 078c624..bae6fdf 100644
--- a/src/niepce/ui/dialogs/preferences.ui
+++ b/src/niepce/ui/dialogs/preferences.ui
@@ -16,6 +16,9 @@
         <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>
+          <placeholder/>
+        </child>
+        <child>
           <object class="GtkNotebook" id="notebook1">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
@@ -108,7 +111,8 @@
             </child>
           </object>
           <packing>
-            <property name="position">1</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
           </packing>
         </child>
         <child internal-child="action_area">
@@ -129,6 +133,8 @@
                 <property name="use_stock">True</property>
               </object>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
diff --git a/src/niepce/ui/dialogs/preferencesdialog.cpp b/src/niepce/ui/dialogs/preferencesdialog.cpp
index fa29517..ff067b4 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.cpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.cpp
@@ -39,6 +39,8 @@ void PreferencesDialog::setup_widget()
         return;
     }
 
+    add_header(_("Preferences"));
+
     Gtk::ComboBox * theme_combo = NULL;
     Gtk::CheckButton * reopen_checkbutton = NULL;
     utils::DataBinderPool * binder_pool = new utils::DataBinderPool();



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