[niepce] gtk: Use gtkmm 3.16 and remove deprecation



commit bce100114143b1eb3499de3acea4f518ef2861af
Author: Hubert Figuière <hub figuiere net>
Date:   Wed May 10 21:20:36 2017 -0400

    gtk: Use gtkmm 3.16 and remove deprecation

 README                                         |    4 ++--
 configure.ac                                   |    2 +-
 src/ext/libview/header.cc                      |    9 ++++++---
 src/fwk/toolkit/metadatawidget.cpp             |   24 ++++++++++++++----------
 src/fwk/toolkit/widgets/editablehscale.cpp     |    3 ++-
 src/fwk/toolkit/widgets/editablehscale.hpp     |    6 +++---
 src/niepce/modules/darkroom/darkroommodule.hpp |    4 ++--
 src/niepce/modules/darkroom/dritemwidget.cpp   |    4 ++--
 src/niepce/modules/darkroom/imagecanvas.cpp    |   11 ++++++-----
 src/niepce/ui/librarycellrenderer.cpp          |   23 +++++++++--------------
 src/niepce/ui/moduleshell.cpp                  |    2 +-
 src/niepce/ui/moduleshell.hpp                  |    2 +-
 src/niepce/ui/thumbstripview.cpp               |    5 +----
 13 files changed, 50 insertions(+), 49 deletions(-)
---
diff --git a/README b/README
index a4525cc..8b29e16 100644
--- a/README
+++ b/README
@@ -5,7 +5,7 @@ This software is licensed under GPL version 3. See file
 COPYING for details.
 Some files may be under GPL version 2 or later.
 
-(c) 2006-2014 Hubert Figuière
+(c) 2006-2017 Hubert Figuière
 Some portions are written by other people.
 
 What is this?
@@ -22,7 +22,7 @@ A C++11 compiler
 gtk+ 3.12
 cairo 1.1
 glibmm 2.32
-gtkmm 3.12
+gtkmm 3.16
 giomm
 cairomm
 cluttermm 1.0
diff --git a/configure.ac b/configure.ac
index 8d81bd1..6ef8e14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,7 +13,7 @@ dnl all the library version.
 dnl if one is harcoded elsewhere, it is a bug
 LIBGIOMM_VERSION=2.16
 LIBGLIBMM_VERSION=2.32
-LIBGTKMM_VERSION=3.14
+LIBGTKMM_VERSION=3.16
 EXEMPI_VERSION=2.2.0
 SQLITE_VERSION=3.0
 GEGL_VERSION=0.3.0
diff --git a/src/ext/libview/header.cc b/src/ext/libview/header.cc
index 0a5d929..d605a4c 100644
--- a/src/ext/libview/header.cc
+++ b/src/ext/libview/header.cc
@@ -112,17 +112,20 @@ Header::SetAlignment(Alignment align) // IN: The new alignment
 {
    switch (align) {
    case Alignment::LEFT:
-      mLabel.set_alignment(0, 0.5);
+      mLabel.set_xalign(0);
+      mLabel.set_yalign(0.5);
       mLabel.set_justify(Gtk::JUSTIFY_LEFT);
       break;
 
    case Alignment::CENTER:
-      mLabel.set_alignment(0.5, 0.5);
+      mLabel.set_xalign(0.5);
+      mLabel.set_yalign(0.5);
       mLabel.set_justify(Gtk::JUSTIFY_CENTER);
       break;
 
    case Alignment::RIGHT:
-      mLabel.set_alignment(1, 0.5);
+      mLabel.set_xalign(1);
+      mLabel.set_yalign(0.5);
       mLabel.set_justify(Gtk::JUSTIFY_RIGHT);
       break;
 
diff --git a/src/fwk/toolkit/metadatawidget.cpp b/src/fwk/toolkit/metadatawidget.cpp
index 6852312..76a6014 100644
--- a/src/fwk/toolkit/metadatawidget.cpp
+++ b/src/fwk/toolkit/metadatawidget.cpp
@@ -100,7 +100,8 @@ MetaDataWidget::create_text_widget(bool readonly, uint32_t id)
 {
     if(readonly) {
         Gtk::Label * l = Gtk::manage(new Gtk::Label());
-        l->set_alignment(0.0f, 0.5f);
+        l->set_xalign(0.0f);
+        l->set_yalign(0.5f);
         return l;
     }
 
@@ -109,7 +110,7 @@ MetaDataWidget::create_text_widget(bool readonly, uint32_t id)
     e->set_wrap_mode(Gtk::WRAP_WORD);
     e->signal_focus_out_event().connect(
         sigc::bind(
-            sigc::mem_fun(*this, 
+            sigc::mem_fun(*this,
                           &MetaDataWidget::on_text_changed),
             e->get_buffer(), id));
     return e;
@@ -120,7 +121,8 @@ MetaDataWidget::create_string_widget(bool readonly, uint32_t id)
 {
     if(readonly) {
         Gtk::Label * l = Gtk::manage(new Gtk::Label());
-        l->set_alignment(0.0f, 0.5f);
+        l->set_xalign(0.0f);
+        l->set_yalign(0.5f);
         return l;
     }
 
@@ -128,7 +130,7 @@ MetaDataWidget::create_string_widget(bool readonly, uint32_t id)
     e->set_has_frame(false); // TODO make that a custom widget
     e->signal_focus_out_event().connect(
         sigc::bind(
-            sigc::mem_fun(*this, 
+            sigc::mem_fun(*this,
                           &MetaDataWidget::on_str_changed),
             e, id));
     return e;
@@ -141,7 +143,7 @@ MetaDataWidget::create_date_widget(bool /*readonly*/, uint32_t id)
     return create_string_widget(true, id);
 }
 
-void 
+void
 MetaDataWidget::create_widgets_for_format(const MetaDataSectionFormat * fmt)
 {
     Gtk::Widget *w = nullptr;
@@ -150,18 +152,20 @@ MetaDataWidget::create_widgets_for_format(const MetaDataSectionFormat * fmt)
 
     while(current && current->label) {
         Gtk::Label *labelw = Gtk::manage(new Gtk::Label(
-                                             Glib::ustring("<b>") 
+                                             Glib::ustring("<b>")
                                              + current->label + "</b>"));
         if(current->type != MetaDT::STRING_ARRAY
            && current->type != MetaDT::TEXT) {
-            labelw->set_alignment(0.0f, 0.5f);
+            labelw->set_xalign(0.0f);
+            labelw->set_yalign(0.5f);
         }
         else {
             // Text can wrap. Different alignment for the label
-            labelw->set_alignment(0.0f, 0.0f);
+            labelw->set_xalign(0.0f);
+            labelw->set_yalign(0.0f);
         }
         labelw->set_use_markup(true);
-    
+
         switch(current->type) {
         case MetaDT::STAR_RATING:
             w = create_star_rating_widget(current->readonly, current->id);
@@ -179,7 +183,7 @@ MetaDataWidget::create_widgets_for_format(const MetaDataSectionFormat * fmt)
             w = create_string_widget(current->readonly, current->id);
             break;
         }
-    
+
         m_table.insert_row(n_row + 1);
         m_table.attach(*labelw, 0, n_row, 1, 1);
         m_table.attach_next_to(*w, *labelw, Gtk::POS_RIGHT, 1, 1);
diff --git a/src/fwk/toolkit/widgets/editablehscale.cpp b/src/fwk/toolkit/widgets/editablehscale.cpp
index 09ad620..5660eb0 100644
--- a/src/fwk/toolkit/widgets/editablehscale.cpp
+++ b/src/fwk/toolkit/widgets/editablehscale.cpp
@@ -31,7 +31,8 @@ EditableHScale::EditableHScale(double min, double max, double step)
     : Gtk::Box(Gtk::ORIENTATION_HORIZONTAL),
       m_icon(nullptr),
       m_adj(Gtk::Adjustment::create(0, min, max, step)),
-      m_scale(m_adj), m_entry(m_adj),
+      m_scale(m_adj, Gtk::ORIENTATION_HORIZONTAL),
+      m_entry(m_adj),
       m_dirty(false)
 {
     _init();
diff --git a/src/fwk/toolkit/widgets/editablehscale.hpp b/src/fwk/toolkit/widgets/editablehscale.hpp
index 4689f83..1e53a4a 100644
--- a/src/fwk/toolkit/widgets/editablehscale.hpp
+++ b/src/fwk/toolkit/widgets/editablehscale.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - fwk/widgets/editablehscale.h
  *
- * Copyright (C) 2008 Hubert Figuiere
+ * Copyright (C) 2008-2017 Hubert Figuière
  *
  * 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
@@ -29,7 +29,7 @@
 
 namespace fwk {
 
-/** A widget similar to a Gtk::HScale with a edit box */
+/** A widget similar to a Gtk::Scale with a edit box */
 class EditableHScale
     : public Gtk::Box
 {
@@ -54,7 +54,7 @@ private:
 
     Gtk::Image      *m_icon;
     Glib::RefPtr<Gtk::Adjustment>  m_adj;
-    Gtk::HScale      m_scale;
+    Gtk::Scale       m_scale;
     Gtk::SpinButton  m_entry;
     bool             m_dirty;
     /** emitted once the value changed */
diff --git a/src/niepce/modules/darkroom/darkroommodule.hpp b/src/niepce/modules/darkroom/darkroommodule.hpp
index 29cb225..7b4ab59 100644
--- a/src/niepce/modules/darkroom/darkroommodule.hpp
+++ b/src/niepce/modules/darkroom/darkroommodule.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - modules/darkroom/darkroommodule.hpp
  *
- * Copyright (C) 2008-2014 Hubert Figuiere
+ * Copyright (C) 2008-2017 Hubert Figuière
  *
  * 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
@@ -74,7 +74,7 @@ private:
     ImageCanvas*                 m_imagecanvas;
     Gtk::ScrolledWindow          m_canvas_scroll;
     ToolboxController::Ptr       m_toolbox_ctrl;
-    Glib::RefPtr<Gtk::ActionGroup> m_actionGroup;
+    Glib::RefPtr<Gio::ActionGroup> m_actionGroup;
     eng::LibFile::WeakPtr        m_imagefile;
     ncr::Image::Ptr              m_image;
     fwk::Dock                   *m_dock;
diff --git a/src/niepce/modules/darkroom/dritemwidget.cpp b/src/niepce/modules/darkroom/dritemwidget.cpp
index 4ac949a..619daf2 100644
--- a/src/niepce/modules/darkroom/dritemwidget.cpp
+++ b/src/niepce/modules/darkroom/dritemwidget.cpp
@@ -1,7 +1,7 @@
 /*
  * niepce - darkroom/dritem.cpp
  *
- * Copyright (C) 2008 Hubert Figuiere
+ * Copyright (C) 2008-2017 Hubert Figuière
  *
  * 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
@@ -33,7 +33,7 @@ DrItemWidget::DrItemWidget(const Glib::ustring & title)
 
 void DrItemWidget::add_widget(const Glib::ustring & label, Gtk::Widget & w)
 {
-    Gtk::Label *l = manage(new Gtk::Label(label, 0.0f, 0.5f));
+    Gtk::Label *l = manage(new Gtk::Label(label, Gtk::ALIGN_START, Gtk::ALIGN_CENTER));
     m_box.pack_start(*l, Gtk::PACK_SHRINK);
     m_box.pack_start(w, Gtk::PACK_SHRINK);
 }
diff --git a/src/niepce/modules/darkroom/imagecanvas.cpp b/src/niepce/modules/darkroom/imagecanvas.cpp
index f0220f0..1958ad6 100644
--- a/src/niepce/modules/darkroom/imagecanvas.cpp
+++ b/src/niepce/modules/darkroom/imagecanvas.cpp
@@ -1,7 +1,7 @@
 /*
  * niepce - darkroom/imagecanvas.cpp
  *
- * Copyright (C) 2008-2013 Hubert Figuiere
+ * Copyright (C) 2008-2017 Hubert Figuière
  *
  * 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
@@ -169,10 +169,11 @@ bool ImageCanvas::on_draw(const Cairo::RefPtr<Cairo::Context>& context)
 //        sc->set_antialias(Cairo::ANTIALIAS_NONE);
 
         // paint the background
-        sc->rectangle(0, 0, canvas_w, canvas_h);
-        Gdk::RGBA color = get_style_context()->get_background_color(Gtk::STATE_FLAG_NORMAL);
-        Gdk::Cairo::set_source_rgba(sc, color);
-        sc->fill();
+        auto ctxt = get_style_context();
+        ctxt->context_save();
+        ctxt->set_state(Gtk::STATE_FLAG_NORMAL);
+        ctxt->render_background(sc, 0, 0, canvas_w, canvas_h);
+        ctxt->context_restore();
 
 
         double out_w = (img_w * scale);
diff --git a/src/niepce/ui/librarycellrenderer.cpp b/src/niepce/ui/librarycellrenderer.cpp
index 1aa7061..cf03e35 100644
--- a/src/niepce/ui/librarycellrenderer.cpp
+++ b/src/niepce/ui/librarycellrenderer.cpp
@@ -1,7 +1,7 @@
 /*
  * niepce - ui/librarycellrenderer.cpp
  *
- * Copyright (C) 2008-2013 Hubert Figuiere
+ * Copyright (C) 2008-2017 Hubert Figuière
  *
  * 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
@@ -215,26 +215,21 @@ LibraryCellRenderer::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
     eng::LibFile::Ptr file = m_libfileproperty.get_value();
 
     Glib::RefPtr<Gtk::StyleContext> style_context = widget.get_style_context();
-    Gdk::RGBA colour;
+
+    style_context->context_save();
     if(flags & Gtk::CELL_RENDERER_SELECTED) {
-        colour = style_context->get_background_color(Gtk::STATE_FLAG_SELECTED);
+        style_context->set_state(Gtk::STATE_FLAG_SELECTED);
     }
     else {
-        colour = style_context->get_background_color(Gtk::STATE_FLAG_NORMAL);
+        style_context->set_state(Gtk::STATE_FLAG_NORMAL);
     }
-
-    Gdk::Cairo::set_source_rgba(cr, colour);
-    cr->rectangle(r.x, r.y, r.width, r.height);
-    cr->fill();
+    style_context->render_background(cr, r.x, r.y, r.width, r.height);
 
     if(m_drawborder) {
-        colour = style_context->get_border_color(Gtk::STATE_FLAG_SELECTED);
-        Gdk::Cairo::set_source_rgba(cr, colour);
-        cr->set_line_width(1.0);
-        cr->rectangle(r.x, r.y, r.width, r.height);
-        cr->stroke();
+        style_context->render_frame(cr, r.x, r.y, r.width, r.height);
     }
-    
+    style_context->context_restore();
+
     Glib::RefPtr<Gdk::Pixbuf> pixbuf = property_pixbuf();
     _drawThumbnail(cr, pixbuf, r);
     if(m_drawrating) {
diff --git a/src/niepce/ui/moduleshell.cpp b/src/niepce/ui/moduleshell.cpp
index ef19562..a3b3bee 100644
--- a/src/niepce/ui/moduleshell.cpp
+++ b/src/niepce/ui/moduleshell.cpp
@@ -1,7 +1,7 @@
 /*
  * niepce - niepce/ui/moduleshell.cpp
  *
- * Copyright (C) 2007-2014 Hubert Figuiere
+ * Copyright (C) 2007-2017 Hubert Figuière
  *
  * 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
diff --git a/src/niepce/ui/moduleshell.hpp b/src/niepce/ui/moduleshell.hpp
index 8be4a87..a112137 100644
--- a/src/niepce/ui/moduleshell.hpp
+++ b/src/niepce/ui/moduleshell.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - ui/moduleshell.hpp
  *
- * Copyright (C) 2007-2014 Hubert Figuiere
+ * Copyright (C) 2007-2017 Hubert Figuière
  *
  * 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
diff --git a/src/niepce/ui/thumbstripview.cpp b/src/niepce/ui/thumbstripview.cpp
index 7bfbc25..abfb227 100644
--- a/src/niepce/ui/thumbstripview.cpp
+++ b/src/niepce/ui/thumbstripview.cpp
@@ -1,7 +1,7 @@
 /* Eye Of Gnome - Thumbnail View
  *
  * Copyright (C) 2006 The Free Software Foundation
- * Copyright (C) 2007-2014 Hubert Figuiere
+ * Copyright (C) 2007-2017 Hubert Figuière
  *
  * C++-ization: Hubert Figuiere <hub figuiere net>
  * Original Author: Claudio Saavedra <csaavedra alumnos utalca cl>
@@ -86,9 +86,6 @@ ThumbStripView::ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store)
     m_renderer = manage(new ThumbStripCell());
 
     pack_start(*m_renderer, FALSE);
-    if (gtk_check_version(3, 16, 0) != nullptr) {
-        m_renderer->property_follow_state() = true;
-    }
     m_renderer->property_height() = 100;
     m_renderer->property_yalign() = 0.5;
     m_renderer->property_xalign() = 0.5;


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