[PC-BSD Commits] r17470 - in pcbsd/current: src-qt4/libpcbsd src-qt4/warden-gui src-sh/de-info/de-profiles

svn at pcbsd.org svn at pcbsd.org
Wed Jun 27 08:43:25 PDT 2012


Author: yurkis
Date: 2012-06-27 15:43:25 +0000 (Wed, 27 Jun 2012)
New Revision: 17470

Modified:
   pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h
   pcbsd/current/src-qt4/libpcbsd/utils.cpp
   pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp
   pcbsd/current/src-sh/de-info/de-profiles/gnome.profile
Log:
added functions to libpcbsd:
1. runInTerminal() - run command in current de graphical terminal emulator
2. openInFileManager() - open directory using file manager from current de
----
warden changed to use this unInTerminal() function for jail chroot
----
little fix for gnome profile

CAUTION: penInFileManager() should check directory name for quotes but don't do this yet!

PLEASE TEST THIS CHANGES

Modified: pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h	2012-06-27 15:31:23 UTC (rev 17469)
+++ pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h	2012-06-27 15:43:25 UTC (rev 17470)
@@ -96,7 +96,6 @@
 };
 
 
-
 class Utils
 {
 public:
@@ -133,6 +132,8 @@
    static QString getValFromSHFile(QString envFile, QString envVal);
    static QString getValFromCSHFile(QString envFile, QString envVal);
    static void restartNetworking();
+   static void runInTerminal(QString command, QString windowTitle=QString());
+   static void openInFileManager(QString location);
 
 };
 

Modified: pcbsd/current/src-qt4/libpcbsd/utils.cpp
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/utils.cpp	2012-06-27 15:31:23 UTC (rev 17469)
+++ pcbsd/current/src-qt4/libpcbsd/utils.cpp	2012-06-27 15:43:25 UTC (rev 17470)
@@ -658,6 +658,66 @@
    infoBox.close();
 }
 
+void Utils::runInTerminal(QString command, QString windowTitle)
+{
+    QStringList out = Utils::runShellCommand("de-info");
+    QString terminal_app;
+    QString terminal_title;
+    QString terminal_comm;
+    bool separateArgs=false;
+
+    for(int i=0; i<out.size(); i++)
+    {
+        QString str = out.at(i).trimmed();
+        qDebug()<<str<<"\n";
+        if (str.indexOf("Terminal:")>=0)
+        {
+            terminal_app = str.replace("Terminal:","");
+            continue;
+        }
+        if(str.indexOf("Terminal title switch:")>=0)
+        {
+            terminal_title = str.replace("Terminal title switch:","");
+            continue;
+        }
+        if (str.indexOf("Terminal command switch:")>=0)
+        {
+            terminal_comm = str.replace("Terminal command switch:","");
+            continue;
+        }
+        if (str.indexOf("Terminal command separate args:")>=0)
+        {
+            separateArgs = (str.replace("Terminal command separate args:","").trimmed() == QString("YES"));
+        }
+    }//for all strings
+    if (!terminal_app.length())
+        return;    
+
+    QStringList args;
+    QStringList comm;
+    if (separateArgs)
+        comm=command.split(" ");
+    else
+        comm<<command.trimmed();
+
+    if (windowTitle.length())
+    {
+        args<<terminal_title.trimmed();
+        args<<windowTitle.trimmed();
+    }
+    args<<terminal_comm.trimmed()<<comm;
+
+    QProcess::startDetached(terminal_app.trimmed(), args);
+}
+
+void Utils::openInFileManager(QString location)
+{
+    //TODO: Process quotes for location
+    QString exec = Utils::runShellCommand("de-info -fileman").at(0);
+    exec = exec.replace("%s", location);
+    QProcess::startDetached(exec);
+}
+
 QStringList Utils::listShellCommandSearch( QString command, QString sch)
 {
   QStringList L = Utils::runShellCommand(command);

Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp	2012-06-27 15:31:23 UTC (rev 17469)
+++ pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp	2012-06-27 15:43:25 UTC (rev 17470)
@@ -1323,8 +1323,9 @@
 {
    if ( ! listJails->currentItem() )
      return;
-   QString cmd = "xterm -T \"Jail: " + listJails->currentItem()->text(0) + "\" -e warden chroot " + listJails->currentItem()->text(0) + " &"; 
-   system(cmd.toLatin1());
+
+   Utils::runInTerminal(QString("warden chroot ") + listJails->currentItem()->text(0),
+                        QString("Jail: ") + listJails->currentItem()->text(0));
 }
 
 void dialogWarden::slotPushEditIP()

Modified: pcbsd/current/src-sh/de-info/de-profiles/gnome.profile
===================================================================
--- pcbsd/current/src-sh/de-info/de-profiles/gnome.profile	2012-06-27 15:31:23 UTC (rev 17469)
+++ pcbsd/current/src-sh/de-info/de-profiles/gnome.profile	2012-06-27 15:43:25 UTC (rev 17470)
@@ -3,7 +3,7 @@
 DE_SU="gksu %s"
 DE_FILEMAN="nautilus %s"
 DE_TERMINAL="gnome-terminal"
-DE_TERMINAL_TITLE="-T"
+DE_TERMINAL_TITLE="-t"
 DE_TERMINAL_COMMAND="-e"
 
 active() {



More information about the Commits mailing list