summaryrefslogtreecommitdiffstats
path: root/kicker/applets/trash
diff options
context:
space:
mode:
Diffstat (limited to 'kicker/applets/trash')
-rw-r--r--kicker/applets/trash/Makefile.am21
-rw-r--r--kicker/applets/trash/trashapplet.cpp165
-rw-r--r--kicker/applets/trash/trashapplet.desktop138
-rw-r--r--kicker/applets/trash/trashapplet.h62
-rw-r--r--kicker/applets/trash/trashbutton.cpp154
-rw-r--r--kicker/applets/trash/trashbutton.h60
6 files changed, 600 insertions, 0 deletions
diff --git a/kicker/applets/trash/Makefile.am b/kicker/applets/trash/Makefile.am
new file mode 100644
index 000000000..a34f87d1c
--- /dev/null
+++ b/kicker/applets/trash/Makefile.am
@@ -0,0 +1,21 @@
+INCLUDES = -I$(top_srcdir)/libkonq -I$(top_srcdir)/kicker/libkicker $(all_includes)
+
+kde_module_LTLIBRARIES = trash_panelapplet.la
+trash_panelapplet_la_SOURCES = trashbutton.cpp trashapplet.cpp
+
+METASOURCES = AUTO
+
+noinst_HEADERS = \
+ trashapplet.h trashbutton.h
+
+lnkdir = $(kde_datadir)/kicker/applets
+lnk_DATA = trashapplet.desktop
+
+EXTRA_DIST = $(lnk_DATA)
+
+trash_panelapplet_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+trash_panelapplet_la_LIBADD = ../../libkicker/libkickermain.la ../../../libkonq/libkonq.la $(LIB_KDEUI) $(LIB_KIO) $(LIB_KUTILS)
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/trashapplet.pot
+
diff --git a/kicker/applets/trash/trashapplet.cpp b/kicker/applets/trash/trashapplet.cpp
new file mode 100644
index 000000000..c27c4e281
--- /dev/null
+++ b/kicker/applets/trash/trashapplet.cpp
@@ -0,0 +1,165 @@
+/* This file is part of the KDE project
+ Copyright (c) 2004 Kevin Ottens <ervin ipsquad net>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <kglobal.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kapplication.h>
+#include <kaboutdata.h>
+#include <kaboutapplication.h>
+#include <kdebug.h>
+#include <kpopupmenu.h>
+#include <kiconloader.h>
+
+#include "trashapplet.h"
+
+extern "C"
+{
+ KDE_EXPORT KPanelApplet* init( QWidget *parent, const QString& configFile)
+ {
+ KGlobal::locale()->insertCatalogue("trashapplet");
+ return new TrashApplet(configFile, KPanelApplet::Normal,
+ KPanelApplet::About, parent, "trashapplet");
+ }
+}
+
+TrashApplet::TrashApplet(const QString& configFile, Type type, int actions, QWidget *parent, const char *name)
+ : KPanelApplet(configFile, type, actions, parent, name), mButton(0)
+{
+ mButton = new TrashButton(this);
+
+ if (!parent)
+ setBackgroundMode(X11ParentRelative);
+
+ mButton->setPanelPosition(position());
+
+ setAcceptDrops(true);
+
+ mpDirLister = new KDirLister();
+
+ connect( mpDirLister, SIGNAL( clear() ),
+ this, SLOT( slotClear() ) );
+ connect( mpDirLister, SIGNAL( completed() ),
+ this, SLOT( slotCompleted() ) );
+ connect( mpDirLister, SIGNAL( deleteItem( KFileItem * ) ),
+ this, SLOT( slotDeleteItem( KFileItem * ) ) );
+
+ mpDirLister->openURL("trash:/");
+}
+
+TrashApplet::~TrashApplet()
+{
+ // disconnect the dir lister before quitting so as not to crash
+ // on kicker exit
+ disconnect( mpDirLister, SIGNAL( clear() ),
+ this, SLOT( slotClear() ) );
+ delete mpDirLister;
+ KGlobal::locale()->removeCatalogue("trashapplet");
+}
+
+void TrashApplet::about()
+{
+ KAboutData data("trashapplet",
+ I18N_NOOP("Trash Applet"),
+ "1.0",
+ I18N_NOOP("\"trash:/\" ioslave frontend applet"),
+ KAboutData::License_GPL_V2,
+ "(c) 2004, Kevin Ottens");
+
+ data.addAuthor("Kevin \'ervin\' Ottens",
+ I18N_NOOP("Maintainer"),
+ "ervin ipsquad net",
+ "http://ervin.ipsquad.net");
+
+ KAboutApplication dialog(&data);
+ dialog.exec();
+}
+
+int TrashApplet::widthForHeight( int height ) const
+{
+ if ( !mButton )
+ {
+ return height;
+ }
+
+ return mButton->widthForHeight( height );
+}
+
+int TrashApplet::heightForWidth( int width ) const
+{
+ if ( !mButton )
+ {
+ return width;
+ }
+
+ return mButton->heightForWidth( width );
+}
+
+void TrashApplet::resizeEvent( QResizeEvent * )
+{
+ if (!mButton)
+ {
+ return;
+ }
+
+ int size = 1;
+
+ size = std::max( size,
+ orientation() == Qt::Vertical ?
+ mButton->heightForWidth( width() ) :
+ mButton->widthForHeight( height() ) );
+
+
+ if(orientation() == Vertical)
+ {
+ mButton->resize( width(), size );
+ }
+ else
+ {
+ mButton->resize( size, height() );
+ }
+}
+
+void TrashApplet::slotClear()
+{
+ kdDebug()<<"MediaApplet::slotClear"<<endl;
+
+ mButton->setItemCount(0);
+}
+
+void TrashApplet::slotCompleted()
+{
+ mCount = mpDirLister->items(KDirLister::AllItems).count();
+ mButton->setItemCount( mCount );
+}
+
+void TrashApplet::slotDeleteItem(KFileItem *)
+{
+ mCount--;
+ mButton->setItemCount( mCount );
+}
+
+
+void TrashApplet::positionChange(Position p)
+{
+ mButton->setPanelPosition(p);
+}
+
+
+#include "trashapplet.moc"
diff --git a/kicker/applets/trash/trashapplet.desktop b/kicker/applets/trash/trashapplet.desktop
new file mode 100644
index 000000000..f1c1eff0a
--- /dev/null
+++ b/kicker/applets/trash/trashapplet.desktop
@@ -0,0 +1,138 @@
+[Desktop Entry]
+Type=Plugin
+Comment=Displays the trashcan and allows files to be dropped onto it
+Comment[af]=Vertoon die asblik en laat toe dat lêers in dit gegooi mag word
+Comment[ar]=يظهر سلّة المهملات و يسمح بإسقاط الملفات فيها
+Comment[be]=Паказвае сметніцу і дазваляе кідаць файлы ў яе
+Comment[bg]=Показване на кошчето и възможност за преместване на файлове в него
+Comment[bn]=আবর্জনার বাক্স দেখায়, যাতে ফাইল ড্রপ করা যায়
+Comment[bs]=Prikazuje kantu za smeće i omogućuje da se u nju bacaju datoteke
+Comment[ca]=Mostra la paperera i permet amollar-hi fitxers
+Comment[cs]=Zobrazuje koš a umožňuje do něj odhazovat soubory
+Comment[csb]=Wëskrzëniwô zamkłósc kòsza ë zezwôlô przecygac do niegò lopczi
+Comment[da]=Viser affaldsspanden og tillader at filer droppes på den
+Comment[de]=Mülleimerfunktion in der Kontrollleiste
+Comment[el]=Εμφανίζει τον Κάδο Απορριμμάτων και επιτρέπει την απόθεση αρχείων πάνω του
+Comment[en_GB]=Displays the wastebin and allows files to be dropped onto it
+Comment[eo]=Montras rubujon kaj ebligas dosiero-alfaligon
+Comment[es]=Muestra la papelera y permite tirar archivos en ella
+Comment[et]=Näitab prügikasti ning lubab faile sellesse visata
+Comment[eu]=Zakarontzia bistaratzen du, fitxategiak jauregitea lagunduz
+Comment[fa]=زباله‌دان را نمایش داده و به پرونده‌ها اجازه می‌دهد در آن بیفتند
+Comment[fi]=Näyttää roskakorin ja sallii tiedostojen pudottamisen siihen
+Comment[fr]=Affiche la corbeille et permet d'y déposer des fichiers
+Comment[fy]=Lit it jiskefet sjen en stiet ta dat triemmen fuortsmiten wurde troch se nei it byldkaike ta te slepen
+Comment[gl]=Mostra a papeleira e permite deitar ficheiros nela
+Comment[he]=מציג את פח האשפה ומאפשר לך לזרוק אליו קבצים
+Comment[hr]=Prikazuje kantu za otpad i omogućuje ispuštanje datoteka u nju
+Comment[hu]=Megjeleníti a szemétkosarat, lehetővé téve fájlok belehelyezését
+Comment[is]=Sýnir ruslakörfuna og leyfir að skrám sé sleppt á hana
+Comment[it]=Mostra il cestino e permette di trascinarci sopra i file
+Comment[ja]=ごみ箱を表示し、ごみ箱へのファイルのドロップを可能にします
+Comment[kk]=Өшірілгендер шелегін керсетіп, оған файлдарды тастауға мүмкіндік береді
+Comment[km]=បង្ហាញ​ធុង​សំរាម និង​អនុញ្ញាត​ឲ្យ​ទម្លាក់​ឯកសារ​លើ​វា
+Comment[lt]=Rodo šiukšliadėžę ir leidžia į ją tempiant numesti bylas
+Comment[mk]=Ја прикажува корпата и овозможува пуштање датотеки врз неа
+Comment[nb]=Viser papirkurven og lar deg legge filer i den
+Comment[nds]=Wiest de Affalltünn, Dateien köönt dor op droppt warrn.
+Comment[ne]=रद्दीटोकरी प्रदर्शन गर्छ र यसमा फाइलहरू राख्न अनुमति दिन्छ
+Comment[nl]=Toont de prullenbak en maakt het mogelijk bestanden weg te gooien door ze naar het pictogram te slepen
+Comment[nn]=Viser papirkorga og lèt deg leggja filer i henne
+Comment[pl]=Pokazuje kosz i pozwala przeciągać do niego pliki
+Comment[pt]=Mostra o caixote do lixo e permite largar ficheiros nele
+Comment[pt_BR]=Mostra a lixeira e permite que arquivos sejam arrastados até ela
+Comment[ro]=Afișează coșul de gunoi și permite aruncare fișierelor în acesta
+Comment[ru]=Показать на рабочем столе корзину для ненужных файлов
+Comment[sk]=Zobrazí odpadkový kôš a povolí vhodenie súborov do neho
+Comment[sl]=Prikaz ikone za Smeti, na katero lahko odvržete datoteke
+Comment[sr]=Приказује канту за смеће и омогућава испуштање фајлова на њу
+Comment[sr@Latn]=Prikazuje kantu za smeće i omogućava ispuštanje fajlova na nju
+Comment[sv]=Visar papperskorgen och tillåter att filer släpps på den
+Comment[th]=แสดงถังขยะและอนุญาตให้มีการปล่อยแฟ้มลงไปได้
+Comment[tr]=Çöp kutusunu gösterir ve dosyaların üzerine taşınmasına izin verir
+Comment[uk]=Показує смітник і дає змогу вкидати в нього файли
+Comment[vi]=Hiển thị thùng rác và cho phép thả các tập tin vào đó
+Comment[wa]=Håyneye l' batch et permete di mete des fitchîs å dvins
+Comment[zh_CN]=显示回收站,并允许您将文件拖至其上
+Comment[zh_TW]=顯示垃圾筒並且允許將檔案丟到其中
+Name=Trash
+Name[af]=Gemors
+Name[ar]=سلة النفايات
+Name[az]=Zibil
+Name[be]=Сметніца
+Name[bg]=Кошче
+Name[bn]=আবর্জনা
+Name[br]=Pod-lastez
+Name[bs]=Smeće
+Name[ca]=Paperera
+Name[cs]=Koš
+Name[csb]=Kòsz
+Name[cy]=Sbwriel
+Name[da]=Affald
+Name[de]=Mülleimer
+Name[el]=Κάδος απορριμμάτων
+Name[en_GB]=Wastebin
+Name[eo]=Rubujo
+Name[es]=Papelera
+Name[et]=Prügikast
+Name[eu]=Zaborra
+Name[fa]=زباله
+Name[fi]=Roskakori
+Name[fr]=Corbeille
+Name[fy]=Jiskefet
+Name[ga]=Bruscar
+Name[gl]=Lixo
+Name[he]=אשפה
+Name[hi]=रद्दी
+Name[hr]=Otpad
+Name[hsb]=Papjernik
+Name[hu]=Szemétkosár
+Name[is]=Rusl
+Name[it]=Cestino
+Name[ja]=ごみ箱
+Name[ka]=ურნა
+Name[kk]=Өшірілгендер
+Name[km]=ធុងសំរាម
+Name[lo]=ຖັງຂີ້ເຫຍື່ອ
+Name[lt]=Šiukšliadėžė
+Name[lv]=Miskaste
+Name[mk]=Корпа
+Name[mn]=Хогийн сав
+Name[ms]=Sampah
+Name[mt]=Skart
+Name[nb]=Papirkurv
+Name[nds]=Affalltünn
+Name[ne]=रद्दीटोकरी
+Name[nl]=Prullenbak
+Name[nn]=Papirkorg
+Name[nso]=Seswaraditlakala
+Name[pa]=ਰੱਦੀ
+Name[pl]=Kosz
+Name[pt]=Lixo
+Name[pt_BR]=Lixo
+Name[ro]=Gunoi
+Name[ru]=Корзина
+Name[se]=Ruskalihtti
+Name[sk]=Kôš
+Name[sl]=Smeti
+Name[sr]=Смеће
+Name[sr@Latn]=Smeće
+Name[sv]=Skräp
+Name[ta]=குப்பை
+Name[te]=చెత్త బుట్ట
+Name[tg]=Ахлотдон
+Name[th]=ถังขยะ
+Name[tr]=Çöp
+Name[tt]=Çüplek
+Name[uk]=Смітник
+Name[uz]=Chiqindilar qutisi
+Name[uz@cyrillic]=Чиқиндилар қутиси
+Name[ven]=Tshikha
+Name[vi]=Thùng rác
+Name[wa]=Batch
+Name[xh]=Inkukumo
+Name[zh_CN]=回收站
+Name[zh_TW]=資源回收桶
+Name[zu]=Izibi
+Icon=trashcan_empty
+X-KDE-Library=trash_panelapplet
diff --git a/kicker/applets/trash/trashapplet.h b/kicker/applets/trash/trashapplet.h
new file mode 100644
index 000000000..bc9662af4
--- /dev/null
+++ b/kicker/applets/trash/trashapplet.h
@@ -0,0 +1,62 @@
+/* This file is part of the KDE project
+ Copyright (c) 2004 Kevin Ottens <ervin ipsquad net>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef TRASHAPPLET_H
+#define TRASHAPPLET_H
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include <kpanelapplet.h>
+#include <qstring.h>
+#include <kurl.h>
+#include <kdirlister.h>
+
+#include "trashbutton.h"
+
+class TrashApplet : public KPanelApplet
+{
+Q_OBJECT
+
+public:
+ TrashApplet(const QString& configFile, Type t = Normal, int actions = 0,
+ QWidget *parent = 0, const char *name = 0);
+ ~TrashApplet();
+
+ int widthForHeight(int height) const;
+ int heightForWidth(int width) const;
+ void about();
+
+protected:
+ void resizeEvent(QResizeEvent *e);
+ void positionChange(Position p);
+
+protected slots:
+ void slotClear();
+ void slotCompleted();
+ void slotDeleteItem(KFileItem *);
+
+private:
+ KDirLister *mpDirLister;
+ TrashButton *mButton;
+ int mCount;
+};
+
+#endif
diff --git a/kicker/applets/trash/trashbutton.cpp b/kicker/applets/trash/trashbutton.cpp
new file mode 100644
index 000000000..e6934a983
--- /dev/null
+++ b/kicker/applets/trash/trashbutton.cpp
@@ -0,0 +1,154 @@
+/* This file is part of the KDE project
+ Copyright (c) 2004 Kevin Ottens <ervin ipsquad net>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "trashbutton.h"
+
+#include <qpopupmenu.h>
+#include <qtooltip.h>
+
+#include <klocale.h>
+#include <krun.h>
+#include <kpopupmenu.h>
+
+#include <kio/netaccess.h>
+
+#include <konq_operations.h>
+#include <konq_popupmenu.h>
+
+TrashButton::TrashButton(QWidget *parent)
+ : PanelPopupButton(parent), mActions(this, this),
+ mFileItem(KFileItem::Unknown, KFileItem::Unknown, "trash:/")
+{
+ KIO::UDSEntry entry;
+ KIO::NetAccess::stat("trash:/", entry, 0L);
+ mFileItem.assign(KFileItem(entry, "trash:/"));
+
+ KAction *a = KStdAction::paste(this, SLOT(slotPaste()),
+ &mActions, "paste");
+ a->setShortcut(0);
+
+ move(0, 0);
+ resize(20, 20);
+
+ setTitle(i18n("Trash"));
+ setIcon( "trashcan_empty" );
+
+ setAcceptDrops(true);
+
+ // Activate this code only if we find a way to have both an
+ // action and a popup menu for the same kicker button
+ //connect(this, SIGNAL(clicked()), this, SLOT(slotClicked()));
+
+ setPopup(new QPopupMenu());
+}
+
+TrashButton::~TrashButton()
+{
+}
+
+void TrashButton::setItemCount(int count)
+{
+ if (count==0)
+ {
+ setIcon( "trashcan_empty" );
+ QToolTip::add(this, i18n("Empty"));
+ }
+ else
+ {
+ setIcon( "trashcan_full" );
+ QToolTip::add(this, i18n("One item", "%n items", count));
+ }
+}
+
+void TrashButton::initPopup()
+{
+ QPopupMenu *old_popup = popup();
+
+ KFileItemList items;
+ items.append(&mFileItem);
+
+ KonqPopupMenu::KonqPopupFlags kpf =
+ KonqPopupMenu::ShowProperties
+ | KonqPopupMenu::ShowNewWindow;
+
+ KParts::BrowserExtension::PopupFlags bef =
+ KParts::BrowserExtension::DefaultPopupItems;
+
+ KonqPopupMenu *new_popup = new KonqPopupMenu(0L, items,
+ KURL("trash:/"), mActions, 0L,
+ this, kpf, bef);
+ KPopupTitle *title = new KPopupTitle(new_popup);
+ title->setTitle(i18n("Trash"));
+
+ new_popup->insertItem(title, -1, 0);
+
+ setPopup(new_popup);
+
+ if (old_popup!=0L) delete old_popup;
+}
+
+// Activate this code only if we find a way to have both an
+// action and a popup menu for the same kicker button
+/*
+void TrashButton::slotClicked()
+{
+ mFileItem.run();
+}
+*/
+
+void TrashButton::slotPaste()
+{
+ KonqOperations::doPaste(this, mFileItem.url());
+}
+
+void TrashButton::dragEnterEvent(QDragEnterEvent* e)
+{
+ e->accept(true);
+}
+
+void TrashButton::dropEvent(QDropEvent *e)
+{
+ KonqOperations::doDrop(0L, mFileItem.url(), e, this);
+}
+
+QString TrashButton::tileName()
+{
+ return mFileItem.name();
+}
+
+void TrashButton::setPanelPosition(KPanelApplet::Position position)
+{
+ switch(position)
+ {
+ case KPanelApplet::pBottom:
+ setPopupDirection(KPanelApplet::Up);
+ break;
+ case KPanelApplet::pTop:
+ setPopupDirection(KPanelApplet::Down);
+ break;
+ case KPanelApplet::pRight:
+ setPopupDirection(KPanelApplet::Left);
+ break;
+ case KPanelApplet::pLeft:
+ setPopupDirection(KPanelApplet::Right);
+ break;
+ }
+}
+
+#include "trashbutton.moc"
diff --git a/kicker/applets/trash/trashbutton.h b/kicker/applets/trash/trashbutton.h
new file mode 100644
index 000000000..7a5d8b59f
--- /dev/null
+++ b/kicker/applets/trash/trashbutton.h
@@ -0,0 +1,60 @@
+/* This file is part of the KDE project
+ Copyright (c) 2004 Kevin Ottens <ervin ipsquad net>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef TRASHBUTTON_H
+#define TRASHBUTTON_H
+
+#include <panelbutton.h>
+#include <qpoint.h>
+#include <qstring.h>
+#include <qpixmap.h>
+#include <qcursor.h>
+#include <qtimer.h>
+#include <kfileitem.h>
+#include <kpanelapplet.h>
+#include <kactioncollection.h>
+
+class TrashButton : public PanelPopupButton
+{
+Q_OBJECT
+
+public:
+ TrashButton(QWidget *parent);
+ ~TrashButton();
+ void setItemCount(int count);
+ void setPanelPosition(KPanelApplet::Position position);
+
+protected:
+ QString tileName();
+ void initPopup();
+ void dragEnterEvent(QDragEnterEvent *e);
+ void dropEvent(QDropEvent *e);
+
+protected slots:
+ // Activate this code only if we find a way to have both an
+ // action and a popup menu for the same kicker button
+ //void slotClicked();
+ void slotPaste();
+
+private:
+ KActionCollection mActions;
+ KFileItem mFileItem;
+};
+
+#endif