def show(self, keyword):
     self.treeview.delete_all_items()
     self.treeview.add_items([TextItem(key) for key in ["linux", "deepin", "word", keyword]])
     self.treeview.select_first_item()        
     # self.treeview.grab_focus()
     
     (x, y) = get_widget_root_coordinate(search_entry, WIDGET_POS_BOTTOM_LEFT, True)
     self.move(x + self.window_offset_x, y + self.window_offset_y)
     self.show_all()
Ejemplo n.º 2
0
    def show(self, search_string, pkg_names):
        search_entry.entry.entry_buffer.grab_focus_flag = True

        self.treeview.delete_all_items()
        self.treeview.add_items(map(lambda pkg_name: TextItem(pkg_name, search_string), pkg_names))
        self.treeview.draw_area.grab_focus()

        (x, y) = get_widget_root_coordinate(search_entry, WIDGET_POS_BOTTOM_LEFT, False)
        self.move(x + self.window_offset_x, y + self.window_offset_y)
        self.show_all()
Ejemplo n.º 3
0
    def show(self, search_string, pkg_names):
        search_entry.entry.entry_buffer.grab_focus_flag = True

        self.treeview.delete_all_items()
        self.treeview.add_items(
            map(lambda pkg_name: TextItem(pkg_name, search_string), pkg_names))
        self.treeview.draw_area.grab_focus()

        (x, y) = get_widget_root_coordinate(search_entry,
                                            WIDGET_POS_BOTTOM_LEFT, False)
        self.move(x + self.window_offset_x, y + self.window_offset_y)
        self.show_all()
Ejemplo n.º 4
0
 def delay_show_notify(self, item):    
     screen_width, screen_height = utils.get_screen_size()
     view_x, view_y =  self.scrolled_window.get_child().get_view_window().get_size()
     (origin_x, origin_y) = get_widget_root_coordinate(self.draw_area, WIDGET_POS_TOP_LEFT, False)
     notify_width = self.song_notify.default_width
     
     if origin_x + view_x + notify_width + self.notify_offset_x > screen_width:
         x = origin_x - notify_width - self.notify_offset_x
     else:    
         x = origin_x + view_x + self.notify_offset_x
     y = origin_y + self.get_item_offset_y(item)
     self.song_notify.update_song(item.song)
     self.song_notify.show(x, y)
Ejemplo n.º 5
0
 def delay_show_notify(self, item):    
     screen_width, screen_height = utils.get_screen_size()
     view_x, view_y =  self.scrolled_window.get_child().get_view_window().get_size()
     (origin_x, origin_y) = get_widget_root_coordinate(self.draw_area, WIDGET_POS_TOP_LEFT, False)
     notify_width = self.song_notify.default_width
     
     if origin_x + view_x + notify_width + self.notify_offset_x > screen_width:
         x = origin_x - notify_width - self.notify_offset_x
     else:    
         x = origin_x + view_x + self.notify_offset_x
     y = origin_y + self.get_item_offset_y(item)
     self.song_notify.update_song(item.song)
     self.song_notify.show(x, y)
Ejemplo n.º 6
0
 def show_predefine(self, widget):
     self.__select_name()
     menu_items = self.menu_dict.values()
     menu_items.insert(2, None)
     Menu(menu_items, True).show(get_widget_root_coordinate(widget))
 def adjust_popup_coord(self):    
     origin_x, origin_y = get_widget_root_coordinate(self.parent_widget, WIDGET_POS_TOP_RIGHT)        
     origin_y += self.item_height * self.item_index
     return origin_x, origin_y
Ejemplo n.º 8
0
 def adjust_popup_coord(self):
     origin_x, origin_y = get_widget_root_coordinate(
         self.parent_widget, WIDGET_POS_TOP_RIGHT)
     origin_y += self.item_height * self.item_index
     return origin_x, origin_y
Ejemplo n.º 9
0
 def show_predefine(self, widget):
     self.__select_name()
     menu_items = self.menu_dict.values()
     menu_items.insert(2, None)
     Menu(menu_items, True).show(get_widget_root_coordinate(widget))
Ejemplo n.º 10
0
      (None,
       "测试测试测试", None),
      (None,
       "测试测试测试", None),
      (None,
       "测试测试测试4", None, (1, 2, 3)),
      (None,
       "测试测试测试5", None),
      (None,
       "测试测试测试6", None),
      ],
     True
     )
 menu.set_menu_item_sensitive_by_index(1, False)
 application.set_menu_callback(lambda button: menu.show(
         get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT),
         (button.get_allocation().width, 0)))
 
 # Add navigatebar.
 tab_window_items = map(create_tab_window_item, ["Tab1", "Tab2", "Tab3", "Tab4", "Tab5"])
 
 droplist = Droplist(
     [("测试测试测试1", None),
      ("测试测试测试2", None),
      ("测试测试测试3", None),
      None,
      ("测试测试测试", None),
      None,
      ("测试测试测试4", None),
      ("测试测试测试5", None),
      ("测试测试测试6", None),
Ejemplo n.º 11
0
 def on_button_press(self, widget, event):
     x, y = get_widget_root_coordinate(widget, WIDGET_POS_BOTTOM_LEFT)
     self.popup_volume.show(x, y)
     volume_grab_window.popup_grab_window_focus_in()
Ejemplo n.º 12
0
 def on_button_press(self, widget, event):    
     x, y =  get_widget_root_coordinate(widget, WIDGET_POS_BOTTOM_LEFT)
     self.popup_volume.show(x, y)
     volume_grab_window.popup_grab_window_focus_in()        
Ejemplo n.º 13
0
 def adjust_event_coords(self, event):
     _, y = get_widget_root_coordinate(self, pos_type=WIDGET_POS_TOP_LEFT)
     x, _ = event.get_root_coords()
     return x, y
Ejemplo n.º 14
0
 def show_theme_menu(self, button):
     # 显示主题上菜单.
     self.title_root_menu.show(
         get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT),
         (button.get_allocation().width, 0))
Ejemplo n.º 15
0
 def adjust_event_coords(self, event):
     _, y = get_widget_root_coordinate(self, pos_type=WIDGET_POS_TOP_LEFT)
     x, _ = event.get_root_coords()
     return x, y
Ejemplo n.º 16
0
        (None, "子菜单B3", sub_menu_c),
    ])

    menu = Menu([
        (None, "测试测试测试1", None),
        (None, "测试测试测试2", sub_menu_a),
        (None, "测试测试测试3", sub_menu_b),
        (None, "测试测试测试", None),
        (None, "测试测试测试", None),
        (None, "测试测试测试4", None, (1, 2, 3)),
        (None, "测试测试测试5", None),
        (None, "测试测试测试6", None),
    ], True)
    menu.set_menu_item_sensitive_by_index(1, False)
    application.set_menu_callback(lambda button: menu.show(
        get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT),
        (button.get_allocation().width, 0)))

    # Add navigatebar.
    tab_window_items = map(create_tab_window_item,
                           ["Tab1", "Tab2", "Tab3", "Tab4", "Tab5"])

    droplist = Droplist([
        ("测试测试测试1", None),
        ("测试测试测试2", None),
        ("测试测试测试3", None),
        None,
        ("测试测试测试", None),
        None,
        ("测试测试测试4", None),
        ("测试测试测试5", None),
Ejemplo n.º 17
0
 def show_theme_menu(self, button): 
     # 显示主题上菜单.
     self.title_root_menu.show(
          get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT),
          (button.get_allocation().width, 0)) 
Ejemplo n.º 18
0
    def init_ui(self):
        self.application = Application()
        self.application.set_default_size(1000, 660)
        self.application.set_skin_preview(get_common_image("frame.png"))
        self.application.set_icon(get_common_image("logo48.png"))
        self.application.add_titlebar(
                ["theme", "menu", "max","min", "close"],
                show_title=False
                )
        self.application.window.set_title(_("Deepin Games"))

        # Init page box.
        self.page_box = gtk.VBox()
        self.page_box.connect('expose-event', self.page_box_render)
        
        # Init page align.
        self.page_align = gtk.Alignment()
        self.page_align.set(0.5, 0.5, 1, 1)
        self.page_align.set_padding(0, 0, 2, 2)
        
        # Append page to switcher.
        self.paned_box = PanedBox(24)
        self.paned_box.add_content_widget(self.page_box)
        self.bottom_tip_bar = BottomTipBar()
        self.bottom_tip_bar.close_button.connect('clicked', lambda w: self.paned_box.bottom_window.hide())
        self.paned_box.add_bottom_widget(self.bottom_tip_bar)

        self.page_align.add(self.paned_box)
        self.application.main_box.pack_start(self.page_align, True, True)
        
        # Init status bar.
        self.statusbar = Statusbar(30)
        status_box = gtk.HBox()

        self.statusbar.status_box.pack_start(status_box, True, True)
        self.application.main_box.pack_start(self.statusbar, False, False)

        self.webview = WebView(COOKIE_FILE)
        webkit.set_web_database_directory_path(CACHE_DIR)
        web_settings = self.webview.get_settings()
        web_settings.set_property("enable-page-cache", True)
        web_settings.set_property("enable-offline-web-application-cache", True)
        #web_settings.set_property("enable-file-access-from-file-uris", True)
        web_settings.set_property("enable-xss-auditor", False)
        web_settings.set_property('enable-universal-access-from-file-uris', True)
        web_settings.set_property("enable-default-context-menu", False)
        self.webview.set_settings(web_settings)
        #self.webview.enable_inspector()
        self.webview.connect('new-window-policy-decision-requested', self.navigation_policy_decision_requested_cb)
        #self.webview.connect('notify::load-status', self.webview_load_status_handler)
        self.webview.connect('notify::title', self.webview_title_changed_handler)
        self.webview.connect('script-alert', self.webview_script_alert_handler)
        self.webview.connect('window-object-cleared', self.webview_window_object_cleared)
        #self.webview.connect('load-progress-changed', self.load_progress)
        
        self.home_url = urllib.basejoin(GAME_CENTER_SERVER_ADDRESS, 'game/?hl=%s' % LANGUAGE)
        self.network_failed_box = NetworkConnectFailed(self.check_network_connection)
        self.check_network_connection()
        #self.page_box.add(self.network_failed_box)

        self.navigatebar = Navigatebar(
                [
                (None, _("Home"), self.show_home_page),
                (None, _("Topics"), self.show_subject_page),
                (None, _("My Games"), self.show_mygame_page),
                ],
                font_size = 11,
                padding_x = 5,
                padding_y = 16,
                vertical=False,
                item_normal_pixbuf=DynamicPixbuf(get_common_image('top/nav_normal.png')),
                item_hover_pixbuf=DynamicPixbuf(get_common_image('top/nav_hover.png')),
                item_press_pixbuf=DynamicPixbuf(get_common_image('top/nav_press.png')),
                )
        self.navigatebar.set_size_request(-1, 56)
        self.navigatebar_align = gtk.Alignment(0, 0, 1, 1)
        self.navigatebar_align.set_padding(0, 0, 4, 0)
        self.navigatebar_align.add(self.navigatebar)
        self.application.titlebar.set_size_request(-1, 56)
        self.application.titlebar.left_box.pack_start(self.navigatebar_align, True, True)
        self.application.window.add_move_event(self.navigatebar)

        self.about_dialog = AboutDialog(_('About us'))
        self.about_dialog.set_transient_for(self.application.window)

        # Init menu.
        #if LANGUAGE == 'en_US':
            #menu_min_width = 185
        #else:
            #menu_min_width = 150

        menu = Menu(
            [
             (None, _("Clear all cached data"), self.clean_download_cache),
             (None, _("See what's new"), lambda : self.show_wizard_win()),
             (None, _("About us"), self.show_about_dialog),
             (None, _("Quit"), lambda: gtk.main_quit()),
             ],
            is_root_menu=True,
            #menu_min_width=menu_min_width,
            )
        self.application.set_menu_callback(
            lambda button:
                menu.show(
                get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT),
                (button.get_allocation().width, 0)))
        
        self.no_favorite_html_path = os.path.join(static_dir, "error-no-favorite.html")
        self.no_recent_html_path = os.path.join(static_dir, "error-no-recent.html")
        self.mygame_frame_path = os.path.join(static_dir, "mygame-frame.html")
        self.gallery_html_path = os.path.join(static_dir, 'game-mygame.html')

        skin_config.connect('theme-changed', self.theme_changed_handler)
        global_event.register_event('show-message', self.update_message)
Ejemplo n.º 19
0
    def init_ui(self):
        self.loginfo("Init ui")
        # Init application.
        self.application = Application(
            resizable=False,
            destroy_func=self.application_close_window,
            )
        self.application.set_default_size(888, 634)
        self.application.set_skin_preview(utils.get_common_image("frame.png"))
        self.application.set_icon(utils.get_common_image("logo48.png"))
        self.application.add_titlebar(
                ["theme", "menu", "min", "close"],
                show_title=False
                )
        self.application.window.set_title(_("Deepin Store"))
        self.application.window.connect("delete-event", self.application_close_window)

        # Init page box.
        self.page_box = gtk.VBox()

        # Init page switcher.
        self.page_switcher = HSlider(200)
        self.page_switcher.append_page(self.page_box)
        self.page_switcher.set_to_page(self.page_box)

        # Init page align.
        self.page_align = gtk.Alignment()
        self.page_align.set(0.5, 0.5, 1, 1)
        self.page_align.set_padding(0, 0, 2, 2)

        # Append page to switcher.
        self.paned_box = PanedBox(24)
        self.paned_box.add_content_widget(self.page_switcher)
        self.bottom_tip_bar = BottomTipBar()
        self.bottom_tip_bar.close_button.connect('clicked', lambda w: self.paned_box.bottom_window.hide())
        self.paned_box.add_bottom_widget(self.bottom_tip_bar)
        self.page_align.add(self.paned_box)
        self.application.main_box.pack_start(self.page_align, True, True)

        # Init status bar.
        self.statusbar = Statusbar(24)
        status_box = gtk.HBox()
        self.message_box = gtk.HBox()

        self.message_label = Label("", enable_gaussian=True)
        label_align = gtk.Alignment()
        label_align.set(0.0, 0.5, 0, 0)
        label_align.set_padding(0, 0, 10, 0)
        label_align.add(self.message_label)
        self.message_box.pack_start(label_align)

        join_us_button = LinkButton(_("Join us"), "http://www.linuxdeepin.com/joinus/job")
        join_us_button_align = gtk.Alignment()
        join_us_button_align.set(0.5, 0.5, 0, 0)
        join_us_button_align.set_padding(0, 3, 0, 10)
        join_us_button_align.add(join_us_button)
        status_box.pack_start(self.message_box, True, True)
        status_box.pack_start(join_us_button_align, False, False)
        self.statusbar.status_box.pack_start(status_box, True, True)
        self.application.main_box.pack_start(self.statusbar, False, False)

        # Init navigatebar.
        self.detail_page = None
        self.home_page = None
        self.upgrade_page = None
        self.uninstall_page = None
        self.install_page = None

        self.navigatebar = Navigatebar(
                [
                (DynamicPixbuf(utils.get_common_image("navigatebar/nav_home.png")), _("Home"), self.show_home_page),
                (DynamicPixbuf(utils.get_common_image("navigatebar/nav_update.png")), _("Upgrade"), self.show_upgrade_page),
                (DynamicPixbuf(utils.get_common_image("navigatebar/nav_uninstall.png")), _("Uninstall"), self.show_uninstall_page),
                (DynamicPixbuf(utils.get_common_image("navigatebar/nav_download.png")), _("Installation"), self.show_install_page),
                ],
                font_size = 11,
                padding_x = 2,
                padding_y = 2,
                vertical=False,
                item_hover_pixbuf=DynamicPixbuf(utils.get_common_image("navigatebar/nav_hover.png")),
                item_press_pixbuf=DynamicPixbuf(utils.get_common_image("navigatebar/nav_press.png")),
                )
        self.navigatebar.set_size_request(-1, 56)
        self.navigatebar_align = gtk.Alignment(0, 0, 1, 1)
        self.navigatebar_align.set_padding(0, 0, 4, 0)
        self.navigatebar_align.add(self.navigatebar)
        self.application.titlebar.set_size_request(-1, 56)
        self.application.titlebar.left_box.pack_start(self.navigatebar_align, True, True)
        self.application.window.add_move_event(self.navigatebar)

        # Init menu.
        if LANGUAGE == 'en_US':
            menu_min_width = 185
        else:
            menu_min_width = 150
        menu = Menu(
            [
             (None, _("Refresh package lists"), lambda:global_event.emit('start-update-list')),
             (None, _("Open download directory"), self.open_download_directory),
             (None, _("Clear up cached packages"), self.clean_download_cache),
             (None, _("View new features"), lambda : self.show_wizard_win()),
             (self.get_pixbuf_group("menu", "setting"), _("Preferences"), self.show_preference_dialog),
             (self.get_pixbuf_group("menu", "close"), _("Quit"), self.exit),
             ],
            is_root_menu=True,
            menu_min_width=menu_min_width,
            )
        self.application.set_menu_callback(
            lambda button:
                menu.show(
                get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT),
                (button.get_allocation().width, 0)))

        self.preference_dialog = DscPreferenceDialog()

        if hasattr(self, 'recommend_status'):
            self.init_home_page(self.recommend_status)
        else:
            self.init_home_page()