Advertisement
Guest User

Untitled

a guest
May 26th, 2020
48
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/src/BudgiePixelSaverApplet.vala b/src/BudgiePixelSaverApplet.vala
  2. index 75b9aac..8fef5df 100644
  3. --- a/src/BudgiePixelSaverApplet.vala
  4. +++ b/src/BudgiePixelSaverApplet.vala
  5. @@ -27,6 +27,7 @@ public class Applet : Budgie.Applet
  6.      bool is_buttons_visible {get; set;}
  7.      bool is_title_visible {get; set;}
  8.      bool is_active_window_csd {get; set;}
  9. +    bool is_active_window_crow {get; set;}
  10.      bool is_active_window_maximized {get; set;}
  11.  
  12.      public string uuid { public set; public get; }
  13. @@ -116,11 +117,12 @@ public class Applet : Budgie.Applet
  14.          });
  15.  
  16.          this.title_bar_manager.on_active_window_changed.connect(
  17. -            (can_minimize, can_maximize, can_close, is_active_window_csd, is_active_window_maximized) => {
  18. +            (can_minimize, can_maximize, can_close, is_active_window_csd, is_active_window_crow, is_active_window_maximized) => {
  19.                  this.minimize_button.set_sensitive(can_minimize);
  20.                  this.maximize_button.set_sensitive(can_maximize);
  21.                  this.close_button.set_sensitive(can_close);
  22.                  this.is_active_window_csd = is_active_window_csd;
  23. +                this.is_active_window_crow = is_active_window_crow;
  24.                  this.is_active_window_maximized = is_active_window_maximized;
  25.                  this.update_visibility(false);
  26.              }
  27. @@ -216,7 +218,7 @@ public class Applet : Budgie.Applet
  28.      }
  29.  
  30.      void update_visibility(bool is_settings_changed = false){
  31. -        bool hide_for_csd = this.is_active_window_csd && this.settings.get_boolean("hide-for-csd");
  32. +        bool hide_for_csd = (this.is_active_window_csd || this.is_active_window_crow) && this.settings.get_boolean("hide-for-csd");
  33.          bool hide_for_unmaximized = !this.is_active_window_maximized && this.settings.get_boolean("hide-for-unmaximized");
  34.  
  35.          /*if (!this.is_buttons_visible) {
  36. diff --git a/src/TitleBarManager.vala b/src/TitleBarManager.vala
  37. index 5ef3667..5bd3066 100644
  38. --- a/src/TitleBarManager.vala
  39. +++ b/src/TitleBarManager.vala
  40. @@ -19,7 +19,7 @@ public class TitleBarManager : Object {
  41.  
  42.      public signal void on_title_changed (string title);
  43.      public signal void on_window_state_changed (bool is_maximized);
  44. -    public signal void on_active_window_changed (bool can_minimize, bool can_maximize, bool can_close, bool is_active_window_csd, bool is_active_window_maximized);
  45. +    public signal void on_active_window_changed (bool can_minimize, bool can_maximize, bool can_close, bool is_active_window_csd, bool is_active_window_crow, bool is_active_window_maximized);
  46.  
  47.      /*
  48.       * Should call this at construster
  49. @@ -125,8 +125,35 @@ public class TitleBarManager : Object {
  50.          return false;
  51.      }
  52.  
  53. +    private bool is_window_crow(Wnck.Window window){
  54. +        try {
  55. +            string[] spawn_args = {"xprop", "-id",
  56. +                "%#.8x".printf((uint)window.get_xid()), "_NET_WM_NAME"};
  57. +            string[] spawn_env = Environ.get ();
  58. +            string ls_stdout;
  59. +            string ls_stderr;
  60. +            int ls_status;
  61. +
  62. +            Process.spawn_sync ("/",
  63. +                spawn_args,
  64. +                spawn_env,
  65. +                SpawnFlags.SEARCH_PATH,
  66. +                null,
  67. +                out ls_stdout,
  68. +                out ls_stderr,
  69. +                out ls_status);
  70. +
  71. +            if(ls_stdout.strip() == "_NET_WM_NAME(UTF8_STRING) = \"Crow Translate\""){
  72. +                return true;
  73. +            }
  74. +        } catch(SpawnError e){
  75. +            error(e.message);
  76. +        }
  77. +        return false;
  78. +    }
  79. +
  80.      private void change_titlebar() {
  81. -        if (active_window == null || is_window_csd(active_window)) return;
  82. +        if (active_window == null || is_window_csd(active_window) ||  is_window_crow(active_window)) return;
  83.  
  84.          try {
  85.                  bool hide_titlebar = false;
  86. @@ -164,6 +191,7 @@ public class TitleBarManager : Object {
  87.          bool can_maximize = false;
  88.          bool can_close = false;
  89.          bool is_csd = false;
  90. +        bool is_crow = false;
  91.          bool is_maximized = false;
  92.          this.active_window = this.screen.get_active_window();
  93.          if(this.active_window != null && this.active_window.get_window_type() != Wnck.WindowType.NORMAL){
  94. @@ -176,6 +204,7 @@ public class TitleBarManager : Object {
  95.              can_maximize = (actions & Wnck.WindowActions.MAXIMIZE) > 0;
  96.              can_close = (actions & Wnck.WindowActions.CLOSE) > 0;
  97.              is_csd = this.is_window_csd(this.active_window);
  98. +            is_crow = this.is_window_crow(this.active_window);
  99.              is_maximized = this.active_window.is_maximized();
  100.  
  101.              this.active_window.name_changed.connect( this.on_active_window_name_changed );
  102. @@ -185,7 +214,7 @@ public class TitleBarManager : Object {
  103.              this.on_title_changed("");
  104.          }
  105.          change_titlebar();
  106. -        this.on_active_window_changed(can_minimize, can_maximize, can_close, is_csd, is_maximized);
  107. +        this.on_active_window_changed(can_minimize, can_maximize, can_close, is_csd, is_crow, is_maximized);
  108.      }
  109.  
  110.      private void on_window_opened(Wnck.Window window){
Advertisement
RAW Paste Data Copied
Advertisement