paperbox r221 - in trunk: . po src ui



Author: markoa
Date: Wed Nov 19 22:12:22 2008
New Revision: 221
URL: http://svn.gnome.org/viewvc/paperbox?rev=221&view=rev

Log:
A dialog with basic document properties

Added:
   trunk/src/dialog-properties.cc
   trunk/src/dialog-properties.hh
   trunk/ui/dialog-properties.glade
Modified:
   trunk/ChangeLog
   trunk/po/POTFILES.in
   trunk/src/Makefile.am
   trunk/src/main-window.cc
   trunk/src/main-window.hh
   trunk/src/paths.hh
   trunk/ui/Makefile.am

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Wed Nov 19 22:12:22 2008
@@ -6,5 +6,6 @@
 src/main.cc
 src/main-window.cc
 ui/dialog-categories.glade
+ui/dialog-properties.glade
 ui/dialog-tag-entry.glade
 ui/window-main.glade

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Wed Nov 19 22:12:22 2008
@@ -23,6 +23,8 @@
 	config.hh \
 	dialog-entry.cc \
 	dialog-entry.hh \
+	dialog-properties.cc \
+	dialog-properties.hh \
 	dialog-tag-entry.cc \
 	dialog-tag-entry.hh \
 	document-tag-cloud-model.cc \

Added: trunk/src/dialog-properties.cc
==============================================================================
--- (empty file)
+++ trunk/src/dialog-properties.cc	Wed Nov 19 22:12:22 2008
@@ -0,0 +1,100 @@
+/*
+ *  Paperbox - dialog-properties.cc
+ *
+ *  Copyright (C) 2008 Marko Anastasov
+ *
+ *  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 Library 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.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <vector>
+#include <glibmm-utils/ustring.h>
+#include "dialog-properties.hh"
+#include "document.hh"
+#include "paths.hh"
+
+namespace paperbox {
+
+    DialogProperties::DialogProperties(GtkDialog* cobject,
+            const Glib::RefPtr<Gnome::Glade::Xml>& glade)
+        :
+        Gtk::Dialog(cobject),
+        glade_(glade),
+        label_location_(0),
+        label_title_(0),
+        label_author_(0),
+        label_pages_(0),
+        label_tags_(0)
+    {
+        glade_->get_widget("label_location_caption", label_location_);
+        g_assert(label_location_);
+
+        glade_->get_widget("label_title_caption", label_title_);
+        g_assert(label_title_);
+
+        glade_->get_widget("label_author_caption", label_author_);
+        g_assert(label_author_);
+
+        glade_->get_widget("label_pages_caption", label_pages_);
+        g_assert(label_pages_);
+
+        glade_->get_widget("label_tags_caption", label_tags_);
+        g_assert(label_tags_);
+    }
+
+    DialogProperties*
+    DialogProperties::create()
+    {
+        Glib::RefPtr<Gnome::Glade::Xml> glade_xml =
+            Gnome::Glade::Xml::create(glade_dialog_properties);
+
+        DialogProperties* p = 0;
+        glade_xml->get_widget_derived("dialog_properties", p);
+        return p;
+    }
+
+    int
+    DialogProperties::run(boost::shared_ptr<Document>& doc)
+    {
+        if (! doc->get_subject().empty()) {
+            set_title(doc->get_subject());
+        } else {
+            set_title(doc->get_file_name());
+        }
+
+        label_location_->set_text(doc->get_file_name());
+        label_title_->set_text(doc->get_subject());
+        label_author_->set_text(doc->get_author());
+        label_pages_->set_text(
+                Glib::Util::stringify<int>(doc->get_page_count()));
+        
+        using std::vector;
+        using Glib::ustring;
+
+        vector<ustring> tags = doc->get_tags();
+        ustring str;
+
+        vector<ustring>::iterator it(tags.begin());
+        vector<ustring>::iterator end(tags.end());
+        for ( ; it != end; ++it) {
+            str += *it;
+            str += ";";
+        }
+
+        label_tags_->set_text(str);
+
+        return Gtk::Dialog::run();
+    }
+
+} // namespace paperbox

Added: trunk/src/dialog-properties.hh
==============================================================================
--- (empty file)
+++ trunk/src/dialog-properties.hh	Wed Nov 19 22:12:22 2008
@@ -0,0 +1,55 @@
+/*
+ *  Paperbox - dialog-properties.hh
+ *
+ *  Copyright (C) 2008 Marko Anastasov
+ *
+ *  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 Library 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.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __PAPER_BOX_DIALOG_PROPERTIES_HH__
+#define __PAPER_BOX_DIALOG_PROPERTIES_HH__
+
+#include <boost/shared_ptr.hpp>
+#include <gtkmm/dialog.h>
+#include <gtkmm/label.h>
+#include <libglademm/xml.h>
+
+namespace paperbox {
+
+    class Document;
+
+    class DialogProperties : public Gtk::Dialog
+    {
+    public:
+        DialogProperties(GtkDialog* cobject,
+                const Glib::RefPtr<Gnome::Glade::Xml>& glade);
+        virtual ~DialogProperties() {}
+
+        static DialogProperties* create();
+
+        int run(boost::shared_ptr<Document>& doc);
+
+    protected:
+        Glib::RefPtr<Gnome::Glade::Xml> glade_;
+        Gtk::Label* label_location_;
+        Gtk::Label* label_title_;
+        Gtk::Label* label_author_;
+        Gtk::Label* label_pages_;
+        Gtk::Label* label_tags_;
+    };
+
+} // namespace paperbox
+
+#endif // __PAPER_BOX_DIALOG_PROPERTIES_HH__

Modified: trunk/src/main-window.cc
==============================================================================
--- trunk/src/main-window.cc	(original)
+++ trunk/src/main-window.cc	Wed Nov 19 22:12:22 2008
@@ -33,6 +33,7 @@
 #include "category-factory.hh"
 #include "config.hh"
 #include "file-utils.hh"
+#include "dialog-properties.hh"
 #include "document-tag-cloud-model.hh"
 #include "document-tile.hh"
 #include "i18n-utils.hh"
@@ -244,6 +245,12 @@
                 sigc::mem_fun(*this, &MainWindow::on_menu_document_tag));
 
         action_group_->add(
+                Gtk::Action::create("DocumentProperties",
+                    Gtk::Stock::PROPERTIES),
+                Gtk::AccelKey("<control>E"),
+                sigc::mem_fun(*this, &MainWindow::on_menu_document_properties));
+
+        action_group_->add(
                 Gtk::Action::create("DocumentQuit", Gtk::Stock::QUIT),
                 sigc::mem_fun(*this, &MainWindow::on_menu_document_quit));
 
@@ -265,6 +272,8 @@
             "           <menuitem action='DocumentOpen'/>"
             "           <menuitem action='DocumentTag'/>"
             "           <separator/>"
+            "           <menuitem action='DocumentProperties'/>"
+            "           <separator/>"
             "           <menuitem action='DocumentQuit'/>"
             "       </menu>"
             "       <menu action='HelpMenu'>"
@@ -354,6 +363,19 @@
     }
 
     void
+    MainWindow::on_menu_document_properties()
+    {
+        DocumentTile* tile =
+            dynamic_cast<DocumentTile*>(tile_view_->get_selection());
+        if (! tile) return;
+
+        shared_ptr<DialogProperties> dialog(
+                DialogProperties::create());
+        shared_ptr<Document> doc = tile->get_document();
+        dialog->run(doc);
+    }
+
+    void
     MainWindow::on_menu_document_quit()
     {
         hide();

Modified: trunk/src/main-window.hh
==============================================================================
--- trunk/src/main-window.hh	(original)
+++ trunk/src/main-window.hh	Wed Nov 19 22:12:22 2008
@@ -78,6 +78,7 @@
         /*** Signal handlers ***/
         void on_menu_document_open();
         void on_menu_document_tag();
+        void on_menu_document_properties();
         void on_menu_document_quit();
         void on_menu_about();
         

Modified: trunk/src/paths.hh
==============================================================================
--- trunk/src/paths.hh	(original)
+++ trunk/src/paths.hh	Wed Nov 19 22:12:22 2008
@@ -36,6 +36,9 @@
     const char* const glade_dialog_entry =
         PAPERBOX_PKGDATADIR G_DIR_SEPARATOR_S "dialog-entry.glade";
 
+    const char* const glade_dialog_properties =
+        PAPERBOX_PKGDATADIR G_DIR_SEPARATOR_S "dialog-properties.glade";
+
     const char* const glade_dialog_tag_entry =
         PAPERBOX_PKGDATADIR G_DIR_SEPARATOR_S "dialog-tag-entry.glade";
 

Modified: trunk/ui/Makefile.am
==============================================================================
--- trunk/ui/Makefile.am	(original)
+++ trunk/ui/Makefile.am	Wed Nov 19 22:12:22 2008
@@ -4,7 +4,11 @@
 
 #menusfiles = actions.xml
 
-gladefiles = dialog-categories.glade dialog-entry.glade dialog-tag-entry.glade window-main.glade
+gladefiles = dialog-categories.glade \
+	     dialog-entry.glade \
+	     dialog-properties.glade \
+	     dialog-tag-entry.glade \
+	     window-main.glade
 
 ui_DATA = $(gladefiles)
 

Added: trunk/ui/dialog-properties.glade
==============================================================================
--- (empty file)
+++ trunk/ui/dialog-properties.glade	Wed Nov 19 22:12:22 2008
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--Generated with glade3 3.4.5 on Wed Nov 19 23:01:25 2008 -->
+<glade-interface>
+  <widget class="GtkDialog" id="dialog_properties">
+    <property name="border_width">5</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-vbox">
+        <property name="visible">True</property>
+        <property name="spacing">2</property>
+        <child>
+          <widget class="GtkTable" id="table_properties">
+            <property name="visible">True</property>
+            <property name="n_rows">5</property>
+            <property name="n_columns">2</property>
+            <property name="column_spacing">12</property>
+            <property name="row_spacing">6</property>
+            <child>
+              <widget class="GtkLabel" id="label_tags_caption">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="xalign">0</property>
+                <property name="selectable">True</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_tags">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">&lt;b&gt;Tags:&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_location">
+                <property name="visible">True</property>
+                <property name="xalign">1.1175870895385742e-08</property>
+                <property name="label" translatable="yes">&lt;b&gt;Location:&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_location_caption">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="xalign">0</property>
+                <property name="selectable">True</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_title">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">&lt;b&gt;Title:&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_title_caption">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="xalign">0</property>
+                <property name="selectable">True</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_author">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">&lt;b&gt;Author:&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_author_caption">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="xalign">0</property>
+                <property name="selectable">True</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_pages">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">&lt;b&gt;Number of pages:&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_pages_caption">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="xalign">0</property>
+                <property name="selectable">True</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="button_ok">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>



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