[gtkmm-documentation] Fix the build with the latest gtkmm from git master.



commit 108e01e688ba94bc236351de97609f52b4fe3d94
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Dec 7 17:39:32 2010 +0100

    Fix the build with the latest gtkmm from git master.
    
    * examples/book/custom/custom_widget/mywidget.cc:
    * examples/book/custom/custom_widget/mywidget.h:
    * examples/book/dialogs/colorselectiondialog/examplewindow.cc:
    * examples/book/dialogs/colorselectiondialog/examplewindow.h:
    * examples/others/calendar/calendar.cc:
    * examples/others/cellrenderercustom/cellrendererpopup.cc:
    * examples/others/cellrenderercustom/cellrenderertoggle.cc:
    Adapt to the change from GtkStyle* to GtkStyleContext.

 ChangeLog                                          |   13 ++++++++++
 examples/book/custom/custom_widget/mywidget.cc     |   25 ++++++++++++++-----
 examples/book/custom/custom_widget/mywidget.h      |    2 +
 .../dialogs/colorselectiondialog/examplewindow.cc  |    8 +++---
 .../dialogs/colorselectiondialog/examplewindow.h   |    2 +-
 examples/others/calendar/calendar.cc               |    2 +-
 .../others/cellrenderercustom/cellrendererpopup.cc |    2 +-
 .../cellrenderercustom/cellrenderertoggle.cc       |   18 +++++--------
 8 files changed, 47 insertions(+), 25 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0ecdc0c..a9a2aef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-12-07  Murray Cumming  <murrayc murrayc com>
+
+	Fix the build with the latest gtkmm from git master.
+
+	* examples/book/custom/custom_widget/mywidget.cc:
+	* examples/book/custom/custom_widget/mywidget.h:
+	* examples/book/dialogs/colorselectiondialog/examplewindow.cc:
+	* examples/book/dialogs/colorselectiondialog/examplewindow.h:
+	* examples/others/calendar/calendar.cc:
+	* examples/others/cellrenderercustom/cellrendererpopup.cc:
+	* examples/others/cellrenderercustom/cellrenderertoggle.cc:
+	Adapt to the change from GtkStyle* to GtkStyleContext.
+
 2010-12-03  Murray Cumming  <murrayc murrayc com>
 
 	Fix the build with the latest gtkmm from git master.
diff --git a/examples/book/custom/custom_widget/mywidget.cc b/examples/book/custom/custom_widget/mywidget.cc
index fd3d0e9..a1f7a45 100644
--- a/examples/book/custom/custom_widget/mywidget.cc
+++ b/examples/book/custom/custom_widget/mywidget.cc
@@ -38,6 +38,7 @@ MyWidget::MyWidget() :
   //This show that the GType still derives from GtkWidget:
   //std::cout << "Gtype is a GtkWidget?:" << GTK_IS_WIDGET(gobj()) << std::endl;
 
+
   //Install a style so that an aspect of this widget may be themed via an RC
   //file:
   gtk_widget_class_install_style_property(GTK_WIDGET_CLASS(
@@ -50,7 +51,19 @@ MyWidget::MyWidget() :
         0,
         G_PARAM_READABLE) );
 
-  gtk_rc_parse("custom_gtkrc");
+  m_refStyleProvider = Gtk::CssProvider::get_default();
+  Glib::RefPtr<Gtk::StyleContext> refStyleContext = get_style_context();
+  refStyleContext->add_provider(m_refStyleProvider, 
+    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    
+  try
+  {
+    m_refStyleProvider->load_from_path("custom_gtkrc");
+  }
+  catch(const Glib::Error& ex)
+  {
+    std::cerr << "Gtk::CssProvider::load_from_path() failed: " << ex.what() << std::endl;
+  }
 }
 
 MyWidget::~MyWidget()
@@ -102,8 +115,6 @@ void MyWidget::on_realize()
   //Call base class:
   Gtk::Widget::on_realize();
 
-  ensure_style();
-
   //Get the themed style from the RC file:
   get_style_property("example_scale", m_scale);
   std::cout << "m_scale (example_scale from the theme/rc-file) is: "
@@ -135,8 +146,8 @@ void MyWidget::on_realize()
     set_window(m_refGdkWindow);
 
     //set colors
-    modify_bg(Gtk::STATE_NORMAL , Gdk::Color("red"));
-    modify_fg(Gtk::STATE_NORMAL , Gdk::Color("blue"));
+    override_background_color(Gdk::RGBA("red"));
+    override_color(Gdk::RGBA("blue"));
 
     //make the widget receive expose events
     m_refGdkWindow->set_user_data(gobj());
@@ -157,11 +168,11 @@ bool MyWidget::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
   const double scale_y = (double)get_allocation().get_height() / m_scale;
 
   // paint the background
-  Gdk::Cairo::set_source_color(cr, get_style()->get_bg(Gtk::STATE_NORMAL));
+  Gdk::Cairo::set_source_rgba(cr, get_style_context()->get_background_color());
   cr->paint();
 
   // draw the foreground
-  Gdk::Cairo::set_source_color(cr, get_style()->get_fg(Gtk::STATE_NORMAL));
+  Gdk::Cairo::set_source_rgba(cr, get_style_context()->get_color());
   cr->move_to(155.*scale_x, 165.*scale_y);
   cr->line_to(155.*scale_x, 838.*scale_y);
   cr->line_to(265.*scale_x, 900.*scale_y);
diff --git a/examples/book/custom/custom_widget/mywidget.h b/examples/book/custom/custom_widget/mywidget.h
index 92198f4..70d0f2f 100644
--- a/examples/book/custom/custom_widget/mywidget.h
+++ b/examples/book/custom/custom_widget/mywidget.h
@@ -20,6 +20,7 @@
 #define GTKMM_CUSTOM_WIDGET_MYWIDGET_H
 
 #include <gtkmm/widget.h>
+#include <gtkmm/cssprovider.h>
 
 class MyWidget : public Gtk::Widget
 {
@@ -39,6 +40,7 @@ protected:
   virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
 
   Glib::RefPtr<Gdk::Window> m_refGdkWindow;
+  Glib::RefPtr<Gtk::CssProvider> m_refStyleProvider;
 
   int m_scale;
 };
diff --git a/examples/book/dialogs/colorselectiondialog/examplewindow.cc b/examples/book/dialogs/colorselectiondialog/examplewindow.cc
index d43f2fd..583bb73 100644
--- a/examples/book/dialogs/colorselectiondialog/examplewindow.cc
+++ b/examples/book/dialogs/colorselectiondialog/examplewindow.cc
@@ -35,9 +35,9 @@ ExampleWindow::ExampleWindow()
   m_Color.set_red(0);
   m_Color.set_blue(65535);
   m_Color.set_green(0);
-  m_Button.set_color(m_Color);
+  m_Button.set_rgba(m_Color);
 
-  m_DrawingArea.modify_bg(Gtk::STATE_NORMAL, m_Color);
+  m_DrawingArea.override_background_color(m_Color);
 
   m_VBox.pack_start(m_DrawingArea);
 
@@ -51,6 +51,6 @@ ExampleWindow::~ExampleWindow()
 void ExampleWindow::on_button_color_set()
 {
   //Store the chosen color, and show it:
-  m_Color = m_Button.get_color();
-  m_DrawingArea.modify_bg(Gtk::STATE_NORMAL, m_Color);
+  m_Color = m_Button.get_rgba();
+  m_DrawingArea.override_background_color(m_Color);
 }
diff --git a/examples/book/dialogs/colorselectiondialog/examplewindow.h b/examples/book/dialogs/colorselectiondialog/examplewindow.h
index ecc8806..39f59a3 100644
--- a/examples/book/dialogs/colorselectiondialog/examplewindow.h
+++ b/examples/book/dialogs/colorselectiondialog/examplewindow.h
@@ -36,7 +36,7 @@ protected:
   Gtk::ColorButton m_Button;
   Gtk::DrawingArea m_DrawingArea; //To show the color.
 
-  Gdk::Color m_Color;
+  Gdk::RGBA m_Color;
 };
 
 #endif //GTKMM_EXAMPLEWINDOW_H
diff --git a/examples/others/calendar/calendar.cc b/examples/others/calendar/calendar.cc
index 73aa985..c8b8974 100644
--- a/examples/others/calendar/calendar.cc
+++ b/examples/others/calendar/calendar.cc
@@ -120,7 +120,7 @@ void CalendarExample::font_selection_ok()
     Glib::ustring font_name = font_dialog_->get_font_name();
     if (!font_name.empty())
     {
-        calendar_->modify_font(Pango::FontDescription(font_name));
+        calendar_->override_font(Pango::FontDescription(font_name));
     }
   }
 }
diff --git a/examples/others/cellrenderercustom/cellrendererpopup.cc b/examples/others/cellrenderercustom/cellrendererpopup.cc
index 5eda435..b2c62bb 100644
--- a/examples/others/cellrenderercustom/cellrendererpopup.cc
+++ b/examples/others/cellrenderercustom/cellrendererpopup.cc
@@ -60,7 +60,7 @@ CellRendererPopup::CellRendererPopup()
 
   popup_window_.signal_button_press_event().connect(sigc::mem_fun(*this, &Self::on_button_press_event));
   popup_window_.signal_key_press_event   ().connect(sigc::mem_fun(*this, &Self::on_key_press_event));
-  popup_window_.signal_style_changed     ().connect(sigc::mem_fun(*this, &Self::on_style_changed));
+  //TODO: popup_window_.signal_style_changed     ().connect(sigc::mem_fun(*this, &Self::on_style_changed));
 }
 
 CellRendererPopup::~CellRendererPopup()
diff --git a/examples/others/cellrenderercustom/cellrenderertoggle.cc b/examples/others/cellrenderercustom/cellrenderertoggle.cc
index 9aba27c..dea68db 100644
--- a/examples/others/cellrenderercustom/cellrenderertoggle.cc
+++ b/examples/others/cellrenderercustom/cellrenderertoggle.cc
@@ -190,30 +190,26 @@ void MyCellRendererToggle::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
   if(width <= 0 || height <= 0)
     return;
 
-  Gtk::StateType state = Gtk::STATE_INSENSITIVE;
+  Gtk::StateFlags state = Gtk::STATE_FLAG_INSENSITIVE;
 
   if(property_activatable_)
-    state = Gtk::STATE_NORMAL;
+    state = (Gtk::StateFlags)0;
 
   if((flags & Gtk::CELL_RENDERER_SELECTED) != 0)
-    state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
-
-  const Gtk::ShadowType shadow = (property_active_) ? Gtk::SHADOW_IN : Gtk::SHADOW_OUT;
+    state = (widget.has_focus()) ? Gtk::STATE_FLAG_SELECTED : Gtk::STATE_FLAG_ACTIVE;
 
   if(property_radio_)
   {
-    widget.get_style()->paint_option(
-      cr, state, shadow,
-      widget, "cellradio",
+    widget.get_style_context()->render_option(
+      cr,
       cell_area.get_x() + cell_xpad,
       cell_area.get_y() + cell_ypad,
       width - 1, height - 1);
   }
   else
   {
-    widget.get_style()->paint_check(
-      cr, state, shadow,
-      widget, "cellcheck",
+    widget.get_style_context()->render_check(
+      cr,
       cell_area.get_x() + cell_xpad,
       cell_area.get_y() + cell_ypad,
       width - 1, height - 1);



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