[med-svn] [aghermann] 04/24: deal with some GTK deprecatiions (gtk_widget_override_font)

andrei zavada hmmr-guest at moszumanska.debian.org
Mon Jun 15 01:48:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to branch WIP
in repository aghermann.

commit 97d6959b88b85ca0acdba47bd410469989e5ff2a
Author: Andrei Zavada <hmmr at ra>
Date:   Fri Jun 12 03:29:06 2015 +0300

    deal with some GTK deprecatiions (gtk_widget_override_font)
---
 upstream/src/aghermann/ui/globals.cc      | 15 +++++++++++++++
 upstream/src/aghermann/ui/globals.hh      | 14 ++++++++++++++
 upstream/src/aghermann/ui/mf/construct.cc |  5 ++---
 upstream/src/aghermann/ui/mw/construct.cc | 15 ++++++---------
 upstream/src/aghermann/ui/sf/construct.cc | 10 +++++-----
 upstream/src/aghermann/ui/sf/d/rk1968.cc  |  7 ++-----
 6 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/upstream/src/aghermann/ui/globals.cc b/upstream/src/aghermann/ui/globals.cc
index 6edd979..c829339 100644
--- a/upstream/src/aghermann/ui/globals.cc
+++ b/upstream/src/aghermann/ui/globals.cc
@@ -28,6 +28,13 @@ GtkWindow
         *agh::ui::global::main_window;
 
 
+// global css
+
+GtkCssProvider
+        *agh::ui::global::css_mono8,
+        *agh::ui::global::css_mono10;
+
+
 // unique
 
 void
@@ -39,6 +46,7 @@ set_unique_app_window( GtkWindow* w)
                 main_window = w);
 }
 
+
 // own init
 
 int
@@ -61,6 +69,13 @@ prepare_for_expdesign()
         }
         g_resources_register( gresource);
 
+        css_mono8 = gtk_css_provider_new();
+        gtk_css_provider_load_from_data(
+                css_mono8, "* {font: Mono 8}", -1, NULL);
+        css_mono10 = gtk_css_provider_new();
+        gtk_css_provider_load_from_data(
+                css_mono8, "* {font: Mono 10}", -1, NULL);
+
         return 0;
 }
 
diff --git a/upstream/src/aghermann/ui/globals.hh b/upstream/src/aghermann/ui/globals.hh
index 2cd9b61..20e4665 100644
--- a/upstream/src/aghermann/ui/globals.hh
+++ b/upstream/src/aghermann/ui/globals.hh
@@ -41,6 +41,20 @@ extern double
         hdpmm,
         vdpmm;
 
+
+extern GtkCssProvider
+        *css_mono8, *css_mono10;
+
+inline void
+set_mono_font(GtkWidget* w, GtkCssProvider* css)
+{
+        gtk_style_context_add_provider(
+                gtk_widget_get_style_context( w),
+                (GtkStyleProvider*)css,
+                GTK_STYLE_PROVIDER_PRIORITY_USER);
+}
+
+
 // quick tmp storage
 #define AGH_BUF_SIZE (1024*5)
 extern char
diff --git a/upstream/src/aghermann/ui/mf/construct.cc b/upstream/src/aghermann/ui/mf/construct.cc
index 8a806c6..dd6f983 100644
--- a/upstream/src/aghermann/ui/mf/construct.cc
+++ b/upstream/src/aghermann/ui/mf/construct.cc
@@ -95,9 +95,8 @@ construct_widgets()
                 NULL);
 
 
-        auto font_desc = pango_font_description_from_string( "Mono 9");
-        gtk_widget_override_font( (GtkWidget*)lMFLog, font_desc);
-        pango_font_description_free( font_desc);
+        agh::ui::global::set_mono_font(
+                (GtkWidget*)lMFLog, agh::ui::global::css_mono8);
 
         log_text_buffer = gtk_text_view_get_buffer( lMFLog);
 
diff --git a/upstream/src/aghermann/ui/mw/construct.cc b/upstream/src/aghermann/ui/mw/construct.cc
index 10457f8..1a01249 100644
--- a/upstream/src/aghermann/ui/mw/construct.cc
+++ b/upstream/src/aghermann/ui/mw/construct.cc
@@ -73,9 +73,6 @@ SExpDesignUIWidgets ()
         g_object_ref( (GObject*)mFFTParamsBinSize);
         g_object_ref( (GObject*)mFFTParamsWindowType);
 
-      // misc
-        auto font_desc = pango_font_description_from_string( "Mono 9");
-
         GtkTreeViewColumn *col;
 
       // =========== 1. Measurements
@@ -300,7 +297,9 @@ SExpDesignUIWidgets ()
         AGH_GBGETOBJ (wScanLog);
         AGH_GBGETOBJ (tScanLog);
 
-        gtk_widget_override_font( (GtkWidget*)tScanLog, font_desc);
+        agh::ui::global::set_mono_font(
+                (GtkWidget*)tScanLog, agh::ui::global::css_mono8);
+        // gtk_widget_override_font( (GtkWidget*)tScanLog, font_desc);
         gtk_text_buffer_create_tag(
                 gtk_text_view_get_buffer( tScanLog),
                 "bold",
@@ -528,7 +527,9 @@ SExpDesignUIWidgets ()
         // used by two GtkTextView's, lEDFFileDetailsReport and lEdfImportFileInfo
         AGH_GBGETOBJ (tEDFFileDetailsReport);
 
-        gtk_widget_override_font( (GtkWidget*)lEDFFileDetailsReport, font_desc);
+        agh::ui::global::set_mono_font(
+                (GtkWidget*)lEDFFileDetailsReport, agh::ui::global::css_mono8);
+        // gtk_widget_override_font( (GtkWidget*)lEDFFileDetailsReport, font_desc);
         g_object_set( lEDFFileDetailsReport,
                       "tabs", pango_tab_array_new_with_positions(
                               2, TRUE,
@@ -552,8 +553,6 @@ SExpDesignUIWidgets ()
         AGH_GBGETOBJ (bEdfImportAdmit);
         AGH_GBGETOBJ (bEdfImportEdfhed);
 
-        gtk_widget_override_font( (GtkWidget*)lEdfImportFileInfo, font_desc);
-
         g_object_set( lEdfImportFileInfo,
                       "tabs", pango_tab_array_new_with_positions(
                                 2, TRUE,
@@ -651,8 +650,6 @@ SExpDesignUIWidgets ()
         gtk_combo_box_set_model_properly(
                 eGlobalADProfiles, mGlobalADProfiles);
         G_CONNECT_1 (eGlobalADProfiles, changed);
-
-        pango_font_description_free( font_desc);
 }
 
 
diff --git a/upstream/src/aghermann/ui/sf/construct.cc b/upstream/src/aghermann/ui/sf/construct.cc
index c923a90..fe785a6 100644
--- a/upstream/src/aghermann/ui/sf/construct.cc
+++ b/upstream/src/aghermann/ui/sf/construct.cc
@@ -78,11 +78,11 @@ SScoringFacilityWidgets ()
         G_CONNECT_2 (eSFCurrentPage, value, changed);
 
         G_CONNECT_1 (eSFCurrentPos, clicked);
-        {
-                auto font_desc = pango_font_description_from_string( "Mono 8");
-                gtk_widget_override_font( (GtkWidget*)eSFCurrentPos, font_desc);
-                pango_font_description_free( font_desc);
-        }
+        agh::ui::global::set_mono_font(
+                (GtkWidget*)eSFCurrentPos, agh::ui::global::css_mono8);
+        // auto font_desc = pango_font_description_from_string( "Mono 8");
+        // gtk_widget_override_font( (GtkWidget*)eSFCurrentPos, font_desc);
+        // pango_font_description_free( font_desc);
 
         G_CONNECT_1 (bSFForward, clicked);
         G_CONNECT_1 (bSFBack, clicked);
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968.cc b/upstream/src/aghermann/ui/sf/d/rk1968.cc
index ef8a6df..691bffd 100644
--- a/upstream/src/aghermann/ui/sf/d/rk1968.cc
+++ b/upstream/src/aghermann/ui/sf/d/rk1968.cc
@@ -68,11 +68,8 @@ SRK1968Dialog (SScoringFacility& p_)
         gtk_combo_box_set_model_properly(
                 eSFRKProfileList, mSFRKProfiles);
 
-        {
-                auto font_desc = pango_font_description_from_string( "Mono 10");
-                gtk_widget_override_font( (GtkWidget*)eSFRKScript, font_desc);
-                pango_font_description_free( font_desc);
-        }
+        agh::ui::global::set_mono_font(
+                (GtkWidget*)eSFRKScript, agh::ui::global::css_mono10);
 
         G_CONNECT_1 (wSFRK, show);
         G_CONNECT_1 (wSFRK, hide);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git



More information about the debian-med-commit mailing list