~viroteck/dockbar/dockbarx

« back to all changes in this revision

Viewing changes to dockbarx.py

  • Committer: Matias Särs
  • Date: 2010-03-27 20:45:12 UTC
  • Revision ID: msevens@kolumbus.fi-20100327204512-vw1wji4v1lr0atb9
- Wine apps are no longer all grouped together, but separated and uses their own icons.
- Small code clean up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
882
882
        # Returns the icon pixbuf for the program. Uses the following metods:
883
883
 
884
884
        # 1) If it is a launcher, return the icon from the launcher's desktopfile
885
 
        # 2) Match the res_class against gio app ids to try to get a desktopfile
 
885
        # 2) Match the identifier against gio app ids to try to get a desktopfile
886
886
        #    that way.
887
887
        # 3) Check if the res_class fits an iconname.
888
888
        # 4) Search in path after a icon matching reclass.
892
892
        else:
893
893
            name = "" # Is this clever? Can there be a "" icon?
894
894
 
 
895
        if name == "wine":
 
896
            name = ""
 
897
 
895
898
        if self.launcher:
896
899
            icon_name = self.launcher.get_icon_name()
897
900
            if os.path.isfile(icon_name):
939
942
                                  flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
940
943
                                  type=gtk.MESSAGE_WARNING,
941
944
                                  buttons=gtk.BUTTONS_OK,
942
 
                                  message_format='Cannot load icon for launcher '+ self.launcher.get_res_class()+'.')
 
945
                                  message_format='Cannot load icon for launcher '+ self.launcher.get_identifier()+'.')
943
946
            dialog.set_title('DockBarX')
944
947
            dialog.run()
945
948
            dialog.destroy()
1492
1495
 
1493
1496
 
1494
1497
class Launcher():
1495
 
    def __init__(self, res_class, path, dockbar=None):
1496
 
        self.res_class = res_class
 
1498
    def __init__(self, identifier, path, dockbar=None):
 
1499
        self.identifier = identifier
1497
1500
        self.path = path
1498
1501
        self.app = None
1499
1502
        if path[:4] == "gio:":
1507
1510
            raise Exception("DesktopFile "+path+" doesn't exist.")
1508
1511
 
1509
1512
 
1510
 
    def get_res_class(self):
1511
 
        return self.res_class
 
1513
    def get_identifier(self):
 
1514
        return self.identifier
1512
1515
 
1513
 
    def set_res_class(self, res_class):
1514
 
        self.res_class = res_class
 
1516
    def set_identifier(self, identifier):
 
1517
        self.identifier = identifier
1515
1518
 
1516
1519
    def get_path(self):
1517
1520
        return self.path
1579
1582
    def __getitem__(self, name):
1580
1583
        return self.get_group(name)
1581
1584
 
1582
 
    def __setitem__(self, res_class, group_button):
1583
 
        self.add_group(res_class, group_button)
 
1585
    def __setitem__(self, identifier, group_button):
 
1586
        self.add_group(identifier, group_button)
1584
1587
 
1585
1588
    def __contains__(self, name):
1586
1589
        if not name:
1594
1597
        return False
1595
1598
 
1596
1599
    def __iter__(self):
1597
 
        return self.get_res_classes().__iter__()
 
1600
        return self.get_identifiers().__iter__()
1598
1601
 
1599
 
    def add_group(self, res_class, group_button, path_to_launcher=None, index=None):
1600
 
        t = (res_class, group_button, path_to_launcher)
 
1602
    def add_group(self, identifier, group_button, path_to_launcher=None, index=None):
 
1603
        t = (identifier, group_button, path_to_launcher)
1601
1604
        if index:
1602
1605
            self.list.insert(index, t)
1603
1606
        else:
1622
1625
            if t[2] == name:
1623
1626
                return t[2]
1624
1627
 
1625
 
    def set_launcher_path(self, res_class, path):
1626
 
        if not res_class:
 
1628
    def set_launcher_path(self, identifier, path):
 
1629
        if not identifier:
1627
1630
            return
1628
1631
        for t in self.list:
1629
 
            if t[0] == res_class:
 
1632
            if t[0] == identifier:
1630
1633
                n = [t[0], t[1], path]
1631
1634
                index = self.list.index(t)
1632
1635
                self.list.remove(t)
1633
1636
                self.list.insert(index, n)
1634
1637
                return True
1635
1638
 
1636
 
    def set_res_class(self, path, res_class):
 
1639
    def set_identifier(self, path, identifier):
1637
1640
        for t in self.list:
1638
1641
            if t[2] == path:
1639
 
                n = (res_class, t[1], t[2])
 
1642
                n = (identifier, t[1], t[2])
1640
1643
                index = self.list.index(t)
1641
1644
                self.list.remove(t)
1642
1645
                self.list.insert(index, n)
1643
 
                n[1].res_class_changed(res_class)
 
1646
                n[1].identifier_changed(identifier)
1644
1647
                return True
1645
1648
 
1646
1649
    def get_groups(self):
1649
1652
            grouplist.append(t[1])
1650
1653
        return grouplist
1651
1654
 
1652
 
    def get_res_classes(self):
 
1655
    def get_identifiers(self):
1653
1656
        namelist = []
1654
1657
        for t in self.list:
1655
1658
            if t[0]:
1663
1666
                namelist.append(t[2])
1664
1667
        return namelist
1665
1668
 
1666
 
    def get_group_identifiers(self):
 
1669
    def get_identifiers_or_paths(self):
1667
1670
        namelist = []
1668
1671
        for t in self.list:
1669
1672
            if t[0] == None:
1704
1707
                self.list.insert(index, t)
1705
1708
                return True
1706
1709
 
1707
 
    def remove_launcher(self, res_class):
1708
 
        if not res_class:
 
1710
    def remove_launcher(self, identifier):
 
1711
        if not identifier:
1709
1712
            return
1710
1713
        for t in self.list:
1711
 
            if res_class == t[0]:
 
1714
            if identifier == t[0]:
1712
1715
                n = (t[0], t[1], None)
1713
1716
                index = self.list.index(t)
1714
1717
                self.list.remove(t)
2286
2289
        "set-icongeo-delay": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,()),
2287
2290
    }
2288
2291
 
2289
 
    def __init__(self,dockbar,class_group=None, launcher=None, index=None, app=None):
2290
 
        # Todo: replace class_group with res_class
 
2292
    def __init__(self,dockbar,class_group=None, identifier=None, launcher=None, index=None, app=None):
2291
2293
        gobject.GObject.__init__(self)
2292
2294
 
2293
2295
        self.launcher = launcher
2294
2296
        self.class_group = class_group
2295
2297
        self.dockbar = dockbar
2296
2298
        self.app = app
2297
 
        if class_group:
2298
 
            self.res_class = class_group.get_res_class()
2299
 
            if self.res_class == "":
2300
 
                self.res_class = class_group.get_name()
 
2299
        if identifier:
 
2300
            self.identifier = identifier
2301
2301
        elif launcher:
2302
 
            self.res_class = launcher.get_res_class()
2303
 
            # launcher.get_res_class() returns None
 
2302
            self.identifier = launcher.get_identifier()
 
2303
            # launcher.get_identifier() returns None
2304
2304
            # if the resclass is still unknown
2305
2305
        else:
2306
2306
            raise Exception, "Can't initiate Group button without class_group or launcher."
2376
2376
        self.popup_label = gtk.Label()
2377
2377
        self.update_name()
2378
2378
        self.popup_label.set_use_markup(True)
2379
 
        if self.res_class:
2380
 
            # Todo: add tooltip when res_class is added.
2381
 
            self.popup_label.set_tooltip_text("Resource class name: "+self.res_class)
 
2379
        if self.identifier:
 
2380
            # Todo: add tooltip when identifier is added.
 
2381
            self.popup_label.set_tooltip_text("Resource class name: "+self.identifier)
2382
2382
        self.winlist.pack_start(self.popup_label,False)
2383
2383
 
2384
2384
 
2428
2428
##        self.dockbar = None
2429
2429
##        self.drag_pixbuf = None
2430
2430
 
2431
 
    def res_class_changed(self, res_class):
2432
 
        self.res_class = res_class
2433
 
        self.launcher.set_res_class(res_class)
2434
 
        self.popup_label.set_tooltip_text("Resource class name: "+self.res_class)
 
2431
    def identifier_changed(self, identifier):
 
2432
        self.identifier = identifier
 
2433
        self.launcher.set_identifier(identifier)
 
2434
        self.popup_label.set_tooltip_text("Resource class name: "+self.identifier)
2435
2435
 
2436
2436
    def update_class_group(self, class_group):
2437
2437
        self.class_group = class_group
2836
2836
        self.hide_list()
2837
2837
 
2838
2838
    def on_drag_data_get(self, widget, context, selection, targetType, eventTime):
2839
 
        if self.res_class:
2840
 
            name = self.res_class
 
2839
        if self.identifier:
 
2840
            name = self.identifier
2841
2841
        else:
2842
2842
            name = self.launcher.get_path()
2843
2843
        selection.set(selection.target, 8, name)
2861
2861
        return True
2862
2862
 
2863
2863
    def on_drag_data_received(self, wid, context, x, y, selection, targetType, t):
2864
 
        if self.res_class:
2865
 
            name = self.res_class
 
2864
        if self.identifier:
 
2865
            name = self.identifier
2866
2866
        else:
2867
2867
            name = self.launcher.get_path()
2868
2868
        if selection.target == 'text/groupbutton_name':
3060
3060
            if window.is_minimized():
3061
3061
                window.unminimize(t)
3062
3062
 
3063
 
    def change_res_class(self, widget=None, event=None):
3064
 
        self.dockbar.change_res_class(self.launcher.get_path(), self.res_class)
 
3063
    def change_identifier(self, widget=None, event=None):
 
3064
        self.dockbar.change_identifier(self.launcher.get_path(), self.identifier)
3065
3065
 
3066
3066
    def add_launcher(self, widget=None, event=None):
3067
3067
        path = "gio:" + self.app.get_id()[:self.app.get_id().rfind('.')].lower()
3068
 
        self.launcher = Launcher(self.res_class, path, self.dockbar)
3069
 
        self.dockbar.groups.set_launcher_path(self.res_class, path)
 
3068
        self.launcher = Launcher(self.identifier, path, self.dockbar)
 
3069
        self.dockbar.groups.set_launcher_path(self.identifier, path)
3070
3070
        self.dockbar.update_launchers_list()
3071
3071
 
3072
3072
    #### Actions
3391
3391
            menu.append(remove_launcher_item)
3392
3392
            remove_launcher_item.connect("activate", self.action_remove_launcher)
3393
3393
            remove_launcher_item.show()
3394
 
            #Edit res_class item
3395
 
            edit_res_class_item = gtk.MenuItem('Edit Resource Name')
3396
 
            menu.append(edit_res_class_item)
3397
 
            edit_res_class_item.connect("activate", self.change_res_class)
3398
 
            edit_res_class_item.show()
 
3394
            #Edit identifier item
 
3395
            edit_identifier_item = gtk.MenuItem('Edit Resource Name')
 
3396
            menu.append(edit_identifier_item)
 
3397
            edit_identifier_item.connect("activate", self.change_identifier)
 
3398
            edit_identifier_item.show()
3399
3399
        if (self.launcher or self.app) and self.windows:
3400
3400
            #Separator
3401
3401
            sep = gtk.SeparatorMenuItem()
3435
3435
        self.dockbar.right_menu_showing = True
3436
3436
 
3437
3437
    def action_remove_launcher(self, widget=None, event = None):
3438
 
        print 'Removing launcher ', self.res_class
3439
 
        if self.res_class:
3440
 
            name = self.res_class
 
3438
        print 'Removing launcher ', self.identifier
 
3439
        if self.identifier:
 
3440
            name = self.identifier
3441
3441
        else:
3442
3442
            name = self.launcher.get_path()
3443
3443
        self.launcher = None
3455
3455
                # The launcher is not of gio-app type.
3456
3456
                # The group button will be reset with its
3457
3457
                # non-launcher name and icon.
3458
 
                self.app = self.dockbar.find_gio_app(self.res_class)
 
3458
                self.app = self.dockbar.find_gio_app(self.identifier)
3459
3459
                self.icon_factory.remove_launcher(class_group=self.class_group, app = self.app)
3460
3460
                self.update_name()
3461
3461
                self.update_state()
3469
3469
                    gr.windows[win].window.minimize()
3470
3470
 
3471
3471
    def action_compiz_scale_windows(self, widget, event):
3472
 
        if not self.res_class or \
 
3472
        if not self.class_group or \
3473
3473
           len(self.windows) - self.minimized_windows_count == 0:
3474
3474
            return
3475
3475
        if len(self.windows) - self.minimized_windows_count == 1:
3479
3479
                    break
3480
3480
            return
3481
3481
        try:
3482
 
            compiz_call('scale/allscreens/initiate_all_key','activate','root', self.root_xid,'match','iclass='+self.res_class)
 
3482
            compiz_call('scale/allscreens/initiate_all_key', \
 
3483
                        'activate','root', self.root_xid,'match', \
 
3484
                        'iclass='+self.class_group.get_res_class())
3483
3485
        except:
3484
3486
            return
3485
3487
        # A new button enter signal is sent when compiz is called,
3487
3489
        gobject.timeout_add(settings['popup_delay']+ 200, self.hide_list)
3488
3490
 
3489
3491
    def action_compiz_shift_windows(self, widget, event):
3490
 
        if not self.res_class or \
 
3492
        if not self.class_group or \
3491
3493
           len(self.windows) - self.minimized_windows_count == 0:
3492
3494
            return
3493
3495
        if len(self.windows) - self.minimized_windows_count == 1:
3497
3499
                    break
3498
3500
            return
3499
3501
        try:
3500
 
            compiz_call('shift/allscreens/initiate_all_key','activate','root', self.root_xid,'match','iclass='+self.res_class)
 
3502
            compiz_call('shift/allscreens/initiate_all_key', \
 
3503
                        'activate','root', self.root_xid,'match', \
 
3504
                        'iclass='+self.class_group.get_res_class())
3501
3505
        except:
3502
3506
            return
3503
3507
        # A new button enter signal is sent when compiz is called,
3665
3669
                self.on_window_closed(None, win)
3666
3670
        if self.groups != None:
3667
3671
            # Removes launcher group buttons
3668
 
            for name in self.groups.get_group_identifiers():
 
3672
            for name in self.groups.get_identifiers_or_paths():
3669
3673
                self.groups[name].hide_list()
3670
3674
                self.groups[name].icon_factory.remove()
3671
3675
                self.groups.remove(name)
3794
3798
##        pdb.set_trace()
3795
3799
        # Initiate launcher group buttons
3796
3800
        for launcher in gconf_launchers:
3797
 
            res_class, path = launcher.split(';')
3798
 
            if res_class == '':
3799
 
                res_class = None
3800
 
            self.add_launcher(res_class, path)
 
3801
            identifier, path = launcher.split(';')
 
3802
            if identifier == '':
 
3803
                identifier = None
 
3804
            self.add_launcher(identifier, path)
3801
3805
 
3802
3806
##        pdb.set_trace()
3803
3807
        #--- Initiate windows
3967
3971
                window_button = active_group.windows[active_window]
3968
3972
                window_button.set_button_active(True)
3969
3973
 
 
3974
    def on_window_closed(self,screen,window):
 
3975
        if window in self.windows:
 
3976
            class_group_name = self.windows[window]
 
3977
            group = self.groups[class_group_name]
 
3978
            if group:
 
3979
                group.del_window(window)
 
3980
                if not group.windows and not group.launcher:
 
3981
                    self.groups.remove(class_group_name)
 
3982
            del self.windows[window]
 
3983
 
3970
3984
    def on_window_opened(self,screen,window):
3971
3985
        if window.is_skip_tasklist() \
3972
3986
        or not (window.get_window_type() in [wnck.WINDOW_NORMAL, wnck.WINDOW_DIALOG]):
3976
3990
        class_group_name = class_group.get_res_class()
3977
3991
        if class_group_name == "":
3978
3992
            class_group_name = class_group.get_name()
3979
 
        self.windows[window]=class_group_name
3980
 
        if class_group_name in self.groups.get_res_classes():
 
3993
        if class_group_name == "Wine":
 
3994
            class_group_name = self.get_wine_app_name(window)
 
3995
        self.windows[window] = class_group_name
 
3996
        if class_group_name in self.groups.get_identifiers():
 
3997
            # This isn't the first open window of this group.
3981
3998
            self.groups[class_group_name].add_window(window)
3982
3999
            return
 
4000
        id = self.find_matching_launcher(class_group_name)
 
4001
        if id:
 
4002
            # The window is matching a launcher without open windows.
 
4003
            path = self.launchers_by_id[id].get_path()
 
4004
            self.groups.set_identifier(path, class_group_name)
 
4005
            self.groups[class_group_name].add_window(window)
 
4006
            self.update_launchers_list()
 
4007
            self.remove_launcher_id_from_undefined_list(id)
 
4008
        else:
 
4009
            # First window of a new group.
 
4010
            app = self.find_gio_app(class_group_name)
 
4011
            self.groups[class_group_name] = GroupButton(self,class_group, identifier=class_group_name, app=app)
 
4012
            self.groups[class_group_name].add_window(window)
 
4013
 
 
4014
    def find_matching_launcher(self, identifier):
3983
4015
        id = None
3984
 
        rc = u""+class_group_name.lower()
 
4016
        rc = u""+identifier.lower()
3985
4017
        if rc != "":
3986
4018
            if rc in self.launchers_by_id:
3987
4019
                id = rc
4007
4039
            if id == None and rc.find(' ')>-1:
4008
4040
                    rc = rc.partition(' ')[0] # Cut all before space
4009
4041
                    # Workaround for apps
4010
 
                    # with res_class like this 'App 1.2.3' (name with ver)
 
4042
                    # with identifier like this 'App 1.2.3' (name with ver)
4011
4043
                    if rc in self.launchers_by_id:
4012
4044
                        id = rc
4013
4045
                        print "Partial name for open window matched with id:", rc
4017
4049
                    elif rc in self.launchers_by_exec:
4018
4050
                        id = self.launchers_by_exec[rc]
4019
4051
                        print "Partial name for open window matched with executable:", rc
4020
 
        if id:
4021
 
            # The window is matching a launcher!
4022
 
            path = self.launchers_by_id[id].get_path()
4023
 
            self.groups.set_res_class(path, class_group_name)
4024
 
            self.groups[class_group_name].add_window(window)
4025
 
            self.update_launchers_list()
4026
 
            self.remove_launcher_id_from_undefined_list(id)
4027
 
        else:
4028
 
            # First window of a new group.
4029
 
            app = self.find_gio_app(class_group_name)
4030
 
            self.groups[class_group_name] = GroupButton(self,class_group, app=app)
4031
 
            self.groups[class_group_name].add_window(window)
4032
 
 
4033
 
 
4034
 
    def on_window_closed(self,screen,window):
4035
 
        if window in self.windows:
4036
 
            class_group_name = self.windows[window]
4037
 
            group = self.groups[class_group_name]
4038
 
            if group:
4039
 
                group.del_window(window)
4040
 
                if not group.windows and not group.launcher:
4041
 
                    self.groups.remove(class_group_name)
4042
 
            del self.windows[window]
4043
 
 
4044
 
    def find_gio_app(self, res_class):
 
4052
        return id
 
4053
 
 
4054
    def find_gio_app(self, identifier):
4045
4055
        app = None
4046
4056
        app_id = None
4047
 
        rc = u""+res_class.lower()
 
4057
        rc = u""+identifier.lower()
4048
4058
        if rc != "":
4049
4059
            # WM_CLASS res_class exists.
4050
4060
            if rc in self.apps_by_id:
4072
4082
                    rc = rc.partition(' ')[0] # Cut all before space
4073
4083
                    print " trying to find as",rc
4074
4084
                    # Workaround for apps
4075
 
                    # with res_class like this 'App 1.2.3' (name with ver)
 
4085
                    # with identifier like this 'App 1.2.3' (name with ver)
4076
4086
                    ### keys()
4077
4087
                    if rc in self.apps_by_id.keys():
4078
4088
                        app_id = rc
4087
4097
                app = self.apps_by_id[app_id]
4088
4098
        return app
4089
4099
 
 
4100
    def get_wine_app_name(self, window):
 
4101
        # This function guesses an application name base on the window name
 
4102
        # since all wine applications are has the identifier "Wine".
 
4103
        name = window.get_name()
 
4104
        # if the name has " - " in it the application is usually the part after it.
 
4105
        name = name.split(" - ")[-1]
 
4106
        return "Wine__" + name
 
4107
 
 
4108
 
 
4109
 
 
4110
 
4090
4111
    #### Launchers
4091
 
    def add_launcher(self, res_class, path):
 
4112
    def add_launcher(self, identifier, path):
4092
4113
        """Adds a new launcher from a desktop file located at path and from the name"""
4093
4114
        try:
4094
 
            launcher = Launcher(res_class, path, dockbar=self)
 
4115
            launcher = Launcher(identifier, path, dockbar=self)
4095
4116
        except:
4096
 
            print "ERROR: Couldn't read desktop entry for " + res_class
 
4117
            print "ERROR: Couldn't read desktop entry for " + identifier
4097
4118
            print "path: "+ path
4098
4119
            return
4099
4120
 
4100
 
        self.groups.add_group(res_class, GroupButton(self, launcher=launcher), path)
4101
 
        if res_class == None:
 
4121
        self.groups.add_group(identifier, GroupButton(self, launcher=launcher), path)
 
4122
        if identifier == None:
4102
4123
            id = path[path.rfind('/')+1:path.rfind('.')].lower()
4103
4124
            name = u""+launcher.get_entry_name().lower()
4104
4125
            exe = launcher.get_executable()
4141
4162
            print "name: ", name
4142
4163
        print "executable: ", exe
4143
4164
        print
4144
 
        for res_class in self.groups.get_non_launcher_names():
4145
 
            rc = u""+res_class.lower()
 
4165
        for identifier in self.groups.get_non_launcher_names():
 
4166
            rc = u""+identifier.lower()
4146
4167
            if not rc:
4147
4168
                continue
4148
4169
            if rc == id:
4163
4184
            if rc.find(' ')>-1:
4164
4185
                    rc = rc.partition(' ')[0] # Cut all before space
4165
4186
                    # Workaround for apps
4166
 
                    # with res_class like this 'App 1.2.3' (name with ver)
 
4187
                    # with identifier like this 'App 1.2.3' (name with ver)
4167
4188
                    if rc == id:
4168
4189
                        break
4169
4190
                    elif rc == name:
4174
4195
            # No open windows where found that could be connected
4175
4196
            # with the new launcher. Id, name and exe will be stored
4176
4197
            # so that it can be checked against new windows later.
4177
 
            res_class = None
 
4198
            identifier = None
4178
4199
            self.launchers_by_id[id] = launcher
4179
4200
            if lname:
4180
4201
                self.launchers_by_longname[name] = id
4183
4204
            self.launchers_by_exec[exe] = id
4184
4205
 
4185
4206
        class_group = None
4186
 
        if res_class:
4187
 
            launcher.set_res_class(res_class)
 
4207
        if identifier:
 
4208
            launcher.set_identifier(identifier)
4188
4209
        # Remove existing groupbutton for the same program
4189
4210
        winlist = []
4190
 
        if calling_button in (res_class, path):
 
4211
        if calling_button in (identifier, path):
4191
4212
            index = self.groups.get_index(calling_button)
4192
4213
            group = self.groups[calling_button]
4193
4214
            class_group = group.get_class_group()
4199
4220
            group.winlist.destroy()
4200
4221
            self.groups.remove(calling_button)
4201
4222
        else:
4202
 
            if res_class in self.groups.get_res_classes():
4203
 
                group = self.groups[res_class]
 
4223
            if identifier in self.groups.get_identifiers():
 
4224
                group = self.groups[identifier]
4204
4225
                class_group = group.get_class_group()
4205
4226
                # Get the windows for repopulation of the new button
4206
4227
                winlist = group.windows.keys()
4208
4229
                group.popup.destroy()
4209
4230
                group.button.destroy()
4210
4231
                group.winlist.destroy()
4211
 
                self.groups.remove(res_class)
 
4232
                self.groups.remove(identifier)
4212
4233
            elif path in self.groups.get_undefined_launchers():
4213
4234
                group = self.groups[path]
4214
4235
                # Destroy the group button
4220
4241
            # Insert the new button after (to the
4221
4242
            # right of or under) the calling button
4222
4243
            index = self.groups.get_index(calling_button) + 1
4223
 
        button = GroupButton(self, class_group=class_group, launcher=launcher, index=index)
4224
 
        self.groups.add_group(res_class, button, path, index)
 
4244
        button = GroupButton(self, class_group=class_group, identifier=identifier, launcher=launcher, index=index)
 
4245
        self.groups.add_group(identifier, button, path, index)
4225
4246
        self.update_launchers_list()
4226
4247
        for window in winlist:
4227
4248
            self.on_window_opened(self.screen, window)
4228
4249
        return True
4229
4250
 
4230
 
    def class_name_dialog(self, res_class=None):
 
4251
    def class_name_dialog(self, identifier=None):
4231
4252
        # Input dialog for inputting the res_class_name.
4232
4253
        dialog = gtk.MessageDialog(
4233
4254
            None,
4244
4265
        #entry = gtk.Entry()
4245
4266
        combobox = gtk.combo_box_entry_new_text()
4246
4267
        entry = combobox.get_child()
4247
 
        if res_class:
4248
 
            entry.set_text(res_class)
 
4268
        if identifier:
 
4269
            entry.set_text(identifier)
4249
4270
        # Fill the popdown list with the names of all class names of buttons that hasn't got a launcher already
4250
4271
        for name in self.groups.get_non_launcher_names():
4251
4272
            combobox.append_text(name)
4296
4317
        self.groups.add_group(name, move_group, move_path, index)
4297
4318
        self.update_launchers_list()
4298
4319
 
4299
 
    def change_res_class(self, path, res_class=None):
4300
 
        res_class = self.class_name_dialog(res_class)
4301
 
        if not res_class:
 
4320
    def change_identifier(self, path, identifier=None):
 
4321
        identifier = self.class_name_dialog(identifier)
 
4322
        if not identifier:
4302
4323
            return False
4303
4324
        winlist = []
4304
 
        if res_class in self.groups.get_res_classes():
4305
 
                group = self.groups[res_class]
 
4325
        if identifier in self.groups.get_identifiers():
 
4326
                group = self.groups[identifier]
4306
4327
                # Get the windows for repopulation of the new button
4307
4328
                winlist = group.windows.keys()
4308
4329
                # Destroy the group button
4309
4330
                group.popup.destroy()
4310
4331
                group.button.destroy()
4311
4332
                group.winlist.destroy()
4312
 
                self.groups.remove(res_class)
4313
 
        self.groups.set_res_class(path, res_class)
 
4333
                self.groups.remove(identifier)
 
4334
        self.groups.set_identifier(path, identifier)
4314
4335
        for window in winlist:
4315
4336
            self.on_window_opened(self.screen, window)
4316
4337
        self.update_launchers_list()
4319
4340
        # Saves launchers_list to gconf.
4320
4341
        launchers_list = self.groups.get_launchers_list()
4321
4342
        gconf_launchers = []
4322
 
        for res_class, path in launchers_list:
4323
 
            if res_class == None:
4324
 
                res_class = ''
4325
 
            gconf_launchers.append(res_class + ';' + path)
 
4343
        for identifier, path in launchers_list:
 
4344
            if identifier == None:
 
4345
                identifier = ''
 
4346
            gconf_launchers.append(identifier + ';' + path)
4326
4347
        GCONF_CLIENT.set_list(GCONF_DIR + '/launchers', gconf.VALUE_STRING, gconf_launchers)
4327
4348
 
4328
4349
    def remove_launcher_id_from_undefined_list(self, id):