[gtkmm-documentation] Update RecentFiles example, remove ToolPalette example



commit e16dbb7f2d3f709cae44c055538553d6915acc73
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Thu Feb 8 16:42:46 2018 +0100

    Update RecentFiles example, remove ToolPalette example
    
    The Gtk::RecentChooser interface and classes that implemented that
    interface have been removed. Use FileChooserDialog to show the list of
    recently used files.
    
    Gtk::ToolPalette has been removed. Remove the ToolPalette example.
    
    * docs/tutorial/C/index-in.docbook: Update the Recently Used Documents
    chapter. Remove the ToolPalette chapter.

 docs/tutorial/C/figures/recentchooserdialog.png |  Bin 18094 -> 0 bytes
 docs/tutorial/C/figures/recentfiles.png         |  Bin 0 -> 115642 bytes
 docs/tutorial/C/figures/toolpalette.png         |  Bin 53603 -> 0 bytes
 docs/tutorial/C/index-in.docbook                |  139 +++--------
 docs/tutorial/Makefile.am                       |    3 +-
 examples/Makefile.am                            |   10 +-
 examples/book/recent_files/examplewindow.cc     |   28 ++-
 examples/book/recent_files/examplewindow.h      |    5 +-
 examples/book/toolpalette/canvas.cc             |  198 ---------------
 examples/book/toolpalette/canvas.h              |   71 ------
 examples/book/toolpalette/examplewindow.cc      |  292 -----------------------
 examples/book/toolpalette/examplewindow.h       |   83 -------
 examples/book/toolpalette/main.cc               |   28 ---
 13 files changed, 55 insertions(+), 802 deletions(-)
---
diff --git a/docs/tutorial/C/figures/recentfiles.png b/docs/tutorial/C/figures/recentfiles.png
new file mode 100644
index 0000000..6eafcdc
Binary files /dev/null and b/docs/tutorial/C/figures/recentfiles.png differ
diff --git a/docs/tutorial/C/index-in.docbook b/docs/tutorial/C/index-in.docbook
index ce62a8a..d5d93e5 100644
--- a/docs/tutorial/C/index-in.docbook
+++ b/docs/tutorial/C/index-in.docbook
@@ -3723,60 +3723,6 @@ A class is derived from <classname>Gtk::Window</classname>.
 
 </chapter>
 
-<chapter id="chapter-toolpalette">
-<title>ToolPalette</title>
-
-<para>A <classname>ToolPalette</classname> is similar to a <classname>Toolbar</classname> but can contain a 
grid of items, categorized into groups. The user may hide or expand each group. As in a toolbar, the items 
may be displayed as only icons, as only text, or as icons with text.
-</para>
-<para>The <classname>ToolPalette</classname>'s items might be dragged or simply activated. For instance, the 
user might drag objects to a canvas to create new items there. Or the user might click an item to activate a 
certain brush size in a drawing application.</para>
-<para><classname>ToolItemGroup</classname>s should be added to the tool palette via the base class's 
<function>Gtk::Container::add()</function> method, for instance like so:
-</para>
-<para>
-<programlisting>
-Gtk::ToolItemGroup* group_brushes =
-  Gtk::manage(new Gtk::ToolItemGroup("Brushes"));
-m_ToolPalette.add(*group_brushes);
-</programlisting>
-</para>
-<para>
-<classname>Gtk::ToolItem</classname>s can then be added to the group. For instance, like so:
-</para>
-<para>
-<programlisting>
-Gtk::ToolButton* button = Gtk::manage(new Gtk::ToolButton(icon, "Big"));
-button->set_tooltip_text("Big Brush);
-group_brushes->insert(*button);
-</programlisting>
-</para>
-<para>You might then handle the <classname>ToolButton</classname>'s <literal>clicked</literal> signal. 
Alternatively, you could allow the item to be dragged to another widget, by calling 
<methodname>Gtk::ToolPalette::add_drag_dest()</methodname> and then using 
<methodname>Gtk::ToolPalette::get_drag_item()</methodname> in the other widget's 
<literal>drag_data_received</literal> signal handler.</para>
-
-<para><ulink url="&url_refdocs_base_gtk;ToolPalette.html">ToolPalette Reference</ulink></para>
-<para><ulink url="&url_refdocs_base_gtk;ToolItemGroup.html">ToolItemGroup Reference</ulink></para>
-<para><ulink url="&url_refdocs_base_gtk;ToolItem.html">ToolItem Reference</ulink></para>
-
-<sect1 id="toolpallete-dranganddrop">
-<title>Drag and Drop</title>
-<para>Call <methodname>add_drag_dest()</methodname> to allow items or groups to be dragged from the tool 
palette to a particular destination widget. You can then use <methodname>get_drag_item()</methodname> to 
discover which ToolItem or ToolItemGroup is being dragged. You can use <literal>dynamic_cast</literal> to 
discover whether it is an item or a group. For instance, you might use this in your 
<literal>drag_data_received</literal> signal handler, to add a dropped item, or to show a suitable icon while 
dragging.</para>
-<para>See the <link linkend="chapter-draganddrop">Drag and Drop</link> chapter for general advice about Drag 
and Drop with &gtkmm;.</para>
-</sect1>
-
-<sect1 id="toolpalette-example"><title>ToolPalette Example</title>
-
-<para>This example adds a <classname>ToolPalette</classname> and a <classname>DrawingArea</classname> to a 
window and allows the user to drag icons from the tool palette to the drawing area. The tool palette contains 
several groups of items. The combo boxes allow the user to change the style and orientation of the tool 
palette.</para>
-
-<figure id="figure-toolpalette">
-  <title>ToolPalette</title>
-  <screenshot>
-    <graphic format="PNG" fileref="&url_figures_base;toolpalette.png"/>
-  </screenshot>
-</figure>
-
-<para><ulink url="&url_examples_base;toolpalette/">Source Code</ulink></para>
-
-</sect1>
-
-</chapter>
-
 <chapter id="chapter-adjustment">
 <title>Adjustments</title>
 
@@ -5447,13 +5393,8 @@ and update the print settings.
   <title>Recently Used Documents</title>
 
   <para>
-    &gtkmm; provides an easy way to manage recently used documents. The classes
-    involved in implementing this functionality are
-    <classname>RecentManager</classname>,
-    <classname>RecentChooserDialog</classname>,
-    <classname>RecentChooserMenu</classname>,
-    <classname>RecentChooserWidget</classname>, and
-    <classname>RecentFilter</classname>.
+    &gtkmm; provides an easy way to manage recently used documents. This functionality
+    is implemented in the <classname>Gtk::RecentManager</classname> class.
   </para>
   <para>
     Each item in the list of recently used files is identified by its URI, and
@@ -5476,11 +5417,6 @@ and update the print settings.
       default <classname>RecentManager</classname> with
       <methodname>get_default()</methodname>.
     </para>
-    <para>
-      <classname>RecentManager</classname> is the model of a model-view pattern,
-      where the view is a class that implements the
-      <classname>RecentChooser</classname> interface.
-    </para>
     <sect2 id="recent-files-adding">
       <title>Adding Items to the List of Recent Files</title>
       <para>
@@ -5605,36 +5541,35 @@ if (info)
     </sect2>
   </sect1>
 
-  <sect1 id="sec-recentchooser">
-    <title>RecentChooser</title>
+  <sect1 id="sec-filechooser">
+    <title>FileChooser</title>
     <para>
-      <classname>RecentChooser</classname> is an interface that can be
-      implemented by widgets displaying the list of recently used files.
-      &gtkmm; provides three built-in implementations for choosing recent files:
-      <classname>RecentChooserWidget</classname>,
-      <classname>RecentChooserDialog</classname>, and
-      <classname>RecentChooserMenu</classname>.
+      <classname>FileChooser</classname> is an interface that can be
+      implemented by widgets displaying a list of files.
+      &gtkmm; provides four built-in implementations for choosing recent files
+      or other files:
+      <classname>FileChooserWidget</classname>,
+      <classname>FileChooserDialog</classname>,
+      <classname>FileChooserButton</classname>, and
+      <classname>FileChooserNative</classname>.
     </para>
     <para>
-      <classname>RecentChooserWidget</classname> is a simple widget for
-      displaying a list of recently used files.
-      <classname>RecentChooserWidget</classname> is the basic building block for
-      <classname>RecentChooserDialog</classname>, but you can embed it into your
+      <classname>FileChooserWidget</classname> is a simple widget for
+      displaying a list of recently used files or other files.
+      <classname>FileChooserWidget</classname> is the basic building block for
+      <classname>FileChooserDialog</classname>, but you can embed it into your
       user interface if you want to.
     </para>
-    <para>
-      <classname>RecentChooserMenu</classname> allows you to list recently used
-      files as a menu.
-    </para>
-    <sect2 id="recentchooserdialog-example">
-      <title>Simple RecentChooserDialog example</title>
+    <sect2 id="filechooserdialog-example">
+      <title>Simple FileChooserDialog example</title>
       <para>
         Shown below is a simple example of how to use the
-        <classname>RecentChooserDialog</classname> class in a program.
+        <classname>FileChooserDialog</classname> class in a program.
         This simple program has a menubar with a
-        <guimenuitem>Recent Files Dialog</guimenuitem> menu item.
-        When you select this menu item, a dialog pops up showing the list of
-        recently used files.
+        <guimenuitem>File Chooser Dialog</guimenuitem> menu item.
+        When you select this menu item, a dialog pops up showing a list of files.
+        If you select <guimenuitem>Recent</guimenuitem> in the sidebar,
+        the list of recently used files is shown.
       </para>
       <note>
         <para>
@@ -5645,12 +5580,12 @@ if (info)
         </para>
       </note>
       <para>
-        After selecting the <guimenuitem>Recent Files Dialog</guimenuitem> menu
-        item, you should see something similar to the following window.
+        After selecting the <guimenuitem>File Chooser Dialog</guimenuitem> menu
+        item and the <guimenuitem>Recent</guimenuitem> sidebar item, you should
+        see something similar to the following window.
       </para>
       <screenshot>
-          <graphic format="PNG"
-              fileref="&url_figures_base;recentchooserdialog.png"/>
+          <graphic format="PNG" fileref="&url_figures_base;recentfiles.png"/>
       </screenshot>
       <para><ulink url="&url_examples_base;recent_files">Source Code</ulink></para>
       <para>
@@ -5661,24 +5596,20 @@ if (info)
       </para>
     </sect2>
     <sect2 id="recent-files-filtering">
-      <title>Filtering Recent Files</title>
+      <title>Filtering Files</title>
       <para>
-        For any of the <classname>RecentChooser</classname> classes, if you
-        don't wish to display all of the items in the list of recent files, you
+        For any of the <classname>FileChooser</classname> classes, if you
+        don't wish to display all of the items in the list of files, you
         can filter the list to show only those that you want. You can filter
-        the list with the help of the <classname>RecentFilter</classname> class.
-        This class allows you to filter recent files by their name
-        (<methodname>add_pattern()</methodname>), their mime type
-        (<methodname>add_mime_type()</methodname>), the application that registered
-        them (<methodname>add_application()</methodname>), or by a custom filter
-        function (<methodname>add_custom()</methodname>). It also provides the
-        ability to filter based on how long ago the file was modified and which
-        groups it belongs to.
+        the list with the help of the <classname>FileFilter</classname> class.
+        This class allows you to filter files by their name
+        (<methodname>add_pattern()</methodname>), or their mime type
+        (<methodname>add_mime_type()</methodname>).
       </para>
       <para>
         After you've created and set up the filter to match only the items you
         want, you can apply a filter to a chooser widget with the
-        <methodname>RecentChooser::add_filter()</methodname> function.
+        <methodname>FileChooser::add_filter()</methodname> function.
       </para>
     </sect2>
   </sect1>
diff --git a/docs/tutorial/Makefile.am b/docs/tutorial/Makefile.am
index 23ad599..e5f1088 100644
--- a/docs/tutorial/Makefile.am
+++ b/docs/tutorial/Makefile.am
@@ -93,12 +93,11 @@ HELP_MEDIA =                                        \
        figures/progressbar.png                 \
        figures/radiobuttons.png                \
        figures/range_widgets.png               \
-       figures/recentchooserdialog.png         \
+       figures/recentfiles.png         \
        figures/scrolledwindow.png              \
        figures/spinbutton.png                  \
        figures/textview.png                    \
        figures/toolbar.png                     \
-       figures/toolpalette.png                 \
        figures/tooltip.png                     \
        figures/treeview_combo_renderer.png     \
        figures/treeview_draganddrop.png        \
diff --git a/examples/Makefile.am b/examples/Makefile.am
index c3f0df5..c9996f3 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -90,7 +90,7 @@ check_PROGRAMS =                                      \
        book/printing/simple/example                    \
        book/progressbar/example                        \
        book/range_widgets/example                      \
-       book/recent_files/example                       \
+       book/recent_files/example \
        book/revealer/example                           \
        book/scrolledwindow/example                     \
        book/searchbar/example                          \
@@ -99,7 +99,6 @@ check_PROGRAMS =                                      \
        book/textview/example                           \
        book/timeout/timeout                            \
        book/toolbar/example                            \
-       book/toolpalette/example                        \
        book/tooltips/example                           \
        book/treeview/combo_renderer/example            \
        book/treeview/drag_and_drop/example             \
@@ -625,13 +624,6 @@ book_toolbar_example_SOURCES =             \
        book/toolbar/examplewindow.h    \
        book/toolbar/main.cc
 
-book_toolpalette_example_SOURCES =             \
-       book/toolpalette/examplewindow.cc       \
-       book/toolpalette/examplewindow.h        \
-       book/toolpalette/canvas.cc      \
-       book/toolpalette/canvas.h       \
-       book/toolpalette/main.cc
-
 book_tooltips_example_SOURCES =                \
        book/tooltips/examplewindow.cc  \
        book/tooltips/examplewindow.h   \
diff --git a/examples/book/recent_files/examplewindow.cc b/examples/book/recent_files/examplewindow.cc
index 6fa2178..ac081a2 100644
--- a/examples/book/recent_files/examplewindow.cc
+++ b/examples/book/recent_files/examplewindow.cc
@@ -21,8 +21,8 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
 : m_Box(Gtk::Orientation::VERTICAL),
   m_refRecentManager(Gtk::RecentManager::get_default())
 {
-  set_title("recent files example");
-  set_default_size(200, 200);
+  set_title("Recent files example");
+  set_default_size(300, 150);
 
   //We can put a MenuBar at the top of the box and other stuff below it.
   add(m_Box);
@@ -34,9 +34,9 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
   m_refActionGroup->add_action("new",
     sigc::mem_fun(*this, &ExampleWindow::on_menu_file_new));
 
-  //A menu item to open the recent-files dialog:
-  m_refActionGroup->add_action("recent-files-dialog",
-    sigc::mem_fun(*this, &ExampleWindow::on_menu_file_recent_files_dialog) );
+  //A menu item to open the file chooser dialog:
+  m_refActionGroup->add_action("files-dialog",
+    sigc::mem_fun(*this, &ExampleWindow::on_menu_file_files_dialog));
 
   m_refActionGroup->add_action("quit",
     sigc::mem_fun(*this, &ExampleWindow::on_menu_file_quit) );
@@ -51,7 +51,7 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
   // See the examples/book/menus/main_menu example for an alternative way of
   // adding the menubar when using Gtk::ApplicationWindow.
   app->set_accel_for_action("example.new", "<Primary>n");
-  app->set_accel_for_action("example.recent-files-dialog", "<Primary>o");
+  app->set_accel_for_action("example.files-dialog", "<Primary>o");
   app->set_accel_for_action("example.quit", "<Primary>q");
 
   //Layout the actions in a menubar and a toolbar:
@@ -66,8 +66,8 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
     "        <attribute name='accel'>&lt;Primary&gt;n</attribute>"
     "      </item>"
     "      <item>"
-    "        <attribute name='label' translatable='yes'>Recent Files _Dialog</attribute>"
-    "        <attribute name='action'>example.recent-files-dialog</attribute>"
+    "        <attribute name='label' translatable='yes'>File Chooser _Dialog</attribute>"
+    "        <attribute name='action'>example.files-dialog</attribute>"
     "        <attribute name='accel'>&lt;Primary&gt;o</attribute>"
     "      </item>"
     "      <item>"
@@ -153,17 +153,21 @@ void ExampleWindow::on_menu_file_quit()
   hide(); //Closes the main window to stop the app->run().
 }
 
-void ExampleWindow::on_menu_file_recent_files_dialog()
+void ExampleWindow::on_menu_file_files_dialog()
 {
-  Gtk::RecentChooserDialog dialog(*this, "Recent Files", m_refRecentManager);
+  Gtk::FileChooserDialog dialog(*this, "Files", Gtk::FileChooser::Action::OPEN,
+    /* use_header_bar= */ true);
   dialog.add_button("Select File", Gtk::ResponseType::OK);
   dialog.add_button("_Cancel", Gtk::ResponseType::CANCEL);
 
   const int response = dialog.run();
   dialog.hide();
-  if(response == Gtk::ResponseType::OK)
+  if (response == Gtk::ResponseType::OK)
   {
-    std::cout << "URI selected = " << dialog.get_current_uri() << std::endl;
+    auto selected_uri = dialog.get_uri();
+    std::cout << "URI selected = " << selected_uri << std::endl;
+    std::cout << (m_refRecentManager->has_item(selected_uri) ? "A" : "Not a")
+      << " recently used file" << std::endl;
   }
 }
 
diff --git a/examples/book/recent_files/examplewindow.h b/examples/book/recent_files/examplewindow.h
index 739bc1a..2cfaca9 100644
--- a/examples/book/recent_files/examplewindow.h
+++ b/examples/book/recent_files/examplewindow.h
@@ -23,12 +23,11 @@ class ExampleWindow : public Gtk::Window
 {
 public:
   ExampleWindow(const Glib::RefPtr<Gtk::Application>& app);
-  virtual ~ExampleWindow();
+  ~ExampleWindow() override;
 
 protected:
   //Signal handlers:
-  void on_menu_file_recent_files_item();
-  void on_menu_file_recent_files_dialog();
+  void on_menu_file_files_dialog();
   void on_menu_file_quit();
   void on_menu_file_new();
 


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