Subject: Bug#316: Can't see session icon in shadow sessions

From: Ricardo Díaz Martín <[email-masked]>
Date: Fri, 4 Oct 2013 12:33:56 +0100

Package: x2goclient
Version: 4.1.0
Tag: patch

When you launch a session using .desktop file (session saved as a launcher
in the desktop) you can't see the tray icon though you choose this option
in x2go settings

Attaching patch to solve this issue.

---

From: Mike Gabriel <[email-masked]>
Date: Tue, 29 Oct 2013 14:30:12 +0000

tag #316 moreinfo
tag #316 - patch
thanks

Hi Ricardo,

> Attaching patch to solve this issue.

I have looked at your patch (and the concept behind it) more closely.  
Your current patch will break setups where people launch X2Go Client  
via a .desktop file and expect no traces of X2Go Client to be seen on  
screen apart from the session itself.

Suggestions: introduce a new cmdline option --tray-icon. This Option  
activates the tray icon even if it is disabled in the  
~/.x2goclient/settings file. In combination with --hide the  
--tray-icon command then makes the tray icon visible for hidden X2Go  
Client instances.

How about that?

Mike
-- 

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: [email-masked], http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb

---

From: Ricardo Díaz Martín <[email-masked]>
Date: Wed, 30 Oct 2013 08:14:09 +0100

tag #316 moreinfo
tag #316 - patch

Hi Mike,

Yes, I think the way you said will be better. So I'm going to add this
command line option and make a new patch ;-)

2013/10/29 Mike Gabriel <[email-masked]>

> I have looked at your patch (and the concept behind it) more closely. Your
> current patch will break setups where people launch X2Go Client via a
> .desktop file and expect no traces of X2Go Client to be seen on screen
> apart from the session itself.
>
> ~/.x2goclient/settings file. In combination with --hide the --tray-icon
> command then makes the tray icon visible for hidden X2Go Client instances.
>
> How about that?
>
> Mike
> --
>
> DAS-NETZWERKTEAM
> mail: mike.gabriel@das-netzwerkteam.**de<[email-masked]>,
> http://das-netzwerkteam.de
>
> freeBusy:
> https://mail.das-netzwerkteam.**de/freebusy/m.gabriel%40das-**
> netzwerkteam.de.xfb<https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb>
>

---

From: Mike Gabriel <[email-masked]>
Date: Wed, 30 Oct 2013 08:10:55 +0000

Hi Ricardo,

> command line option and make a new patch ;-)

Cool.

Thanks!
Mike
-- 

DAS-NETZWERKTEAM

GnuPG Key ID 0x25771B31

freeBusy:

---

From: Ricardo Díaz Martín <[email-masked]>
Date: Wed, 30 Oct 2013 10:21:39 +0100

tag #316 - patch

Mike,

Attaching the new patch.

Now there is new command line parameter --tray-icon for x2goclient. When
x2goclient find this parameter tray icon will be shown (also when --hide
parameter is present too).

When x2goclient asking about create desktop icon in hide mode there is a
new checkbox to set if desktop launcher is going to show tray icon or not
(default is not).

So take a look and tell me something about.

Cheers!

2013/10/30 Mike Gabriel <[email-masked]>

>> command line option and make a new patch ;-)
From 05e964a38219ce13a37010429f339f098422f74f Mon Sep 17 00:00:00 2001
From: Ricardo Diaz <[email-masked]>
Date: Wed, 30 Oct 2013 10:05:48 +0100
Subject: [PATCH 3/3] --tray-icon comand line

---
 onmainwindow.cpp | 51 ++++++++++++++++++++++++++++++++++++++-------------
 onmainwindow.h   |  1 +
 2 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/onmainwindow.cpp b/onmainwindow.cpp
index 031ba2f..64b3486 100644
--- a/onmainwindow.cpp
+++ b/onmainwindow.cpp
@@ -101,6 +101,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent )
     lastSession=0l;
     changeBrokerPass=false;
     resumeAfterSuspending=false;
+    forceToShowTrayicon=false;
 
     appSeparator=0;
     config.brokerNoAuth=false;
@@ -1099,7 +1100,7 @@ void ONMainWindow::trayIconInit()
             trayIcon->setToolTip(tr("Left mouse button to hide/restore - Right mouse button to display context menu"));
         }
 
-        if (!startHidden | trayEnabled)
+        if (!startHidden | forceToShowTrayicon)
         {
             trayIcon->show();
             plugAppsInTray();
@@ -2034,17 +2035,29 @@ void ONMainWindow::slotEdit ( SessionButton* bt )
 
 void ONMainWindow::slotCreateDesktopIcon ( SessionButton* bt )
 {
-    bool crHidden= ( QMessageBox::question (
-                         this,
-                         tr ( "Create session icon on desktop" ),
-                         tr ( "Desktop icons can be configured "
-                              "not to show x2goclient (hidden mode). "
-                              "If you like to use this feature you'll "
-                              "need to configure login by a gpg key "
-                              "or gpg smart card.\n\n"
-                              "Use x2goclient hidden mode?" ),
-                         QMessageBox::Yes|QMessageBox::No ) ==
-                     QMessageBox::Yes );
+    QMessageBox messageBox(QMessageBox::Question,
+                           tr ( "Create session icon on desktop" ),
+                           tr ( "Desktop icons can be configured "
+                                "not to show x2goclient (hidden mode). "
+                                "If you like to use this feature you'll "
+                                "need to configure login by a gpg key "
+                                "or gpg smart card.\n\n"
+                                "Use x2goclient hidden mode?" ),
+                           QMessageBox::Yes|QMessageBox::No,
+                           this);
+
+    //adding a chekbox to know if user want to enable trayicon in hide sessions
+    QCheckBox cbShowTrayIcon(tr("Show session tray icon when running"));
+    messageBox.layout()->addWidget(&cbShowTrayIcon);
+    QGridLayout* gridLayout = (QGridLayout*) messageBox.layout();
+    gridLayout->addWidget(&cbShowTrayIcon, gridLayout->rowCount(), 0, 1, gridLayout->columnCount());
+    cbShowTrayIcon.blockSignals(true);
+
+    //getting the result
+    bool crHidden = (messageBox.exec() == QMessageBox::Yes);
+    bool bShowTrayicon = (cbShowTrayIcon.checkState() == Qt::Checked);
+
+
     X2goSettings st ( "sessions" );
 
     QString name=st.setting()->value ( bt->id() +"/name",
@@ -2073,6 +2086,10 @@ void ONMainWindow::slotCreateDesktopIcon ( SessionButton* bt )
     QString cmd="x2goclient";
     if ( crHidden )
         cmd="x2goclient --hide";
+
+    if (bShowTrayicon)
+        cmd += " --tray-icon";
+
     QTextStream out ( &file );
     out << "[Desktop Entry]\n"<<
         "Exec="<<cmd<<" --sessionid="<<bt->id() <<"\n"<<
@@ -6477,6 +6494,12 @@ bool ONMainWindow::parseParameter ( QString param )
         return true;
     }
 
+    //force to show trayicon
+    if (param == "--tray-icon")
+    {
+        forceToShowTrayicon = true;
+        return true;
+    }
 
     QString setting,value;
     QStringList vals=param.split ( "=" );
@@ -6978,7 +7001,9 @@ void ONMainWindow::showHelp()
         "--set-kbd=<0|1>\t\t\t overwrite current keyboard settings\n"
         "--autostart=<app> \t\t launch \"app\" by session start in \"published "
         "applications\" mode\n"
-        "--session-conf=<file>\t\t path to alternative session config\n";
+        "--session-conf=<file>\t\t path to alternative session config\n"
+        "--tray-icon\t\t force to show session trayicon\n";
+
     qCritical ( "%s",helpMsg.toLocal8Bit().data() );
     if (!startHidden)
     {
diff --git a/onmainwindow.h b/onmainwindow.h
index 70504d2..f12c8a6 100644
--- a/onmainwindow.h
+++ b/onmainwindow.h
@@ -594,6 +594,7 @@ private:
     QList<serv> x2goServers;
     QList<Application> applications;
     QList<sshKey> cmdSshKeys;
+    bool forceToShowTrayicon; //true if --tray-icon passed in command line
 
     QPushButton* bSusp;
     QPushButton* bTerm;
-- 
1.8.3.2