[gnote] Make use of client side decorations configurable



commit 7b91ce2b0677fd2515e369c548ab04871b914ba3
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Apr 25 21:12:26 2015 +0300

    Make use of client side decorations configurable

 data/org.gnome.gnote.gschema.xml.in |    5 +++++
 src/mainwindow.cpp                  |   21 +++++++++++++++++----
 src/preferences.cpp                 |    3 ++-
 src/preferences.hpp                 |    3 ++-
 4 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/data/org.gnome.gnote.gschema.xml.in b/data/org.gnome.gnote.gschema.xml.in
index 7c15bca..f2e765b 100644
--- a/data/org.gnome.gnote.gschema.xml.in
+++ b/data/org.gnome.gnote.gschema.xml.in
@@ -135,6 +135,11 @@
       <_summary>Save note window size and autosize note window to it</_summary>
       <_description>Saves note window size and automatically resizes main window to this size, when note is 
opened.</_description>
     </key>
+    <key name="use-client-side-decorations" type="s">
+      <default>'gnome'</default>
+      <_summary>Use client side window decorations</_summary>
+      <_description>Should Gnote draw it's window titlebar, or leave that to window manager. Possible values 
are 'enabled' to draw them, 'disabled' to leave them to window manager, or a comma separated list of desktop 
environments, where Gnote should draw decorations itself. Requires application restart.</_description>
+    </key>
     <child name="global-keybindings" schema="org.gnome.gnote.global-keybindings" />
     <child name="export-html" schema="org.gnome.gnote.export-html" />
     <child name="sync" schema="org.gnome.gnote.sync" />
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9dd0d13..d7808db 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -18,11 +18,11 @@
  */
 
 
-#include <cstring>
-
+#include "base/macros.hpp"
 #include "ignote.hpp"
 #include "mainwindow.hpp"
 #include "notewindow.hpp"
+#include "sharp/string.hpp"
 
 namespace gnote {
 
@@ -103,12 +103,25 @@ MainWindow *MainWindow::present_default(const Note::Ptr & note)
 
 bool MainWindow::use_client_side_decorations()
 {
-  if (s_use_client_side_decorations < 0) {
-    if(std::strcmp(std::getenv("DESKTOP_SESSION"), "gnome") == 0) {
+  if(s_use_client_side_decorations < 0) {
+    Glib::ustring setting = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_string(
+      Preferences::USE_CLIENT_SIDE_DECORATIONS);
+    if(setting == "enabled") {
       s_use_client_side_decorations = 1;
     }
+    else if(setting == "disabled") {
+      s_use_client_side_decorations = 0;
+    }
     else {
       s_use_client_side_decorations = 0;
+      std::vector<std::string> desktops;
+      sharp::string_split(desktops, setting, ",");
+      const char *current_desktop = std::getenv("DESKTOP_SESSION");
+      FOREACH(std::string de, desktops) {
+        if(de == current_desktop) {
+          s_use_client_side_decorations = 1;
+        }
+      }
     }
   }
 
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 40cf028..4168ac5 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2014 Aurimas Cernius
+ * Copyright (C) 2011-2015 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -64,6 +64,7 @@ namespace gnote {
   const char * Preferences::USE_STATUS_ICON = "use-status-icon";
   const char * Preferences::OPEN_NOTES_IN_NEW_WINDOW = "open-notes-in-new-window";
   const char * Preferences::AUTOSIZE_NOTE_WINDOW = "autosize-note-window";
+  const char * Preferences::USE_CLIENT_SIDE_DECORATIONS = "use-client-side-decorations";
 
   const char * Preferences::MAIN_WINDOW_MAXIMIZED = "main-window-maximized";
   const char * Preferences::SEARCH_WINDOW_WIDTH = "search-window-width";
diff --git a/src/preferences.hpp b/src/preferences.hpp
index 2f6994f..8b4bdd1 100644
--- a/src/preferences.hpp
+++ b/src/preferences.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2014 Aurimas Cernius
+ * Copyright (C) 2011-2015 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -68,6 +68,7 @@ namespace gnote {
     static const char *SEARCH_WINDOW_HEIGHT;
     static const char *SEARCH_WINDOW_SPLITTER_POS;
     static const char *SEARCH_SORTING;
+    static const char *USE_CLIENT_SIDE_DECORATIONS;
 
     static const char *KEYBINDING_SHOW_NOTE_MENU;
     static const char *KEYBINDING_OPEN_START_HERE;


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