From b03023679923bfd452938d1249644cc1c328419c Mon Sep 17 00:00:00 2001
From: Demin Dmitriy <demindf@gmail.com>
Date: Sun, 1 Nov 2015 06:59:23 +0300
Subject: [PATCH] libxfce4ui xfce4panel: add gtk3 support

---
 pkgs/desktops/xfce/core/libxfce4ui.nix  | 15 +++++++++------
 pkgs/desktops/xfce/core/xfce4-panel.nix | 16 ++++++++++++----
 pkgs/desktops/xfce/default.nix          |  3 ++-
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/pkgs/desktops/xfce/core/libxfce4ui.nix b/pkgs/desktops/xfce/core/libxfce4ui.nix
index be4ca5d17c0..2cb20febcb9 100644
--- a/pkgs/desktops/xfce/core/libxfce4ui.nix
+++ b/pkgs/desktops/xfce/core/libxfce4ui.nix
@@ -1,5 +1,9 @@
 { stdenv, fetchurl, pkgconfig, intltool, gtk, libxfce4util, xfconf
-, libglade, libstartup_notification }:
+, libglade, libstartup_notification
+, withGtk3 ? false, gtk3
+}:
+
+with { inherit (stdenv.lib) optional; };
 
 stdenv.mkDerivation rec {
   p_name  = "libxfce4ui";
@@ -14,15 +18,14 @@ stdenv.mkDerivation rec {
 
   #TODO: gladeui
   # Install into our own prefix instead.
-  preConfigure =
-    ''
-      configureFlags="--with-libglade-module-path=$out/lib/libglade/2.0"
-    '';
+  configureFlags = [
+    "--with-libglade-module-path=$out/lib/libglade/2.0"
+  ] ++ optional withGtk3 "--enable-gtk3";
 
   buildInputs =
     [ pkgconfig intltool gtk libxfce4util xfconf libglade
       libstartup_notification
-    ];
+    ] ++ optional withGtk3 gtk3;
 
   preFixup = "rm $out/share/icons/hicolor/icon-theme.cache";
 
diff --git a/pkgs/desktops/xfce/core/xfce4-panel.nix b/pkgs/desktops/xfce/core/xfce4-panel.nix
index 5a8cc9dc0e5..0f9066876c6 100644
--- a/pkgs/desktops/xfce/core/xfce4-panel.nix
+++ b/pkgs/desktops/xfce/core/xfce4-panel.nix
@@ -1,6 +1,10 @@
 { stdenv, fetchurl, pkgconfig, intltool, gtk, libxfce4util, libxfce4ui
-, libwnck, exo, garcon, xfconf, libstartup_notification
-, makeWrapper, xfce4mixer }:
+, libxfce4ui_gtk3, libwnck, exo, garcon, xfconf, libstartup_notification
+, makeWrapper, xfce4mixer
+, withGtk3 ? false, gtk3
+}:
+
+with { inherit (stdenv.lib) optional; };
 
 stdenv.mkDerivation rec {
   p_name  = "xfce4-panel";
@@ -16,11 +20,15 @@ stdenv.mkDerivation rec {
   patches = [ ./xfce4-panel-datadir.patch ];
   patchFlags = "-p1";
 
+  configureFlags = optional withGtk3 "--enable-gtk3";
+
   buildInputs =
     [ pkgconfig intltool gtk libxfce4util exo libwnck
       garcon xfconf libstartup_notification makeWrapper
-    ] ++ xfce4mixer.gst_plugins;
-  propagatedBuildInputs = [ libxfce4ui ];
+    ] ++ xfce4mixer.gst_plugins
+      ++ optional withGtk3 gtk3;
+
+  propagatedBuildInputs = [ (if withGtk3 then libxfce4ui_gtk3 else libxfce4ui) ];
 
   postInstall = ''
     wrapProgram "$out/bin/xfce4-panel" \
diff --git a/pkgs/desktops/xfce/default.nix b/pkgs/desktops/xfce/default.nix
index 2f563dbbf5c..1ff585843e5 100644
--- a/pkgs/desktops/xfce/default.nix
+++ b/pkgs/desktops/xfce/default.nix
@@ -22,6 +22,7 @@ xfce_self = rec { # the lines are very long but it seems better than the even-od
   garcon          = callPackage ./core/garcon.nix { };
   gtk_xfce_engine = callPackage ./core/gtk-xfce-engine.nix { }; # ToDo: when should be used?
   libxfce4ui      = callPackage ./core/libxfce4ui.nix { };
+  libxfce4ui_gtk3 = libxfce4ui.override { withGtk3 = true; };
   libxfce4util    = callPackage ./core/libxfce4util.nix { };
   libxfcegui4     = callPackage ./core/libxfcegui4.nix { };
   thunar          = callPackage ./core/thunar.nix { };
@@ -32,6 +33,7 @@ xfce_self = rec { # the lines are very long but it seems better than the even-od
                   = callPackage ./thunar-plugins/dropbox { };
   tumbler         = callPackage ./core/tumbler.nix { };
   xfce4panel      = callPackage ./core/xfce4-panel.nix { }; # ToDo: impure plugins from /run/current-system/sw/lib/xfce4
+  xfce4panel_gtk3 = xfce4panel.override { withGtk3 = true; };
   xfce4session    = callPackage ./core/xfce4-session.nix { };
   xfce4settings   = callPackage ./core/xfce4-settings.nix { };
   xfce4_power_manager = callPackage ./core/xfce4-power-manager.nix { };
@@ -67,7 +69,6 @@ xfce_self = rec { # the lines are very long but it seems better than the even-od
 
   #### PANEL PLUGINS        from "mirror://xfce/src/panel-plugins/${p_name}/${ver_maj}/${name}.tar.{bz2,gz}"
 
-
   xfce4_battery_plugin     = callPackage ./panel-plugins/xfce4-battery-plugin.nix     { };
   xfce4_clipman_plugin     = callPackage ./panel-plugins/xfce4-clipman-plugin.nix     { };
   xfce4_cpufreq_plugin     = callPackage ./panel-plugins/xfce4-cpufreq-plugin.nix     { };