[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    "Add to Autostart" patch for superkaramba
From:       Florian Roth <florian () synatic ! net>
Date:       2006-06-11 20:30:29
Message-ID: 200606122230.39604.florian () synatic ! net
[Download RAW message or body]

Hi,

I found it very annoying to always have to create the autostart entrys for a 
superkarmaba theme by myself. So I added an "Add to Autostart" button to the 
theme selection dialog right beside the "Add to desktop" button. Clicking on 
it will automatically create a .desktop file in the users autostart folder 
for the selected theme.

Greets
Florian Roth

["sk_autostart.diff" (text/x-diff)]

Index: src/themesdlg.cpp
===================================================================
--- src/themesdlg.cpp	(revision 550440)
+++ src/themesdlg.cpp	(working copy)
@@ -51,6 +51,9 @@
 #include <kio/job.h>
 #include <kprotocolinfo.h>
 
+#include <kdesktopfile.h>
+#include <kglobalsettings.h>
+
 ThemesDlg::ThemesDlg(QWidget *parent, const char *name)
  : ThemesLayout(parent, name)
 {
@@ -200,6 +203,39 @@
   }
 }
 
+void ThemesDlg::addToAutostart()
+{
+  ThemeWidget* w = static_cast<ThemeWidget*>(tableThemes->selectedItem());
+  if(w)
+  {
+    ThemeFile* tf = w->themeFile();
+    if(tf)
+    {
+      QString autostart = KGlobalSettings::autostartPath();
+      QString file = autostart + "/" + tf->name() + ".desktop";
+    
+      KDesktopFile desktop(file, false);
+      desktop.setGroup("Desktop Entry");
+      desktop.writeEntry("Comment", tf->description());
+      desktop.writeEntry("Encoding", "UTF-8");
+      desktop.writeEntry("Exec", "superkaramba \"" + tf->file() + "\"");
+      desktop.writeEntry("GenericName", tf->description());
+      desktop.writeEntry("Icon", "superkaramba");
+      desktop.writeEntry("MimeType", "");
+      desktop.writeEntry("Name", tf->name());
+      desktop.writeEntry("Path", "");
+      desktop.writeEntry("StartupNotify", "false");
+      desktop.writeEntry("Terminal", "false");
+      desktop.writeEntry("TerminalOptions", "");
+      desktop.writeEntry("Type", "Application");
+      desktop.writeEntry("X-DCOP-ServiceType", "");
+      desktop.writeEntry("X-KDE-SubstituteUID", "false");
+      desktop.writeEntry("X-KDE-Username", "");
+      desktop.sync();
+    }
+  }
+}
+
 void ThemesDlg::openLocalTheme()
 {
   QStringList fileNames;
@@ -238,6 +274,7 @@
 void ThemesDlg::selectionChanged(int index)
 {
   buttonAddToDesktop->setEnabled(index > 1);
+  buttonAddToAutostart->setEnabled(index > 1);
 
   for(uint i=2; i < tableThemes->count(); ++i)
   {
Index: src/themes_layout.ui
===================================================================
--- src/themes_layout.ui	(revision 550460)
+++ src/themes_layout.ui	(working copy)
@@ -119,6 +119,23 @@
                     </property>
                 </spacer>
                 <widget class="KPushButton">
+                  <property name="name">
+                    <cstring>buttonAddToAutostart</cstring>
+                  </property>
+                  <property name="minimumSize">
+                    <size>
+                      <width>0</width>
+                      <height>0</height>
+                    </size>
+                  </property>
+                  <property name="stdItem" stdset="0">
+                    <number>27</number>
+                  </property>
+                  <property name="text">
+                    <string>Add to Auto&amp;start</string>
+                  </property>
+                </widget>
+                <widget class="KPushButton">
                     <property name="name">
                         <cstring>buttonAddToDesktop</cstring>
                     </property>
@@ -195,6 +212,12 @@
         <slot>addToDesktop()</slot>
     </connection>
     <connection>
+      <sender>buttonAddToAutostart</sender>
+      <signal>clicked()</signal>
+      <receiver>ThemesLayout</receiver>
+      <slot>addToAutostart()</slot>
+    </connection>
+    <connection>
         <sender>tableThemes</sender>
         <signal>selected(int)</signal>
         <receiver>ThemesLayout</receiver>
@@ -223,11 +246,13 @@
     <tabstop>editSearch</tabstop>
     <tabstop>comboShow</tabstop>
     <tabstop>tableThemes</tabstop>
+    <tabstop>buttonAddToAutostart</tabstop>
     <tabstop>buttonAddToDesktop</tabstop>
     <tabstop>buttonClose</tabstop>
 </tabstops>
 <slots>
     <slot access="protected">addToDesktop()</slot>
+    <slot access="protected">addToAutostart()</slot>
     <slot access="protected">selectionChanged(int)</slot>
     <slot access="protected">search(const QString&amp;)</slot>
 </slots>
Index: src/themesdlg.h
===================================================================
--- src/themesdlg.h	(revision 550440)
+++ src/themesdlg.h	(working copy)
@@ -58,6 +58,7 @@
 
   protected slots:
     virtual void addToDesktop();
+    virtual void addToAutostart();
     virtual void selectionChanged(int);
     virtual void openLocalTheme();
     virtual void getNewStuff();


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic