def __init__(self, network_interface):
        gtk.VBox.__init__(self)

        self.theme = None

        self.set_spacing(10)

        self.cache_view = CacheView(network_interface, download_dir=get_download_wallpaper_dir())
        self.cache_view_sw = self.cache_view.get_scrolled_window()

        self.nolink_image = ImageBox(app_theme.get_pixbuf("individuation/notlink.png"))

        self.back_button = Button(_("Back"))
        self.back_button.connect("clicked", self.__on_back)
        download_button = Button(_("Download All"))
        download_button.connect("clicked", self.on_download_button_clicked)

        control_box = gtk.HBox(spacing=10)
        control_box.pack_start(self.back_button, False, False)

        self.control_align = gtk.Alignment()
        self.control_align.set(1.0, 0.5, 0, 0)
        self.control_align.set_padding(0, 5, 0, 10)
        self.control_align.add(control_box)

        self.pack_start(self.cache_view_sw, True, True)
        self.pack_start(self.control_align, False, True)

        event_manager.add_callback("fetch-failed", self.__fetch_failed)
Example #2
0
    def __init__(self, confirm_callback=None):
        DialogBox.__init__(self, 
                           title=_("Close"),
                           default_width=360,
                           default_height=145,
                           mask_type=DIALOG_MASK_SINGLE_PAGE,
                           )
        
        self.confirm_callback = confirm_callback
        radio_group = gtk.HBox(spacing=50)
        self.minimize_radio = RadioButton(_("Minimize to tray"))
        self.minimize_radio.set_active(True)
        self.quit_radio = RadioButton(_("Quit"))
        
        radio_group.pack_start(self.minimize_radio, False, True)
        radio_group.pack_start(self.quit_radio, False, True)
        self.remembar_button = CheckButton(_("Don't prompt again"))
        self.remembar_button.set_active(True)
        
        radio_group_align = gtk.Alignment()
        radio_group_align.set_padding(30, 0, 10, 0)
        radio_group_align.add(radio_group)
                
        confirm_button = Button(_("OK"))
        confirm_button.connect("clicked", self.on_confirm_button_clicked)

        cancel_button = Button(_("Cancel"))
        cancel_button.connect("clicked", self.on_cancel_button_clicked)        
        
        # Connect widgets.
        self.body_box.pack_start(radio_group_align, False, True)
        self.left_button_box.set_buttons([self.remembar_button,])
        self.right_button_box.set_buttons([confirm_button, cancel_button])
 def __init__(self):
     DialogBox.__init__(self, _("Task Manager"), 350, 450, DIALOG_MASK_SINGLE_PAGE,
                        modal=False, close_callback=self.hide_all)
     
     self.is_changed = False
     scrolled_window = ScrolledWindow(0, 0)
     scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
     
     scrolled_align = gtk.Alignment()
     scrolled_align.set(1, 1, 1, 1)
     scrolled_align.set_padding(10, 0, 0, 0)
     scrolled_align.add(scrolled_window)
     
     self.jobs_view = JobsView()
     self.jobs_view.draw_mask = self.get_mask_func(self.jobs_view)
     scrolled_window.add_child(self.jobs_view)
     
     pause_button = Button(_("Pause"))
     pause_button.connect("clicked", self.pause_job)
     stop_button = Button(_("Close"))
     stop_button.connect("clicked", lambda w: self.hide_all())
     
     self.body_box.add(scrolled_align)
     self.right_button_box.set_buttons([pause_button, stop_button])
     
     Dispatcher.connect("transfor-job", self.add_new_job)
class BluetoothReplyDialog(DialogBox):
    DIALOG_MASK_SINGLE_PAGE = 0

    def __init__(self, message, default_width=300, default_height=140, is_succeed=True):
        DialogBox.__init__(self, "", default_width, default_height, self.DIALOG_MASK_SINGLE_PAGE)

        self.hbox = gtk.HBox()
        self.image_align = gtk.Alignment()
        self.image_align.set(0, 0, 0, 0)
        self.image_align.set_padding(0, 0, 20, 0)
        self.image_box = ImageBox(app_theme.get_pixbuf("bluetooth/succeed.png"))
        if not is_succeed:
            self.image_box = ImageBox(app_theme.get_pixbuf("bluetooth/failed.png"))
        self.image_align.add(self.image_box)
        self.message_align = gtk.Alignment()
        self.message_align.set(0, 0, 0, 0)
        self.message_align.set_padding(20, 0, 10, 0)
        if not is_succeed:
            self.message_align.set_padding(0, 0, 10, 0)
        self.message_label = Label(message, wrap_width = 200)
        self.message_align.add(self.message_label)
        self.hbox.pack_start(self.image_align)
        self.hbox.pack_start(self.message_align)
        self.confirm_align = gtk.Alignment()
        self.confirm_align.set(0, 0, 0, 0)
        self.confirm_align.set_padding(20, 0, 200, 0)
        self.confirm_button = Button(_("Ok"))
        self.confirm_button.set_size_request(70, WIDGET_HEIGHT)
        self.confirm_button.connect("clicked", lambda widget : self.destroy())
        self.confirm_align.add(self.confirm_button)

        self.body_box.pack_start(self.hbox, False, False)
        self.body_box.pack_start(self.confirm_align, False, False)
 def __init__(self, song=None):
     super(InfoSetting, self).__init__()
     self.song = song
     main_align = gtk.Alignment()
     main_align.set_padding(40, 0, 100, 0)
     main_align.set(0, 0, 0.5, 0.5)
     self.main_table = gtk.Table(6, 3)
     self.main_table.set_col_spacings(10)
     self.main_table.set_row_spacings(10)
     
     self.title_entry  = self.create_combo_entry(0, 1, _("Title:"))
     self.artist_entry = self.create_combo_entry(1, 2, _("Artist:"))
     self.album_entry  = self.create_combo_entry(2, 3, _("Album:"))
     self.genre_entry  = self.create_combo_entry(3, 4, _("Genre:"))
     self.date_entry   = self.create_combo_entry(4, 5, _("Date:"))
     
     main_align.add(self.main_table)
     
     # Update song
     if song:
         self.update_song(song)
         
     save_button = Button(_("Save"))    
     save_button.connect("clicked", self.save_taginfo)
     block_box = gtk.EventBox()
     block_box.set_visible_window(False)
     block_box.set_size_request(90, -1)
     button_box = gtk.HBox()
     button_box.pack_start(create_right_align(), True, True)
     button_box.pack_start(save_button, False, False)
     button_box.pack_start(block_box, False, False)
     self.pack_start(main_align, False, True)
     self.pack_start(button_box, False, False)
Example #6
0
def resolve_accel_entry_conflict(origin_entry, conflict_entry, tmp_accel_buf):
    dialog = DialogBox(" ", 620, 150)
    dialog.window_frame.connect("expose-event", draw_widget_background)
    dialog.set_keep_above(True)
    dialog.set_modal(True)
    dialog.body_align.set_padding(15, 10, 10, 10)
    label1 = Label(
        _("The shortcut \"%s\" is already used for \"%s\"") %
        (tmp_accel_buf.get_accel_label(), conflict_entry.settings_description),
        enable_select=False,
        enable_double_click=False)
    label2 = Label(_(
        "If you reassign the shortcut to \"%s\", the \"%s\" shortcut will be disabled."
    ) % (origin_entry.settings_description,
         conflict_entry.settings_description),
                   enable_select=False,
                   enable_double_click=False)
    dialog.body_box.pack_start(label1)
    dialog.body_box.pack_start(label2)
    button_reassign = Button(_("Reassign"))
    button_cancel = Button(_("Cancel"))
    button_cancel.connect("clicked",
                          lambda b: origin_entry.reassign_cancel(dialog))
    button_reassign.connect(
        "clicked",
        lambda b: origin_entry.reassign(tmp_accel_buf, conflict_entry, dialog))
    dialog.right_button_box.set_buttons([button_cancel, button_reassign])
    dialog.show_all()
 def __init__(self):
     DialogBox.__init__(self, _("Search"), 460, 300, DIALOG_MASK_SINGLE_PAGE,
                        modal=False, window_hint=None, close_callback=self.hide_all)
     title_label = Label(_("Title:"))
     self.title_entry = TextEntry("")
     self.title_entry.set_size(300, 25)
     self.search_button = Button(_("Search"))
     self.search_button.connect("clicked", self.search_song)
     
     control_box = gtk.HBox(spacing=5)
     control_box.pack_start(title_label, False, False)
     control_box.pack_start(self.title_entry, False, False)
     control_box.pack_start(self.search_button, False, False)
     
     scrolled_window = ScrolledWindow(0, 0)
     scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
     self.result_view = ListView()
     self.result_view.connect("double-click-item", self.double_click_cb)
     self.result_view.draw_mask = self.get_mask_func(self.result_view)
     self.result_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Type"), _("Size")])
     scrolled_window.add_child(self.result_view)
     
     self.prompt_label = Label("")
     download_button = Button(_("Download"))
     download_button.connect("clicked", self.download_song)
     cancel_button = Button(_("Close"))
     cancel_button.connect("clicked", lambda w: self.hide_all())
     
     self.body_box.set_spacing(5)
     self.body_box.pack_start(control_box, False, False)
     self.body_box.pack_start(scrolled_window, True, True)
     self.left_button_box.set_buttons([self.prompt_label])
     self.right_button_box.set_buttons([download_button, cancel_button])
Example #8
0
class BluetoothInputDialog(BluetoothDialog):
    
    def __init__(self, title, ok_cb=None, cancel_cb=None):
        BluetoothDialog.__init__(self, title)
        
        self.ok_cb = ok_cb
        self.cancel_cb = cancel_cb
        
        self.input_entry_align = gtk.Alignment()
        self.input_entry_align.set_padding(20, 20, 5, 5)
        
        self.input_entry = InputEntry("")
        self.input_entry.set_size(500, 25)
        
        self.ok_button = Button(_("OK"))
        self.ok_button.connect("clicked", self.__ok_callback)
        self.cancel_button = Button(_("Cancel"))
        self.cancel_button.connect("clicked", self.__cancel_callback)
        
        self.input_entry_align.add(self.input_entry)
        self.vbox.pack_end(self.input_entry_align)
        self.add_dtk_button(self.ok_button, gtk.RESPONSE_OK)
        self.add_dtk_button(self.cancel_button, gtk.RESPONSE_CANCEL)
        
        self.input_entry.entry.connect("press-return", ok_cb, self.input_entry.get_text())
        
    def __ok_callback(self, widget):
        if self.ok_cb:
            apply(self.ok_cb, [self.input_entry.get_text()])
            
    def __cancel_callback(self, widget):
        if self.cancel_cb:
            self.cancel_cb()
Example #9
0
    def __init__(self, song=None):
        super(InfoSetting, self).__init__()
        self.song = song
        main_align = gtk.Alignment()
        main_align.set_padding(40, 0, 100, 0)
        main_align.set(0, 0, 0.5, 0.5)
        self.main_table = gtk.Table(6, 3)
        self.main_table.set_col_spacings(10)
        self.main_table.set_row_spacings(10)

        self.title_entry = self.create_combo_entry(0, 1, _("Title"))
        self.artist_entry = self.create_combo_entry(1, 2, _("Artist"))
        self.album_entry = self.create_combo_entry(2, 3, _("Album"))
        self.genre_entry = self.create_combo_entry(3, 4, _("Genre"))
        self.date_entry = self.create_combo_entry(4, 5, _("Date"))

        main_align.add(self.main_table)

        # Update song
        if song:
            self.update_song(song)

        save_button = Button(_("Save"))
        save_button.connect("clicked", self.save_taginfo)
        block_box = gtk.EventBox()
        block_box.set_visible_window(False)
        block_box.set_size_request(90, -1)
        button_box = gtk.HBox()
        button_box.pack_start(create_right_align(), True, True)
        button_box.pack_start(save_button, False, False)
        button_box.pack_start(block_box, False, False)
        self.pack_start(main_align, False, True)
        self.pack_start(button_box, False, False)
Example #10
0
    def __init__(self):
        DialogBox.__init__(self,
                           _("Task Manager"),
                           350,
                           450,
                           DIALOG_MASK_SINGLE_PAGE,
                           modal=False,
                           close_callback=self.hide_all)

        self.is_changed = False
        scrolled_window = ScrolledWindow(0, 0)
        scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)

        scrolled_align = gtk.Alignment()
        scrolled_align.set(1, 1, 1, 1)
        scrolled_align.set_padding(10, 0, 0, 0)
        scrolled_align.add(scrolled_window)

        self.jobs_view = JobsView()
        self.jobs_view.draw_mask = self.get_mask_func(self.jobs_view)
        scrolled_window.add_child(self.jobs_view)

        pause_button = Button(_("Pause"))
        pause_button.connect("clicked", self.pause_job)
        stop_button = Button(_("Close"))
        stop_button.connect("clicked", lambda w: self.hide_all())

        self.body_box.add(scrolled_align)
        self.right_button_box.set_buttons([pause_button, stop_button])

        Dispatcher.connect("transfor-job", self.add_new_job)
 def create_lyrics_dir_table(self):    
     main_table = gtk.Table(3, 2)
     main_table.set_row_spacings(CONTENT_ROW_SPACING)
     
     dir_title_label = Label(_("Lyrics directory"))
     dir_title_label.set_size_request(200, 12)
     label_align = gtk.Alignment()
     label_align.set_padding(0, 0, 0, 0)
     label_align.add(dir_title_label)
     
     self.dir_entry = InputEntry()
     self.dir_entry.set_text(os.path.expanduser(config.get("lyrics", "save_lrc_path", "~/.lyrics")))
     self.dir_entry.set_editable(False)        
     self.dir_entry.set_size(250, 25)
     
     modify_button = Button(_("Change"))
     modify_button.connect("clicked", self.change_lyrics_save_dir)
     hbox = gtk.HBox(spacing=5)
     hbox.pack_start(self.dir_entry, False, False)
     hbox.pack_start(modify_button, False, False)
     
     main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
     main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
     main_table.attach(hbox, 0, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)
     return main_table
Example #12
0
    def __init__(self, monitor_dir):

        gtk.VBox.__init__(self)
        self.set_spacing(10)
        self.select_view = SelectView(monitor_dir,
                                      filter_dir=["deepin-wallpapers"],
                                      add_system=False)
        self.select_view.connect("items-change", self.select_view_item_changed)
        self.select_view.connect("double-click-item",
                                 self.select_view_double_clicked)
        self.select_view_sw = self.select_view.get_scrolled_window()

        label_box = gtk.VBox()
        no_favorites_label = Label(_("Your Favorites folder is empty."))
        align_up = get_align(align=(0.5, 0.5, 0, 0))
        align_up.add(no_favorites_label)
        go_to_local_action = ActionButton(
            _("Add from Local Pictures"),
            lambda: event_manager.emit("switch-to-local-pictures", self))
        align_down = get_align(align=(0.5, 0.5, 0, 0))
        align_down.add(go_to_local_action)

        label_box.pack_start(align_up, False, False)
        label_box.pack_start(align_down, False, False)
        self.no_favorites_align = gtk.Alignment(0.5, 0.5, 0, 0)
        self.no_favorites_align.add(label_box)

        self.notice_label = Label("")

        set_wallpapper_button = Button(_("Set as wallpaper"))
        set_wallpapper_button.connect("clicked", self.__on_set_as_wallpapper)

        delete_button = Button(_("Delete"))
        delete_button.connect("clicked", self.__on_delete)

        self.button_box = gtk.HBox(spacing=10)
        self.button_box.pack_start(set_wallpapper_button, False, False)
        self.button_box.pack_start(delete_button, False, False)

        self.control_box = gtk.HBox()
        self.control_box.set_size_request(-1, 20)
        self.control_box.pack_start(self.notice_label, False, False)

        self.control_align = gtk.Alignment()
        self.control_align.set(0.5, 0.5, 1, 1)
        self.control_align.set_padding(0, 5, 20, 10)
        self.control_align.add(self.control_box)

        if len(self.select_view.items) == 0:
            self.pack_start(self.no_favorites_align, True, True)
        else:
            self.pack_start(self.select_view_sw, True, True)
        self.pack_end(self.control_align, False, True)

        event_manager.add_callback("select-select-wallpaper",
                                   self.__on_select_select_wallpaper)

        self.timeout_notice_hide_id = None
    def __init__(self):
        super(PreferenceDialog, self).__init__(_("Preferences"), 575, 495, 
                                               mask_type=DIALOG_MASK_MULTIPLE_PAGE,
                                               close_callback=self.hide_all)
        
        self.set_position(gtk.WIN_POS_CENTER)
        
        self.main_box = gtk.VBox()
        close_button = Button(_("Close"))
        close_button.connect("clicked", lambda w: self.hide_all())
        
        # Init widget.
        self.general_setting = GeneralSetting()
        self.hotkey_setting = HotKeySetting()
        self.desktop_lyrics_setting = DesktopLyricsSetting()
        self.scroll_lyrics_setting = ScrollLyricsSetting()
        self.plugins_manager = PluginsManager()
        
        # Category bar
        self.category_bar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
        self.category_bar.set_expand_column(0)
        self.category_bar.draw_mask = self.draw_treeview_mask
        self.category_bar.set_size_request(132, 516)
        self.category_bar.connect("single-click-item", self.on_categorybar_single_click)

        # Init catagory bar.
        self.__init_category_bar()
        
        category_box = gtk.VBox()
        background_box = BackgroundBox()
        background_box.set_size_request(132, 11)
        background_box.draw_mask = self.draw_treeview_mask
        category_box.pack_start(background_box, False, False)
        
        category_bar_align = gtk.Alignment()
        category_bar_align.set(0, 0, 1, 1,)
        category_bar_align.set_padding(0, 1, 0, 0)
        category_bar_align.add(self.category_bar)
        category_box.pack_start(category_bar_align, True, True)
        
        # Pack widget.
        left_box = gtk.VBox()
        self.right_box = gtk.VBox()
        left_box.add(category_box)
        self.right_box.add(self.general_setting)
        right_align = gtk.Alignment()
        right_align.set_padding(0, 0, 10, 0)
        right_align.add(self.right_box)

        body_box = gtk.HBox()
        body_box.pack_start(left_box, False, False)
        body_box.pack_start(right_align, False, False)
        self.main_box.add(body_box)
        
        # DialogBox code.
        self.body_box.pack_start(self.main_box, True, True)
        self.right_button_box.set_buttons([close_button])        
Example #14
0
 def __init__(self):
     DialogBox.__init__(
         self, _("Lyrics search"), 460, 300, DIALOG_MASK_MULTIPLE_PAGE, close_callback=self.hide_all, 
         modal=False, window_hint=None, skip_taskbar_hint=False, window_pos=gtk.WIN_POS_CENTER)
     
     self.artist_entry = InputEntry()
     self.artist_entry.set_size(130, 23)
     self.title_entry = InputEntry()
     self.title_entry.set_size(130, 23)
     artist_label = Label(_("Artist:"))
     title_label = Label(_("Title:"))
     right_align = gtk.Alignment()
     right_align.set(0, 0, 0, 1)
     
     self.search_button = Button(_("Search"))
     self.search_button.connect("clicked", self.search_lyric_cb)
     self.process_id = 0
     
     info_box = gtk.HBox(spacing=25)
     
     control_box = gtk.HBox(spacing=5)
     title_box = gtk.HBox(spacing=5)        
     title_box.pack_start(title_label, False, False)
     title_box.pack_start(self.title_entry)
     artist_box = gtk.HBox(spacing=5)
     artist_box.pack_start(artist_label, False, False)
     artist_box.pack_start(self.artist_entry)
     control_box.pack_start(title_box, False, False)
     control_box.pack_start(artist_box, False, False)
     
     info_box.pack_start(control_box, False, False)
     info_box.pack_start(self.search_button, False, False)
     
     sort_items = [ lambda items, reverse : self.sort_by_key(items, reverse, "title"),
                    lambda items, reverse : self.sort_by_key(items, reverse, "artist")]
     self.result_view = TreeView()
     self.result_view.set_expand_column(0)
     self.result_view.connect("double-click-item", self.double_click_cb)
     self.result_view.set_column_titles([_("Title"), _("Artist")], sort_items)
     self.result_view.draw_mask = self.draw_view_mask
     
     self.prompt_label = Label("")
     download_button = Button(_("Download"))
     download_button.connect("clicked", self.download_lyric_cb)
     cancel_button = Button(_("Close"))
     cancel_button.connect("clicked", lambda w: self.hide_all())
     
     info_box_align = gtk.Alignment()
     info_box_align.set_padding(5, 0, 5, 0)
     info_box_align.add(info_box)
     
     self.body_box.set_spacing(5)
     self.body_box.pack_start(info_box_align, False, False)
     self.body_box.pack_start(self.result_view, True, True)
     self.left_button_box.set_buttons([self.prompt_label])
     self.right_button_box.set_buttons([download_button, cancel_button])
     self.lrc_manager = LrcManager()
class SongSearchUI(DialogBox):
    
    def __init__(self):
        DialogBox.__init__(self, _("Search"), 460, 300, DIALOG_MASK_SINGLE_PAGE,
                           modal=False, window_hint=None, close_callback=self.hide_all)
        title_label = Label(_("Title:"))
        self.title_entry = TextEntry("")
        self.title_entry.set_size(300, 25)
        self.search_button = Button(_("Search"))
        self.search_button.connect("clicked", self.search_song)
        
        control_box = gtk.HBox(spacing=5)
        control_box.pack_start(title_label, False, False)
        control_box.pack_start(self.title_entry, False, False)
        control_box.pack_start(self.search_button, False, False)
        
        scrolled_window = ScrolledWindow(0, 0)
        scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.result_view = ListView()
        self.result_view.connect("double-click-item", self.double_click_cb)
        self.result_view.draw_mask = self.get_mask_func(self.result_view)
        self.result_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Type"), _("Size")])
        scrolled_window.add_child(self.result_view)
        
        self.prompt_label = Label("")
        download_button = Button(_("Download"))
        download_button.connect("clicked", self.download_song)
        cancel_button = Button(_("Close"))
        cancel_button.connect("clicked", lambda w: self.hide_all())
        
        self.body_box.set_spacing(5)
        self.body_box.pack_start(control_box, False, False)
        self.body_box.pack_start(scrolled_window, True, True)
        self.left_button_box.set_buttons([self.prompt_label])
        self.right_button_box.set_buttons([download_button, cancel_button])
        
    def search_song(self, widget):    
        self.result_view.clear()
        title = self.title_entry.entry.get_text()
        if not title.strip():
            return 
        self.prompt_label.set_text(_("Now searching"))        
        # widget.set_sensitive(False)
        utils.ThreadRun(multi_ways_query_song, self.render_song_infos, [title]).start()
        
    @post_gui    
    def render_song_infos(self, song_infos):
        if song_infos:
            try:
                items = [QueryInfoItem(song_info) for song_info in song_infos]
            except Exception, e:    
                print e
            else:    
                self.result_view.add_items(items)
        self.prompt_label.set_text(_("Finish!"))        
 def create_output_box(self):
     output_label = Label("%s:" % _("Output"))
     self.output_entry = InputEntry(os.path.expanduser("~/"))
     self.output_entry.set_size(210, 24)
     change_button = Button(_("Change"))
     change_button.connect("clicked", self.set_output_directory)
     output_box = gtk.HBox(spacing=5)
     output_box.pack_start(output_label, False, False)
     output_box.pack_start(self.output_entry, False, False)
     output_box.pack_start(change_button, False, False)
     return output_box
Example #17
0
 def create_output_box(self):
     output_label = Label("%s:" % _("Output"))
     self.output_entry = InputEntry(os.path.expanduser("~/"))
     self.output_entry.set_size(210, 24)
     change_button = Button(_("Change"))
     change_button.connect("clicked", self.set_output_directory)
     output_box = gtk.HBox(spacing=5)
     output_box.pack_start(output_label, False, False)
     output_box.pack_start(self.output_entry, False, False)
     output_box.pack_start(change_button, False, False)
     return output_box
    def add_button(self, add_button):
        container_remove_all(self.buttons_align.get_children()[0])

        self.__setup_reset_button()
        button = Button(add_button)
        button.set_size_request(self.button_width, WIDGET_HEIGHT)
        button.connect("clicked", self.__add_button_clicked, add_button)
        self.buttons_list = []
        self.buttons_list.append(button)
        self.buttons_list.append(self.reset_button)
        self.buttons_align = self.__setup_buttons_align(self.buttons_list)        
        self.right_box.pack_start(self.buttons_align)
    def add_button(self, add_button):
        container_remove_all(self.buttons_align.get_children()[0])

        self.__setup_reset_button()
        button = Button(add_button)
        button.set_size_request(self.button_width, WIDGET_HEIGHT)
        button.connect("clicked", self.__add_button_clicked, add_button)
        self.buttons_list = []
        self.buttons_list.append(button)
        self.buttons_list.append(self.reset_button)
        self.buttons_align = self.__setup_buttons_align(self.buttons_list)
        self.right_box.pack_start(self.buttons_align)
    def __init__(self, monitor_dir):

        gtk.VBox.__init__(self)
        self.set_spacing(10)
        self.select_view = SelectView(monitor_dir, filter_dir=["deepin-wallpapers"], add_system=False)
        self.select_view.connect("items-change", self.select_view_item_changed)
        self.select_view.connect("double-click-item", self.select_view_double_clicked)
        self.select_view_sw = self.select_view.get_scrolled_window()

        label_box = gtk.VBox()
        no_favorites_label = Label(_("Your Favorites folder is empty."))
        align_up = get_align(align=(0.5, 0.5, 0, 0))
        align_up.add(no_favorites_label)
        go_to_local_action = ActionButton(_("Add from Local Pictures"), lambda: event_manager.emit("switch-to-local-pictures", self))
        align_down = get_align(align=(0.5, 0.5, 0, 0))
        align_down.add(go_to_local_action)

        label_box.pack_start(align_up, False, False)
        label_box.pack_start(align_down, False, False)
        self.no_favorites_align = gtk.Alignment(0.5, 0.5, 0, 0)
        self.no_favorites_align.add(label_box)

        self.notice_label = Label("")

        set_wallpapper_button = Button(_("Set as wallpaper"))
        set_wallpapper_button.connect("clicked", self.__on_set_as_wallpapper)

        delete_button = Button(_("Delete"))
        delete_button.connect("clicked", self.__on_delete)

        self.button_box = gtk.HBox(spacing=10)
        self.button_box.pack_start(set_wallpapper_button, False, False)
        self.button_box.pack_start(delete_button, False, False)
                                                                                   
        self.control_box = gtk.HBox()
        self.control_box.set_size_request(-1, 20)
        self.control_box.pack_start(self.notice_label, False, False)
                                                                                
        self.control_align = gtk.Alignment()
        self.control_align.set(0.5, 0.5, 1, 1)
        self.control_align.set_padding(0, 5, 20, 10)
        self.control_align.add(self.control_box)

        if len(self.select_view.items) == 0:
            self.pack_start(self.no_favorites_align, True, True)
        else:
            self.pack_start(self.select_view_sw, True, True)
        self.pack_end(self.control_align, False, True)
  
        event_manager.add_callback("select-select-wallpaper", self.__on_select_select_wallpaper)

        self.timeout_notice_hide_id = None
def process_unmodifier_key(tmp_accel_buf):
    dialog = DialogBox(" ", 550, 150)
    dialog.window_frame.connect("expose-event", draw_widget_background)
    dialog.set_keep_above(True)
    dialog.set_modal(True)
    dialog.body_align.set_padding(15, 10, 10, 10)
    label1 = Label(_("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.")% tmp_accel_buf.get_accel_label(), enable_select=False, enable_double_click=False)
    label2 = Label(_("Please try with a key such as Control, Alt or Shift at the same time."), enable_select=False, enable_double_click=False)
    dialog.body_box.pack_start(label1)
    dialog.body_box.pack_start(label2)
    button = Button(_("Cancel"))
    button.connect("clicked", lambda b: dialog.destroy())
    dialog.right_button_box.set_buttons([button])
    dialog.show_all()
Example #22
0
 def create_location_box(self):
     location_align = gtk.Alignment()
     location_align.set(1.0, 1.0, 0.5, 0.5)
     location_box = gtk.HBox(spacing=5)
     location_label = Label("%s" % _("Location"))
     self.location_entry = InputEntry("")
     self.location_entry.set_size(250, 25)
     open_button = Button(_("Open directory"))
     open_button.connect("clicked", self.open_song_location)
     location_box.pack_start(location_label, False, True)
     location_box.pack_start(self.location_entry, False, True)
     location_box.pack_start(open_button, False, True)
     location_align.add(location_box)
     return location_align
 def create_location_box(self):
     location_align = gtk.Alignment()
     location_align.set(1.0, 1.0, 0.5, 0.5)
     location_box = gtk.HBox(spacing=5)
     location_label = Label(_("Location:"))
     self.location_entry = InputEntry("")
     self.location_entry.set_size(250, 25)
     open_button = Button(_("Open directory"))
     open_button.connect("clicked", self.open_song_location)
     location_box.pack_start(location_label, False, True)
     location_box.pack_start(self.location_entry, False, True)
     location_box.pack_start(open_button, False, True)
     location_align.add(location_box)
     return location_align
class BluetoothProgressDialog(DialogBox):
    DIALOG_MASK_SINGLE_PAGE = 0

    def __init__(self, default_width=300, default_height=160, cancel_cb=None):
        DialogBox.__init__(self, "", default_width, default_height, self.DIALOG_MASK_SINGLE_PAGE)

        self.cancel_cb = cancel_cb

        self.message_align = gtk.Alignment()
        self.message_align.set(0, 0, 0, 0)
        self.message_align.set_padding(0, 0, 10, 0)
        self.message_label = Label("", label_width=300)
        self.message_align.add(self.message_label)
        self.progress_align = gtk.Alignment()
        self.progress_align.set(0, 0, 0, 0)
        self.progress_align.set_padding(20, 0, 10, 10)
        self.progress_bar = ProgressBar()
        self.progress_bar.set_size_request(default_width, -1)
        self.progress_align.add(self.progress_bar)
        self.percentage_align = gtk.Alignment()
        self.percentage_align.set(0, 0, 0, 0)
        self.percentage_align.set_padding(10, 0, 140, 0)
        self.percentage_label = Label("0%", label_width=300)
        self.percentage_label.set_size_request(default_width, -1)
        self.percentage_align.add(self.percentage_label)
        self.cancel_align = gtk.Alignment()
        self.cancel_align.set(0, 0, 0, 0)
        self.cancel_align.set_padding(20, 0, 200, 0)
        self.cancel_button = Button(_("Cancel"))
        self.cancel_button.set_size_request(70, WIDGET_HEIGHT)
        self.cancel_button.connect("clicked", self.__on_cancel_button_clicked)
        self.cancel_align.add(self.cancel_button)

        self.body_box.pack_start(self.message_align, False, False)
        self.body_box.pack_start(self.progress_align, False, False)
        self.body_box.pack_start(self.percentage_align, False, False)
        self.body_box.pack_start(self.cancel_align)

    def set_message(self, message):
        self.message_label.set_text(message)

    def set_progress(self, progress):
        self.progress_bar.set_progress(progress)
        self.percentage_label.set_text(_("Sent %d") % progress + "%")

    def __on_cancel_button_clicked(self, widget):
        if self.cancel_cb:
            self.cancel_cb()
            self.destroy()
class AgentDialog(DialogBox):
    def __init__(self,
                 title,
                 message,
                 default_width=400,
                 default_height=220,
                 confirm_callback=None,
                 cancel_callback=None,
                 confirm_button_text="Yes",
                 cancel_button_text="No"):
        DialogBox.__init__(self, "", default_width, default_height, DIALOG_MASK_SINGLE_PAGE)
        self.confirm_callback = confirm_callback
        self.cancel_callback = cancel_callback

        self.title_align = gtk.Alignment()
        self.title_align.set(0, 0, 0, 0)
        self.title_align.set_padding(0, 0, FRAME_LEFT_PADDING, 8)
        self.title_label = Label(title, wrap_width=300)

        self.label_align = gtk.Alignment()
        self.label_align.set(0.5, 0.5, 0, 0)
        self.label_align.set_padding(0, 0, 8, 8)
        self.label = Label(message, text_x_align=ALIGN_MIDDLE, text_size=55)

        self.confirm_button = Button(confirm_button_text)
        self.cancel_button = Button(cancel_button_text)

        self.confirm_button.connect("clicked", lambda w: self.click_confirm_button())
        self.cancel_button.connect("clicked", lambda w: self.click_cancel_button())

        self.body_box.pack_start(self.title_align, False, False)
        self.title_align.add(self.title_label)
        self.body_box.pack_start(self.label_align, True, True)
        self.label_align.add(self.label)

        self.right_button_box.set_buttons([self.cancel_button, self.confirm_button])

    def click_confirm_button(self):
        if self.confirm_callback != None:
            self.confirm_callback()

        self.destroy()

    def click_cancel_button(self):
        if self.cancel_callback != None:
            self.cancel_callback()

        self.destroy()
class CachePage(gtk.VBox):
    def __init__(self, network_interface):
        gtk.VBox.__init__(self)

        self.theme = None

        self.set_spacing(10)

        self.cache_view = CacheView(network_interface, download_dir=get_download_wallpaper_dir())
        self.cache_view_sw = self.cache_view.get_scrolled_window()

        self.nolink_image = ImageBox(app_theme.get_pixbuf("individuation/notlink.png"))

        self.back_button = Button(_("Back"))
        self.back_button.connect("clicked", self.__on_back)
        download_button = Button(_("Download All"))
        download_button.connect("clicked", self.on_download_button_clicked)

        control_box = gtk.HBox(spacing=10)
        control_box.pack_start(self.back_button, False, False)

        self.control_align = gtk.Alignment()
        self.control_align.set(1.0, 0.5, 0, 0)
        self.control_align.set_padding(0, 5, 0, 10)
        self.control_align.add(control_box)

        self.pack_start(self.cache_view_sw, True, True)
        self.pack_start(self.control_align, False, True)

        event_manager.add_callback("fetch-failed", self.__fetch_failed)

    def __fetch_failed(self, name, obj, data):
        self.cache_view_sw.set_size_request(0, 0)
        self.nolink_align = gtk.Alignment()
        self.nolink_align.set(0, 0, 0, 0)
        self.nolink_align.set_padding(0, 0, 160, 0)
        self.nolink_align.add(self.nolink_image)
        self.pack_start(self.nolink_align)
        self.control_align.set_child_visible(False)

    def set_theme(self, theme):
        self.theme = theme

    def __on_back(self, widget):
        event_manager.emit("back-to-detailpage", self.theme)

    def on_download_button_clicked(self, widget):
        self.cache_view.emit_download()
    def __init_widget(self):
        self.manual_table = TableAsm()

        self.manual_radio = self.__row_check(
            _("Manual"), self.manual_table, None)
        self.http_entry, self.http_spin = self.__row_entry_spin(
            _("Http Proxy"), self.manual_table, "http")
        self.https_entry, self.https_spin = self.__row_entry_spin(
            _("Https Proxy"), self.manual_table, "https")
        self.ftp_entry, self.ftp_spin = self.__row_entry_spin(
            _("FTP Proxy"), self.manual_table, "ftp")
        self.socks_entry, self.socks_spin = self.__row_entry_spin(
            _("Socks Proxy"), self.manual_table, "socks")

        self.auto_table = TableAsm(
            left_width=STANDARD_LINE, right_width=self.ENTRY_WIDTH)
        self.auto_radio = self.__row_check(
            _("Automatic"), self.auto_table, self.manual_radio)
        self.conf_entry = self.auto_table.row_input_entry(
            _("Configuration url"))

        auto_align = gtk.Alignment(0, 0, 0, 0)
        auto_align.add(self.auto_table)

        table_box = gtk.VBox(spacing=15)
        table_box.pack_start(self.manual_table, False, False)
        table_box.pack_start(auto_align, False, False)

        align = gtk.Alignment(0, 0, 0, 0)
        align.set_padding(35, 0, 0, 0)
        align.add(table_box)
        self.pack_start(align)

        apply_button = Button(_("Apply"))
        apply_button.connect("clicked", self.save_changes)
        foot_box = FootBox()
        align.connect("expose-event", self.expose_line)
        foot_box.set_buttons([apply_button])
        self.pack_end(foot_box, False, False)
        #self.connect("expose-event", self.expose_event)

        self.manual_radio.connect("toggled", self.manual_radio_selected_cb)
        self.auto_radio.connect("toggled", self.auto_radio_selected_cb)
        self.manual_table.table_build()
        self.auto_table.table_build()
    def __init_widget(self):
        self.manual_table = TableAsm()

        self.manual_radio = self.__row_check(_("Manual"), self.manual_table,
                                             None)
        self.http_entry, self.http_spin = self.__row_entry_spin(
            _("Http Proxy"), self.manual_table, "http")
        self.https_entry, self.https_spin = self.__row_entry_spin(
            _("Https Proxy"), self.manual_table, "https")
        self.ftp_entry, self.ftp_spin = self.__row_entry_spin(
            _("FTP Proxy"), self.manual_table, "ftp")
        self.socks_entry, self.socks_spin = self.__row_entry_spin(
            _("Socks Proxy"), self.manual_table, "socks")

        self.auto_table = TableAsm(left_width=STANDARD_LINE,
                                   right_width=self.ENTRY_WIDTH)
        self.auto_radio = self.__row_check(_("Automatic"), self.auto_table,
                                           self.manual_radio)
        self.conf_entry = self.auto_table.row_input_entry(
            _("Configuration url"))

        auto_align = gtk.Alignment(0, 0, 0, 0)
        auto_align.add(self.auto_table)

        table_box = gtk.VBox(spacing=15)
        table_box.pack_start(self.manual_table, False, False)
        table_box.pack_start(auto_align, False, False)

        align = gtk.Alignment(0, 0, 0, 0)
        align.set_padding(35, 0, 0, 0)
        align.add(table_box)
        self.pack_start(align)

        apply_button = Button(_("Apply"))
        apply_button.connect("clicked", self.save_changes)
        foot_box = FootBox()
        align.connect("expose-event", self.expose_line)
        foot_box.set_buttons([apply_button])
        self.pack_end(foot_box, False, False)
        #self.connect("expose-event", self.expose_event)

        self.manual_radio.connect("toggled", self.manual_radio_selected_cb)
        self.auto_radio.connect("toggled", self.auto_radio_selected_cb)
        self.manual_table.table_build()
        self.auto_table.table_build()
def resolve_accel_entry_conflict(origin_entry, conflict_entry, tmp_accel_buf):
    dialog = DialogBox(" ", 620, 150)
    dialog.window_frame.connect("expose-event", draw_widget_background)
    dialog.set_keep_above(True)
    dialog.set_modal(True)
    dialog.body_align.set_padding(15, 10, 10, 10)
    label1 = Label(_("The shortcut \"%s\" is already used for \"%s\"")%
                   (tmp_accel_buf.get_accel_label(), conflict_entry.settings_description), enable_select=False, enable_double_click=False)
    label2 = Label(_("If you reassign the shortcut to \"%s\", the \"%s\" shortcut will be disabled.")%
                   (origin_entry.settings_description, conflict_entry.settings_description), enable_select=False, enable_double_click=False)
    dialog.body_box.pack_start(label1)
    dialog.body_box.pack_start(label2)
    button_reassign = Button(_("Reassign"))
    button_cancel = Button(_("Cancel"))
    button_cancel.connect("clicked", lambda b: origin_entry.reassign_cancel(dialog))
    button_reassign.connect("clicked", lambda b: origin_entry.reassign(tmp_accel_buf, conflict_entry, dialog))
    dialog.right_button_box.set_buttons([button_cancel, button_reassign])
    dialog.show_all()
 def __init__(self, songs=None):
     DialogBox.__init__(self, _("Converter"), 385, 200, DIALOG_MASK_SINGLE_PAGE,
                        modal=True)
     
     self.songs = songs or [Player.song]
     default_format = "MP3 (CBR)"
     default_index = FORMATS.keys().index(default_format)
     format_box, self.format_combo_box = self.create_combo_widget(_("Format"),
                                                             [(key, None) for key in FORMATS.keys()],
                                                             default_index)
     quality_box, self.quality_combo_box = self.create_combo_widget(_("Quality"),
                                                                    self.get_quality_items(default_format),
                                                                    self.get_quality_index(default_format),
                                                                    65)
     format_quality_box = gtk.HBox(spacing=68)
     format_quality_box.pack_start(format_box, False, False)
     format_quality_box.pack_start(quality_box, False, False)
     
     exists_box, self.exists_combo_box = self.create_combo_widget(_("Target file already exists"),
                                                             [(_("Ask"), True), (_("Cover"), False)],
                                                             0)
     
     start_button = Button(_("Start"))
     close_button = Button(_("Close"))
     self.add_check_button = CheckButton(_("Add to Playlist after finished"), padding_x=2)
     
     main_table = gtk.Table()
     main_table.set_row_spacings(10)
     main_table.attach(format_quality_box, 0, 2, 0, 1, yoptions=gtk.FILL)
     main_table.attach(set_widget_left(exists_box), 0, 2, 1, 2, yoptions=gtk.FILL)
     main_table.attach(self.create_output_box(), 0, 2, 2, 3, yoptions=gtk.FILL)
     main_table.attach(set_widget_left(self.add_check_button), 0, 2, 3, 4, yoptions=gtk.FILL)
     
     main_align = gtk.Alignment()
     main_align.set_padding(10, 10, 15, 10)
     main_align.add(main_table)
     
     # Connect signals.
     self.format_combo_box.connect("item-selected", self.reset_quality_items)
     start_button.connect("clicked", self.add_and_close)
     close_button.connect("clicked", lambda w: self.destroy())
     
     self.body_box.pack_start(main_align, False, True)
     self.right_button_box.set_buttons([start_button, close_button])
Example #31
0
 def __init__(self, songs=None):
     DialogBox.__init__(self, _("Convert"), 385, 200, DIALOG_MASK_SINGLE_PAGE,
                        modal=True)
     
     self.songs = songs or [Player.song]
     default_format = "MP3 (CBR)"
     default_index = FORMATS.keys().index(default_format)
     format_box, self.format_combo_box = self.create_combo_widget(_("Format"),
                                                             [(key, None) for key in FORMATS.keys()],
                                                             default_index)
     quality_box, self.quality_combo_box = self.create_combo_widget(_("Quality"),
                                                                    self.get_quality_items(default_format),
                                                                    self.get_quality_index(default_format),
                                                                    65)
     format_quality_box = gtk.HBox(spacing=68)
     format_quality_box.pack_start(format_box, False, False)
     format_quality_box.pack_start(quality_box, False, False)
     
     exists_box, self.exists_combo_box = self.create_combo_widget(_("Target file already exists"),
                                                             [(_("Ask"), True), (_("Cover"), False)],
                                                             0)
     
     start_button = Button(_("Start"))
     close_button = Button(_("Close"))
     self.add_check_button = CheckButton(_("Add to Playlist when finished"), padding_x=2)
     
     main_table = gtk.Table()
     main_table.set_row_spacings(10)
     main_table.attach(format_quality_box, 0, 2, 0, 1, yoptions=gtk.FILL)
     main_table.attach(set_widget_left(exists_box), 0, 2, 1, 2, yoptions=gtk.FILL)
     main_table.attach(self.create_output_box(), 0, 2, 2, 3, yoptions=gtk.FILL)
     main_table.attach(set_widget_left(self.add_check_button), 0, 2, 3, 4, yoptions=gtk.FILL)
     
     main_align = gtk.Alignment()
     main_align.set_padding(10, 10, 15, 10)
     main_align.add(main_table)
     
     # Connect signals.
     self.format_combo_box.connect("item-selected", self.reset_quality_items)
     start_button.connect("clicked", self.add_and_close)
     close_button.connect("clicked", lambda w: self.destroy())
     
     self.body_box.pack_start(main_align, False, True)
     self.right_button_box.set_buttons([start_button, close_button])
class Sections(gtk.Alignment):
    def __init__(self, connection, set_button, settings_obj=None):
        gtk.Alignment.__init__(self, 0, 0, 0, 0)
        self.connection = connection
        self.set_button = set_button
        # 新增settings_obj变量,用于访问shared_methods.Settings对象
        self.settings_obj = settings_obj

        self.set_padding(35, 0, 20, 0)

        self.main_box = gtk.VBox()
        self.tab_name = "sfds"
        basic = SettingSection(_("Basic"))

        self.button = Button(_("Advanced"))
        self.button.connect("clicked", self.show_more_options)
        self.wired = SettingSection(_("Wired"), always_show=False)
        align = gtk.Alignment(0, 0, 0, 0)
        align.set_padding(0, 0, 376, 0)
        align.set_size_request(-1, 30)
        align.add(self.button)

        basic.load([
            PPTPConf(connection, set_button, settings_obj=self.settings_obj),
            align
        ])

        self.main_box.pack_start(basic, False, False)

        self.add(self.main_box)

    def show_more_options(self, widget):
        widget.destroy()
        self.ipv4 = SettingSection(_("IPv4 settings"), always_show=True)
        self.ipv4.load([
            IPV4Conf(self.connection,
                     self.set_button,
                     settings_obj=self.settings_obj)
        ])
        ppp = SettingSection(_("PPP settings"), always_show=True)
        ppp.load([PPPConf(settings_obj=self.settings_obj)])
        Dispatcher.emit("vpn-type-change", self.connection)
        self.main_box.pack_start(self.ipv4, False, False, 15)
        self.main_box.pack_start(ppp, False, False)
    def __init__(self):
        gtk.VBox.__init__(self)
        self.open_dialog = False
        self.tmp_editing_session = None

        # UI style
        style.draw_background_color(self)
        self.tree = TreeView(
            [],
            enable_drag_drop=False,
            enable_hover=True,
            enable_multiple_select=False,
        )
        self.tree.set_expand_column(3)
        self.tree.set_column_titles(
            (_("Active"), _("Application"), _("Description"), _("Exec")), )

        self.tree.set_size_request(800, -1)
        self.tree.connect("right-press-items", self.right_press_item)

        self.tree.draw_mask = self.draw_mask
        self.tree.add_items(self.get_list())
        align = gtk.Alignment(0, 0, 0, 1)
        align.set_padding(15, 0, 20, 20)
        align.add(self.tree)
        align.connect("expose-event", self.expose_line)

        add_button = Button(_("New"))
        self.delete_button = Button(_("Delete"))
        add_button.connect("clicked", self.add_autostart)
        self.delete_button.connect("clicked", self.delete_autostart)
        self.delete_button.set_sensitive(False)

        foot_box = FootBox(adjustment=15)
        foot_box.set_buttons([add_button, self.delete_button])
        self.pack_start(align, True, True)

        self.pack_end(foot_box, False, False)
        #self.pack_end(self.new_box, False, False)

        self.show_all()

        self._init_monitor()
class WaitingDialog(DialogBox):

    def __init__(self, title, info_message, cancel_callback=None):
        DialogBox.__init__(self, 
                title, 
                mask_type=DIALOG_MASK_SINGLE_PAGE, 
                close_callback=self.dialog_close_action)
        self.set_size_request(-1, -1)
        self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        self.loading_widget = Loading() 
        loading_widget_align = gtk.Alignment()
        loading_widget_align.set(0.5, 0.5, 0, 0)
        loading_widget_align.set_padding(padding_top=0, padding_bottom=0, padding_left=0, padding_right=8)
        loading_widget_align.add(self.loading_widget)

        self.info_message_label = Label(info_message, enable_select=False, wrap_width=200, text_size=10)
        info_message_align = gtk.Alignment()
        info_message_align.set(0.5, 0.5, 0, 0)
        info_message_align.add(self.info_message_label)

        outer_align = gtk.Alignment()
        outer_align.set(0.5, 0.5, 0, 0)
        outer_align.set_padding(padding_top=10, padding_bottom=10, padding_left=25, padding_right=25)

        outer_hbox = gtk.HBox()
        outer_hbox.pack_start(loading_widget_align, False, False)
        outer_hbox.pack_start(info_message_align, False, False)
        outer_align.add(outer_hbox)

        self.close_button = Button(_("Cancel"))
        if cancel_callback:
            self.close_button.connect("clicked", cancel_callback)
        else:
            self.close_button.connect("clicked", lambda w: self.hide_all())

        self.body_box.pack_start(outer_align, False, False)
        self.right_button_box.set_buttons([self.close_button])

    def dialog_close_action(self):
        self.hide_all()
    def __init__(self):
        gtk.VBox.__init__(self)
        self.open_dialog = False
        self.tmp_editing_session = None
        
        # UI style
        style.draw_background_color(self)
        self.tree = TreeView([],enable_drag_drop=False,
                             enable_hover=True,
                             enable_multiple_select=False,
                             )
        self.tree.set_expand_column(3)
        self.tree.set_column_titles((_("Active"), _("Application"), _("Description"), _("Exec")),)

        self.tree.set_size_request(800, -1)
        self.tree.connect("right-press-items", self.right_press_item)

        self.tree.draw_mask = self.draw_mask
        self.tree.add_items(self.get_list())
        align = gtk.Alignment(0, 0, 0, 1)
        align.set_padding(15, 0, 20, 20)
        align.add(self.tree)
        align.connect("expose-event", self.expose_line)


        add_button = Button(_("New"))
        self.delete_button = Button(_("Delete"))
        add_button.connect("clicked", self.add_autostart)
        self.delete_button.connect("clicked", self.delete_autostart)
        self.delete_button.set_sensitive(False)
        
        foot_box = FootBox(adjustment=15)
        foot_box.set_buttons([add_button, self.delete_button])
        self.pack_start(align, True, True)
        
        self.pack_end(foot_box, False, False)
        #self.pack_end(self.new_box, False, False)

        self.show_all()

        self._init_monitor()
Example #36
0
def process_unmodifier_key(tmp_accel_buf):
    dialog = DialogBox(" ", 550, 150)
    dialog.window_frame.connect("expose-event", draw_widget_background)
    dialog.set_keep_above(True)
    dialog.set_modal(True)
    dialog.body_align.set_padding(15, 10, 10, 10)
    label1 = Label(_(
        "The shortcut \"%s\" cannot be used because it will become impossible to type using this key."
    ) % tmp_accel_buf.get_accel_label(),
                   enable_select=False,
                   enable_double_click=False)
    label2 = Label(_(
        "Please try with a key such as Control, Alt or Shift at the same time."
    ),
                   enable_select=False,
                   enable_double_click=False)
    dialog.body_box.pack_start(label1)
    dialog.body_box.pack_start(label2)
    button = Button(_("Cancel"))
    button.connect("clicked", lambda b: dialog.destroy())
    dialog.right_button_box.set_buttons([button])
    dialog.show_all()
class Sections(gtk.Alignment):

    def __init__(self, connection, set_button, settings_obj=None):
        gtk.Alignment.__init__(self, 0, 0 ,1, 0)
        self.set_padding(35, 0, 20, 0)
        self.connection = connection
        self.set_button = set_button
        # 新增settings_obj变量,用于访问shared_methods.Settings对象
        self.settings_obj = settings_obj

        self.main_box = gtk.VBox()
        basic = SettingSection(_("Basic"))

        self.button = Button(_("Advanced"))
        #self.button.set_size_request(50, 22)
        self.button.connect("clicked", self.show_more_options)
        align = gtk.Alignment(0, 1.0, 0, 0)
        align.set_padding(0, 0, 376, 0)
        align.set_size_request(-1 ,30)
        align.add(self.button)
        
        basic.load([DSLConf(connection, set_button, settings_obj=self.settings_obj), align])

        self.main_box.pack_start(basic, False, False)

        self.add(self.main_box)

    def show_more_options(self, widget):
        widget.destroy()
        wired = SettingSection(_("Wired"), always_show=True)
        ipv4 = SettingSection(_("IPv4 settings"), always_show=True)
        ppp = SettingSection(_("PPP"), always_show=True)
        wired.load([Wired(self.connection, self.set_button, settings_obj=self.settings_obj)])
        ipv4.load([IPV4Conf(self.connection, self.set_button, settings_obj=self.settings_obj)])
        ppp.load([PPPConf(self.connection, self.set_button, settings_obj=self.settings_obj)])
        #self.main_box.pack_start(self.space, False, False)
        self.main_box.pack_start(wired, False, False, 15)
        self.main_box.pack_start(ipv4, False, False)
        self.main_box.pack_start(ppp, False, False, 15)
Example #38
0
    def create_download_dir_table(self):
        main_table = gtk.Table(4, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        dir_title_label = Label(_("Download settings"))
        dir_title_label.set_size_request(200, 12)
        label_align = gtk.Alignment()
        label_align.set_padding(0, 0, 0, 0)
        label_align.add(dir_title_label)

        download_number_label = Label(_('Maximum number of download tasks: '))
        self.download_number_comobox = ComboBox(
                items = [(str(i+1), i+1) for i in range(10)],
                select_index = int(get_download_number())-1,
                )
        self.download_number_comobox.connect("item-selected", self.download_number_comobox_changed)
        download_number_hbox = gtk.HBox(spacing=5)
        download_number_hbox.pack_start(download_number_label, False, False)
        download_number_hbox.pack_start(self.download_number_comobox, False, False)

        change_download_dir_label = Label(_("Download directory: "))
        self.dir_entry = InputEntry()
        self.dir_entry.set_text(get_software_download_dir())
        self.dir_entry.set_editable(False)
        self.dir_entry.set_size(200, 25)

        modify_button = Button(_("Change"))
        modify_button.connect("clicked", self.change_download_save_dir)
        download_dir_hbox = gtk.HBox(spacing=5)
        download_dir_hbox.pack_start(change_download_dir_label, False, False)
        download_dir_hbox.pack_start(self.dir_entry, False, False)
        download_dir_hbox.pack_start(modify_button, False, False)

        main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(download_number_hbox, 0, 2, 2, 3, xoptions=gtk.FILL)
        main_table.attach(download_dir_hbox, 0, 2, 3, 4, xoptions=gtk.FILL)
        return main_table
class Sections(gtk.Alignment):

    def __init__(self, connection, set_button, settings_obj=None):
        gtk.Alignment.__init__(self, 0, 0 ,0, 0)
        self.connection = connection
        self.set_button = set_button
        # 新增settings_obj变量,用于访问shared_methods.Settings对象
        self.settings_obj = settings_obj

        self.set_padding(35, 0, 20, 0)

        self.main_box = gtk.VBox()
        self.tab_name = "sfds"
        basic = SettingSection(_("Basic"))

        self.button = Button(_("Advanced"))
        self.button.connect("clicked", self.show_more_options)
        self.wired = SettingSection(_("Wired"), always_show=False)
        align = gtk.Alignment(0, 0, 0, 0)
        align.set_padding(0, 0, 376, 0)
        align.set_size_request(-1 , 30)
        align.add(self.button)
        
        basic.load([PPTPConf(connection, set_button, settings_obj=self.settings_obj), align])

        self.main_box.pack_start(basic, False, False)

        self.add(self.main_box)

    def show_more_options(self, widget):
        widget.destroy()
        self.ipv4 = SettingSection(_("IPv4 settings"), always_show=True)
        self.ipv4.load([IPV4Conf(self.connection, self.set_button, settings_obj=self.settings_obj)])
        ppp = SettingSection(_("PPP settings"), always_show=True)
        ppp.load([PPPConf(settings_obj=self.settings_obj)])
        Dispatcher.emit("vpn-type-change", self.connection)
        self.main_box.pack_start(self.ipv4, False, False, 15)
        self.main_box.pack_start(ppp, False, False)
class ConvTAskGui(DialogBox):
    def __init__(self):
        DialogBox.__init__(self, 
                           _("Task Manager for format conversion"), 
                           FORM_WIDTH, FORM_HEIGHT, 
                           mask_type=DIALOG_MASK_SINGLE_PAGE, #DIALOG_MASK_MULTIPLE_PAGE,
                           close_callback=self.hide_all,
                           modal=True,
                           window_hint=gtk.gdk.WINDOW_TYPE_HINT_DIALOG,
                           window_pos=gtk.WIN_POS_CENTER,
                           resizable=False,
                           )
        self.init_widgets()
        # add widgets.
        self.body_box.pack_start(self.scrolled_window, False, False)
        
        
    def init_widgets(self):
        
        self.scrolled_window = ScrolledWindow()
        self.list_view = ListView()                
        self.list_view.draw_mask = self.get_mask_func(self.list_view)
        self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.scrolled_window.add_child(self.list_view)
        
        # self.start_btn = Button(_("Start"))
        self.show_time_label = Label("")
        self.pause_btn = Button(_("Pause"))
        self.close_btn = Button(_("Close"))
        
        self.show_time_label_align = gtk.Alignment()
        self.show_time_label_align.set(0.0, 0.5, 1.0, 1.0)
        self.show_time_label_align.add(self.show_time_label)
                        
        self.left_button_box.set_buttons([self.show_time_label_align])
        self.right_button_box.set_buttons([self.pause_btn, self.close_btn])        
                
        self.close_btn.connect("clicked", lambda w : self.hide_all())
Example #41
0
    def create_download_dir_table(self):
        main_table = gtk.Table(4, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        dir_title_label = Label(_("Download settings"))
        dir_title_label.set_size_request(200, 12)
        label_align = gtk.Alignment()
        label_align.set_padding(0, 0, 0, 0)
        label_align.add(dir_title_label)

        download_number_label = Label(_('Maximum number of download tasks: '))
        self.download_number_comobox = ComboBox(
                items = [(str(i+1), i+1) for i in range(10)],
                select_index = int(get_download_number())-1,
                )
        self.download_number_comobox.connect("item-selected", self.download_number_comobox_changed)
        download_number_hbox = gtk.HBox(spacing=5)
        download_number_hbox.pack_start(download_number_label, False, False)
        download_number_hbox.pack_start(self.download_number_comobox, False, False)

        change_download_dir_label = Label(_("Download directory: "))
        self.dir_entry = InputEntry()
        self.dir_entry.set_text(get_software_download_dir())
        self.dir_entry.set_editable(False)
        self.dir_entry.set_size(200, 25)

        modify_button = Button(_("Change"))
        modify_button.connect("clicked", self.change_download_save_dir)
        download_dir_hbox = gtk.HBox(spacing=5)
        download_dir_hbox.pack_start(change_download_dir_label, False, False)
        download_dir_hbox.pack_start(self.dir_entry, False, False)
        download_dir_hbox.pack_start(modify_button, False, False)

        main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(download_number_hbox, 0, 2, 2, 3, xoptions=gtk.FILL)
        main_table.attach(download_dir_hbox, 0, 2, 3, 4, xoptions=gtk.FILL)
        return main_table
Example #42
0
class Sections(gtk.Alignment):

    def __init__(self, connection, set_button, settings_obj=None):
        gtk.Alignment.__init__(self, 0, 0 ,0, 0)
        self.set_padding(35, 0, 20, 0)

        self.main_box = gtk.VBox()
        self.tab_name = "sfds"
        basic = SettingSection(_("Basic"))

        self.button = Button(_("Advanced"))
        self.button.set_size_request(50, 22)
        self.button.connect("clicked", self.show_more_options)
        self.broadband = SettingSection(_("Broadband"), always_show=True)
        self.ipv4 = SettingSection(_("IPv4 settings"), always_show=True)
        self.ppp = SettingSection(_("PPP"), always_show=True)
        align = gtk.Alignment(0, 0, 0, 0)
        align.set_padding(0, 0, 225, 0)
        align.add(self.button)
        
        self.broadband = Broadband(connection, set_button, settings_obj)
        basic.load([self.broadband, align])
        self.ipv4.load([IPV4Conf(connection, set_button, settings_obj=settings_obj)])
        self.ppp.load([PPPConf(connection, set_button, settings_obj)])

        self.space = gtk.HBox()
        self.space.set_size_request(-1 ,30)

        self.main_box.pack_start(basic, False, False)

        self.add(self.main_box)

    def show_more_options(self, widget):
        widget.destroy()
        #self.main_box.pack_start(self.space, False, False)
        self.main_box.pack_start(self.ipv4, False, False)
        self.main_box.pack_start(self.ppp, False, False, 15)
 def __init__(self, song=None):
     super(CoverSetting, self).__init__()
     
     cover_box = gtk.VBox()
     cover_image_align =  gtk.Alignment()
     cover_image_align.set(0.5, 0.5, 0.5, 0.5)
     self.cover_image = gtk.Image()
     self.cover_image.set_size_request(300, 180)
     
     
     cover_image_align.add(self.cover_image)
     cover_box.add(cover_image_align)
     cover_box.set_size_request(400, 220)
     
     cover_box_align = gtk.Alignment()
     cover_box_align.set_padding(20, 20, 10, 10)
     cover_box_align.set(0.5, 0.5, 0.5, 0.5)
     cover_box_align.add(cover_box)
     
     button_box = gtk.HBox(spacing=10)
     button_box_align = gtk.Alignment()
     button_box_align.set_padding(0, 0, 0, 30)
     button_box_align.set(0, 0, 1.0, 1.0)
     button_box_align.add(button_box)
     change_button = Button(_("Change"))
     change_button.connect("clicked", self.change_cover_image)
     delete_button = Button(_("Default"))
     delete_button.connect("clicked", self.delete_cover_image)
     button_box.pack_start(create_right_align(), True, True)
     button_box.pack_start(change_button, False, False)
     button_box.pack_start(delete_button, False, False)
     
     self.pack_start(cover_box_align, False, True)
     self.pack_start(button_box_align, False, True)
     
     if song:
         self.update_song(song)
    def __init__(self, connection, set_button, settings_obj=None):
        gtk.Alignment.__init__(self, 0, 0 ,0, 0)
        self.set_padding(35, 0, 20, 0)
        self.connection = connection
        self.set_button = set_button
        # 新增settings_obj变量,用于访问shared_methods.Settings对象
        self.settings_obj = settings_obj
        
        if isinstance(connection, NMRemoteConnection):
            net_manager.set_primary_wire(settings_obj.device, connection)

        self.main_box = gtk.VBox()

        basic = SettingSection(_("Wired"), always_show=True)
        button = Button(_("Advanced"))
        button.connect("clicked", self.show_more_options)

        align = gtk.Alignment(0, 0, 0, 0)
        align.set_padding(0, 0, 285, 0)
        align.add(button)

        basic.load([Wired(self.connection, self.set_button, settings_obj), align])
        self.main_box.pack_start(basic, False, False)
        self.add(self.main_box)
class OpenUrlDialog(DialogBox):
    def __init__(self):
        DialogBox.__init__(self, _("Open Url"),
                mask_type=DIALOG_MASK_MULTIPLE_PAGE,
                window_pos=gtk.WIN_POS_CENTER
                )
        self.hbox_ali = gtk.Alignment(0, 0, 1, 1)
        self.hbox_ali.set_padding(5, 5, 5, 5)
        self.hbox = gtk.HBox()
        self.hbox_ali.add(self.hbox)
        self.url_text = InputEntry()
        self.ok_btn = Button(_("Ok"))
        self.cancel_btn = Button(_("Cancel"))
        self.url_text.set_size(280, 25)
        self.hbox.pack_start(self.url_text, True, True)
        #self.hbox.pack_start(self.ok_btn, True, True, 5)
        self.right_button_box.set_buttons([self.ok_btn, self.cancel_btn])
        #
        self.body_box.pack_start(self.hbox_ali, True, True)
        #
        self.cancel_btn.connect("clicked", self.__cancel_btn_clicked_event)

    def __cancel_btn_clicked_event(self, widget):
        self.destroy()
Example #46
0
    def __init__(self, songs, init_index=0):
        super(SongEditor, self).__init__(_("Properties"),
                                         500,
                                         400,
                                         mask_type=DIALOG_MASK_TAB_PAGE)
        self.set_position(gtk.WIN_POS_CENTER)

        close_button = Button(_("Close"))
        close_button.connect("clicked", self.click_close_button)

        previous_button = Button(_("Previous"))
        previous_button.connect("clicked",
                                lambda w: self.update_previous_song())
        next_button = Button(_("Next"))
        next_button.connect("clicked", lambda w: self.update_next_song())

        self.record_label = Label("0/0")

        action_box = gtk.HBox(spacing=5)
        action_box.pack_start(previous_button, False, False)
        action_box.pack_start(self.record_label, False, False)
        action_box.pack_start(next_button, False, False)

        MediaDB.connect("simple-changed", self.db_simple_changed)

        # action_box.
        if len(songs) <= 1:
            action_box.set_no_show_all(True)
        else:
            self.record_label.set_text("%d/%d" % (init_index + 1, len(songs)))

        # tabs
        self.song_info = SongInfo(songs[init_index])
        self.info_setting = InfoSetting(songs[init_index])
        self.cover_setting = CoverSetting(songs[init_index])

        self.tab_box = TabBox()
        self.tab_box.add_items([(_("Track Infomation"), self.song_info),
                                (_("Tag Settings"), self.info_setting),
                                (_("Cover Settings"), self.cover_setting)])

        # DialogBox code, simple, ah? :)
        self.left_button_box.set_buttons([action_box])
        self.right_button_box.set_buttons([close_button])
        self.body_box.pack_start(self.tab_box, True, True)

        # Constants.
        self.current_index = init_index
        self.songs = songs
Example #47
0
 def __init__(self, song=None):
     super(CoverSetting, self).__init__()
     
     cover_box = gtk.VBox()
     cover_image_align =  gtk.Alignment()
     cover_image_align.set(0.5, 0.5, 0.5, 0.5)
     self.cover_image = gtk.Image()
     self.cover_image.set_size_request(300, 180)
     
     
     cover_image_align.add(self.cover_image)
     cover_box.add(cover_image_align)
     cover_box.set_size_request(400, 220)
     
     cover_box_align = gtk.Alignment()
     cover_box_align.set_padding(20, 20, 10, 10)
     cover_box_align.set(0.5, 0.5, 0.5, 0.5)
     cover_box_align.add(cover_box)
     
     button_box = gtk.HBox(spacing=10)
     button_box_align = gtk.Alignment()
     button_box_align.set_padding(0, 0, 0, 30)
     button_box_align.set(0, 0, 1.0, 1.0)
     button_box_align.add(button_box)
     change_button = Button(_("Change"))
     change_button.connect("clicked", self.change_cover_image)
     
     fetch_button = Button(_("Retrieve from the Internet"))
     fetch_button.connect("clicked", self.fetch_cover_image)
     
     delete_button = Button(_("Reset"))
     delete_button.connect("clicked", self.delete_cover_image)
     button_box.pack_start(create_right_align(), True, True)
     button_box.pack_start(change_button, False, False)
     button_box.pack_start(delete_button, False, False)
     button_box.pack_start(fetch_button, False, False)        
     
     self.pack_start(cover_box_align, False, True)
     self.pack_start(button_box_align, False, True)
     
     if song:
         self.update_song(song)
Example #48
0
class ConfirmDialog(DialogBox):
    '''
    Simple message confirm dialog.

    @undocumented: click_confirm_button
    @undocumented: click_cancel_button
    '''
    def __init__(
        self,
        title,
        message,
        default_width=330,
        default_height=145,
        confirm_callback=None,
        cancel_callback=None,
        cancel_first=True,
        message_text_size=9,
    ):
        '''
        Initialize ConfirmDialog class.

        @param title: Title for confirm dialog.
        @param message: Confirm message.
        @param default_width: Dialog width, default is 330 pixel.
        @param default_height: Dialog height, default is 145 pixel.
        @param confirm_callback: Callback when user click confirm button.
        @param cancel_callback: Callback when user click cancel button.
        @param cancel_first: Set as True if to make cancel button before confirm button, default is True.
        @param message_text_size: Text size of message, default is 11.
        '''
        # Init.
        DialogBox.__init__(self,
                           title,
                           default_width,
                           default_height,
                           DIALOG_MASK_SINGLE_PAGE,
                           close_callback=self.hide)
        self.confirm_callback = confirm_callback
        self.cancel_callback = cancel_callback

        self.label_align = gtk.Alignment()
        self.label_align.set(0.5, 0.5, 0, 0)
        self.label_align.set_padding(0, 0, 8, 8)
        self.label = Label(message,
                           text_x_align=ALIGN_MIDDLE,
                           text_size=message_text_size)

        self.confirm_button = Button(_("OK"))
        self.cancel_button = Button(_("Cancel"))

        self.confirm_button.connect("clicked",
                                    lambda w: self.click_confirm_button())
        self.cancel_button.connect("clicked",
                                   lambda w: self.click_cancel_button())

        # Connect widgets.
        self.body_box.pack_start(self.label_align, True, True)
        self.label_align.add(self.label)

        if cancel_first:
            self.right_button_box.set_buttons(
                [self.cancel_button, self.confirm_button])
        else:
            self.right_button_box.set_buttons(
                [self.confirm_button, self.cancel_button])

    def click_confirm_button(self):
        '''
        Internal function to handle click confirm button.
        '''
        if self.confirm_callback != None:
            self.confirm_callback()

        self.hide()

    def click_cancel_button(self):
        '''
        Internal function to handle click cancel button.
        '''
        if self.cancel_callback != None:
            self.cancel_callback()

        self.hide()
class FootBox(gtk.HBox):
    '''
    class docs
    '''
    def __init__(self):
        '''
        init docs
        '''
        gtk.HBox.__init__(self)

        self.button_width = 80

        self.module_id = None

        self.buttons_list = []
        self.__setup_reset_button()
        self.buttons_list.append(self.reset_button)

        self.__is_init_ui = False

    def __setup_reset_button(self):
        self.reset_button = Button(_("Reset"))
        #self.reset_button.set_size_request(self.button_width, WIDGET_HEIGHT)
        self.reset_button.connect("clicked", self.__reset_button_clicked)

    def __setup_buttons_align(self, list):
        buttons_align = self.__setup_align(
            padding_top=7,
            padding_left=80 - (len(list) - 1) * 10,
            padding_right=TEXT_WINDOW_RIGHT_WIDGET_PADDING)
        buttons_box = gtk.HBox(spacing=5)
        i = 0
        while i < len(list):
            buttons_box.pack_start(list[i], False, False)
            i += 1

        buttons_align.add(buttons_box)

        return buttons_align

    def __init_ui(self):
        self.status_label = self.__setup_label("")
        self.right_box = gtk.VBox()
        self.buttons_align = self.__setup_buttons_align(self.buttons_list)
        self.right_box.pack_start(self.buttons_align)

        self.pack_start(self.status_label)
        self.pack_end(self.right_box, False, False)
        self.set_size_request(-1, STATUS_HEIGHT)

        self.connect("expose-event", self.__expose)

        self.__is_init_ui = True

    def __handle_dbus_reply(*reply):
        pass

    def __handle_dbus_error(*error):
        pass

    def __add_button_clicked(self, widget, argv):
        bus = dbus.SessionBus()
        module_dbus_name = "com.deepin.%s_settings" % (self.module_id)
        module_object_name = "/com/deepin/%s_settings" % (self.module_id)
        if is_dbus_name_exists(module_dbus_name):
            bus_object = bus.get_object(module_dbus_name, module_object_name)
            method = bus_object.get_dbus_method("message_receiver")
            method("add_button_cb",
                   argv,
                   reply_handler=self.__handle_dbus_reply,
                   error_handler=self.__handle_dbus_error)

    def __reset_button_clicked(self, widget):
        bus = dbus.SessionBus()
        module_dbus_name = "com.deepin.%s_settings" % (self.module_id)
        module_object_name = "/com/deepin/%s_settings" % (self.module_id)
        if is_dbus_name_exists(module_dbus_name):
            bus_object = bus.get_object(module_dbus_name, module_object_name)
            method = bus_object.get_dbus_method("message_receiver")
            method("reset",
                   "",
                   reply_handler=self.__handle_dbus_reply,
                   error_handler=self.__handle_dbus_error)

    def hide(self):
        self.hide_all()

    def show(self, module_id):
        self.module_id = module_id

        if not self.__is_init_ui:
            self.__init_ui()

        self.show_all()

    def hide_reset(self):
        self.reset_button.set_child_visible(False)

    def show_reset(self):
        self.reset_button.set_child_visible(True)

    def add_button(self, add_button):
        container_remove_all(self.buttons_align.get_children()[0])

        self.__setup_reset_button()
        button = Button(add_button)
        button.set_size_request(self.button_width, WIDGET_HEIGHT)
        button.connect("clicked", self.__add_button_clicked, add_button)
        self.buttons_list = []
        self.buttons_list.append(button)
        self.buttons_list.append(self.reset_button)
        self.buttons_align = self.__setup_buttons_align(self.buttons_list)
        self.right_box.pack_start(self.buttons_align)

    def hide_status(self):
        self.status_label.set_text("")

    def set_status(self, status):
        self.status_label.set_text(status)
        gobject.timeout_add(3000, self.hide_status)

    def __expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
        draw_line(cr, rect.x, rect.y + 1, rect.x + rect.width, rect.y + 1)

    def __setup_align(self,
                      xalign=0,
                      yalign=0,
                      xscale=0,
                      yscale=0,
                      padding_top=0,
                      padding_bottom=0,
                      padding_left=FRAME_LEFT_PADDING,
                      padding_right=0):
        align = gtk.Alignment()
        align.set(xalign, yalign, xscale, yscale)
        align.set_padding(padding_top, padding_bottom, padding_left,
                          padding_right)
        return align

    def __setup_label(self,
                      text="",
                      text_size=CONTENT_FONT_SIZE,
                      label_width=600):
        label = Label(
            text=text,
            text_size=text_size,
            text_x_align=ALIGN_MIDDLE,
            label_width=label_width,
            enable_select=False,
        )
        return label
Example #50
0
class DetailPage(gtk.VBox):
    '''
    class docs
    '''
    def __init__(self):
        '''
        init docs
        '''
        gtk.VBox.__init__(self)

        self.__background_settings = deepin_gsettings.new(
            "com.deepin.dde.background")

        self.draw_title_background = self.draw_tab_title_background
        self.theme = None

        self.wallpaper_box = gtk.VBox()
        self.window_theme_box = gtk.VBox()
        self.wallpaper_view = WallpaperView(padding_x=30,
                                            padding_y=ITEM_PADDING_Y)
        self.wallpaper_view_sw = self.wallpaper_view.get_scrolled_window()
        self.wallpaper_view_sw.set_size_request(-1, 426)

        position_group, self.position_combobox = get_combo_group(
            _("Position"), DRAW_COMBO_ITEM, self.on_position_combox_selected)
        time_group, self.time_combobox = get_combo_group(
            _("Duration"), TIME_COMBO_ITEM, self.on_time_combox_selected)

        self.__is_random = True
        if self.__background_settings.get_int("background-duration") == 0:
            self.__is_random = False
        self.unorder_play, self.random_toggle = get_toggle_group(
            _("Random"), self.__on_random_toggled, self.__is_random)
        self.button_align = gtk.Alignment()
        self.button_box = gtk.HBox(spacing=5)
        self.select_all_button = Button(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)
        self.select_all_button.connect("clicked", self.__on_select_all)
        self.delete_button = Button(_("Delete"))
        self.delete_button.set_size_request(80, WIDGET_HEIGHT)
        self.delete_button.connect("clicked", self.__on_delete)
        self.button_box.pack_start(self.select_all_button, False, False)
        self.button_box.pack_start(self.delete_button, False, False)
        self.button_align.add(self.button_box)

        self.action_bar = gtk.HBox(spacing=26)
        self.action_bar.pack_start(position_group, False, False)
        self.action_bar.pack_start(time_group, False, False)
        self.action_bar.pack_start(self.unorder_play, False, False)
        self.action_bar.pack_end(self.button_align, False, False)
        action_bar_align = gtk.Alignment()
        action_bar_align.set_size_request(-1, STATUS_HEIGHT)
        action_bar_align.set_padding(5, 5, 50, 20)
        action_bar_align.add(self.action_bar)

        self.wallpaper_box.pack_start(self.wallpaper_view_sw, True, True)
        self.wallpaper_box.pack_start(action_bar_align, False, False)

        self.pack_start(self.wallpaper_box, False, False)

        event_manager.add_callback("select-wallpaper",
                                   self.on_wallpaper_select)
        event_manager.add_callback("apply-wallpaper",
                                   self.__on_wallpaper_apply)
        event_manager.add_callback("add-wallpapers", self.__on_add_wallpapers)

    def __random_enable(self):
        self.time_combobox.set_sensitive(True)
        self.unorder_play.set_child_visible(True)
        self.random_toggle.set_child_visible(True)
        self.random_toggle.set_active(self.theme.get_background_random_mode())

    def __random_disable(self):
        self.time_combobox.set_sensitive(False)
        self.unorder_play.set_child_visible(False)
        self.random_toggle.set_child_visible(False)
        self.random_toggle.set_active(self.theme.get_background_random_mode())

    def on_wallpaper_select(self, name, obj, select_item):
        if self.wallpaper_view.is_randomable():
            self.__random_enable()
        else:
            self.__random_disable()

        if self.wallpaper_view.is_select_all():
            self.select_all_button.set_label(_("Clear all"))
        else:
            self.select_all_button.set_label(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)

    def __on_wallpaper_apply(self, name, obj, select_item):
        self.__random_disable()

        if self.wallpaper_view.is_select_all():
            self.select_all_button.set_label(_("Clear all"))
        else:
            self.select_all_button.set_label(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)

    def __on_select_all(self, widget):
        self.wallpaper_view.select_all()
        if self.wallpaper_view.is_select_all():
            self.select_all_button.set_label(_("Clear all"))
        else:
            self.select_all_button.set_label(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)

        if self.wallpaper_view.is_randomable():
            self.__random_enable()
        else:
            self.__random_disable()

    def __on_delete(self, widget):
        event_manager.emit("switch-to-deletepage", self.theme)

    def __on_random_toggled(self, widget):
        self.theme.set_background_random_mode(widget.get_active())

    def draw_tab_title_background(self, cr, widget):
        rect = widget.allocation
        cr.set_source_rgb(1, 1, 1)
        cr.rectangle(0, 0, rect.width, rect.height - 1)
        cr.fill()

    def on_position_combox_selected(self, widget, label, data, index):
        self.theme.set_background_draw_mode(data)
        self.theme.save()

    def on_time_combox_selected(self, widget, label, data, index):
        self.theme.set_background_duration(data)
        self.theme.save()

    def __set_delete_button_visible(self):
        is_editable = self.wallpaper_view.is_editable()
        if is_editable:
            self.button_align.set_padding(0, 0, 113, 5)
        else:
            self.button_align.set_padding(0, 0, 204, 5)

        self.delete_button.set_child_visible(is_editable)

    def __on_add_wallpapers(self, name, obj, image_paths):
        if len(self.wallpaper_view.items) < 2:
            self.select_all_button.set_child_visible(False)
        else:
            self.select_all_button.set_child_visible(True)
            self.select_all_button.set_label(_("Select all"))

        self.__set_delete_button_visible()

    def set_theme(self, theme):
        self.theme = theme

        draw_mode = self.theme.get_background_draw_mode()
        item_index = 0
        for index, item in enumerate(DRAW_COMBO_ITEM):
            if draw_mode == item[-1]:
                item_index = index

        self.position_combobox.set_select_index(item_index)

        duration = self.theme.get_background_duration()
        item_index = 0
        for index, item in enumerate(TIME_COMBO_ITEM):
            if duration == item[-1]:
                item_index = index

        self.time_combobox.set_select_index(item_index)
        self.wallpaper_view.set_theme(theme)

        self.__set_delete_button_visible()

        if self.wallpaper_view.is_randomable():
            self.__random_enable()
        else:
            self.__random_disable()

        if len(self.wallpaper_view.items) < 2:
            self.select_all_button.set_child_visible(False)
        else:
            self.select_all_button.set_child_visible(True)

        if self.wallpaper_view.is_select_all():
            self.select_all_button.set_label(_("Clear all"))
            self.select_all_button.set_size_request(80, WIDGET_HEIGHT)

    def draw_mask(self, cr, x, y, w, h):
        '''
        Draw mask interface.
        
        @param cr: Cairo context.
        @param x: X coordiante of draw area.
        @param y: Y coordiante of draw area.
        @param w: Width of draw area.
        @param h: Height of draw area.
        '''
        cr.set_source_rgb(1, 1, 1)
        cr.rectangle(x, y, w, h)
        cr.fill()
Example #51
0
class NewSessionDialog(DialogBox):
    '''
    Simple input dialog.
    
    @undocumented: click_confirm_button
    @undocumented: click_cancel_button
    '''
    def __init__(self,
                 default_width=350,
                 default_height=160,
                 confirm_callback=None,
                 cancel_callback=None):
        '''
        Initialize InputDialog class.
        
        @param title: Input dialog title.
        @param init_text: Initialize input text.
        @param default_width: Width of dialog, default is 330 pixel.
        @param default_height: Height of dialog, default is 330 pixel.
        @param confirm_callback: Callback when user click confirm button, this callback accept one argument that return by user input text.
        @param cancel_callback: Callback when user click cancel button, this callback not need argument.
        '''
        # Init.
        DialogBox.__init__(self, _("Autostart app"), default_width,
                           default_height, DIALOG_MASK_SINGLE_PAGE)
        self.confirm_callback = confirm_callback
        self.cancel_callback = cancel_callback
        self.on_click = None

        self.confirm_button = Button(_("OK"))
        self.cancel_button = Button(_("Cancel"))

        self.confirm_button.connect("clicked",
                                    lambda w: self.click_confirm_button())
        self.cancel_button.connect("clicked",
                                   lambda w: self.click_cancel_button())
        self.connect(
            "destroy", self._close_callback
        )  #self.close_callback is None at this moment, so we use _close_callback
        # get system pixbuf
        icon_theme = gtk.IconTheme()
        icon_theme.set_custom_theme("Deepin")
        icon_info = None
        if icon_theme:
            icon_info = icon_theme.lookup_icon("folder-open", 16,
                                               gtk.ICON_LOOKUP_NO_SVG)

        self.icon_pixbuf = None
        if icon_info:
            self.icon_pixbuf = DynamicPixbuf(icon_info.get_filename())
        else:
            self.icon_pixbuf = app_theme.get_pixbuf("navigate/none-small.png")

        table = self.add_new_box()
        self.pack(self.body_box, [table])
        self.right_button_box.set_buttons(
            [self.cancel_button, self.confirm_button])

        self.connect("show", self.focus_input)

    def set_on_click(self, func):
        self.on_click = func

    def pack(self, container, widgets, expand=False, fill=False):
        for widget in widgets:
            container.pack_start(widget, expand, fill)

    def add_new_box(self):
        table = gtk.Table()
        #hbox.set_size_request(-1, 30)
        name_label = Label(_("Name:"), enable_select=False)
        name_label.set_can_focus(False)
        exec_label = Label(_("Exec:"), enable_select=False)
        exec_label.set_can_focus(False)
        desc_label = Label(_("Comment:"), enable_select=False)
        desc_label.set_can_focus(False)

        self.name_entry = InputEntry()
        self.exec_entry = InputEntry()
        self.desc_entry = InputEntry()
        self.name_entry.set_size(200, 22)
        self.exec_entry.set_size(200, 22)
        self.desc_entry.set_size(200, 22)

        name_label_align = self.wrap_with_align(name_label)
        exec_label_align = self.wrap_with_align(exec_label)
        desc_label_align = self.wrap_with_align(desc_label)

        name_align = style.wrap_with_align(self.name_entry)
        exec_align = style.wrap_with_align(self.exec_entry)
        desc_align = style.wrap_with_align(self.desc_entry)

        table = gtk.Table(3, 4)
        self.table_add(table,
                       [name_label_align, exec_label_align, desc_label_align],
                       0)
        self.table_add(table, [name_align, exec_align, desc_align], 1)

        open_folder = ImageButton(self.icon_pixbuf, self.icon_pixbuf,
                                  self.icon_pixbuf)
        open_folder.connect(
            "clicked", lambda w: OpenFileDialog(
                "Choose file", self, ok_callback=self.ok_callback))
        table.attach(style.wrap_with_align(open_folder), 2, 3, 1, 2)

        align = gtk.Alignment(0.5, 0, 0, 0)
        style.set_table(table)
        align.add(table)
        return align

    def table_add(self, table, widget, column):
        for index, w in enumerate(widget):
            table.attach(w, column, column + 1, index, index + 1)

    def wrap_with_align(self, label):

        align = gtk.Alignment(1, 0.5, 0, 0)
        align.set_padding(0, 0, 1, 0)
        align.add(label)
        return align

    def ok_callback(self, file_name):
        self.exec_entry.set_text(file_name)

    def _close_callback(self, widget):
        self.cancel_callback()
        self.destroy()

    def focus_input(self, widget):
        '''
        Grab focus on input entry.
        
        @param widget: InputDialog widget.
        '''
        self.name_entry.entry.grab_focus()

    def click_confirm_button(self):
        '''
        Inernal fucntion to handle click confirm button.
        '''
        if self.confirm_callback != None:
            self.confirm_callback(self)

        self.destroy()

    def click_cancel_button(self):
        '''
        Inernal fucntion to handle click cancel button.
        '''
        if self.cancel_callback != None:
            self.cancel_callback()

        self.destroy()
class FootBox(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)

        self.set_size_request(-1, 35)

        self.apply_method = None
        self.init_ui()

        self.timer = Timer(3000, self.__clear_tips)

        Dispatcher.connect("button-change", self.set_button)
        Dispatcher.connect("set-tip", self.set_tip)

        event_manager.add_callback("update-delete-button",
                                   self.__on_update_delete_button)

    def __on_update_delete_button(self, name, obj, data):
        #self.btn_delete.set_child_visible(data)
        self.queue_draw()

    def expose_line(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        style.draw_out_line(cr, rect)

    def init_ui(self):
        self.tip_align = gtk.Alignment(0, 0.5, 0, 1)
        self.tip = Label("", text_x_align=pango.ALIGN_CENTER, label_width=500)
        self.tip_align.set_padding(5, 5, 20, 0)
        self.tip_align.add(self.tip)

        self.btn_delete = Button(_("Delete"))
        self.btn_delete.connect("clicked", self.delete_click)
        self.btn_delete.set_no_show_all(True)
        self.btn_save = Button()
        self.btn_save.connect("clicked", self.button_click)

        button_box = gtk.HBox(spacing=10)
        button_box.pack_start(self.btn_delete)
        button_box.pack_start(self.btn_save)

        self.buttons_align = gtk.Alignment(1, 0.5, 0, 0)
        self.buttons_align.set_padding(0, 0, 0, 10)
        self.buttons_align.add(button_box)
        self.pack(self, [self.tip_align], True, True)
        self.pack_end(self.buttons_align, False, False)

    def pack(self, parent, widgets, expand=False, fill=False):
        for widget in widgets:
            parent.pack_start(widget, expand, fill)

    def set_lock(self, state):
        self.__setting_module.set_lock(state)

    def get_lock(self):
        return self.__setting_module.get_lock()

    def set_button(self, widget, content, state):
        self.btn_save.set_label(_("Save"))
        self.btn_save.set_sensitive(state)

    def delete_click(self, widget):
        if self.focus_connection:
            Dispatcher.delete_setting(self.focus_connection)
            Dispatcher.to_main_page()

    def show_delete(self, connection):
        self.btn_delete.show()
        self.focus_connection = connection

    def hide_delete(self):
        self.btn_delete.hide()
        self.focus_connection = None

        #if content == "save":
        #if state and not self.get_lock():
        #Dispatcher.emit("setting-saved")
        #else:
        #self.btn_save.set_label(_("connect"))
        #self.btn_save.set_sensitive(False)
        #else:
        #self.btn_save.set_label(_("connect"))
        #self.btn_save.set_sensitive(True)

    def get_button(self):
        return self.__setting_module.get_button_state()

    def set_setting(self, module):
        self.__setting_module = module

    def button_click(self, widget):
        #if self.btn_save.label == "save":
        Dispatcher.emit("setting-saved")
        #elif self.btn_save.label == _("connect"):
        #Dispatcher.set_tip("setting saved")
        #Dispatcher.emit("setting-appled")

    def __clear_tips(self):
        self.tip.set_text("")

    def set_tip(self, widget, new_tip):
        self.tip.set_text(_("Tip:") + new_tip)
        self.timer.restart()
    def __init__(self, connection=None):
        gtk.Alignment.__init__(self, 0, 0, 0, 0)

        #################
        self.provider_select = None
        self.connect('expose-event', self.expose_event)
        self.prop_dict = {}

        main_table = gtk.Table(2, 2, False)
        main_table.set_row_spacing(1, 10)
        main_table.set_col_spacings(4)
        self.add(main_table)

        self.country_tree = TreeView(
            enable_multiple_select=False,
            enable_drag_drop=False,
        )
        self.country_tree.set_expand_column(1)

        self.country_tree.set_size_request(365, 380)
        self.country_tree.draw_mask = self.draw_mask
        self.country_tree.connect("button-press-item", self.country_selected)
        left_box_align = gtk.Alignment(0, 0, 0, 0)
        left_box_align.set_padding(1, 1, 1, 1)
        left_box_align.add(self.country_tree)
        left_box_align.show_all()

        left_box = gtk.VBox()
        # wrap title
        country_title = TitleBar(
            app_theme.get_pixbuf("network/globe-green.png"),
            _("Country or Region:"),
            has_separator=False)
        left_box.pack_start(country_title, False, False)
        left_box.pack_start(left_box_align, False, False)

        self.provider_tree = TreeView(
            enable_multiple_select=False,
            enable_drag_drop=False,
        )
        self.provider_tree.set_expand_column(0)
        self.provider_tree.set_size_request(365, 380)
        self.provider_tree.draw_mask = self.draw_mask
        self.provider_tree.connect("button-press-item", self.provider_selected)
        right_box_align = gtk.Alignment(0, 0, 0, 0)
        right_box_align.set_padding(1, 1, 1, 1)
        right_box_align.add(self.provider_tree)
        right_box = gtk.VBox()
        # wrap title
        provider_title = TitleBar(app_theme.get_pixbuf("network/building.png"),
                                  _("Provider:"),
                                  has_separator=False)
        right_box.pack_start(provider_title, False, False)
        right_box.pack_start(right_box_align, False, False)

        main_left_align = gtk.Alignment(0, 0, 0, 0)
        main_left_align.set_padding(15, 0, 20, 0)
        main_left_align.add(left_box)
        main_table.attach(main_left_align, 0, 1, 0, 1)
        main_right_align = gtk.Alignment(0, 0, 0, 0)
        main_right_align.set_padding(15, 0, 0, 20)
        main_right_align.add(right_box)
        main_table.attach(main_right_align, 1, 2, 0, 1)

        hints = _(
            "Tips:This assistant helps you easily set up a mobile broadband connection to a cellular network."
        )

        left_box_align.connect("expose-event", self.expose_outline)
        right_box_align.connect("expose-event", self.expose_outline)

        next_button = Button("Next")
        next_button.connect("clicked", self.next_button_clicked)

        self.foot_box = FootBox()
        self.foot_box.set_buttons([next_button])
        self.foot_box.set_tip(hints)
        main_table.attach(self.foot_box, 0, 2, 1, 2)

        self.show_all()