LINUX LITE 7.2 FINAL RELEASED - SEE RELEASE ANNOUNCEMENTS SECTION FOR DETAILS


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lite Control Center - Suggestions welcomed
Guys, decided to write a python3 script which will open a gtk3+ window from which desktop icons can be added and removed by simply clicking the switch.
There are quite a few icons in the desktop tab this could save some space.
Code:
#!/usr/bin/env python3
#xfce4-desktop icons switch, Misko
from gi.repository import Gtk
import os
import sys
from subprocess import Popen
from gi.repository.GdkPixbuf import Pixbuf

#Temporary window icon don't forget to change!
icon="/usr/share/pixmaps/Thunar/Thunar-about-logo.png"


class XfDesktopIconsWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="Xfce Desktop Icons")

        self.set_default_size(-1, 200)
        self.set_border_width(10)

        self.grid = Gtk.Grid()
        self.add(self.grid)


        self.create_label()
        self.create_buttons()
   

       
    def create_label(self):
        label = Gtk.Label()
        label.set_markup("To show and hide desktop icons use the switch on the right")
        label.set_line_wrap(True)
        label.set_size_request(200, -1)


        table = Gtk.Table(1, 1, False)
        table.set_border_width(10)
        table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
        self.grid.attach(table, 1, 0, 2, 1)

    def create_buttons(self):
        label1 = Gtk.Label("File System    ", xalign=1)
        label2 = Gtk.Label("Home    ", xalign=1)
        label3 = Gtk.Label("Trash    ", xalign=1)
        label4 = Gtk.Label("Network   ", xalign=1)
        label5 = Gtk.Label("Removable Drives   ", xalign=1)

        self.grid.attach(label1, 1, 1, 1, 1)
        self.grid.attach(label2, 1, 2, 1, 1)
        self.grid.attach(label3, 1, 3, 1, 1)
        self.grid.attach(label4, 1, 4, 1, 1)
        self.grid.attach(label5, 1, 5, 1, 1)

        button1 = Gtk.Switch()
        button1.connect("notify::active", self.on_switch_activateda)
        button1.set_name('button')
        cmd = 'xfconf-query --channel xfce4-desktop --property "/desktop-icons/file-icons/show-filesystem" | grep -c "true"'
        wicdd = os.popen(cmd)
        wicdd = wicdd.readline()
        if int(wicdd) == 0:
           button1.set_active(False)
        else:
           button1.set_active(True)
        self.grid.attach_next_to(button1, label1, Gtk.PositionType.RIGHT, 1, 1)

        button2 = Gtk.Switch()
        button2.connect("notify::active", self.on_switch_activatedb)
        cmd = 'xfconf-query --channel xfce4-desktop --property "/desktop-icons/file-icons/show-home" | grep -c "true"'
        wicdb = os.popen(cmd)
        wicdb = wicdb.readline()
        if int(wicdb) == 0:
           button2.set_active(False)
        else:
           button2.set_active(True)
        self.grid.attach_next_to(button2, label2, Gtk.PositionType.RIGHT, 1, 1)

        button3= Gtk.Switch()
        button3.connect("notify::active", self.on_switch_activatedc)
        cmd = 'xfconf-query --channel xfce4-desktop --property "/desktop-icons/file-icons/show-trash" | grep -c "true"'
        wicdb = os.popen(cmd)
        wicdb = wicdb.readline()
        if int(wicdb) == 0:
           button3.set_active(False)
        else:
           button3.set_active(True)
        self.grid.attach_next_to(button3, label3, Gtk.PositionType.RIGHT, 1, 1)

        button4= Gtk.Switch()
        button4.connect("notify::active", self.on_switch_activatedd)
        cmd = 'ls ~/Desktop | grep -c "networks.desktop"'
        wicdb = os.popen(cmd)
        wicdb = wicdb.readline()
        if int(wicdb) == 0:
           button4.set_active(False)
        else:
           button4.set_active(True)
        self.grid.attach_next_to(button4, label4, Gtk.PositionType.RIGHT, 1, 1)

        button5= Gtk.Switch()
        button5.connect("notify::active", self.on_switch_activatede)
        cmd = 'xfconf-query --channel xfce4-desktop -n --property "/desktop-icons/file-icons/show-device-removable" | grep -c "true"'
        wicdb = os.popen(cmd)
        wicdb = wicdb.readline()
        if int(wicdb) == 0:
           button5.set_active(False)
        else:
           button5.set_active(True)
        self.grid.attach_next_to(button5, label5, Gtk.PositionType.RIGHT, 1, 1)

        buttonc = Gtk.Button(label="_Close", use_underline=True)
        buttonc.set_border_width(10)
        buttonc.connect("clicked", self.on_close_clicked)
        self.grid.attach(buttonc,  2, 7, 1, 1)



    def on_switch_activateda(self, switch, gparam):
        if switch.get_active():
            os.system('xfconf-query --channel xfce4-desktop -n --property "/desktop-icons/file-icons/show-filesystem" --set "true"')
            state = "on"
        else:
            os.system('xfconf-query --channel xfce4-desktop -n --property "/desktop-icons/file-icons/show-filesystem" --set "false"')
            state = "off"
        print("File System icon is set", state)

    def on_switch_activatedb(self, switch, gparam):
        if switch.get_active():
            os.system('xfconf-query --channel xfce4-desktop -n --property "/desktop-icons/file-icons/show-home" --set "true"')
            state = "on"
        else:
            os.system('xfconf-query --channel xfce4-desktop -n --property "/desktop-icons/file-icons/show-home" --set "false"')
            state = "off"
        print("Home icon is", state)

    def on_switch_activatedc(self, switch, gparam):
        if switch.get_active():
            os.system('xfconf-query --channel xfce4-desktop -n --property "/desktop-icons/file-icons/show-trash" --set "true"')
            state = "on"
        else:
            os.system('xfconf-query --channel xfce4-desktop -n --property "/desktop-icons/file-icons/show-trash" --set "false"')
            state = "off"
        print("Trash icon is", state)

    def on_switch_activatedd(self, switch, gparam):
        if switch.get_active():
            os.system('cp /usr/share/litecc/frontend/icons/desktop/networks.desktop ~/Desktop')
            state = "on"
        else:
            os.system('rm -rf ~/Desktop/networks.desktop')
            state = "off"
        print("Network icon is", state)

    def on_switch_activatede(self, switch, gparam):
        if switch.get_active():
            os.system('xfconf-query --channel xfce4-desktop -n --property "/desktop-icons/file-icons/show-device-removable" --set "true"')
            state = "on"
        else:
            os.system('xfconf-query --channel xfce4-desktop -n --property "/desktop-icons/file-icons/show-device-removable" --set "false"')
            state = "off"
        print("Show Removable is", state)

    def on_close_clicked(self, button):
        print("Closing Xfce Desktop Icons")
        Gtk.main_quit()

window = XfDesktopIconsWindow()     
window.connect("delete-event", Gtk.main_quit)
window.set_resizable(False)
window.set_position(Gtk.WindowPosition.CENTER)
window.set_icon(Pixbuf.new_from_file("{0}".format(icon)))
window.set_name('DesktopIcons')
window.show_all()
Gtk.main()
Also added and option to show/hide removable drives.
Might need some work but this is working fine so far.
[Image: 7tW3zsg.png]
What do you think guys?
@ misko_2083
Great idea, it is quite a "busy" screen.
So a "New" single icon "Manage Desktop Icons" would launch what you show above.
Looks good to me.
Upgrades WIP 2.6 to 2.8 - (6 X 2.6 to 2.8 completed on: 20/02/16 All O.K )
Linux Lite 3.0 Humming on a ASRock N3070 Mobo ~ btrfs RAID 10 Install on 4 Disks Smile

Computers Early days:
ZX Spectrum(1982) , HP-150 MS-DOS(1983) , Amstrad CPC464(1984) ,  BBC Micro B+64(1985) , My First PC HP-Vectra(1987)
I ran updates using the Software Updates red link on the My Computer tab.  But after running the updates, the Software Updates link didn't refresh to a green link with today's date.
Want to thank me?  Click my [Thank] link.
Hi,

I have just tested here, and it's O.K
Try again, if it fails, check log, in case one of the repos is not responding.??
Upgrades WIP 2.6 to 2.8 - (6 X 2.6 to 2.8 completed on: 20/02/16 All O.K )
Linux Lite 3.0 Humming on a ASRock N3070 Mobo ~ btrfs RAID 10 Install on 4 Disks Smile

Computers Early days:
ZX Spectrum(1982) , HP-150 MS-DOS(1983) , Amstrad CPC464(1984) ,  BBC Micro B+64(1985) , My First PC HP-Vectra(1987)
It updates the link, from red to green with the new date, if I close and reopen Linux Lite Control Center.
Want to thank me?  Click my [Thank] link.
I think that's how it's supposed to work.
Linux Lite 5.0 on Lenovo Edge 540 <3
That is the way it is working.  Might be more straightforward if it dynamically refreshes instead of refreshing only after closing and reopening the control center.  That's all I'm saying.
Want to thank me?  Click my [Thank] link.
@ torreydale

Ah, O.K, understood,
I have no idea what's involved to make dynamic, at guess though, not a simple tweak.
Upgrades WIP 2.6 to 2.8 - (6 X 2.6 to 2.8 completed on: 20/02/16 All O.K )
Linux Lite 3.0 Humming on a ASRock N3070 Mobo ~ btrfs RAID 10 Install on 4 Disks Smile

Computers Early days:
ZX Spectrum(1982) , HP-150 MS-DOS(1983) , Amstrad CPC464(1984) ,  BBC Micro B+64(1985) , My First PC HP-Vectra(1987)
(08-03-2015, 03:07 PM)Wirezfree link Wrote:@ misko_2083
Great idea, it is quite a "busy" screen.
So a "New" single icon "Manage Desktop Icons" would launch what you show above.
Looks good to me.
Thanks, I haven't had communication with Jerry in the last few days. Maybe he would preffer using web tehnologies in the frontend that would communicate with stuff in the backend rather than launching a separate application.
(08-04-2015, 02:09 PM)torreydale link Wrote:That is the way it is working.  Might be more straightforward if it dynamically refreshes instead of refreshing only after closing and reopening the control center.  That's all I'm saying.
Yes, that's the way it works. There is a plan to add a refresh button. It should do some stuff in the backend when receives a call from the frontend.
(08-04-2015, 05:36 PM)misko_2083 link Wrote:Thanks, I haven't had communication with Jerry in the last few days.

I've been on qTox most of the time, haven't seen you sign in until today Smile


Forum Jump:


Users browsing this thread: 4 Guest(s)