/[svn]/gigedit/trunk/src/gigedit/gigedit.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/gigedit.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3488 by persson, Sat Feb 16 19:56:56 2019 UTC revision 3489 by persson, Sun Mar 3 09:08:20 2019 UTC
# Line 37  Line 37 
37  #include <glibmm/miscutils.h>  #include <glibmm/miscutils.h>
38  #include <gtkmm/main.h>  #include <gtkmm/main.h>
39    
40  #ifdef WIN32  #if defined(WIN32) || defined(__APPLE__)
41  #include <gtkmm/icontheme.h>  #include <gtkmm/icontheme.h>
42  #endif  #endif
43    
# Line 152  bool gigedit_installdir_is_parent = fals Line 152  bool gigedit_installdir_is_parent = fals
152    
153  #ifdef __APPLE__  #ifdef __APPLE__
154  std::string gigedit_localedir;  std::string gigedit_localedir;
155    std::string gigedit_datadir;
156  #endif  #endif
157    
158  void init_app() {  void init_app() {
# Line 172  void init_app() { Line 173  void init_app() {
173              std::string libdir = Glib::path_get_dirname(info.dli_fname);              std::string libdir = Glib::path_get_dirname(info.dli_fname);
174  #endif  #endif
175    
176                // newer pango versions don't use modules
177    #if PANGO_VERSION_MAJOR == 1 && PANGO_VERSION_MINOR < 38
178              if (Glib::getenv("PANGO_SYSCONFDIR") == "" &&              if (Glib::getenv("PANGO_SYSCONFDIR") == "" &&
179                  Glib::file_test(Glib::build_filename(libdir,                  Glib::file_test(Glib::build_filename(libdir,
180                                                       "pango/pango.modules"),                                                       "pango/pango.modules"),
181                                  Glib::FILE_TEST_EXISTS)) {                                  Glib::FILE_TEST_EXISTS)) {
182                  Glib::setenv("PANGO_SYSCONFDIR", libdir, true);                  Glib::setenv("PANGO_SYSCONFDIR", libdir, true);
183              }              }
184    #endif
185              if (Glib::getenv("GDK_PIXBUF_MODULE_FILE") == "") {              if (Glib::getenv("GDK_PIXBUF_MODULE_FILE") == "") {
186                  std::string module_file =                  std::string module_file =
187                      Glib::build_filename(libdir,                      Glib::build_filename(libdir,
188                                           "gtk-2.0/gdk-pixbuf.loaders");                                           "gdk-pixbuf-2.0/2.10.0/loaders.cache");
189                  if (Glib::file_test(module_file, Glib::FILE_TEST_EXISTS)) {                  if (Glib::file_test(module_file, Glib::FILE_TEST_EXISTS)) {
190                      Glib::setenv("GDK_PIXBUF_MODULE_FILE", module_file, true);                      Glib::setenv("GDK_PIXBUF_MODULE_FILE", module_file, true);
191                  }                  }
192              }              }
193                std::string datadir = Glib::build_filename(
194                    Glib::path_get_dirname(libdir), "share");
195    
196                if (Glib::file_test(datadir, Glib::FILE_TEST_EXISTS)) {
197                    gigedit_datadir = datadir;
198    
199                    std::string localedir = Glib::build_filename(datadir, "locale");
200                    if (Glib::file_test(localedir, Glib::FILE_TEST_EXISTS)) {
201                        gigedit_localedir = localedir;
202                    }
203                    std::string schemadir =
204                        Glib::build_filename(gigedit_datadir, "glib-2.0/schemas");
205                    if (Glib::file_test(schemadir, Glib::FILE_TEST_EXISTS)) {
206                        Glib::setenv("GSETTINGS_SCHEMA_DIR", schemadir);
207                    }
208                }
209    //FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler?    //FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler?
210    //#if HAVE_GETTEXT    //#if HAVE_GETTEXT
211              std::string localedir = Glib::build_filename(libdir, "locale");              if (!gigedit_localedir.empty()) {
             if (Glib::file_test(localedir, Glib::FILE_TEST_EXISTS)) {  
                 gigedit_localedir = localedir;  
212                  bindtextdomain(GETTEXT_PACKAGE, gigedit_localedir.c_str());                  bindtextdomain(GETTEXT_PACKAGE, gigedit_localedir.c_str());
213              } else {              } else {
214                  bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);                  bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
# Line 257  void init_app() { Line 275  void init_app() {
275      }      }
276  }  }
277    
278    
279    #if GTKMM_MAJOR_VERSION >= 3
280    
281    /**
282     * This is required since GTK 3, because those GTK super heros came up with
283     * the clever idea to simply disable things like icons and keyboard shortcuts
284     * for menus and for buttons by default for all users, all devices and all
285     * apps. Yey! Seriously, I have no idea what came on their mind to find that
286     * was a good idea!
287     */
288    void enforceGtk3Settings() {
289    
290        // got no behavior change on those 2 settings, so ignoring them for now,
291        // actually I though I could use them to show the mnemonics in the GTK 3
292        // menus again, but it seems that was entirely removed from around GTK 3.10.
293        //g_object_set(gtk_settings_get_default(), "gtk-auto-mnemonics", false, NULL);
294        //g_object_set(gtk_settings_get_default(), "gtk-can-change-accels", true, NULL);
295    
296        // bring back keyboard accelerators with GTK 3
297        g_object_set(gtk_settings_get_default(), "gtk-enable-accels", true, NULL);
298        g_object_set(gtk_settings_get_default(), "gtk-enable-mnemonics", true, NULL);
299    
300        // bring back icons with GTK 3
301        g_object_set(gtk_settings_get_default(), "gtk-menu-images", true, NULL);
302        g_object_set(gtk_settings_get_default(), "gtk-button-images", true, NULL);
303    
304        // who knows ... one day those GTK "masterminds" decide to disable tooltips by default as well
305        g_object_set(gtk_settings_get_default(), "gtk-enable-tooltips", true, NULL);
306    }
307    
308    #endif // GTKM 3
309    
310    
311  void init_app_after_gtk_init() {  void init_app_after_gtk_init() {
312    #if GTKMM_MAJOR_VERSION >= 3
313        enforceGtk3Settings();
314    #endif
315        
316  //FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler?  //FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler?
317  #if (/*HAVE_GETTEXT &&*/ defined(__APPLE__))  #if (/*HAVE_GETTEXT &&*/ defined(__APPLE__))
318      // Gtk::Main binds the gtk locale to a possible non-existent      // Gtk::Main binds the gtk locale to a possible non-existent
319      // directory. If we have bundled gtk locale files, we rebind here,      // directory. If we have bundled gtk locale files, we rebind here,
320      // after the Gtk::Main constructor.      // after the Gtk::Main constructor.
321      if (!gigedit_localedir.empty()) {      if (!gigedit_localedir.empty()) {
322    #if GTKMM_MAJOR_VERSION < 3
323          bindtextdomain("gtk20", gigedit_localedir.c_str());          bindtextdomain("gtk20", gigedit_localedir.c_str());
324    #else
325            bindtextdomain("gtk30", gigedit_localedir.c_str());
326    #endif
327      }      }
328  #endif  #endif
329    
# Line 274  void init_app_after_gtk_init() { Line 333  void init_app_after_gtk_init() {
333          Gtk::IconTheme::get_default()->append_search_path(icon_dir);          Gtk::IconTheme::get_default()->append_search_path(icon_dir);
334      }      }
335  #endif  #endif
336    #ifdef __APPLE__
337        if (!gigedit_datadir.empty()) {
338            std::string icon_dir = Glib::build_filename(gigedit_datadir, "icons");
339            Gtk::IconTheme::get_default()->append_search_path(icon_dir);
340        }
341    #endif    
342  }  }
343    
344  void connect_signals(GigEdit* gigedit, MainWindow* mainwindow) {  void connect_signals(GigEdit* gigedit, MainWindow* mainwindow) {

Legend:
Removed from v.3488  
changed lines
  Added in v.3489

  ViewVC Help
Powered by ViewVC