[gtkmm-documentation] Fix 'make check' after Gtk::Arrow has been deprecated



commit 57a78a16b0f3bc34e1f31a922c34ff057ba71627
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Wed May 21 16:59:43 2014 +0200

    Fix 'make check' after Gtk::Arrow has been deprecated
    
    * examples/Makefile.am: Delete examples/others/arrow/direction.
    * examples/others/arrow/arrow.cc: Delete this file, rename direction.cc
    to arrow.cc, and use Gtk::Button::set_image_from_icon_name() instead of
    Gtk::Arrow.
    * examples/others/arrow/direction.cc: Rename to arrow.cc.
    * examples/others/cellrenderercustom/popupentry.cc:
    Use Gtk::Button::set_image_from_icon_name() instead of Gtk::Arrow.

 examples/Makefile.am                             |    4 -
 examples/others/arrow/arrow.cc                   |   79 ++++++++++++++-------
 examples/others/arrow/direction.cc               |   83 ----------------------
 examples/others/cellrenderercustom/popupentry.cc |    9 ++-
 4 files changed, 61 insertions(+), 114 deletions(-)
---
diff --git a/examples/Makefile.am b/examples/Makefile.am
index fd34320..b53f572 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -113,7 +113,6 @@ check_PROGRAMS =                                    \
        book/treeview/tree/example                      \
        book/update_ui/example                          \
        others/arrow/arrow                              \
-       others/arrow/direction                          \
        others/calendar/calendar                        \
        others/cellrenderercustom/cellrenderertoggle    \
        others/cellrenderercustom/testpopup             \
@@ -691,9 +690,6 @@ book_update_ui_example_SOURCES =    \
 others_arrow_arrow_SOURCES = \
        others/arrow/arrow.cc
 
-others_arrow_direction_SOURCES = \
-       others/arrow/direction.cc
-
 others_calendar_calendar_SOURCES = \
        others/calendar/calendar.cc
 
diff --git a/examples/others/arrow/arrow.cc b/examples/others/arrow/arrow.cc
index 85b2c3d..b409f7d 100644
--- a/examples/others/arrow/arrow.cc
+++ b/examples/others/arrow/arrow.cc
@@ -1,25 +1,47 @@
-#include <gtkmm/box.h>
-#include <gtkmm/arrow.h>
+/* example-start arrow arrow.c */
+
+#include <gtkmm/grid.h>
 #include <gtkmm/button.h>
 #include <gtkmm/window.h>
 #include <gtkmm/application.h>
 
+// 2014-05-21: The pan-[up,down,left,right]-symbolic icons are new.
+// See https://bugzilla.gnome.org/show_bug.cgi?id=729565
+// If they are not available in your selected icon theme, perhaps you can
+// use the go-[up,down,previous,next]-symbolic icons.
+#define USE_PAN_ICON_NAMES 0
+
 class ArrowButton : public Gtk::Button
 {
 public:
-   ArrowButton(Gtk::ArrowType,Gtk::ShadowType);
-   virtual ~ArrowButton();
+   ArrowButton(Gtk::ArrowType arrow_type);
+   ~ArrowButton();
 };
 
-/* Create an Arrow widget with the specified parameters
- * and pack it into a button */
-ArrowButton::ArrowButton(Gtk::ArrowType arrow_type,Gtk::ShadowType shadow_type)
+/* Create a button with an arrow image of the specified direction.
+ * Gtk::Arrow has been deprecated. This is how to do it now. */
+ArrowButton::ArrowButton(Gtk::ArrowType arrow_type)
   : Gtk::Button()
 {
-    Gtk::Arrow* arrow = Gtk::manage (new Gtk::Arrow (arrow_type, shadow_type));
-  add (*arrow);
+  Glib::ustring icon_name;
+  switch (arrow_type)
+  {
+#if USE_PAN_ICON_NAMES
+    case Gtk::ARROW_UP:    icon_name = "pan-up-symbolic"; break;
+    case Gtk::ARROW_DOWN:  icon_name = "pan-down-symbolic"; break;
+    case Gtk::ARROW_LEFT:  icon_name = "pan-left-symbolic"; break;
+    case Gtk::ARROW_RIGHT: icon_name = "pan-right-symbolic"; break;
+#else
+    case Gtk::ARROW_UP:    icon_name = "go-up-symbolic"; break;
+    case Gtk::ARROW_DOWN:  icon_name = "go-down-symbolic"; break;
+    case Gtk::ARROW_LEFT:  icon_name = "go-previous-symbolic"; break;
+    case Gtk::ARROW_RIGHT: icon_name = "go-next-symbolic"; break;
+#endif
+    default:               icon_name = "dialog-question"; break;
+  }
+  set_image_from_icon_name(icon_name, Gtk::ICON_SIZE_BUTTON, true);
 }
-  
+ 
 ArrowButton::~ArrowButton()
 {}
 
@@ -33,32 +55,37 @@ public:
 
 AppWindow::AppWindow()
 {
-  ArrowButton *button;
-  Gtk::Box    *box;
+  ArrowButton* button = 0;
+  Gtk::Grid* grid = 0;
 
   set_title ("Arrow Buttons");
 
   /* Sets the border width of the window. */
   set_border_width (10);
   
-  /* Create a box to hold the arrows/buttons */
-  box = Gtk::manage (new Gtk::Box (Gtk::ORIENTATION_HORIZONTAL));
-  box->set_border_width (2);
+  /* Create a grid to hold the arrows/buttons */
+  grid = Gtk::manage (new Gtk::Grid ());
+  grid->set_row_homogeneous(true);
+  grid->set_column_homogeneous(true);
+  grid->set_border_width (2);
 
   /* Pack and show all our widgets */
-  button = Gtk::manage (new ArrowButton (Gtk::ARROW_LEFT, Gtk::SHADOW_ETCHED_IN));
-  box->pack_start (*button, Gtk::PACK_SHRINK, 3);
+  button = Gtk::manage (new ArrowButton (Gtk::ARROW_UP));
+  grid->attach (*button, 1, 0, 1, 1);
 
-  button = Gtk::manage(new ArrowButton (Gtk::ARROW_RIGHT, Gtk::SHADOW_ETCHED_IN));
-  box->pack_start(*button, Gtk::PACK_SHRINK, 3);
+  button = Gtk::manage (new ArrowButton (Gtk::ARROW_LEFT));
+  grid->attach (*button, 0, 1, 1, 1);
 
-  button = Gtk::manage (new ArrowButton (Gtk::ARROW_LEFT, Gtk::SHADOW_ETCHED_OUT));
-  box->pack_start (*button, Gtk::PACK_SHRINK, 3);
+  button = Gtk::manage (new ArrowButton (Gtk::ARROW_RIGHT));
+  grid->attach (*button, 2, 1, 1, 1);
 
-  button = Gtk::manage (new ArrowButton (Gtk::ARROW_RIGHT, Gtk::SHADOW_ETCHED_OUT));
-  box->pack_start (*button, Gtk::PACK_SHRINK, 3);
+  button = Gtk::manage (new ArrowButton (Gtk::ARROW_DOWN));
+  grid->attach (*button, 1, 2, 1, 1);
+
+  grid->set_row_spacing(5);
+  grid->set_column_spacing(5);
  
-  add (*box);
+  add (*grid);
   show_all ();
 }
 
@@ -68,7 +95,9 @@ AppWindow::~AppWindow()
 int main (int argc, char *argv[])
 {
   Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
-
   AppWindow arrows;
+
   return app->run(arrows);
 }
+
+/* example-end */
diff --git a/examples/others/cellrenderercustom/popupentry.cc 
b/examples/others/cellrenderercustom/popupentry.cc
index 424185f..28d9aee 100644
--- a/examples/others/cellrenderercustom/popupentry.cc
+++ b/examples/others/cellrenderercustom/popupentry.cc
@@ -21,6 +21,11 @@
 
 #include <gdk/gdkkeysyms.h>
 
+// 2014-05-21: The pan-[up,down,left,right]-symbolic icons are new.
+// See https://bugzilla.gnome.org/show_bug.cgi?id=729565
+// If they are not available in your selected icon theme, perhaps you can
+// use the go-[up,down,left,right]-symbolic icons.
+#define ICON_NAME_PREFIX "go" // preferably "pan"
 
 PopupEntry::PopupEntry(const Glib::ustring& path)
 :
@@ -41,7 +46,7 @@ PopupEntry::PopupEntry(const Glib::ustring& path)
 
   button_ = new Gtk::Button();
   hbox->pack_start(*Gtk::manage(button_), Gtk::PACK_SHRINK);
-  button_->add(*Gtk::manage(new Gtk::Arrow(Gtk::ARROW_DOWN, Gtk::SHADOW_OUT)));
+  button_->set_image_from_icon_name(ICON_NAME_PREFIX "-down-symbolic", Gtk::ICON_SIZE_BUTTON, true);
 
   set_can_focus();
   add_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
@@ -85,7 +90,7 @@ int PopupEntry::get_button_width()
   Gtk::Button *const button = new Gtk::Button();
   window.add(*Gtk::manage(button));
 
-  button->add(*Gtk::manage(new Gtk::Arrow(Gtk::ARROW_DOWN, Gtk::SHADOW_OUT)));
+  button->set_image_from_icon_name(ICON_NAME_PREFIX "-down-symbolic", Gtk::ICON_SIZE_BUTTON, true);
 
   // Urgh.  Hackish :/
   window.move(-500, -500);


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