Example #1
0
	def __init__(self, applet):
		self.applet = applet
		self.applet.set_tooltip_text("Tilo")
		#print self.applet.get_size()
		#print self.applet.get_position()
		if self.applet.get_pos_type() == gtk.POS_TOP:
			backend.save_setting('orientation', 'top')
		else:
			backend.save_setting('orientation', 'bottom')
		#Get the default icon theme
		import Globals as Globals
		self.Globals = Globals
		self.theme = gtk.icon_theme_get_default()
		self.icons['stock_folder'] = gtk.gdk.pixbuf_new_from_file(Globals.StartButton[0])
	        self.setup_context_menu()

		if Globals.Settings['Distributor_Logo']:
			import IconFactory as iconfactory
			self.iconfactory = iconfactory
			self.applet_button = self.iconfactory.GetSystemIcon('distributor-logo')
		else: self.applet_button = Globals.Applogo

		self.applet.icon.file(self.applet_button, size=awnlib.Icon.APPLET_SIZE)
		#Connect to signals
		self.applet.connect('button-press-event', self.button_press)
		self.applet.connect_size_changed(self.size_changed)
		#self.theme.connect('changed', self.icon_theme_changed)
		from Menu_Main import Main_Menu
		self.hwg = Main_Menu(self.HideMenu)
Example #2
0
 def addfav(self, widget, event, name, execs, ico, typ):
     """Add to Favorites"""
     typ = str(typ)
     favlist = backend.load_setting("favorites")
     if "%s::%s::%s::%s" % (name, execs, ico, typ) not in favlist:
         favlist.append("%s::%s::%s::%s" % (name, execs, ico, typ))
         backend.save_setting("favorites", favlist)
         del self.menucache["<Favorites>"]
         self.notifier.notify("%s %s" % (name, _("added to favorites list")), Globals.name, Globals.Applogo, 5000)
Example #3
0
	def removefav(self,widget,event,name, execs,ico,typ):
		"""Remove from Favorites"""
		typ = str(typ)
		favlist = backend.load_setting("favorites")
		if '%s::%s::%s::%s' % (name, execs, ico, typ) in favlist:
			favlist.remove('%s::%s::%s::%s' % (name, execs, ico, typ))
			backend.save_setting("favorites",favlist)
			self.emit('changed')
			self.notifier.notify('%s %s' % (name, _('removed from favorites list')),Globals.name,Globals.Applogo,5000)
Example #4
0
	def addfav(self,widget,event,name, execs,ico,typ):
		"""Add to Favorites"""
		typ = str(typ)
		favlist = backend.load_setting("favorites")
		if '%s::%s::%s::%s' % (name, execs, ico, typ) not in favlist:
			favlist.append('%s::%s::%s::%s' % (name, execs, ico, typ))
			backend.save_setting("favorites",favlist)
		
			self.notifier.notify('%s %s' % (name, _('added to favorites list')),Globals.name,Globals.Applogo,5000)
Example #5
0
 def removefav(self, widget, event, name, execs, ico, typ):
     """Remove from Favorites"""
     typ = str(typ)
     favlist = backend.load_setting("favorites")
     if "%s::%s::%s::%s" % (name, execs, ico, typ) in favlist:
         favlist.remove("%s::%s::%s::%s" % (name, execs, ico, typ))
         backend.save_setting("favorites", favlist)
         del self.menucache["<Favorites>"]
         self.emit("changed")
         self.notifier.notify(
             "%s %s" % (name, _("removed from favorites list")), Globals.name, Globals.Applogo, 5000
         )
Example #6
0
	def ShowMenu(self,widget):
		if self.show == False:


			#rootwin = self.hwg.window.get_screen().get_root_window()
			#x, y, mods = rootwin.get_pointer()
			x,y,z = gtk.status_icon_position_menu(self.m, self.tray)
			if self.hwg:
				if not self.hwg.window.window:
					if y < gtk.gdk.screen_height()/2:
						backend.save_setting('orientation', 'top')
					else:
						backend.save_setting('orientation', 'bottom')				
			self.hwg.Adjust_Window_Dimensions(x,y)
			self.hwg.show_window()
			self.show = True
		else:
			self.HideMenu()
	def change_orientation(self,arg1,data):
		self.get_panel_properties()
		if self.orientation != backend.load_setting("orientation"):
			if self.orientation == None:
				backend.save_setting('orientation', 'bottom')
				backend.save_setting('size', self.size)
			else:
				utils.show_message(_('Menu needs to restart , restart now?'))
				backend.save_setting('orientation', self.orientation)
				backend.save_setting('size', self.size)
				sys.exit()
Example #8
0
    def ShowMenu(self):
	if self.show == False:

		#rootwin = self.hwg.window.get_screen().get_root_window()
		#x, y, mods = rootwin.get_pointer()
		x = self.popupPosition(QSize(self.Globals.MenuWidth,self.Globals.MenuHeight)).x()
		y = self.popupPosition(QSize(self.Globals.MenuWidth,self.Globals.MenuHeight)).y()
		screen = QDesktopWidget().screenGeometry()
		if self.hwg:
			if not self.hwg.window.window:
				print y + (self.Globals.MenuHeight/2) , screen.height()/2
				if y + (self.Globals.MenuHeight/2) < screen.height()/2:
					backend.save_setting('orientation', 'top')
				else:
					backend.save_setting('orientation', 'bottom')				
		self.hwg.Adjust_Window_Dimensions(x,y)
		self.hwg.show_window()
		self.show = True
	else:
		self.HideMenu()
Example #9
0
 def change_orientation(self, arg1, data):
     orient = self.applet.get_orient()
     self.orientation = None
     if orient == 1:
         self.orientation = "top"
     else:
         self.orientation = "bottom"
     if self.orientation != backend.load_setting("orientation"):
         if self.orientation is None:
             backend.save_setting("orientation", "bottom")
             backend.save_setting("size", self.size)
         else:
             # utils.show_message(_('Menu needs to restart , restart now?'))
             backend.save_setting("orientation", self.orientation)
             backend.save_setting("size", self.size)
Example #10
0
    def __init__(self, applet):
        self.applet = applet
        self.applet.set_tooltip_text("Sundara Menu")
        #print self.applet.get_size()
        #print self.applet.get_position()
        if self.applet.get_pos_type() == gtk.POS_TOP:
            backend.save_setting('orientation', 'top')
        else:
            backend.save_setting('orientation', 'bottom')
        #Get the default icon theme
        import Globals as Globals
        self.Globals = Globals
        self.theme = gtk.icon_theme_get_default()
        self.icons['stock_folder'] = gtk.gdk.pixbuf_new_from_file(
            Globals.StartButton[0])
        self.setup_context_menu()

        import IconFactory as iconfactory
        self.iconfactory = iconfactory
        self.applet_button = '/usr/share/avant-window-navigator/applets/SundaraMenu/logo.png'

        self.applet.icon.file(self.applet_button, size=awnlib.Icon.APPLET_SIZE)
        #Connect to signals
        self.applet.connect('button-press-event', self.button_press)
        self.applet.connect_size_changed(self.size_changed)
        #self.theme.connect('changed', self.icon_theme_changed)
        from Menu_Main import Main_Menu
        self.hwg = Main_Menu(self.HideMenu)
        #print self.hwg.window.window.is_visible()
        gobject.timeout_add(500, self.HideMenu)
        show_window = self.hwg.show_window

        def _show_window():
            if time.time() - Main_Menu.last_click > 2:
                return
            return show_window()

        self.hwg.show_window = _show_window
Example #11
0
	def change_orientation(self,arg1,data):
		orient = self.applet.get_orient()
		self.orientation = None
		if orient == 1:
			self.orientation = 'top'
		else:
			self.orientation = 'bottom'
		if self.orientation != backend.load_setting("orientation"):
			if self.orientation is None:
				backend.save_setting('orientation', 'bottom')
				backend.save_setting('size', self.size)
			else:
				utils.show_message(_('Menu needs to restart , restart now?'))
				backend.save_setting('orientation', self.orientation)
				backend.save_setting('size', self.size)
				sys.exit()
Example #12
0
def SetDefaultSettings():
	"""Sets Default Settings using the backend"""
	for x in DefaultSettings:
		backend.save_setting(x,DefaultSettings[x])
	FirstUse = True
Example #13
0

lista1 = gconf_client.get_list("/apps/docky-2/Docky/Interface/DockPreferences/Dock1/Launchers",1)
if not 'file://' + INSTALL_PREFIX + '/share/dockmanager/scripts/GnoMenu/GnoMenuDocky.desktop' in lista1:
	lista1.append('file://' + INSTALL_PREFIX + '/share/dockmanager/scripts/GnoMenu/GnoMenuDocky.desktop')
	gconf_client.set_list("/apps/docky-2/Docky/Interface/DockPreferences/Dock1/Launchers",1,lista1)
	# Set the launcher in docky
	

position = gtk.gdk.get_default_root_window().get_pointer()[0]

#gtk.gdk.screen_width()/2 - (len(lista)*size)/2 + (pos * size)+ size #last size is for the anchor
print position

if orient == "Top":
	backend.save_setting('orientation', 'top')
else:
	backend.save_setting('orientation', 'bottom')


class TestObject(dbus.service.Object):
    def __init__(self, conn, object_path='/com/gnomenu/GnoMenu/object'):
        dbus.service.Object.__init__(self, conn, object_path)
	from Menu_Main import Main_Menu
	self.Main_Menu = Main_Menu
	import Globals as Globals
	self.Globals = Globals
	self.hwg = self.Main_Menu(self.HideMenu)

    @dbus.service.signal('com.gnomenu.GnoMenu')
    def Activate(self, message):
Example #14
0
    def ConstructMenu(self):
        """Construct the menu"""
        # aaa = time.clock()
        self.menustring = str(self.Menu)
        if self.menustring in self.menucache:
            self.L_Names, self.L_Icons, self.L_Icons_menu, self.L_Types, self.L_Paths, self.L_Execs = self.menucache[
                self.menustring
            ]
            return

        self.L_Names = []
        self.L_Icons = []
        self.L_Types = []
        self.L_Paths = []
        self.L_Execs = []
        self.L_Icons_menu = []
        self.searchresults = 0

        # ==============================================================
        # XDG PROGRAMS MENU
        # ==============================================================
        if isinstance(self.Menu, self.menuparser.MenuInstance):

            if Globals.Settings["Shownetandemail"] == 1:
                if self.BaseMenu == self.menuparser.CacheApplications:
                    self.AddInternetButtons()
                    # if self.BaseMenu ==self.menuparser.CacheSettings or self.BaseMenu ==self.menuparser.CacheApplications:
            for entry in self.menuparser.GetMenuEntries(self.Menu):
                if isinstance(entry, self.menuparser.MenuInstance):
                    name, icon, path, comment = self.menuparser.GetDirProps(entry)  # Folder
                    self.addtomenu(name, icon, 0, path, "")
                    if Globals.Settings["Show_Tips"]:
                        self.ItemComments[name] = comment
                elif isinstance(entry, self.menuparser.EntryInstance):  # Application
                    name, icon, execute, comment = self.menuparser.GetEntryProps(entry)
                    self.addtomenu(name, icon, 1, "", execute)
                    if Globals.Settings["Show_Tips"]:
                        self.ItemComments[name] = comment
            if self.Menu == self.menuparser.CacheApplications and int(Globals.Settings["Disable_PS"]) == 0:
                self.AddPlacesButton()
                self.AddSystemButton()

                # ==============================================================
                # AUXILIARY FUNCTIONS MENU
                # ==============================================================
        elif self.Menu == "<AuxiliaryFunctions>":

            self.addtomenu(_("About Me"), "user-info", 5, "", "mate-about-me")
            self.addtomenu(_("Appearance"), "mate-settings-theme", 5, "", "mate-appearance-properties")
            self.addtomenu(_("Menu editor"), "mozo", 6, "", "mozo")
            self.addtomenu(_("Screensaver"), "preferences-desktop-screensaver", 5, "", "mate-screensaver-preferences")
            self.addtomenu(_("System Monitor"), "utilities-system-monitor", 5, "", "mate-system-monitor")
            self.addtomenu(
                _("Tilo settings utility"),
                "%slogo.png" % Globals.GraphicsDirectory,
                7,
                "",
                "%sTilo-Settings.py" % Globals.ProgramDirectory,
            )
            # ==============================================================
            # FAVORITES ITEMS MENU
            # ==============================================================
        elif self.Menu == "<Favorites>":
            client = []
            x = backend.load_setting("favorites")
            if x != None:
                client = x
            try:
                client.sort(key=str.upper)
            except:
                pass

            for elem in client:
                try:
                    name, exe, ico, typ = elem.split("::")
                    self.addtomenu(name, ico, int(typ), "", exe)
                except:
                    backend.save_setting("favorites", [])

            if client == []:
                self.addtomenu(
                    _("No favorites\nUse the mouse right button\nto add or remove favorites"),
                    gtk.STOCK_MISSING_IMAGE,
                    9,
                    "",
                    "",
                )
                # ==============================================================
                # WEB BOOKMARKS MENU
                # ==============================================================
        elif self.Menu == "<WebBookmarks>":

            try:
                if self.webbookmarker is None:
                    self.webbookmarker = bookmarks.BookmarksMenu().getBookmarks()
                for item in map(list, self.webbookmarker):
                    self.addtomenu(item[0], item[3], 3, item[1], item[1])
            except:
                print "Error reading web bookmarks"

            # ==============================================================
            # SHUTDOWN MENU
            # ==============================================================
        elif self.Menu == "<Shutdown>":
            self.addtomenu(_("Shutdown"), "gtk-quit", 1, "", Globals.Settings["Shutdown"])
            self.addtomenu(_("Reboot"), "mate-session-reboot", 1, "", Globals.Settings["Restart"])
            self.addtomenu(_("Suspend"), "mate-session-suspend", 1, "", Globals.Settings["Suspend"])
            self.addtomenu(_("Hibernate"), "mate-session-hibernate", 1, "", Globals.Settings["Hibernate"])
            self.addtomenu(_("Logout"), "mate-session-logout", 1, "", Globals.Settings["LogoutNow"])
            self.addtomenu(_("Lock Screen"), "system-lock-screen", 1, "", Globals.Settings["Lock"])
            # ==============================================================
            # RECENT ITEMS MENU
            # ==============================================================
        elif self.Menu == "<RecentItems>":

            # self.recent_manager.set_limit(Globals.RI_numberofitems)
            if self.recents_changed or self.recents is None:
                self.recent = self.recent_manager.get_items()
                self.recents_changed = False
                self.recent.sort(self.recentSortCriterium)
            x = 0
            for item in self.recent:
                name = item.get_short_name()
                self.L_Names.append(name)
                self.L_Icons.append(self.IconFactory.getthumb(item))
                self.L_Icons_menu.append(name)
                self.L_Types.append(3)
                self.L_Paths.append("")
                self.L_Execs.append(item.get_uri())
                # self.addtomenu(item.get_short_name(),self.IconFactory.getthumb(item),3,"",item.get_uri())
                x = x + 1
                if x == Globals.RI_numberofitems:
                    break
            self.addtomenu(_("Clear recent documents"), gtk.STOCK_CLEAR, 10, "", "")
            self.sorted_list = []

            # ==============================================================
            # RECENT APPS MENU
            # ==============================================================
        elif self.Menu == "<RecentApps>":

            # self.recent_manager.set_limit(Globals.RI_numberofitems)
            if self.recents_changed or self.recents is None:
                self.recent = self.recent_manager.get_items()
                self.recents_changed = False
                self.recent.sort(self.recentSortCriterium)
            x = 0
            for item in self.recent:
                if isgio:
                    mime = item.get_mime_type()
                    app = gio.app_info_get_default_for_type(mime, 0)
                    if app:
                        if app.get_name() not in self.L_Names:
                            self.addtomenu(
                                app.get_name(), self.IconFactory.getgicon(app.get_icon()), 1, "", app.get_executable()
                            )
                            x = x + 1
                            if x == Globals.RI_numberofitems:
                                break
                else:
                    app = item.last_application()
                    appinfo = item.get_application_info(app)
                    # print appinfo[0].split(' ')[0]
                    if app not in self.L_Names:
                        self.addtomenu(app, appinfo[0].split(" ")[0], 1, "", appinfo[0].split(" ")[0])
                        x = x + 1
                        if x == Globals.RI_numberofitems:
                            break
            self.sorted_list = []

            # ==============================================================
            # RECENT BOOKMARKS / PLACES MENU
            # ==============================================================
        elif self.Menu == "<Bookmarks>":

            self.addtomenu(_("File System"), "drive-harddisk", 3, "/", "/")
            if isgio:
                self.drives = self.monitor.get_connected_drives()
                for drive in self.drives:
                    if drive.has_media():
                        self.mounts = drive.get_volumes()
                        for mount in self.mounts:
                            ico = mount.get_icon()
                            a = self.IconFactory.getgicon(ico)
                            self.L_Names.append(mount.get_name())
                            self.L_Icons.append(self.IconFactory.geticonfile(a))
                            self.L_Icons_menu.append(a)
                            self.L_Types.append(3)
                            self.L_Paths.append("")
                            try:
                                self.L_Execs.append(str(mount.get_mount().get_root().get_uri()).replace("file://", ""))
                            except:
                                self.L_Execs.append("")

            self.addtomenu(_("Home Folder"), "user-home", 3, "", Globals.HomeDirectory)
            self.addtomenu(_("Computer"), "computer", 3, "", "computer:///")
            self.addtomenu(_("Network"), "network", 3, "", "network:///")
            self.addtomenu(_("Trash"), "user-trash", 3, "", "trash:///")
            if os.path.isfile("%s/.gtk-bookmarks" % Globals.HomeDirectory):
                f = open("%s/.gtk-bookmarks" % Globals.HomeDirectory, "r")
                data = f.readlines(600)
                f.close()
                f = None
                for i in data:
                    self.bm = str(i).replace("\n", "")
                    if self.bm.find(" ") != -1:
                        self.folder = urllib.url2pathname(self.bm[: self.bm.find(" ")])
                        self.name = urllib.url2pathname(self.bm[self.bm.find(" ") + 1 :])
                    else:
                        self.folder = self.bm
                        self.name = urllib.url2pathname(str(self.bm).split("/").pop())
                    try:
                        if isgio:
                            Gfile = gio.File(self.folder)
                            tuble = [Gfile, Gfile.query_info("standard::*"), []]
                            ico = tuble[1].get_icon()
                            self.addtomenu(self.name, self.IconFactory.getgicon(ico), 3, "", self.folder)
                        else:
                            self.addtomenu(self.name, "folder", 3, "", self.folder)
                    except:
                        pass

        else:
            # ==============================================================
            # XDG PROGRAMS MENU (SEARCH)
            # ==============================================================
            # self.searchresults = 0
            for i in [self.menuparser.CacheApplications, self.menuparser.CacheSettings]:
                for entry in self.menuparser.GetMenuEntries(i):

                    if isinstance(entry, self.menuparser.MenuInstance):  # Folder
                        name, icon, path, comment = self.menuparser.GetDirProps(entry)  # Folder

                        if self.menuparser.has_matemenu:
                            self.SearchMenu(path)
                        else:
                            self.SearchMenu(i.getMenu(entry.getPath(True)))

                    elif isinstance(entry, self.menuparser.EntryInstance):  # Application
                        name, icon, execute, comment = self.menuparser.GetEntryProps(entry)
                        if name.upper().count(self.Menu) != 0 or execute.upper().count(self.Menu) != 0:
                            self.addtomenu(name, icon, 1, "", execute)
                            self.searchresults = self.searchresults + 1

            if self.searchresults == 0:
                self.addtomenu("<separator>", "", 8, "", "")
                self.addtomenu(_("No items matched your search criteria"), "", 9, "", "")
            else:
                self.addtomenu
                self.addtomenu("<separator>", "", 8, "", "")
                self.addtomenu(_("Found %s results to your search") % str(self.searchresults), "", 9, "", "")
                # Add back button so long as it isn't the base XDG menu
        if isinstance(self.Menu, self.menuparser.MenuInstance):
            if self.Menu != self.menuparser.CacheApplications:
                self.AddBackButton()
        else:
            if Globals.MenuTabCount == 0:
                if Globals.OnlyShowFavs == False and Globals.OnlyShowRecentApps == False:
                    self.AddBackButton()
                else:
                    if self.Menu != "<Favorites>" and self.Menu != "<RecentApps>":
                        self.AddBackButton()
                        # gc.collect()

                        # print time.clock() -aaa
        self.menucache[self.menustring] = (
            self.L_Names,
            self.L_Icons,
            self.L_Icons_menu,
            self.L_Types,
            self.L_Paths,
            self.L_Execs,
        )
Example #15
0
	def store_settings(self):
		"""Stores orientation in settings"""
		if self.orientation != backend.load_setting("orientation"):
			if self.orientation is None:
				backend.save_setting('orientation', 'bottom')
				backend.save_setting('size', self.size)
			else:
				utils.show_message(_('Menu needs to restart , restart now?'))
				backend.save_setting('orientation', self.orientation)
				backend.save_setting('size', self.size)
				sys.exit()
		try:
			backend.save_setting('orientation', self.orientation)
			backend.save_setting('size', self.size)
		except:pass
Example #16
0
    def store_settings(self):
        """Stores orientation in settings"""
        if self.orientation != backend.load_setting("orientation"):
            if self.orientation is None:
                backend.save_setting("orientation", "bottom")
                backend.save_setting("size", self.size)
            else:
                import utils

                utils.show_message(_("Menu needs to restart , restart now?"))
                backend.save_setting("orientation", self.orientation)
                backend.save_setting("size", self.size)
                sys.exit()
        try:
            backend.save_setting("orientation", self.orientation)
            backend.save_setting("size", self.size)
        except:
            pass
Example #17
0

lista1 = mateconf_client.get_list("/apps/docky-2/Docky/Interface/DockPreferences/Dock1/Launchers", 1)
if not "file://" + INSTALL_PREFIX + "/share/dockmanager/scripts/Tilo/TiloDocky.desktop" in lista1:
    lista1.append("file://" + INSTALL_PREFIX + "/share/dockmanager/scripts/Tilo/TiloDocky.desktop")
    mateconf_client.set_list("/apps/docky-2/Docky/Interface/DockPreferences/Dock1/Launchers", 1, lista1)
    # Set the launcher in docky


position = gtk.gdk.get_default_root_window().get_pointer()[0]

# gtk.gdk.screen_width()/2 - (len(lista)*size)/2 + (pos * size)+ size #last size is for the anchor
print position

if orient == "Top":
    backend.save_setting("orientation", "top")
else:
    backend.save_setting("orientation", "bottom")


class TestObject(dbus.service.Object):
    def __init__(self, conn, object_path="/com/tilo/Tilo/object"):
        dbus.service.Object.__init__(self, conn, object_path)
        from Menu_Main import Main_Menu

        self.Main_Menu = Main_Menu
        import Globals as Globals

        self.Globals = Globals
        self.hwg = self.Main_Menu(self.HideMenu)
Example #18
0
	def SetDefaultSettings():
		for x in DefaultSettings:
			backend.save_setting(x,DefaultSettings[x])
		FirstUse = True
Example #19
0
	def SaveSettings(self):
                self.verify_input_data()
		backend.save_setting("Bind_Key",self.entry_check1.get_text())
		backend.save_setting("Show_Tips",int(self.check7.get_active()))
		backend.save_setting("TabHover",int(self.check4.get_active()))
		backend.save_setting("Sound_Theme",self.combo_sound.get_active_text())
		backend.save_setting("Menu_Name",self.combo_menu.get_active_text())
		backend.save_setting("IconSize",int(self.spinbutton1.get_value()))
		backend.save_setting("ListSize",int(self.spinbutton2.get_value()))
		backend.save_setting("MenuHeight",int(self.menu_height_spinbt.get_value()))
		backend.save_setting("SuperL",int(self.check1.get_active()))
		backend.save_setting("Icon_Name",self.combo_icon.get_active_text())
		backend.save_setting("Button_Name",self.combo_button.get_active_text())