[gtkmm-documentation] Replace use of deprecated FontSelectionDialog.



commit 9dca3119c8e0dc0428c2da497c699c2116c2790d
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Aug 25 10:53:06 2011 +0200

    Replace use of deprecated FontSelectionDialog.
    
    * examples/Makefile.am:
    * examples/book/dialogs/fontchooserdialog/: Rename to fontchooserdialog/,
    though this is really just an example of FontChooserButton.
      * examples/others/calendar/calendar.cc: Use FontChooserDialog instead of
      FontSelectionDialog.
      * docs/tutorial/Makefile.am
      * docs/tutorial/C/figures/: Rename the screenshot, though we should retake
      it. Let's redo them all soon.
      * docs/tutorial/C/gtkmm-tutorial-in.xml: Update for this change too.

 ChangeLog                                          |   14 ++++++
 ...iondialog.png => dialogs_fontchooserdialog.png} |  Bin 24800 -> 24800 bytes
 docs/tutorial/C/gtkmm-tutorial-in.xml              |    8 ++--
 docs/tutorial/Makefile.am                          |    2 +-
 examples/Makefile.am                               |   10 ++--
 .../examplewindow.cc                               |    3 +-
 .../examplewindow.h                                |    0
 .../main.cc                                        |    0
 examples/others/calendar/calendar.cc               |   46 +++++--------------
 9 files changed, 38 insertions(+), 45 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 789b7ae..6cbf015 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-08-25  Murray Cumming  <murrayc murrayc com>
+
+	Replace use of deprecated FontSelectionDialog.
+
+	* examples/Makefile.am:
+	* examples/book/dialogs/fontchooserdialog/: Rename to fontchooserdialog/,
+	though this is really just an example of FontChooserButton.
+  * examples/others/calendar/calendar.cc: Use FontButton instead of 
+  FontSelectionDialog.
+  * docs/tutorial/Makefile.am
+  * docs/tutorial/C/figures/: Rename the screenshot, though we should retake 
+  it. Let's redo them all soon.
+  * docs/tutorial/C/gtkmm-tutorial-in.xml: Update for this change too.
+	
 2011-08-05  Murray Cumming  <murrayc murrayc com>
 
 	Toolbar, Tooltips examples: Fix packing.
diff --git a/docs/tutorial/C/figures/dialogs_fontselectiondialog.png b/docs/tutorial/C/figures/dialogs_fontchooserdialog.png
similarity index 100%
rename from docs/tutorial/C/figures/dialogs_fontselectiondialog.png
rename to docs/tutorial/C/figures/dialogs_fontchooserdialog.png
diff --git a/docs/tutorial/C/gtkmm-tutorial-in.xml b/docs/tutorial/C/gtkmm-tutorial-in.xml
index cfcf9ea..04b0168 100644
--- a/docs/tutorial/C/gtkmm-tutorial-in.xml
+++ b/docs/tutorial/C/gtkmm-tutorial-in.xml
@@ -4101,17 +4101,17 @@ font.
 
 <para><ulink url="&url_refdocs_base_gtk;FontSelectionDialog.html">Reference</ulink></para>
 
-<sect2 id="fontselectiondialog-example">
+<sect2 id="fontchooserdialog-example">
 <title>Example</title>
 
-<figure id="figure-dialogs-fontselectiondialog">
+<figure id="figure-dialogs-fontchooserdialog">
   <title>FontSelectionDialog</title>
   <screenshot>
-    <graphic format="PNG" fileref="&url_figures_base;dialogs_fontselectiondialog.png"/>
+    <graphic format="PNG" fileref="&url_figures_base;dialogs_fontchooserdialog.png"/>
   </screenshot>
 </figure>
 
-<para><ulink url="&url_examples_base;dialogs/fontselectiondialog">Source Code</ulink></para>
+<para><ulink url="&url_examples_base;dialogs/fontchooserdialog">Source Code</ulink></para>
 </sect2>
 
 </sect1>
diff --git a/docs/tutorial/Makefile.am b/docs/tutorial/Makefile.am
index fe6578b..fc41d60 100644
--- a/docs/tutorial/Makefile.am
+++ b/docs/tutorial/Makefile.am
@@ -42,7 +42,7 @@ DOC_FIGURES =					\
 	figures/dialogs_about.png		\
 	figures/dialogs_colorselectiondialog.png\
 	figures/dialogs_filechooser.png		\
-	figures/dialogs_fontselectiondialog.png	\
+	figures/dialogs_fontchooserdialog.png	\
 	figures/dialogs_messagedialog.png	\
 	figures/dialogs_simple.png		\
 	figures/drag_and_drop.png		\
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 87ed7cf..6a44b03 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -33,7 +33,7 @@ check_PROGRAMS =					\
 	book/dialogs/aboutdialog/example		\
 	book/dialogs/colorselectiondialog/example	\
 	book/dialogs/filechooserdialog/example		\
-	book/dialogs/fontselectiondialog/example	\
+	book/dialogs/fontchooserdialog/example	\
 	book/dialogs/messagedialog/example		\
 	book/dialogs/simple/example			\
 	book/drag_and_drop/drag_and_drop		\
@@ -271,10 +271,10 @@ book_dialogs_filechooserdialog_example_SOURCES =	\
 	book/dialogs/filechooserdialog/examplewindow.h	\
 	book/dialogs/filechooserdialog/main.cc
 
-book_dialogs_fontselectiondialog_example_SOURCES =		\
-	book/dialogs/fontselectiondialog/examplewindow.cc	\
-	book/dialogs/fontselectiondialog/examplewindow.h	\
-	book/dialogs/fontselectiondialog/main.cc
+book_dialogs_fontchooserdialog_example_SOURCES =		\
+	book/dialogs/fontchooserdialog/examplewindow.cc	\
+	book/dialogs/fontchooserdialog/examplewindow.h	\
+	book/dialogs/fontchooserdialog/main.cc
 
 book_dialogs_messagedialog_example_SOURCES =		\
 	book/dialogs/messagedialog/examplewindow.cc	\
diff --git a/examples/book/dialogs/fontselectiondialog/examplewindow.cc b/examples/book/dialogs/fontchooserdialog/examplewindow.cc
similarity index 92%
rename from examples/book/dialogs/fontselectiondialog/examplewindow.cc
rename to examples/book/dialogs/fontchooserdialog/examplewindow.cc
index 5ec10a1..224e276 100644
--- a/examples/book/dialogs/fontselectiondialog/examplewindow.cc
+++ b/examples/book/dialogs/fontchooserdialog/examplewindow.cc
@@ -20,10 +20,11 @@
 #include <iostream>
 
 
+//TODO: This is not actually a FontChooserDialog example.
 ExampleWindow::ExampleWindow()
 : m_Button("sans")
 {
-  set_title("Gtk::FontSelectionDialog example");
+  set_title("Gtk::FontChooserDialog example");
 
   add(m_Button);
   m_Button.signal_font_set().connect(sigc::mem_fun(*this,
diff --git a/examples/book/dialogs/fontselectiondialog/examplewindow.h b/examples/book/dialogs/fontchooserdialog/examplewindow.h
similarity index 100%
rename from examples/book/dialogs/fontselectiondialog/examplewindow.h
rename to examples/book/dialogs/fontchooserdialog/examplewindow.h
diff --git a/examples/book/dialogs/fontselectiondialog/main.cc b/examples/book/dialogs/fontchooserdialog/main.cc
similarity index 100%
rename from examples/book/dialogs/fontselectiondialog/main.cc
rename to examples/book/dialogs/fontchooserdialog/main.cc
diff --git a/examples/others/calendar/calendar.cc b/examples/others/calendar/calendar.cc
index 5bfff04..ca359ca 100644
--- a/examples/others/calendar/calendar.cc
+++ b/examples/others/calendar/calendar.cc
@@ -25,6 +25,7 @@ enum { DEF_PAD_SMALL = 5 };
 
 enum { TM_YEAR_BASE = 1900 };
 
+//TODO: This whole example is not very good and needs review.
 class CalendarExample : public Gtk::Window
 {
 
@@ -34,7 +35,6 @@ public:
 
   void set_flags();
   void font_selection_ok();
-  void select_font();
   void toggle_flag(Gtk::CheckButton *toggle);
 
   void month_changed();
@@ -42,10 +42,12 @@ public:
   void day_selected_double_click();
 
 protected:
+  void on_font_button_font_set();
+ 
   Gtk::CheckButton* flag_checkboxes_[5];
   bool settings_[5];
 
-  Gtk::FontSelectionDialog* font_dialog_;
+  Gtk::FontButton* font_button_;
   Gtk::Calendar* calendar_;
   Gtk::Label* label_selected_;
   Gtk::Label* label_selected_double_click_;
@@ -113,42 +115,18 @@ void CalendarExample::toggle_flag(Gtk::CheckButton *toggle)
   set_flags();
 }
 
-void CalendarExample::font_selection_ok()
+void CalendarExample::on_font_button_font_set()
 {
-  if(calendar_)
+  const Glib::ustring font_name = font_button_->get_font_name();
+  if(!font_name.empty())
   {
-    Glib::ustring font_name = font_dialog_->get_font_name();
-    if (!font_name.empty())
-    {
-        calendar_->override_font(Pango::FontDescription(font_name));
-    }
+    calendar_->override_font(Pango::FontDescription(font_name));
   }
 }
 
 
-void CalendarExample::select_font()
-{
-  if (!font_dialog_)
-  {
-    font_dialog_  = new Gtk::FontSelectionDialog("Font Selection Dialog");
-    font_dialog_->set_position(Gtk::WIN_POS_MOUSE);
-    font_dialog_->get_ok_button()->signal_clicked().connect(sigc::mem_fun(*this, &CalendarExample::font_selection_ok));
-    //font_dialog_->get_cancel_button()->signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &CalendarExample::destroy_widget), font_dialog_));
-  }
-
-  if (!font_dialog_->get_visible())
-    font_dialog_->show();
-  else
-  {
-    delete font_dialog_;
-    font_dialog_ = 0;
-  }
-}
-
 CalendarExample::CalendarExample()
 {
-  font_dialog_ = NULL;
-
   for (int i = 0; i < 5; i++) {
     settings_[i] = 0;
   }
@@ -215,9 +193,9 @@ CalendarExample::CalendarExample()
   }
 
   /* Build the right font-button */ 
-  Gtk::Button* button = Gtk::manage(new Gtk::Button("Font..."));
-  button->signal_clicked().connect(sigc::mem_fun(*this, &CalendarExample::select_font));
-  vbox2->pack_start (*button, Gtk::PACK_SHRINK);
+  font_button_ = Gtk::manage(new Gtk::FontButton());
+  font_button_->signal_font_set().connect(sigc::mem_fun(*this, &CalendarExample::on_font_button_font_set));
+  vbox2->pack_start(*font_button_, Gtk::PACK_SHRINK);
 
   /*
    *  Build the Signal-event part.
@@ -253,7 +231,7 @@ CalendarExample::CalendarExample()
   vbox->pack_start(*bbox, Gtk::PACK_SHRINK);
   bbox->set_layout(Gtk::BUTTONBOX_END);
 
-  button = Gtk::manage(new Gtk::Button("Close"));
+  Gtk::Button* button = Gtk::manage(new Gtk::Button("Close"));
   button->signal_clicked().connect(&Gtk::Main::quit);
   bbox->add(*button);
   button->set_can_default();



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