~vlijm/jonb.homelauncher/2.0

« back to all changes in this revision

Viewing changes to draft/application_lists.py

  • Committer: vlijm
  • Date: 2012-12-06 19:17:17 UTC
  • Revision ID: vlijm@planet.nl-20121206191717-7vrmzzqt3e5sbn72
added advanced functions, changed many other function, bug fixes etc

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
class ApplicationLists(Extract):
26
26
    """
27
 
    lists are the most important ingrediënt in editing quicklists.
28
 
    this class creates all application lists and produces all data
29
 
    about their basic properties, to be used in the editor.
30
 
    in qle -version 2, the editor no longer comes with a predefined
31
 
    application list, but this class reads the (all) installed
32
 
    applications and standalone quicklists. also, by default, the
33
 
    edtor will only show (all) quicklists that are actually locked
34
 
    in the launcher.
 
27
    lists are the most important ingrediënt in editing quicklists. this class
 
28
    creates all application lists and produces all data about their basic
 
29
    properties, to be used in the editor. in qle -version 2, the editor no
 
30
    longer comes with a predefined application list, but this class reads the
 
31
    (all) installed applications and standalone quicklists. also, by default,
 
32
    the edtor will only show (all) quicklists that are actually locked in the
 
33
    launcher.
35
34
    """
36
35
 
37
 
    def __init__(self, textfile = None,
 
36
    def __init__(self,
 
37
                 textfile = None,
38
38
                 string = None,
39
39
                 position = None,
40
40
                 findmodus = None,
89
89
 
90
90
    def list_standalones(self):
91
91
        """
92
 
        low level function; creates a list of all standalone
93
 
        desktopfiles.
 
92
        low level function; creates a list of all standalone desktopfiles.
94
93
        """
95
94
        self.define_locations()
96
95
        self.standalones = []
107
106
 
108
107
    def read_list_infile(self):
109
108
        """
110
 
        low level function; this function converts a list in a textfiles
111
 
        into a list in python. serves a.o. read_current_launcher.
 
109
        low level function; this function converts a list in a textfiles into
 
110
        a list in python. serves a.o. read_current_launcher.
112
111
        """
113
112
        self.check_textfile =  open(self.current_textfile, "r")
114
113
        self.read_textfile = eval(self.check_textfile.read())
148
147
            return "earlier_ubuntu"
149
148
        else:
150
149
            return "precise_and_later"
151
 
        
 
150
    
152
151
    def edit_mode(self):
153
152
        """
154
 
        this function is to determine the edit mode
155
 
        (Actions= or Ayatana...) depending on the Ubuntu version
156
 
        and / or the .desktop file.
 
153
        this function is to determine the edit mode(Actions= or Ayatana...)
 
154
        depending on the Ubuntu version and / or the .desktop file.
157
155
        """
158
156
        self.current_textfile = self.textfile # for "bypass"
159
157
        self.searchtext = self.readtext_offile()
164
162
            self.ed_mode = "newstyle"
165
163
        self.textfile = self.current_textfile # pick up bypass
166
164
        return self.ed_mode
167
 
 
 
165
    
168
166
    def create_database_installedapps(self):
169
167
        """
170
168
        creates a database of all installed applications. data include:
182
180
 
183
181
    def lookup_data(self):
184
182
        """
185
 
        looks up all the data from the desktop files, needed for the
186
 
        database(s)
 
183
        looks up all the data from the desktop files, needed for the databases
187
184
        """
188
185
        self.application_data = {}
189
186
        self.textfile = self.lookup_directory+"/"+self.application
217
214
        # [5] edit mode; X-Ayatana... / Actions=...
218
215
        self.application_data["editmode"] = self.edit_mode()
219
216
        return self.application_data
220
 
        
 
217
    
221
218
    def create_database_standalones(self):
222
219
        """
223
 
        creates a database of all standalone .desktop files.
224
 
        data include: [[marker, system name, interface name,
225
 
        interface name (lower case), default command]].
 
220
        creates a database of all standalone .desktop files. data include:
 
221
        [[marker, system name, interface name, interface name (lower case),
 
222
        default command]].
226
223
        """
227
224
        self.define_locations()
228
225
        self.lookup_list = self.list_standalones()
235
232
 
236
233
    def create_completelist(self):
237
234
        """
238
 
        creates the all-in-one desktop file database.
239
 
        this is final result (1), written to
240
 
        ~/.qle/application_database.txt
 
235
        creates the all-in-one desktop file database. this is final result (1),
 
236
        written to ~/.qle/application_database.txt
241
237
        """
242
238
        self.list_default = self.create_database_installedapps()
243
239
        self.list_standalones = self.create_database_standalones()
249
245
 
250
246
    def create_launcheritems_database(self):
251
247
        """
252
 
        creates the database (all fields) of the launcheritems;
253
 
        in fact an outtake of the result of create_completelist(),
254
 
        ordered like the current launcher. this is final result (2),
255
 
        written to ~/.qle/launcheritems_database.txt
 
248
        creates the database (all fields) of the launcheritems; in fact an
 
249
        outtake of the result of create_completelist(), ordered like the
 
250
        current launcher. this is final result (2), written to
 
251
        /.qle/launcheritems_database.txt
256
252
        """
257
253
        self.define_locations()
258
254
        self.launcher_list = self.read_current_launcher()
273
269
 
274
270
    def produce_applistofinterfacenames(self):
275
271
        """
276
 
        this function produces an application list of interface names
277
 
        to be used in the QLE interface; this is the complete list.
 
272
        this function produces an application list of interface names to be
 
273
        used in the QLE interface; this is the complete list.
278
274
        """
279
275
        self.define_locations()
280
276
        self.current_textfile = self.complete_appdb
284
280
 
285
281
    def produce_launcherlistofinterfacenames(self):
286
282
        """
287
 
        this function produces the application interface name -list
288
 
        of the launcheritems.
 
283
        this function produces the application interface name -list of the
 
284
        launcheritems.
289
285
        """
290
286
        self.define_locations()
291
287
        self.current_textfile = self.launcheritems_file