[fgrun/f17: 3/4] upstream patch r665 implements system-wide settings

Fabrice Bellet bellet at fedoraproject.org
Mon Jul 30 20:31:41 UTC 2012


commit ad5b2db579d136bcca0e9ad76735be5a71957881
Author: Fabrice Bellet <fabrice at bellet.info>
Date:   Mon Jul 30 22:28:27 2012 +0200

    upstream patch r665 implements system-wide settings

 fgrun-1.6.1-default-settings-for-fedora.patch |   16 --
 fgrun-1.6.1-systemprefs.patch                 |  209 +++++++++++++++++++++++++
 fgrun.prefs                                   |   10 ++
 fgrun.spec                                    |   16 ++-
 4 files changed, 232 insertions(+), 19 deletions(-)
---
diff --git a/fgrun-1.6.1-systemprefs.patch b/fgrun-1.6.1-systemprefs.patch
new file mode 100644
index 0000000..d52da63
--- /dev/null
+++ b/fgrun-1.6.1-systemprefs.patch
@@ -0,0 +1,209 @@
+Index: src/wizard.h
+===================================================================
+--- src/wizard.h	(revision 664)
++++ src/wizard.h	(revision 665)
+@@ -310,6 +310,7 @@
+   static void refresh_airports( Fl_Widget*, void* ); 
+ private:
+   Fl_Preferences prefs; 
++  Fl_Preferences systemPrefs; 
+   LogWindow* logwin; 
+   Fl_Pixmap folder_open_pixmap; 
+   Fl_Pixmap warning_pixmap; 
+Index: src/wizard_funcs.cxx
+===================================================================
+--- src/wizard_funcs.cxx	(revision 664)
++++ src/wizard_funcs.cxx	(revision 665)
+@@ -235,9 +235,23 @@
+     char buf[ buflen ];
+ 
+     prefs.get( "fg_exe", buf, def_fg_exe.c_str(), buflen-1);
++    if (buf[0] == '\0')
++    {
++        systemPrefs.get( "fg_exe_init", buf, def_fg_exe.c_str(), buflen-1);
++        prefs.set("fg_exe_init", buf);
++        systemPrefs.get( "fg_exe", buf, def_fg_exe.c_str(), buflen-1);
++        prefs.set("fg_exe", buf);
++    }
+     fg_exe_->value( buf );
+ 
+     prefs.get( "fg_root", buf, def_fg_root.c_str(), buflen-1);
++    if (buf[0] == '\0')
++    {
++        systemPrefs.get( "fg_root_init", buf, def_fg_exe.c_str(), buflen-1);
++        prefs.set("fg_root_init", buf);
++        systemPrefs.get( "fg_root", buf, def_fg_exe.c_str(), buflen-1);
++        prefs.set("fg_root", buf);
++    }
+     fg_root_->value( buf );
+     SGPath fgPath(buf);
+     if ( fg_root_->size() == 0 )
+@@ -266,14 +280,21 @@
+         aircraft_dir_list_->add( va[i].c_str() );
+ 
+     string fg_scenery;
+-    if (!def_fg_scenery.empty())
++    if (prefs.get( "fg_scenery", buf, "", buflen-1))
+     {
+-        fg_scenery = def_fg_scenery;
++        fg_scenery = buf;
+     }
+-    else if (prefs.get( "fg_scenery", buf, "", buflen-1))
++    else if (systemPrefs.get( "fg_scenery", buf, "", buflen-1))
+     {
+         fg_scenery = buf;
++        prefs.set("fg_scenery", buf);
++        systemPrefs.get( "fg_scenery_init", buf, def_fg_exe.c_str(), buflen-1);
++        prefs.set("fg_scenery_init", buf);
+     }
++    else if (!def_fg_scenery.empty())
++    {
++        fg_scenery = def_fg_scenery;
++    }
+     else if (fg_root_->size() > 0)
+     {
+         char *e = getenv( "FG_SCENERY" );
+@@ -292,7 +313,13 @@
+     scenery_dir_list_->clear();
+     vs_t vs( sgPathSplit( fg_scenery ) );
+ 
+-    prefs.get("ts_dir", ts_dir, (def_ts_dir>=0) ? def_ts_dir : 0);
++    if (!prefs.get("ts_dir", ts_dir, 0) && systemPrefs.get("ts_dir", ts_dir, (def_ts_dir>=0) ? def_ts_dir : 0))
++    {
++        prefs.set("ts_dir", ts_dir);
++        int iVal;
++        systemPrefs.get("ts_dir_init", iVal, 0);
++        prefs.set("ts_dir_init", iVal);
++    }
+ 
+     for (vs_t::size_type i = 0; i < vs.size(); ++i)
+     {
+@@ -302,7 +329,13 @@
+             scenery_dir_list_->add( vs[i].c_str() );
+     }
+ 
+-    prefs.get( "ts_exe", buf, def_ts_exe.c_str(), buflen-1);
++    if (!prefs.get( "ts_exe", buf, "", buflen-1) && systemPrefs.get( "ts_exe", buf, def_ts_exe.c_str(), buflen-1))
++    {
++        prefs.set("ts_exe", buf);
++        systemPrefs.get("ts_exe_init", buf, "", buflen-1);
++        prefs.set("ts_exe_init", buf);
++        prefs.get( "ts_exe", buf, "", buflen-1);
++    }
+     ts_exe_->value( buf );
+ 
+     bool fg_exe_ok = fg_exe_->size() != 0 && is_valid_fg_exe( fg_exe_->value() ),
+@@ -2271,35 +2304,29 @@
+ 
+     const int buflen = FL_PATH_MAX;
+     char buf[ buflen ];
+-    const char* not_set = "NOT SET";
+ 
+-    prefs.get( "fg_exe_init", buf, not_set, buflen-1);
+-    if ( strcmp( buf, not_set ) != 0 )
++    if ( prefs.get( "fg_exe_init", buf, "", buflen-1) != 0 )
+     {
+         prefs.set( "fg_exe", buf );
+     }
+ 
+-    prefs.get( "fg_root_init", buf, not_set, buflen-1);
+-    if ( strcmp( buf, not_set ) != 0 )
++    if ( prefs.get( "fg_root_init", buf, "", buflen-1) != 0 )
+     {
+         prefs.set( "fg_root", buf );
+     }
+ 
+-    prefs.get( "fg_scenery_init", buf, not_set, buflen-1 );
+-    if ( strcmp( buf, not_set ) != 0 )
++    if ( prefs.get( "fg_scenery_init", buf, "", buflen-1 ) != 0 )
+     {
+         prefs.set( "fg_scenery", buf );
+     }
+ 
+-    prefs.get( "ts_exe_init", buf, not_set, buflen-1);
+-    if ( strcmp( buf, not_set ) != 0 )
++    if ( prefs.get( "ts_exe_init", buf, "", buflen-1) != 0 )
+     {
+         prefs.set( "ts_exe", buf );
+     }
+ 
+     int iVal = -1;
+-    prefs.get( "ts_dir_init", iVal, -1);
+-    if ( iVal != -1 )
++    if ( prefs.get( "ts_dir_init", iVal, -1) != 0 )
+     {
+         ts_dir = iVal;
+         prefs.set( "ts_dir", ts_dir );
+Index: src/wizard.fl
+===================================================================
+--- src/wizard.fl	(revision 664)
++++ src/wizard.fl	(revision 665)
+@@ -84,13 +84,13 @@
+     decl {TerraSyncThread &operator=( const TerraSyncThread & );} {private local
+     }
+   }
+-  Function {Wizard() : prefs( Fl_Preferences::USER, "flightgear.org", "fgrun" ), logwin(0), folder_open_pixmap(folder_open_xpm), warning_pixmap(warning_xpm), question_pixmap(question_xpm), adv(0), fgThread(0), tsThread(0), fgPid(0), tsPid(0)} {open
++  Function {Wizard() : prefs( Fl_Preferences::USER, "flightgear.org", "fgrun" ), systemPrefs( Fl_Preferences::SYSTEM, "flightgear.org", "fgrun" ),logwin(0), folder_open_pixmap(folder_open_xpm), warning_pixmap(warning_xpm), question_pixmap(question_xpm), adv(0), fgThread(0), tsThread(0), fgPid(0), tsPid(0)} {open
+   } {
+     Fl_Window win {
+       label {FlightGear Wizard} open
+       private xywh {579 307 800 600} type Double visible
+     } {
+-      Fl_Wizard wiz {open
++      Fl_Wizard wiz {
+         private xywh {0 0 800 560}
+         code0 {win->resizable( wiz );}
+       } {
+@@ -312,7 +312,7 @@
+             }
+           }
+         }
+-        Fl_Group {page[3]} {open
++        Fl_Group {page[3]} {
+           private xywh {0 0 800 560}
+         } {
+           Fl_Group {} {
+@@ -497,7 +497,7 @@
+               } {
+                 Fl_Button {} {
+                   label {Deselect all}
+-                  callback {deselect_all_scenarii_cb();} selected
++                  callback {deselect_all_scenarii_cb();}
+                   tooltip {Ctrl-click to deselect a single item} xywh {495 230 265 25} resizable
+                 }
+                 Fl_Box scenarii_help {
+@@ -712,6 +712,8 @@
+   }
+   decl {Fl_Preferences prefs;} {private local
+   }
++  decl {Fl_Preferences systemPrefs;} {selected private local
++  }
+   decl {LogWindow* logwin;} {private local
+   }
+   decl {Fl_Pixmap folder_open_pixmap;} {private local
+Index: src/main.cxx
+===================================================================
+--- src/main.cxx	(revision 664)
++++ src/main.cxx	(revision 665)
+@@ -157,7 +157,7 @@
+ 
+     if ( silent )
+     {
+-        Fl_Preferences prefs( Fl_Preferences::USER, "flightgear.org", "fgrun" );
++        Fl_Preferences prefs( Fl_Preferences::SYSTEM, "flightgear.org", "fgrun" );
+         char abs_name[ FL_PATH_MAX ];
+ 
+         if ( !def_fg_exe.empty() )
+Index: src/wizard.cxx
+===================================================================
+--- src/wizard.cxx	(revision 664)
++++ src/wizard.cxx	(revision 665)
+@@ -449,7 +449,7 @@
+   ((Wizard*)(o->parent()->parent()->user_data()))->cb_OK1_i(o,v);
+ }
+ 
+-Wizard::Wizard() : prefs( Fl_Preferences::USER, "flightgear.org", "fgrun" ), logwin(0), folder_open_pixmap(folder_open_xpm), warning_pixmap(warning_xpm), question_pixmap(question_xpm), adv(0), fgThread(0), tsThread(0), fgPid(0), tsPid(0) {
++Wizard::Wizard() : prefs( Fl_Preferences::USER, "flightgear.org", "fgrun" ), systemPrefs( Fl_Preferences::SYSTEM, "flightgear.org", "fgrun" ),logwin(0), folder_open_pixmap(folder_open_xpm), warning_pixmap(warning_xpm), question_pixmap(question_xpm), adv(0), fgThread(0), tsThread(0), fgPid(0), tsPid(0) {
+   { win = new Fl_Double_Window(800, 600, _("FlightGear Wizard"));
+     win->user_data((void*)(this));
+     { wiz = new Fl_Wizard(0, 0, 800, 560);
diff --git a/fgrun.prefs b/fgrun.prefs
new file mode 100644
index 0000000..c522fbf
--- /dev/null
+++ b/fgrun.prefs
@@ -0,0 +1,10 @@
+; FLTK preferences file format 1.0
+; vendor: flightgear.org
+; application: fgrun
+
+[.]
+
+fg_exe:/usr/bin/fgfs
+fg_root:/usr/share/flightgear
+fg_scenery:/usr/share/flightgear/Scenery
+ts_exe:/usr/bin/terrasync
diff --git a/fgrun.spec b/fgrun.spec
index 09f69c7..4fa3b65 100644
--- a/fgrun.spec
+++ b/fgrun.spec
@@ -1,13 +1,14 @@
 Name:           fgrun
 Summary:        Graphical front-end for launching FlightGear flight simulator
 Version:        1.6.1
-Release:        3%{?dist}
+Release:        4%{?dist}
 License:        GPLv2+ and CC-BY-SA
 Group:          Amusements/Games
 URL:            http://sourceforge.net/projects/fgrun
 Source0:        http://sourceforge.net/projects/fgrun/files/fgrun/%{version}/fgrun-%{version}.tar.bz2
 Source1:        %{name}.desktop
 Source2:        README.Fedora
+Source3:        fgrun.prefs
 # The icon is licensed under the CC Attribution-Share Alike 3.0 license
 # http://commons.wikimedia.org/wiki/File:Bt_plane.svg
 Source10:       http://upload.wikimedia.org/wikipedia/commons/9/9c/Bt_plane.svg
@@ -18,7 +19,7 @@ Source14:       Bt_plane-64.png
 Source15:       Bt_plane-128.png
 Patch0:         fgrun-1.6.1-build-fgrun-with-static-ui-libs.patch
 Patch1:         fgrun-1.6.1-fix-crash-when-setting-defaults.patch
-Patch2:         fgrun-1.6.1-default-settings-for-fedora.patch
+Patch2:         fgrun-1.6.1-systemprefs.patch
 Buildroot:      %{_tmppath}/%{name}-%{version}-%{release}-root
 Requires:       FlightGear, opengl-games-utils, hicolor-icon-theme
 BuildRequires:  SimGear-devel >= 2.6.0
@@ -34,7 +35,7 @@ FlightGear flight simulator
 %setup -q
 %patch0 -p1
 %patch1 -p1
-%patch2 -p1
+%patch2 -p0
 cp -a %{SOURCE2} .
 
 %build 
@@ -48,6 +49,9 @@ make %{?_smp_mflags}
 rm -fr $RPM_BUILD_ROOT
 make install DESTDIR=$RPM_BUILD_ROOT
 ln -s opengl-game-wrapper.sh $RPM_BUILD_ROOT%{_bindir}/fgrun-wrapper
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/fltk/flightgear.org
+install -m 0644 %{SOURCE3} \
+        $RPM_BUILD_ROOT%{_sysconfdir}/fltk/flightgear.org/fgrun.prefs
 %find_lang %{name}
 
 desktop-file-install                                    \
@@ -93,11 +97,17 @@ rm -fr %{buildroot}
 %files  -f %{name}.lang
 %defattr(-,root,root,-) 
 %doc COPYING NEWS AUTHORS README README.Fedora
+%dir %{_sysconfdir}/fltk
+%dir %{_sysconfdir}/fltk/flightgear.org
+%{_sysconfdir}/fltk/flightgear.org/fgrun.prefs
 %{_bindir}/* 
 %{_datadir}/applications/*.desktop
 %{_datadir}/icons/hicolor/*/apps/*
 
 %changelog 
+* Tue Jul 24 2012 Fabrice Bellet <fabrice at bellet.info> 1.6.1-4
+- upstream patch r665 implements system-wide settings
+
 * Thu Jul 19 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.6.1-3
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
 


More information about the scm-commits mailing list