Ejemplo n.º 1
0
    def __init__(self, feature='', module='', splash_window=None):
        GuiBuilder.__init__(self, file_name='mainwindow.ui')

        tweaks_page = FeaturePage('tweaks')
        admins_page = FeaturePage('admins')
        self.no_result_box.label = self.result_text
        self.search_page = SearchPage(self.no_result_box)
        clip_page = ClipPage()
        self.apps_page = AppsPage(self.back_button, self.next_button)
        janitor_page = JanitorPage()
        self.preferences_dialog = PreferencesDialog(self.mainwindow)

        self.recently_used_settings = GSetting(
            'com.ubuntu-tweak.tweak.recently-used')

        self.feature_dict['overview'] = self.notebook.append_page(
            clip_page, Gtk.Label('overview'))
        self.feature_dict['apps'] = self.notebook.append_page(
            self.apps_page, Gtk.Label())
        self.feature_dict['tweaks'] = self.notebook.append_page(
            tweaks_page, Gtk.Label('tweaks'))
        self.feature_dict['admins'] = self.notebook.append_page(
            admins_page, Gtk.Label('admins'))
        self.feature_dict['janitor'] = self.notebook.append_page(
            janitor_page, Gtk.Label('janitor'))
        self.feature_dict['wait'] = self.notebook.append_page(
            self._crete_wait_page(), Gtk.Label('wait'))
        self.feature_dict['search'] = self.notebook.append_page(
            self.search_page, Gtk.Label('search'))

        # Always show welcome page at first
        self.mainwindow.connect('realize', self._initialize_ui_states,
                                splash_window)
        self.back_button.connect('clicked', self.on_back_button_clicked)
        self.next_button.connect('clicked', self.on_next_button_clicked)
        tweaks_page.connect('module_selected', self.on_module_selected)
        self.search_page.connect('module_selected', self.on_module_selected)
        admins_page.connect('module_selected', self.on_module_selected)
        self.apps_page.connect('loaded', self.show_apps_page)
        clip_page.connect('load_module',
                          lambda widget, name: self.do_load_module(name))
        clip_page.connect(
            'load_feature',
            lambda widget, name: self.select_target_feature(name))

        self.mainwindow.show()

        if module:
            self.do_load_module(module)
        elif feature:
            self.select_target_feature(feature)

        accel_group = Gtk.AccelGroup()
        self.search_entry.add_accelerator('activate', accel_group, Gdk.KEY_f,
                                          Gdk.ModifierType.CONTROL_MASK,
                                          Gtk.AccelFlags.VISIBLE)
        self.mainwindow.add_accel_group(accel_group)
        thread.start_new_thread(self.preload_proxy_cache, ())
Ejemplo n.º 2
0
    def __init__(self, feature='', module='', splash_window=None):
        GuiBuilder.__init__(self, file_name='mainwindow.ui')

        tweaks_page = FeaturePage('tweaks')
        admins_page = FeaturePage('admins')
        self.no_result_box.label = self.result_text
        self.search_page = SearchPage(self.no_result_box)
        clip_page = ClipPage()
        self.apps_page = AppsPage(self.back_button, self.next_button)
        janitor_page = JanitorPage()
        self.preferences_dialog = PreferencesDialog(self.mainwindow)

        self.recently_used_settings = GSetting('com.ubuntu-tweak.tweak.recently-used')

        self.feature_dict['overview'] = self.notebook.append_page(clip_page, Gtk.Label('overview'))
        self.feature_dict['apps'] = self.notebook.append_page(self.apps_page, Gtk.Label())
        self.feature_dict['tweaks'] = self.notebook.append_page(tweaks_page, Gtk.Label('tweaks'))
        self.feature_dict['admins'] = self.notebook.append_page(admins_page, Gtk.Label('admins'))
        self.feature_dict['janitor'] = self.notebook.append_page(janitor_page, Gtk.Label('janitor'))
        self.feature_dict['wait'] = self.notebook.append_page(self._crete_wait_page(),
                                                           Gtk.Label('wait'))
        self.feature_dict['search'] = self.notebook.append_page(self.search_page,
                                                           Gtk.Label('search'))

        # Always show welcome page at first
        self.mainwindow.connect('realize', self._initialize_ui_states, splash_window)
        self.back_button.connect('clicked', self.on_back_button_clicked)
        self.next_button.connect('clicked', self.on_next_button_clicked)
        tweaks_page.connect('module_selected', self.on_module_selected)
        self.search_page.connect('module_selected', self.on_module_selected)
        admins_page.connect('module_selected', self.on_module_selected)
        self.apps_page.connect('loaded', self.show_apps_page)
        clip_page.connect('load_module', lambda widget, name: self.do_load_module(name))
        clip_page.connect('load_feature', lambda widget, name: self.select_target_feature(name))

        self.mainwindow.show()

        if module:
            self.do_load_module(module)
        elif feature:
            self.select_target_feature(feature)

        accel_group = Gtk.AccelGroup()
        self.search_entry.add_accelerator('activate',
                                          accel_group,
                                          Gdk.KEY_f,
                                          Gdk.ModifierType.CONTROL_MASK,
                                          Gtk.AccelFlags.VISIBLE)
        self.mainwindow.add_accel_group(accel_group)
        thread.start_new_thread(self.preload_proxy_cache, ())
Ejemplo n.º 3
0
class UbuntuTweakWindow(GuiBuilder):
    current_feature = 'overview'
    feature_dict = {}
    navigation_dict = {'tweaks': [None, None]}
    # the module name and page index: 'Compiz': 2
    loaded_modules = {}
    # reversed dict: 2: 'CompizClass'
    modules_index = {}

    def __init__(self, feature='', module='', splash_window=None):
        GuiBuilder.__init__(self, file_name='mainwindow.ui')

        tweaks_page = FeaturePage('tweaks')
        admins_page = FeaturePage('admins')
        self.no_result_box.label = self.result_text
        self.search_page = SearchPage(self.no_result_box)
        clip_page = ClipPage()
        self.apps_page = AppsPage(self.back_button, self.next_button)
        janitor_page = JanitorPage()
        self.preferences_dialog = PreferencesDialog(self.mainwindow)

        self.recently_used_settings = GSetting('com.ubuntu-tweak.tweak.recently-used')

        self.feature_dict['overview'] = self.notebook.append_page(clip_page, Gtk.Label('overview'))
        self.feature_dict['apps'] = self.notebook.append_page(self.apps_page, Gtk.Label())
        self.feature_dict['tweaks'] = self.notebook.append_page(tweaks_page, Gtk.Label('tweaks'))
        self.feature_dict['admins'] = self.notebook.append_page(admins_page, Gtk.Label('admins'))
        self.feature_dict['janitor'] = self.notebook.append_page(janitor_page, Gtk.Label('janitor'))
        self.feature_dict['wait'] = self.notebook.append_page(self._crete_wait_page(),
                                                           Gtk.Label('wait'))
        self.feature_dict['search'] = self.notebook.append_page(self.search_page,
                                                           Gtk.Label('search'))

        # Always show welcome page at first
        self.mainwindow.connect('realize', self._initialize_ui_states, splash_window)
        self.back_button.connect('clicked', self.on_back_button_clicked)
        self.next_button.connect('clicked', self.on_next_button_clicked)
        tweaks_page.connect('module_selected', self.on_module_selected)
        self.search_page.connect('module_selected', self.on_module_selected)
        admins_page.connect('module_selected', self.on_module_selected)
        self.apps_page.connect('loaded', self.show_apps_page)
        clip_page.connect('load_module', lambda widget, name: self.do_load_module(name))
        clip_page.connect('load_feature', lambda widget, name: self.select_target_feature(name))

        self.mainwindow.show()

        if module:
            self.do_load_module(module)
        elif feature:
            self.select_target_feature(feature)

        accel_group = Gtk.AccelGroup()
        self.search_entry.add_accelerator('activate',
                                          accel_group,
                                          Gdk.KEY_f,
                                          Gdk.ModifierType.CONTROL_MASK,
                                          Gtk.AccelFlags.VISIBLE)
        self.mainwindow.add_accel_group(accel_group)
        thread.start_new_thread(self.preload_proxy_cache, ())

    def show_apps_page(self, widget):
        self.notebook.set_current_page(self.feature_dict['apps'])

    def preload_proxy_cache(self):
        #This function just called to make sure the cache is loaded as soon as possible
        proxy.is_package_installed('ubuntu-tweak')

    def on_search_entry_activate(self, widget):
        widget.grab_focus()
        self.on_search_entry_changed(widget)

    def on_search_entry_changed(self, widget):
        text = widget.get_text()
        self.set_current_module(None, None)

        if text:
            self.notebook.set_current_page(self.feature_dict['search'])
            self.search_page.search(text)
            self.search_entry.set_property('secondary-icon-name', 'edit-clear')
        else:
            self.on_feature_button_clicked(getattr(self, '%s_button' % self.current_feature), self.current_feature)
            self.search_page.clean()
            self.search_entry.set_property('secondary-icon-name', 'edit-find')

    def on_search_entry_icon_press(self, widget, icon_pos, event):
        widget.set_text('')

    def get_module_and_index(self, name):
        index = self.loaded_modules[name]

        return self.modules_index[index], index

    def select_target_feature(self, text):
        toggle_button = getattr(self, '%s_button' % text, None)
        log.info("select_target_feature: %s" % text)
        if toggle_button:
            self.current_feature = text
            toggle_button.set_active(True)

    def _initialize_ui_states(self, widget, splash_window):
        self.window_size_setting = GSetting('com.ubuntu-tweak.tweak.window-size')
        width, height = self.window_size_setting.get_value()
        if width >= 900 and height >= 506:
            self.mainwindow.set_default_size(width, height)

        for feature_button in ('overview_button', 'apps_button', 'admins_button', \
                               'tweaks_button', 'janitor_button'):
            button = getattr(self, feature_button)

            label = button.get_child().get_label()
            button.get_child().set_markup('<b>%s</b>' % label)
            button.get_child().set_use_underline(True)
        splash_window.destroy()

    def _crete_wait_page(self):
        vbox = Gtk.VBox()

        label = Gtk.Label()
        label.set_markup("<span size=\"xx-large\">%s</span>" % \
                        _('Please wait a moment...'))
        label.set_justify(Gtk.Justification.FILL)
        vbox.pack_start(label, False, False, 50)
        hbox = Gtk.HBox()
        vbox.pack_start(hbox, False, False, 0)

        vbox.show_all()

        return vbox

    def on_mainwindow_destroy(self, widget=None):
        allocation = widget.get_allocation()
        self.window_size_setting.set_value((allocation.width, allocation.height))

        Gtk.main_quit()
        try:
            proxy.exit()
        except Exception, e:
            log.error(e)
Ejemplo n.º 4
0
class UbuntuTweakWindow(GuiBuilder):
    current_feature = 'overview'
    feature_dict = {}
    navigation_dict = {'tweaks': [None, None]}
    # the module name and page index: 'Compiz': 2
    loaded_modules = {}
    # reversed dict: 2: 'CompizClass'
    modules_index = {}

    def __init__(self, feature='', module='', splash_window=None):
        GuiBuilder.__init__(self, file_name='mainwindow.ui')

        tweaks_page = FeaturePage('tweaks')
        admins_page = FeaturePage('admins')
        self.no_result_box.label = self.result_text
        self.search_page = SearchPage(self.no_result_box)
        clip_page = ClipPage()
        self.apps_page = AppsPage(self.back_button, self.next_button)
        janitor_page = JanitorPage()
        self.preferences_dialog = PreferencesDialog(self.mainwindow)

        self.recently_used_settings = GSetting(
            'com.ubuntu-tweak.tweak.recently-used')

        self.feature_dict['overview'] = self.notebook.append_page(
            clip_page, Gtk.Label('overview'))
        self.feature_dict['apps'] = self.notebook.append_page(
            self.apps_page, Gtk.Label())
        self.feature_dict['tweaks'] = self.notebook.append_page(
            tweaks_page, Gtk.Label('tweaks'))
        self.feature_dict['admins'] = self.notebook.append_page(
            admins_page, Gtk.Label('admins'))
        self.feature_dict['janitor'] = self.notebook.append_page(
            janitor_page, Gtk.Label('janitor'))
        self.feature_dict['wait'] = self.notebook.append_page(
            self._crete_wait_page(), Gtk.Label('wait'))
        self.feature_dict['search'] = self.notebook.append_page(
            self.search_page, Gtk.Label('search'))

        # Always show welcome page at first
        self.mainwindow.connect('realize', self._initialize_ui_states,
                                splash_window)
        self.back_button.connect('clicked', self.on_back_button_clicked)
        self.next_button.connect('clicked', self.on_next_button_clicked)
        tweaks_page.connect('module_selected', self.on_module_selected)
        self.search_page.connect('module_selected', self.on_module_selected)
        admins_page.connect('module_selected', self.on_module_selected)
        self.apps_page.connect('loaded', self.show_apps_page)
        clip_page.connect('load_module',
                          lambda widget, name: self.do_load_module(name))
        clip_page.connect(
            'load_feature',
            lambda widget, name: self.select_target_feature(name))

        self.mainwindow.show()

        if module:
            self.do_load_module(module)
        elif feature:
            self.select_target_feature(feature)

        accel_group = Gtk.AccelGroup()
        self.search_entry.add_accelerator('activate', accel_group, Gdk.KEY_f,
                                          Gdk.ModifierType.CONTROL_MASK,
                                          Gtk.AccelFlags.VISIBLE)
        self.mainwindow.add_accel_group(accel_group)
        thread.start_new_thread(self.preload_proxy_cache, ())

    def show_apps_page(self, widget):
        self.notebook.set_current_page(self.feature_dict['apps'])

    def preload_proxy_cache(self):
        #This function just called to make sure the cache is loaded as soon as possible
        proxy.is_package_installed('ubuntu-tweak')

    def on_search_entry_activate(self, widget):
        widget.grab_focus()
        self.on_search_entry_changed(widget)

    def on_search_entry_changed(self, widget):
        text = widget.get_text()
        self.set_current_module(None, None)

        if text:
            self.notebook.set_current_page(self.feature_dict['search'])
            self.search_page.search(text)
            self.search_entry.set_property('secondary-icon-name', 'edit-clear')
        else:
            self.on_feature_button_clicked(
                getattr(self, '%s_button' % self.current_feature),
                self.current_feature)
            self.search_page.clean()
            self.search_entry.set_property('secondary-icon-name', 'edit-find')

    def on_search_entry_icon_press(self, widget, icon_pos, event):
        widget.set_text('')

    def get_module_and_index(self, name):
        index = self.loaded_modules[name]

        return self.modules_index[index], index

    def select_target_feature(self, text):
        toggle_button = getattr(self, '%s_button' % text, None)
        log.info("select_target_feature: %s" % text)
        if toggle_button:
            self.current_feature = text
            toggle_button.set_active(True)

    def _initialize_ui_states(self, widget, splash_window):
        self.window_size_setting = GSetting(
            'com.ubuntu-tweak.tweak.window-size')
        width, height = self.window_size_setting.get_value()
        if width >= 900 and height >= 506:
            self.mainwindow.set_default_size(width, height)

        for feature_button in ('overview_button', 'apps_button', 'admins_button', \
                               'tweaks_button', 'janitor_button'):
            button = getattr(self, feature_button)

            label = button.get_child().get_label()
            button.get_child().set_markup('<b>%s</b>' % label)
            button.get_child().set_use_underline(True)
        splash_window.destroy()

    def _crete_wait_page(self):
        vbox = Gtk.VBox()

        label = Gtk.Label()
        label.set_markup("<span size=\"xx-large\">%s</span>" % \
                        _('Please wait a moment...'))
        label.set_justify(Gtk.Justification.FILL)
        vbox.pack_start(label, False, False, 50)
        hbox = Gtk.HBox()
        vbox.pack_start(hbox, False, False, 0)

        vbox.show_all()

        return vbox

    def on_mainwindow_destroy(self, widget=None):
        allocation = widget.get_allocation()
        self.window_size_setting.set_value(
            (allocation.width, allocation.height))

        Gtk.main_quit()
        try:
            proxy.exit()
        except Exception, e:
            log.error(e)