run the program and the main window comes up with the status icon. When
I minimize the window, instead of minimizing it, it hides it. So the
window is gone but the icon is still in the tasktray. (minimizing to
tasktray) What I am trying to accomplish is that when you click the
tasktray icon then the window unhides and comes back.

everything works flawlessly except i can't get:

def activate_icon_cb(widget, data = None):
        pass

to have access to self.window from the __init__ to run the
self.window.show(). I'have tried setting it up like:

def activate_icon_cb(self, widget, data = None):
        pass

# statusIcon.set_from_stock(gtk.STOCK_HOME)
statusIcon.set_from_file("pixmaps/dmcal.png")
statusIcon.set_tooltip("DM-Crypt & LUKS Encryption Suite")
statusIcon.connect('activate', activate_icon_cb(self))
statusIcon.connect('popup-menu', popup_menu_cb, menu)
statusIcon.set_visible(True)

but it says self isn't defined. When I tried recalling the widget from
the glade file and showing it that way instead of showing it it just
made another. But I have to bring the first on back up not make a new
one.

Thanks for helping me with this.

Nate

Here is the majority of the code:

class dmcalGTK:
    """The DMCal Application"""

    def __init__(self):

            #Set the glade file
            self.gladefile = "dmcal.glade"
            self.wTree = gtk.glade.XML(self.gladefile, "dmcalMain")

            self.window = self.wTree.get_widget("dmcalMain")
            self.window.connect('window-state-event', self.window_event)

            #Create our dictionary and connect it
            dic = {"on_create_container_activate" :
self.create_container_activate,
                   "on_dmcalMain_destroy" : self.dmcalMain_destroy,
                   "on_aboutMenuItem_activate" : self.showAbout,
                   "on_quitButton_clicked" : self.dmcalMain_destroy,
                   "on_newButton_clicked" :
self.create_container_activate,
                   "on_addButton_clicked" : self.showFileSelection,
                   "on_quitmenuitem_activate" : self.dmcalMain_destroy,
                   "on_removeButton_clicked" : self.removecontainer,
                   "on_saveMenuItem_activate" : self.savelist}
            self.wTree.signal_autoconnect(dic)

            preferencesMI = self.wTree.get_widget("preferencesMenuItem")
            preferencesMI.set_sensitive(0)

            #Setup the treeview
            self.treeview = self.wTree.get_widget('treeview2')
            
            #Create the liststore model to use with the treeview
            #Pattern: ICON, NAME TEXT, PATH TEXT
            self.treelist = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str)
            
            #Attatch the liststore model to the treeview
            self.treeview.set_model(self.treelist)
            
            #Get the icons
            self.yes = self.treeview.render_icon('gtk-yes',
gtk.ICON_SIZE_SMALL_TOOLBAR)
            self.no = self.treeview.render_icon('gtk-no',
gtk.ICON_SIZE_SMALL_TOOLBAR)
            
            #Setup the columns on the listview
            
            column = gtk.TreeViewColumn('', gtk.CellRendererPixbuf(),
pixbuf=0)
            self.treeview.append_column(column)
            column = gtk.TreeViewColumn('Name', gtk.CellRendererText(),
text=1)
            self.treeview.append_column(column)
            column = gtk.TreeViewColumn('Location',
gtk.CellRendererText(), text=2)
            self.treeview.append_column(column)
            column = gtk.TreeViewColumn('Mount Point',
gtk.CellRendererText(), text=3)
            self.treeview.append_column(column)

            self.treelist.append([self.yes, 'container.enc',
'/home/nomb/container.enc', '/media/enc'])

            self.treeselection = self.treeview.get_selection()
            self.treeselection.select_path(0)
    
            if commands.getoutput("whoami") != "root":
                print "Non-Root - Limited functionality..."

                #Disable create new container menu entry
                newcontainerMenuItem =
self.wTree.get_widget("create_container")
                newcontainerMenuItem.set_sensitive(0)

                #Disable create new container button
                newcontainerButton = self.wTree.get_widget("newButton")
                newcontainerButton.set_sensitive(0)

                #Disable mount button
                mntButton = self.wTree.get_widget("mountButton")
                mntButton.set_sensitive(0)

                #Disable un-mount button
                unmntButton = self.wTree.get_widget("unmountButton")
                unmntButton.set_sensitive(0)
            
                #Set alert message to status bar
                statusbar = self.wTree.get_widget("statusbar1")
                statusbarid = statusbar.get_context_id("need root")
                statusbar.push(statusbarid, "Some functions require root
permissions and path... (su -)")


    def quit_cb(widget, data = None):
        if data:
            data.set_visible(False)
        gtk.main_quit()

    def popup_menu_cb(widget, button, time, data = None):
        if button == 3:
            if data:
                data.show_all()
                data.popup(None, None, None, 3, time)
        pass    

    def activate_icon_cb(widget, data = None):
        pass

    def icon_show_about(widget, data = None):
        dmcalDialog = dmcalAbout()
        result = dmcalDialog.run()

    statusIcon = gtk.StatusIcon()

    menu = gtk.Menu()
    menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
    menuItem.connect('activate', icon_show_about)
    menu.append(menuItem)
    menuItem = gtk.SeparatorMenuItem()
    menu.append(menuItem)
    menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT)
    menuItem.connect('activate', quit_cb, statusIcon)
    menu.append(menuItem)

    # statusIcon.set_from_stock(gtk.STOCK_HOME)
    statusIcon.set_from_file("pixmaps/dmcal.png")
    statusIcon.set_tooltip("DM-Crypt & LUKS Encryption Suite")
    statusIcon.connect('activate', activate_icon_cb)
    statusIcon.connect('popup-menu', popup_menu_cb, menu)
    statusIcon.set_visible(True)

    def window_event(self, widget, event):
        #print event.new_window_state
        if event.new_window_state == gtk.gdk.WINDOW_STATE_ICONIFIED:
            self.window.hide()

====================
This email/fax message is for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution of this
email/fax is prohibited. If you are not the intended recipient, please
destroy all paper and electronic copies of the original message.
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to