def __signals_connect(self): ''' widget signals connect''' self.container_widgets["main_hbox"].connect("expose-event", self.container_expose_cb) # window signals self.button_widgets["right_hand_radio"].connect("toggled", self.left_or_right_set, "right") self.button_widgets["left_hand_radio"].connect("toggled", self.left_or_right_set, "left") self.settings.connect("changed", self.touchpad_setting_changed_cb) self.settings1.connect("changed", self.mouse_setting_changed_cb) # acceleration operation self.scale_widgets["pointer_speed_accel"].connect( "button-release-event", self.scalebar_value_changed, "motion-acceleration") # sensitivity operation self.scale_widgets["pointer_speed_sensitiv"].connect( "button-release-event", self.scalebar_value_changed, "motion-threshold") # double-click operation self.scale_widgets["double_click_rate"].connect( "button-release-event", self.scalebar_value_changed, "double-click") self.button_widgets["double_test"].set_data("has_double_clicked", False) self.button_widgets["double_test"].set_data("last_press_time", 0) self.button_widgets["double_test"].connect("button-press-event", self.double_click_test) self.button_widgets["double_test"].connect("expose-event", self.double_click_test_expose) self.scale_widgets["drag_threshold_time"].connect( "button-release-event", self.scalebar_value_changed, "drag-threshold") # relevant setting self.button_widgets["keyboard_setting"].connect("button-press-event", self.relevant_press, "keyboard") self.button_widgets["mouse_setting"].connect("button-press-event", self.relevant_press, "mouse") set_clickable_cursor(self.button_widgets["keyboard_setting"]) set_clickable_cursor(self.button_widgets["mouse_setting"]) self.button_widgets["set_to_default"].connect("clicked", self.set_to_default)
def __init__( self, text, callback_action=None, enable_gaussian=False, text_color=ui_theme.get_color("link_text"), ): ''' Initialize LinkButton class. @param text: Link content. @param link: Link address. @param enable_gaussian: To enable gaussian effect on link, default is True. @param text_color: Link color, just use when option enable_gaussian is False. ''' Label.__init__(self, text, text_color, enable_gaussian=enable_gaussian, text_size=9, gaussian_radious=1, border_radious=0, underline=True) self.callback_action = callback_action set_clickable_cursor(self) self.connect('button-press-event', self.button_press_action)
def query(self, keyword): results = self.__keyword_search.query(keyword) is_drawn_module_name = False ''' TODO: clear preview widgets ''' for widget in self.result_box.get_children(): self.result_box.remove(widget) if len(results) == 0: no_result_align = self.__setup_align(padding_top=45, padding_left=180) no_result_image = ImageBox( app_theme.get_pixbuf("search/noresult.png")) no_result_align.add(no_result_image) self.result_box.pack_start(no_result_align, False, False) self.show_all() return for module_keyword in self.__keywords: is_drawn_module_name = False for keyword in module_keyword[2]: if keyword[0] in results: if not is_drawn_module_name: module_name_align = self.__setup_align() module_name_box = gtk.HBox(spacing=WIDGET_SPACING) module_image = gtk.Image() module_image.set_from_pixbuf(module_keyword[3]) module_name_label = self.__setup_label( "<span foreground=\"blue\" underline=\"single\">%s</span>" % module_keyword[1], TITLE_FONT_SIZE) set_clickable_cursor(module_name_label) module_name_label.connect("button-press-event", self.__button_press, module_keyword[0]) module_name_box.pack_start(module_image, False, False) module_name_box.pack_start(module_name_label, False, False) module_name_align.add(module_name_box) self.result_box.pack_start(module_name_align, False, False) is_drawn_module_name = True module_keyword_align = self.__setup_align(padding_left=30) module_keyword_label = self.__setup_label( "<span foreground=\"blue\" underline=\"single\">%s</span>" % keyword[1]) set_clickable_cursor(module_keyword_label) module_keyword_label.connect("button-press-event", self.__button_press, module_keyword[0], keyword[0]) module_keyword_align.add(module_keyword_label) self.result_box.pack_start(module_keyword_align, False, False) ''' TODO: if remove widgets from self, it is better to show_all ''' self.show_all()
def __init__(self, text, callback_action=None, enable_gaussian=False, text_color=ui_theme.get_color("link_text"), ): Label.__init__(self, text, text_color, enable_gaussian=enable_gaussian, text_size=9, gaussian_radious=1, border_radious=0, underline=False) self.callback_action = callback_action set_clickable_cursor(self) self.connect('button-press-event', self.button_press_action)
def query(self, keyword): results = self.__keyword_search.query(keyword) is_drawn_module_name = False ''' TODO: clear preview widgets ''' for widget in self.result_box.get_children(): self.result_box.remove(widget) if len(results) == 0: no_result_align = self.__setup_align(padding_top = 45, padding_left = 180) no_result_image = ImageBox(app_theme.get_pixbuf("search/noresult.png")) no_result_align.add(no_result_image) self.result_box.pack_start(no_result_align, False, False) self.show_all() return for module_keyword in self.__keywords: is_drawn_module_name = False for keyword in module_keyword[2]: if keyword[0] in results: if not is_drawn_module_name: module_name_align = self.__setup_align() module_name_box = gtk.HBox(spacing = WIDGET_SPACING) module_image = gtk.Image() module_image.set_from_pixbuf(module_keyword[3]) module_name_label = self.__setup_label("<span foreground=\"blue\" underline=\"single\">%s</span>" % module_keyword[1], TITLE_FONT_SIZE) set_clickable_cursor(module_name_label) module_name_label.connect("button-press-event", self.__button_press, module_keyword[0]) module_name_box.pack_start(module_image, False, False) module_name_box.pack_start(module_name_label, False, False) module_name_align.add(module_name_box) self.result_box.pack_start(module_name_align, False, False) is_drawn_module_name = True module_keyword_align = self.__setup_align(padding_left = 30) module_keyword_label = self.__setup_label("<span foreground=\"blue\" underline=\"single\">%s</span>" % keyword[1]) set_clickable_cursor(module_keyword_label) module_keyword_label.connect("button-press-event", self.__button_press, module_keyword[0], keyword[0]) module_keyword_align.add(module_keyword_label) self.result_box.pack_start(module_keyword_align, False, False) ''' TODO: if remove widgets from self, it is better to show_all ''' self.show_all()
def __signals_connect(self): ''' widget signals connect''' self.container_widgets["main_hbox"].connect("expose-event", self.container_expose_cb) # window signals self.button_widgets["right_hand_radio"].connect( "toggled", self.left_or_right_set, "right") self.button_widgets["left_hand_radio"].connect("toggled", self.left_or_right_set, "left") self.settings.connect("changed", self.touchpad_setting_changed_cb) self.settings1.connect("changed", self.mouse_setting_changed_cb) # acceleration operation self.scale_widgets["pointer_speed_accel"].connect( "button-release-event", self.scalebar_value_changed, "motion-acceleration") # sensitivity operation self.scale_widgets["pointer_speed_sensitiv"].connect( "button-release-event", self.scalebar_value_changed, "motion-threshold") # double-click operation self.scale_widgets["double_click_rate"].connect( "button-release-event", self.scalebar_value_changed, "double-click") self.button_widgets["double_test"].set_data("has_double_clicked", False) self.button_widgets["double_test"].set_data("last_press_time", 0) self.button_widgets["double_test"].connect("button-press-event", self.double_click_test) self.button_widgets["double_test"].connect( "expose-event", self.double_click_test_expose) self.scale_widgets["drag_threshold_time"].connect( "button-release-event", self.scalebar_value_changed, "drag-threshold") # relevant setting self.button_widgets["keyboard_setting"].connect( "button-press-event", self.relevant_press, "keyboard") self.button_widgets["mouse_setting"].connect("button-press-event", self.relevant_press, "mouse") set_clickable_cursor(self.button_widgets["keyboard_setting"]) set_clickable_cursor(self.button_widgets["mouse_setting"]) self.button_widgets["set_to_default"].connect("clicked", self.set_to_default)
def __init__( self, text, callback_action=None, enable_gaussian=False, text_color=ui_theme.get_color("link_text"), ): Label.__init__(self, text, text_color, enable_gaussian=enable_gaussian, text_size=9, gaussian_radious=1, border_radious=0, underline=False) self.callback_action = callback_action set_clickable_cursor(self) self.connect('button-press-event', self.button_press_action)
def __init__(self, text, enable_gaussian=False, text_color=ui_theme.get_color("link_text"), ): ''' Initialize LinkButton class. @param text: Link content. @param link: Link address. @param enable_gaussian: To enable gaussian effect on link, default is True. @param text_color: Link color, just use when option enable_gaussian is False. ''' Label.__init__(self, text, text_color, enable_gaussian=enable_gaussian, text_size=9, gaussian_radious=1, border_radious=0, underline=True) self.callback_action = None set_clickable_cursor(self) self.connect('button-press-event', self.button_press_action)
def __signals_connect(self): ''' widget signals connect''' self.alignment_widgets["main_hbox"].connect("expose-event", self.container_expose_cb) # left-handed operation self.settings.connect("changed", self.settings_changed_cb) self.button_widgets["right_hand_radio"].connect("toggled", self.left_or_right_set, False) self.button_widgets["left_hand_radio"].connect("toggled", self.left_or_right_set, True) # acceleration operation self.scale_widgets["pointer_speed_accel"].connect( "button-release-event", self.scalebar_value_changed, "motion-acceleration") # sensitivity operation self.scale_widgets["pointer_speed_sensitiv"].connect( "button-release-event", self.scalebar_value_changed, "motion-threshold") # double-click operation self.scale_widgets["double_click_rate"].connect( "button-release-event", self.scalebar_value_changed, "double-click") # adjustment widget self.adjust_widgets["pointer_speed_accel"].connect("value-changed", lambda w: self.scale_widgets["pointer_speed_accel"].set_value( self.adjust_widgets["pointer_speed_accel"].get_value())) self.adjust_widgets["pointer_speed_sensitiv"].connect("value-changed", lambda w: self.scale_widgets["pointer_speed_sensitiv"].set_value( self.adjust_widgets["pointer_speed_sensitiv"].get_value())) self.adjust_widgets["double_click_rate"].connect("value-changed", lambda w: self.scale_widgets["double_click_rate"].set_value( self.adjust_widgets["double_click_rate"].get_value())) self.button_widgets["double_test"].set_data("has_double_clicked", False) self.button_widgets["double_test"].set_data("last_press_time", 0) self.button_widgets["double_test"].connect("button-press-event", self.double_click_test) self.button_widgets["double_test"].connect("expose-event", self.double_click_test_expose) # relevant setting self.button_widgets["keyboard_setting"].connect("button-press-event", self.relevant_press, "keyboard") self.button_widgets["touchpad_setting"].connect("button-press-event", self.relevant_press, "touchpad") set_clickable_cursor(self.button_widgets["keyboard_setting"]) set_clickable_cursor(self.button_widgets["touchpad_setting"]) self.button_widgets["set_to_default"].connect("clicked", self.set_to_default)
def get_user_info(self, weibo): '''get weibo user info''' info = weibo.get_user_name() gtk.gdk.threads_enter() #self.get_user_error_text = "" weibo_hbox = weibo.get_box() hbox = gtk.HBox(False) vbox = gtk.VBox(False) weibo_hbox.pack_start(vbox, False, False) vbox.pack_start(hbox) #print weibo.t_type, info if info: self.is_get_user_info[weibo] = 1 label = Label(text=info, label_width=70, enable_select=False) check = CheckButton() #check = gtk.CheckButton() check.connect("toggled", self.weibo_check_toggle, weibo) check.set_active(True) check_vbox = gtk.VBox(False) check_align = gtk.Alignment(0.5, 0.5, 0, 0) check_align.add(check_vbox) check_vbox.pack_start(check, False, False) button = ImageButton( app_theme.get_pixbuf("share/" + weibo.t_type + ".png"), app_theme.get_pixbuf("share/" + weibo.t_type + ".png"), app_theme.get_pixbuf("share/" + weibo.t_type + ".png")) utils.set_clickable_cursor(button) button.connect("enter-notify-event", self.show_tooltip, _("Click to switch user")) hbox.pack_start(check_align, False, False) hbox.pack_start(button, False, False, 5) hbox.pack_start(label, False, False) else: self.is_get_user_info[weibo] = 0 check = CheckButton() #check = gtk.CheckButton() check.set_sensitive(False) check_vbox = gtk.VBox(False) check_align = gtk.Alignment(0.5, 0.5, 0, 0) check_align.add(check_vbox) check_vbox.pack_start(check, False, False) button = ImageButton( app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"), app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"), app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png")) utils.set_clickable_cursor(button) button.connect("enter-notify-event", self.show_tooltip, _("Click to login")) hbox.pack_start(check_align, False, False) hbox.pack_start(button, False, False, 5) # curl time out info_error = weibo.get_curl_error() if info_error: #self.get_user_error_text += "%s:%s." % (weibo.t_type, _(info_error)) hbox.pack_start( Label(text="(%s)" % _(info_error), label_width=70,enable_select=False, text_color = app_theme.get_color("left_char_num1")), False, False) button.connect("clicked", self.weibo_login, weibo) self.__weibo_check_button_list.append(check) self.__weibo_image_button_list.append(button) gtk.gdk.threads_leave() return weibo_hbox
def __init__(self): ''' init docs ''' gtk.VBox.__init__(self) self.brightness_id = None self.display_manager = DisplayManager() self.__xrandr_settings = self.display_manager.get_xrandr_settings() self.__xrandr_settings.connect("changed", self.__xrandr_changed) self.resize_width = 790 self.resize_height = 200 self.monitor_items = [] self.__output_names = [] self.__current_output_name = self.display_manager.get_primary_output_name() self.__setup_monitor_items() self.sizes_items = [] self.monitor_combo = None if len(self.monitor_items) > 1 and self.display_manager.is_copy_monitors(): self.__set_same_sizes() else: self.__setup_sizes_items() self.multi_monitors_items = [(_("Copy Display"), 1), (_("Extend Display"), 2), (_("Only shown in display 1"), 3), (_("Only shown in display 2"), 4)] self.rotation_items = [(_("Normal"), 1), (_("Right"), 2), (_("Left"), 3), (_("Inverted"), 4)] self.duration_items = [("1 %s" % _("Minute"), 1), ("2 %s" % _("Minutes"), 2), ("3 %s" % _("Minutes"), 3), ("5 %s" % _("Minutes"), 5), ("10 %s" % _("Minutes"), 10), ("30 %s" % _("Minutes"), 30), ("1 %s" % _("Hour"), 60), (_("Never"), DisplayManager.BIG_NUM / 60)] ''' scrolled_window ''' self.scrolled_window = ScrolledWindow() self.scrolled_window.set_size_request(-1, 425) self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.main_box = gtk.VBox() self.main_box.set_size_request(600, -1) self.body_box = gtk.HBox() ''' left, right align ''' self.left_align = self.__setup_align(padding_top = FRAME_TOP_PADDING, padding_left = TEXT_WINDOW_LEFT_PADDING) self.right_align = self.__setup_align(padding_top = FRAME_TOP_PADDING, padding_left = 0) ''' left, right box ''' self.left_box = gtk.VBox(spacing = WIDGET_SPACING) self.right_box = gtk.VBox(spacing = WIDGET_SPACING) ''' monitor operation && detect ''' self.monitor_resize_align = self.__setup_align(padding_top = 11, padding_left = int(TEXT_WINDOW_LEFT_PADDING / 2)) self.monitor_resize_box = MonitorResizableBox(self.display_manager) self.monitor_resize_box.select_output(self.__current_output_name) self.monitor_resize_box.connect("select-output", self.__select_output) self.monitor_resize_box.connect("resize", self.__resize_box) self.monitor_resize_align.add(self.monitor_resize_box) ''' monitor display ''' self.monitor_display_align = self.__setup_title_align( app_theme.get_pixbuf("display/monitor_display.png"), _("Display"), 0) ''' monitor ''' self.monitor_align = self.__setup_align() self.monitor_box = gtk.HBox(spacing = WIDGET_SPACING) self.monitor_label = self.__setup_label(_("Monitor")) self.monitor_combo = self.__setup_combo(self.monitor_items) self.monitor_combo.set_select_index(self.display_manager.get_primary_output_name_index(self.monitor_items)) self.monitor_combo.connect("item-selected", self.__combo_item_selected, "monitor_combo") self.__widget_pack_start(self.monitor_box, [self.monitor_label, self.monitor_combo]) self.monitor_align.add(self.monitor_box) ''' goto individuation or power setting ''' self.goto_align = self.__setup_align() self.goto_box = gtk.VBox(spacing = WIDGET_SPACING) self.goto_label = self.__setup_label(_("Relevant Settings"), text_size = TITLE_FONT_SIZE, width = None, align = ALIGN_START) goto_color = GOTO_FG_COLOR self.goto_individuation_label = self.__setup_label( text = _("<span foreground=\"%s\" underline=\"single\">Personalization</span>") % goto_color, width = None, align = ALIGN_START) self.goto_individuation_label.connect("button-press-event", self.__button_press, "individuation") set_clickable_cursor(self.goto_individuation_label) self.goto_power_label = self.__setup_label( text = _("<span foreground=\"%s\" underline=\"single\">Power</span>") % goto_color, width = None, align = ALIGN_START) self.goto_power_label.connect("button-press-event", self.__button_press, "power") set_clickable_cursor(self.goto_power_label) self.__widget_pack_start(self.goto_box, [self.goto_label, self.goto_individuation_label, self.goto_power_label ]) self.goto_align.add(self.goto_box) ''' sizes ''' self.sizes_align = self.__setup_align() self.sizes_box = gtk.HBox(spacing = WIDGET_SPACING) self.sizes_label = self.__setup_label(_("Resolution")) self.sizes_combo = self.__setup_combo(self.sizes_items) if self.sizes_combo: self.sizes_combo.set_select_index( self.display_manager.get_screen_size_index(self.__current_output_name, self.sizes_items)) self.sizes_combo.connect("item-selected", self.__combo_item_selected, "sizes_combo") self.__widget_pack_start(self.sizes_box, [self.sizes_label, self.sizes_combo]) self.sizes_align.add(self.sizes_box) ''' rotation ''' self.rotation_align = self.__setup_align() self.rotation_box = gtk.HBox(spacing = WIDGET_SPACING) self.rotation_label = self.__setup_label(_("Rotation")) self.rotation_combo = self.__setup_combo(self.rotation_items) self.rotation_combo.set_select_index(self.display_manager.get_screen_rotation_index(self.__current_output_name)) self.rotation_combo.connect("item-selected", self.__combo_item_selected, "rotation_combo") self.__widget_pack_start(self.rotation_box, [self.rotation_label, self.rotation_combo]) self.rotation_align.add(self.rotation_box) ''' multi-monitors ''' self.multi_monitors_align = self.__setup_align() self.multi_monitors_box = gtk.HBox(spacing = WIDGET_SPACING) self.multi_monitors_label = self.__setup_label(_("Multi-Monitor")) self.multi_monitors_combo = self.__setup_combo(self.multi_monitors_items) self.multi_monitors_combo.set_select_index(self.display_manager.get_multi_monitor_index()) self.multi_monitors_combo.connect("item-selected", self.__combo_item_selected, "multi_monitors_combo") self.__widget_pack_start(self.multi_monitors_box, [self.multi_monitors_label, self.multi_monitors_combo]) self.multi_monitors_align.add(self.multi_monitors_box) if self.display_manager.get_output_count() < 2: self.multi_monitors_align.set_size_request(-1, 0) self.multi_monitors_align.set_child_visible(False) ''' monitor brightness ''' self.monitor_bright_align = self.__setup_title_align( app_theme.get_pixbuf("display/monitor_bright.png"), _("Brightness")) ''' brightness ''' self.brightness_align = self.__setup_align() self.brightness_box = gtk.HBox(spacing = 2) self.brightness_label_align = self.__setup_align(padding_top = 8, padding_left = 0, padding_right = 5) self.brightness_label = self.__setup_label(_("Brightness")) self.brightness_label_align.add(self.brightness_label) self.brightness_scale = HScalebar(point_dpixbuf = app_theme.get_pixbuf("scalebar/point.png"), value_min = 0.1, value_max = 1.0) self.brightness_scale.set_size_request(HSCALEBAR_WIDTH, 33) self.brightness_scale.set_value(self.display_manager.get_screen_brightness()) self.brightness_scale.connect("value-changed", self.__set_brightness) self.__widget_pack_start(self.brightness_box, [self.brightness_label_align, self.brightness_scale]) self.brightness_align.add(self.brightness_box) ''' auto adjust monitor brightness ''' self.auto_adjust_align = self.__setup_align() self.auto_adjust_box = gtk.HBox(spacing = WIDGET_SPACING) self.auto_adjust_label = self.__setup_label(_("Auto-Brightness")) self.auto_adjust_toggle_align = self.__setup_align(padding_top = 4, padding_left = 158) self.auto_adjust_toggle = self.__setup_toggle() self.auto_adjust_toggle.set_active(self.display_manager.is_enable_close_monitor()) self.auto_adjust_toggle.connect("toggled", self.__toggled, "auto_adjust_toggle") self.auto_adjust_toggle_align.add(self.auto_adjust_toggle) self.__widget_pack_start(self.auto_adjust_box, [self.auto_adjust_label, self.auto_adjust_toggle_align]) self.auto_adjust_align.add(self.auto_adjust_box) ''' close monitor ''' self.close_monitor_align = self.__setup_align() self.close_monitor_box = gtk.HBox(spacing = WIDGET_SPACING) self.close_monitor_label = self.__setup_label(_("Turn off monitor")) self.close_monitor_combo = self.__setup_combo(self.duration_items) self.close_monitor_combo.set_select_index(self.display_manager.get_close_monitor_index(self.duration_items)) self.close_monitor_combo.connect("item-selected", self.__combo_item_selected, "close_monitor_combo") self.__widget_pack_start(self.close_monitor_box, [self.close_monitor_label, self.close_monitor_combo]) self.close_monitor_align.add(self.close_monitor_box) ''' monitor lock ''' self.monitor_lock_align = self.__setup_title_align( app_theme.get_pixbuf("lock/lock.png"), _("Lock Screen")) ''' auto monitor lock ''' self.auto_lock_align = self.__setup_align() self.auto_lock_box = gtk.HBox(spacing = WIDGET_SPACING) self.auto_lock_label = self.__setup_label(_("Lock screen automatically")) self.auto_lock_toggle_align = self.__setup_align(padding_top = 4, padding_left = 158) self.auto_lock_toggle = self.__setup_toggle() is_enable_lock_display = self.display_manager.is_enable_lock_display() self.auto_lock_toggle.set_active(is_enable_lock_display) self.auto_lock_toggle.connect("toggled", self.__toggled, "auto_lock_toggle") self.auto_lock_toggle_align.add(self.auto_lock_toggle) self.__widget_pack_start(self.auto_lock_box, [self.auto_lock_label, self.auto_lock_toggle_align]) self.auto_lock_align.add(self.auto_lock_box) ''' lock display ''' self.lock_display_align = self.__setup_align(padding_bottom = 20) self.lock_display_box = gtk.HBox(spacing = WIDGET_SPACING) self.lock_display_label = self.__setup_label(_("Lock Screen")) self.lock_display_combo = self.__setup_combo(self.duration_items) self.lock_display_combo.set_select_index(self.display_manager.get_lock_display_index(self.duration_items)) self.lock_display_combo.connect("item-selected", self.__combo_item_selected, "lock_display_combo") self.__widget_pack_start(self.lock_display_box, [self.lock_display_label, self.lock_display_combo]) self.lock_display_align.add(self.lock_display_box) ''' left_align pack_start ''' self.__widget_pack_start(self.left_box, [self.monitor_display_align, self.monitor_align, self.sizes_align, self.rotation_align, self.multi_monitors_align, self.monitor_bright_align, self.brightness_align, #self.auto_adjust_align, #self.close_monitor_align, self.monitor_lock_align, self.auto_lock_align, self.lock_display_align]) self.left_align.add(self.left_box) ''' right_align pack_start ''' self.__widget_pack_start(self.right_box, [self.goto_align]) self.right_box.set_size_request(280, -1) self.right_align.add(self.right_box) ''' main && body box ''' self.main_box.pack_start(self.monitor_resize_align, False, False) self.body_box.pack_start(self.left_align) self.body_box.pack_start(self.right_align, False, False) self.main_box.pack_start(self.body_box) ''' this->HBox pack_start ''' self.scrolled_window.add_child(self.main_box) self.pack_start(self.scrolled_window) self.__send_message("status", ("display", ""))
def __init__(self, filename=""): ''' init share @param filename: the file to share ''' self.upload_image = filename self.thumb_width = 188 self.thumb_height = 168 self.MAX_CHAR = 140 #self.__text_frame_color = (0.76, 0.76, 0.76) self.__win_width = 602 open(COOKIE_FILE,'wb').close() self.window = DialogBox(_("Share to social networks"), close_callback=gtk.main_quit) self.window.set_keep_above(True) self.window.set_size_request(self.__win_width+20, 288) self.window.set_resizable(False) #self.window.titlebar.connect("expose-event", self.__expose_top_and_bottome) #self.window.button_box.connect("expose-event", self.__expose_top_and_bottome) # create slider self.slider = HSlider() self.slider_list = [] self.share_box = gtk.VBox(False) # first page, input context self.web_box = gtk.VBox(False, 10) # second page, login self.result_box = gtk.VBox(False, 10) # third page, share result share_align = gtk.Alignment() share_align.set(0.5, 0.5, 0, 0) share_align.add(self.share_box) share_align.connect("expose-event", self.__slider_expose) # go back button web_left_button = ImageButton( app_theme.get_pixbuf("share/back_normal.png"), app_theme.get_pixbuf("share/back_hover.png"), app_theme.get_pixbuf("share/back_press.png")) web_left_button.connect("clicked", lambda w: self.set_slide_index(0)) web_left_button.set_can_focus(False) utils.set_clickable_cursor(web_left_button) # show url entry self.web_url_entry = InputEntry() self.web_url_entry.set_editable(False) self.web_url_entry.set_size(555, 20) self.web_url_entry.entry.right_menu_visible_flag = False # alig url entry web_navigate_vbox = gtk.VBox(False) web_navigate_vbox.pack_start(self.web_url_entry) web_navigate_t_align = gtk.Alignment() web_navigate_t_align.set(0.0, 0.5, 0, 0) web_navigate_t_align.add(web_navigate_vbox) # pack back button and url entry web_navigate_box = gtk.HBox(False, 7) web_navigate_box.pack_start(web_left_button, False, False) web_navigate_box.pack_start(web_navigate_t_align) web_navigate_align = gtk.Alignment() web_navigate_align.set(0.5, 0.5, 0, 0) web_navigate_align.set_padding(4, 0, 11, 13) web_navigate_align.add(web_navigate_box) # create a webkit self.web_view = WebView(COOKIE_FILE) self.web_view.connect("notify::load-status", self.web_view_load_status) self.web_view.connect("load-error", self.web_view_load_error) self.web_scrolled_window = ScrolledWindow() self.web_scrolled_window.add(self.web_view) self.web_scrolled_window.set_size_request(590, 228) self.web_box.pack_start(web_navigate_align, False, False) self.web_box.pack_start(self.web_scrolled_window) #self.web_box.set_size_request(-1, 258) web_align = gtk.Alignment() web_align.set(0.5, 0.0, 0, 1) web_align.add(self.web_box) web_align.connect("expose-event", self.__slider_expose) res_align = gtk.Alignment() res_align.set(0.5, 0.5, 0, 0) res_align.add(self.result_box) res_align.connect("expose-event", self.__slider_expose) self.slider.set_to_page(share_align) self.slider_list.append(share_align) self.slider_list.append(web_align) self.slider_list.append(res_align) self.__weibo_list = [] self.sina = weibo.Sina(self.web_view) self.qq = weibo.Tencent(self.web_view) self.__weibo_list.append(self.sina) self.__weibo_list.append(self.qq) if default_locale != 'zh_CN': self.twitter = weibo.Twitter(self.web_view) #self.__weibo_list.append(self.twitter) self.__current_weibo = None self.weibo_name_l18n = { 'Sina': _("Sina"), 'Tencent': _("Tencent"), 'Twitter': _("Twitter"), } self.window.body_box.pack_start(self.slider, True, True) self.init_share_box()
def init_widgets(self): self.icon_width = self.icon_height = HEIGHT # self.user_hbox = gtk.HBox() self.user_icon = gtk.Image() self.user_icon.set_size_request(HEIGHT, HEIGHT) # user_name = self.cmd_dbus.get_user_name() user_name_width = get_text_size(user_name)[0] if user_name_width > WIDTH: de_user_name = user_name.decode("utf-8") user_name = de_user_name[0:10] + "..." self.user_label_ali = gtk.Alignment(0, 0, 1, 1) self.user_label_ali.set_padding(0, 0, 5, 0) self.user_label_event = gtk.EventBox() self.user_label = gtk.Label(user_name) self.user_label_event.add(self.user_label) self.user_label_ali.add(self.user_label_event) self.user_icon.connect_after("expose-event", self.user_label_event_expose_event) # self.user_hbox.pack_start(self.user_icon, False, False) self.user_hbox.pack_start(self.user_label_ali, False, False) # self.h_separator_top_ali = gtk.Alignment(1, 1, 1, 1) self.h_separator_top_ali.set_padding(5, 5, 0, 0) hseparator_color = [(0, ("#777777", 0.0)), (0.5, ("#000000", 0.3)), (1, ("#777777", 0.0))] self.h_separator_top = HSeparator(hseparator_color, 0, 0) self.h_separator_top_ali.add(self.h_separator_top) self.switch_separator_bottom = HSeparator(hseparator_color, 0, 0) self.switch_separator_bottom_ali = gtk.Alignment(1, 1, 1, 1) self.switch_separator_bottom_ali.set_padding(5, 5, 0, 0) self.switch_separator_bottom_ali.add(self.switch_separator_bottom) # ali_padding = 100 font_size = 10 self.switch_btn = SelectButton(_("Switch user"), font_size=font_size, ali_padding=ali_padding) self.stop_btn = SelectButton(_("Shut down"), font_size=font_size, ali_padding=ali_padding) self.restart_btn = SelectButton(_("Restart"), font_size=font_size, ali_padding=ali_padding) self.suspend_btn = SelectButton(_("Suspend"), font_size=font_size, ali_padding=ali_padding) self.logout_btn = SelectButton(_("Log out"), font_size=font_size, ali_padding=ali_padding) self.lock_btn = SelectButton(_("Lock"), font_size=font_size, ali_padding=ali_padding) # self.switch_btn.set_size_request(WIDTH, HEIGHT) self.stop_btn.set_size_request(WIDTH, HEIGHT) self.restart_btn.set_size_request(WIDTH, HEIGHT) self.suspend_btn.set_size_request(WIDTH, HEIGHT) self.logout_btn.set_size_request(WIDTH, HEIGHT) self.lock_btn.set_size_request(WIDTH, HEIGHT) # self.pack_start(self.user_hbox, True, True) self.pack_start(self.h_separator_top_ali, True, True) self.pack_start(self.switch_btn, True, True) self.pack_start(self.switch_separator_bottom_ali, True, True) self.pack_start(self.stop_btn, True, True) self.pack_start(self.restart_btn, True, True) self.pack_start(self.suspend_btn, True, True) self.pack_start(self.logout_btn, True, True) if self.cmd_dbus.real_name != "Guest": self.pack_start(self.lock_btn, True, True) set_clickable_cursor(self.user_label_event) gobject.timeout_add_seconds(2, self.check_is_livecd)
def get_user_info(self, weibo): '''get weibo user info''' info = weibo.get_user_name() gtk.gdk.threads_enter() #self.get_user_error_text = "" weibo_hbox = weibo.get_box() hbox = gtk.HBox(False) vbox = gtk.VBox(False) weibo_hbox.pack_start(vbox, False, False) vbox.pack_start(hbox) #print weibo.t_type, info if info: self.is_get_user_info[weibo] = 1 label = Label(text=info, label_width=70, enable_select=False) check = CheckButton() #check = gtk.CheckButton() check.connect("toggled", self.weibo_check_toggle, weibo) check.set_active(True) check_vbox = gtk.VBox(False) check_align = gtk.Alignment(0.5, 0.5, 0, 0) check_align.add(check_vbox) check_vbox.pack_start(check, False, False) button = ImageButton( app_theme.get_pixbuf("share/" + weibo.t_type + ".png"), app_theme.get_pixbuf("share/" + weibo.t_type + ".png"), app_theme.get_pixbuf("share/" + weibo.t_type + ".png")) utils.set_clickable_cursor(button) button.connect("enter-notify-event", self.show_tooltip, _("Click to switch user")) hbox.pack_start(check_align, False, False) hbox.pack_start(button, False, False, 5) hbox.pack_start(label, False, False) else: self.is_get_user_info[weibo] = 0 check = CheckButton() #check = gtk.CheckButton() check.set_sensitive(False) check_vbox = gtk.VBox(False) check_align = gtk.Alignment(0.5, 0.5, 0, 0) check_align.add(check_vbox) check_vbox.pack_start(check, False, False) button = ImageButton( app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"), app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"), app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png")) utils.set_clickable_cursor(button) button.connect("enter-notify-event", self.show_tooltip, _("Click to login")) hbox.pack_start(check_align, False, False) hbox.pack_start(button, False, False, 5) # curl time out info_error = weibo.get_curl_error() if info_error: #self.get_user_error_text += "%s:%s." % (weibo.t_type, _(info_error)) hbox.pack_start( Label(text="(%s)" % _(info_error), label_width=70,enable_select=False, text_color = ui_theme.get_color("category_item")), False, False) button.connect("clicked", self.weibo_login, weibo) self.__weibo_check_button_list.append(check) self.__weibo_image_button_list.append(button) gtk.gdk.threads_leave() return weibo_hbox
def __init__(self): ''' init docs ''' gtk.VBox.__init__(self) self.brightness_id = None self.display_manager = DisplayManager() self.__xrandr_settings = self.display_manager.get_xrandr_settings() self.__xrandr_settings.connect("changed", self.__xrandr_changed) self.resize_width = 790 self.resize_height = 200 self.monitor_items = [] self.__output_names = [] self.__current_output_name = self.display_manager.get_primary_output_name( ) self.__setup_monitor_items() self.sizes_items = [] self.monitor_combo = None if len(self.monitor_items ) > 1 and self.display_manager.is_copy_monitors(): self.__set_same_sizes() else: self.__setup_sizes_items() self.multi_monitors_items = [(_("Copy Display"), 1), (_("Extend Display"), 2), (_("Only shown in display 1"), 3), (_("Only shown in display 2"), 4)] self.rotation_items = [(_("Normal"), 1), (_("Right"), 2), (_("Left"), 3), (_("Inverted"), 4)] self.duration_items = [("1 %s" % _("Minute"), 1), ("2 %s" % _("Minutes"), 2), ("3 %s" % _("Minutes"), 3), ("5 %s" % _("Minutes"), 5), ("10 %s" % _("Minutes"), 10), ("30 %s" % _("Minutes"), 30), ("1 %s" % _("Hour"), 60), (_("Never"), DisplayManager.BIG_NUM / 60)] ''' scrolled_window ''' self.scrolled_window = ScrolledWindow() self.scrolled_window.set_size_request(-1, 425) self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.main_box = gtk.VBox() self.main_box.set_size_request(600, -1) self.body_box = gtk.HBox() ''' left, right align ''' self.left_align = self.__setup_align( padding_top=FRAME_TOP_PADDING, padding_left=TEXT_WINDOW_LEFT_PADDING) self.right_align = self.__setup_align(padding_top=FRAME_TOP_PADDING, padding_left=0) ''' left, right box ''' self.left_box = gtk.VBox(spacing=WIDGET_SPACING) self.right_box = gtk.VBox(spacing=WIDGET_SPACING) ''' monitor operation && detect ''' self.monitor_resize_align = self.__setup_align( padding_top=11, padding_left=int(TEXT_WINDOW_LEFT_PADDING / 2)) self.monitor_resize_box = MonitorResizableBox(self.display_manager) self.monitor_resize_box.select_output(self.__current_output_name) self.monitor_resize_box.connect("select-output", self.__select_output) self.monitor_resize_box.connect("resize", self.__resize_box) self.monitor_resize_align.add(self.monitor_resize_box) ''' monitor display ''' self.monitor_display_align = self.__setup_title_align( app_theme.get_pixbuf("display/monitor_display.png"), _("Display"), 0) ''' monitor ''' self.monitor_align = self.__setup_align() self.monitor_box = gtk.HBox(spacing=WIDGET_SPACING) self.monitor_label = self.__setup_label(_("Monitor")) self.monitor_combo = self.__setup_combo(self.monitor_items) self.monitor_combo.set_select_index( self.display_manager.get_primary_output_name_index( self.monitor_items)) self.monitor_combo.connect("item-selected", self.__combo_item_selected, "monitor_combo") self.__widget_pack_start(self.monitor_box, [self.monitor_label, self.monitor_combo]) self.monitor_align.add(self.monitor_box) ''' goto individuation or power setting ''' self.goto_align = self.__setup_align() self.goto_box = gtk.VBox(spacing=WIDGET_SPACING) self.goto_label = self.__setup_label(_("Relevant Settings"), text_size=TITLE_FONT_SIZE, width=None, align=ALIGN_START) goto_color = GOTO_FG_COLOR self.goto_individuation_label = self.__setup_label(text=_( "<span foreground=\"%s\" underline=\"single\">Personalization</span>" ) % goto_color, width=None, align=ALIGN_START) self.goto_individuation_label.connect("button-press-event", self.__button_press, "individuation") set_clickable_cursor(self.goto_individuation_label) self.goto_power_label = self.__setup_label( text=_("<span foreground=\"%s\" underline=\"single\">Power</span>") % goto_color, width=None, align=ALIGN_START) self.goto_power_label.connect("button-press-event", self.__button_press, "power") set_clickable_cursor(self.goto_power_label) self.__widget_pack_start(self.goto_box, [ self.goto_label, self.goto_individuation_label, self.goto_power_label ]) self.goto_align.add(self.goto_box) ''' sizes ''' self.sizes_align = self.__setup_align() self.sizes_box = gtk.HBox(spacing=WIDGET_SPACING) self.sizes_label = self.__setup_label(_("Resolution")) self.sizes_combo = self.__setup_combo(self.sizes_items) if self.sizes_combo: self.sizes_combo.set_select_index( self.display_manager.get_screen_size_index( self.__current_output_name, self.sizes_items)) self.sizes_combo.connect("item-selected", self.__combo_item_selected, "sizes_combo") self.__widget_pack_start(self.sizes_box, [self.sizes_label, self.sizes_combo]) self.sizes_align.add(self.sizes_box) ''' rotation ''' self.rotation_align = self.__setup_align() self.rotation_box = gtk.HBox(spacing=WIDGET_SPACING) self.rotation_label = self.__setup_label(_("Rotation")) self.rotation_combo = self.__setup_combo(self.rotation_items) self.rotation_combo.set_select_index( self.display_manager.get_screen_rotation_index( self.__current_output_name)) self.rotation_combo.connect("item-selected", self.__combo_item_selected, "rotation_combo") self.__widget_pack_start(self.rotation_box, [self.rotation_label, self.rotation_combo]) self.rotation_align.add(self.rotation_box) ''' multi-monitors ''' self.multi_monitors_align = self.__setup_align() self.multi_monitors_box = gtk.HBox(spacing=WIDGET_SPACING) self.multi_monitors_label = self.__setup_label(_("Multi-Monitor")) self.multi_monitors_combo = self.__setup_combo( self.multi_monitors_items) self.multi_monitors_combo.set_select_index( self.display_manager.get_multi_monitor_index()) self.multi_monitors_combo.connect("item-selected", self.__combo_item_selected, "multi_monitors_combo") self.__widget_pack_start( self.multi_monitors_box, [self.multi_monitors_label, self.multi_monitors_combo]) self.multi_monitors_align.add(self.multi_monitors_box) if self.display_manager.get_output_count() < 2: self.multi_monitors_align.set_size_request(-1, 0) self.multi_monitors_align.set_child_visible(False) ''' monitor brightness ''' self.monitor_bright_align = self.__setup_title_align( app_theme.get_pixbuf("display/monitor_bright.png"), _("Brightness")) ''' brightness ''' self.brightness_align = self.__setup_align() self.brightness_box = gtk.HBox(spacing=2) self.brightness_label_align = self.__setup_align(padding_top=8, padding_left=0, padding_right=5) self.brightness_label = self.__setup_label(_("Brightness")) self.brightness_label_align.add(self.brightness_label) self.brightness_scale = HScalebar( point_dpixbuf=app_theme.get_pixbuf("scalebar/point.png"), value_min=0.1, value_max=1.0) self.brightness_scale.set_size_request(HSCALEBAR_WIDTH, 33) self.brightness_scale.set_value( self.display_manager.get_screen_brightness()) self.brightness_scale.connect("value-changed", self.__set_brightness) self.__widget_pack_start( self.brightness_box, [self.brightness_label_align, self.brightness_scale]) self.brightness_align.add(self.brightness_box) ''' auto adjust monitor brightness ''' self.auto_adjust_align = self.__setup_align() self.auto_adjust_box = gtk.HBox(spacing=WIDGET_SPACING) self.auto_adjust_label = self.__setup_label(_("Auto-Brightness")) self.auto_adjust_toggle_align = self.__setup_align(padding_top=4, padding_left=158) self.auto_adjust_toggle = self.__setup_toggle() self.auto_adjust_toggle.set_active( self.display_manager.is_enable_close_monitor()) self.auto_adjust_toggle.connect("toggled", self.__toggled, "auto_adjust_toggle") self.auto_adjust_toggle_align.add(self.auto_adjust_toggle) self.__widget_pack_start( self.auto_adjust_box, [self.auto_adjust_label, self.auto_adjust_toggle_align]) self.auto_adjust_align.add(self.auto_adjust_box) ''' close monitor ''' self.close_monitor_align = self.__setup_align() self.close_monitor_box = gtk.HBox(spacing=WIDGET_SPACING) self.close_monitor_label = self.__setup_label(_("Turn off monitor")) self.close_monitor_combo = self.__setup_combo(self.duration_items) self.close_monitor_combo.set_select_index( self.display_manager.get_close_monitor_index(self.duration_items)) self.close_monitor_combo.connect("item-selected", self.__combo_item_selected, "close_monitor_combo") self.__widget_pack_start( self.close_monitor_box, [self.close_monitor_label, self.close_monitor_combo]) self.close_monitor_align.add(self.close_monitor_box) ''' monitor lock ''' self.monitor_lock_align = self.__setup_title_align( app_theme.get_pixbuf("lock/lock.png"), _("Lock Screen")) ''' auto monitor lock ''' self.auto_lock_align = self.__setup_align() self.auto_lock_box = gtk.HBox(spacing=WIDGET_SPACING) self.auto_lock_label = self.__setup_label( _("Lock screen automatically")) self.auto_lock_toggle_align = self.__setup_align(padding_top=4, padding_left=158) self.auto_lock_toggle = self.__setup_toggle() is_enable_lock_display = self.display_manager.is_enable_lock_display() self.auto_lock_toggle.set_active(is_enable_lock_display) self.auto_lock_toggle.connect("toggled", self.__toggled, "auto_lock_toggle") self.auto_lock_toggle_align.add(self.auto_lock_toggle) self.__widget_pack_start( self.auto_lock_box, [self.auto_lock_label, self.auto_lock_toggle_align]) self.auto_lock_align.add(self.auto_lock_box) ''' lock display ''' self.lock_display_align = self.__setup_align(padding_bottom=20) self.lock_display_box = gtk.HBox(spacing=WIDGET_SPACING) self.lock_display_label = self.__setup_label(_("Lock Screen")) self.lock_display_combo = self.__setup_combo(self.duration_items) self.lock_display_combo.set_select_index( self.display_manager.get_lock_display_index(self.duration_items)) self.lock_display_combo.connect("item-selected", self.__combo_item_selected, "lock_display_combo") self.__widget_pack_start( self.lock_display_box, [self.lock_display_label, self.lock_display_combo]) self.lock_display_align.add(self.lock_display_box) ''' left_align pack_start ''' self.__widget_pack_start( self.left_box, [ self.monitor_display_align, self.monitor_align, self.sizes_align, self.rotation_align, self.multi_monitors_align, self.monitor_bright_align, self.brightness_align, #self.auto_adjust_align, #self.close_monitor_align, self.monitor_lock_align, self.auto_lock_align, self.lock_display_align ]) self.left_align.add(self.left_box) ''' right_align pack_start ''' self.__widget_pack_start(self.right_box, [self.goto_align]) self.right_box.set_size_request(280, -1) self.right_align.add(self.right_box) ''' main && body box ''' self.main_box.pack_start(self.monitor_resize_align, False, False) self.body_box.pack_start(self.left_align) self.body_box.pack_start(self.right_align, False, False) self.main_box.pack_start(self.body_box) ''' this->HBox pack_start ''' self.scrolled_window.add_child(self.main_box) self.pack_start(self.scrolled_window) self.__send_message("status", ("display", ""))
def share_to_weibo_result(self): '''result of share to weibo''' font_color = app_theme.get_color("share_result_text") res_hbox = gtk.HBox(False) res_hbox.set_size_request(-1, 240) res_left_box = DialogLeftButtonBox() res_right_box = DialogRightButtonBox() res_left_box.button_align.set(0.5, 0.0, 0, 1) res_right_box.button_align.set(0.5, 0.0, 0, 1) res_left_box.button_align.set_padding(5, 9, 19, 0) res_right_box.button_align.set_padding(30, 0, 0, 0) res_left_box.set_size_request(405, -1) res_right_box.set_size_request(195, -1) res_hbox.pack_start(res_left_box) res_hbox.pack_start( VSeparator(app_theme.get_shadow_color("VSeparator").get_color_info(), 0, 0)) res_hbox.pack_start(res_right_box) res_vbox = gtk.VBox(False) follow_vbox = gtk.VBox(False) tmp_img = gtk.Image() # only use as a placeholder tmp_img.set_size_request(-1, 50) res_vbox.pack_start(tmp_img, False, False) follow_tip_hbox = gtk.HBox(False) img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/deepin_logo.png")) follow_tip_hbox.pack_start(img, False, False, 5) follow_tip_hbox.pack_start( Label("%s %s" % (_("Follow"), "Linux Deepin"), text_color=app_theme_get_dynamic_color("#5f5f5f"), text_size=12, enable_select=False), False, False) follow_vbox.pack_start(follow_tip_hbox, False, False, 13) for weibo in self.to_share_weibo_res: vbox = gtk.VBox(False, 1) tip_box = gtk.HBox() error_box = gtk.HBox() vbox.pack_start(tip_box, False, False) vbox.pack_start(error_box, False, False) if self.to_share_weibo_res[weibo][0]: # upload succeed img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/share_succeed.png")) #link = LinkButton(_(weibo.t_type), text_size=13, self.to_share_weibo_res[weibo][1]) link = Label(_(weibo.t_type), text_size=12, text_color=app_theme.get_color("link_text")) #, enable_gaussian=True, gaussian_radious=1, border_radious=0) link.add_events(gtk.gdk.BUTTON_PRESS_MASK) link.connect("enter-notify-event", lambda w, e: self.__draw_under_line(w)) link.connect("leave-notify-event", lambda w, e: w.queue_draw()) link.connect("button-press-event", self.goto_weibo_button_clicked, weibo) link_box = gtk.HBox(False) link_box.pack_start(link, False, False) utils.set_clickable_cursor(link) text = _("Share to") label = Label(text, text_size=12, text_color=font_color, enable_select=False) text = _("Successful") label1 = Label(text, text_size=12, text_color=font_color, enable_select=False) tip_box.pack_start(img, False, False, 15) tip_box.pack_start(label, False, False, 3) tip_box.pack_start(link_box, False, False, 3) tip_box.pack_start(label1, False, False) # only use as a placeholder img = gtk.Image() img.set_size_request(20, 1) error_box.pack_start(img, False, False, 16) tmp = Label(" ", text_size=9, label_width=200) tmp.set_size_request(200, 1) error_box.pack_start(tmp, False, False) #print text else: # upload failed img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/share_failed.png")) #text = "% %s %s." % (_(weibo.t_type), _("upload failed")) text = _("Share to") label1 = Label(text, text_size=12, text_color=font_color, enable_select=False) label2 = Label(_(weibo.t_type), text_size=12, text_color=font_color, enable_select=False) text = _("Failed") label3 = Label(text, text_size=12, text_color=font_color, enable_select=False) if weibo.curl.error: error = "(%s)" % _(weibo.curl.error) elif weibo.get_error_msg(): error = "(%s)" % _(weibo.get_error_msg()) else: error = "(%s)" % _("Unknown reason") #print "%s: %s" % (weibo.t_type, error) #print "%s: %s" % (weibo.t_type, weibo.get_error_msg()) label = Label(text, text_size=12, text_color=font_color, enable_select=False) tip_box.pack_start(img, False, False, 15) tip_box.pack_start(label1, False, False, 3) tip_box.pack_start(label2, False, False, 3) tip_box.pack_start(label3, False, False) img = gtk.Image() # only use as a placeholder img.set_size_request(20, 20) error_box.pack_start(img, False, False, 16) error_box.pack_start(Label(error, text_size=9, label_width=200, text_color=font_color, enable_select=False), False, False) #print text res_vbox.pack_start(vbox, False, False, 10) for weibo in self.deepin_info: box = gtk.HBox(False, 15) # followed img = gtk.image_new_from_pixbuf(app_theme.get_pixbuf("share/"+weibo.t_type+".png").get_pixbuf()) box.pack_start(img, False, False) if self.deepin_info[weibo] is not None and self.deepin_info[weibo][3]: if not default_locale.startswith("zh_"): button = gtk.image_new_from_pixbuf( app_theme.get_pixbuf("share/followed_en.png").get_pixbuf()) else: button = gtk.image_new_from_pixbuf( app_theme.get_pixbuf("share/followed.png").get_pixbuf()) else: # to follow if not default_locale.startswith("zh_"): button = ImageButton( app_theme.get_pixbuf("share/follow_normal_en.png"), app_theme.get_pixbuf("share/follow_hover_en.png"), app_theme.get_pixbuf("share/follow_press_en.png")) else: button = ImageButton( app_theme.get_pixbuf("share/follow_normal.png"), app_theme.get_pixbuf("share/follow_hover.png"), app_theme.get_pixbuf("share/follow_press.png")) button.connect("clicked", self.friendships_add_button_clicked, weibo, box) box.pack_start(button, False, False) align = gtk.Alignment() align.set(0.0, 0.5, 0, 0) align.set_padding(0, 0, 30, 0) align.add(box) follow_vbox.pack_start(align, False, False, 8) res_left_box.set_buttons([res_vbox]) res_right_box.set_buttons([follow_vbox]) self.result_box.pack_start(res_hbox, False, False) self.result_box.show_all() self.set_slide_index(2)
def __init__(self, filename=""): ''' init share @param filename: the file to share ''' self.upload_image = filename self.thumb_width = 188 self.thumb_height = 168 self.MAX_CHAR = 140 #self.__text_frame_color = (0.76, 0.76, 0.76) self.__win_width = 602 open(COOKIE_FILE,'wb').close() self.window = DialogBox(_("Share to social networks"), close_callback=gtk.main_quit) self.window.set_keep_above(True) self.window.set_size_request(self.__win_width+20, 288) self.window.set_resizable(False) self.window.titlebar.connect("expose-event", self.__expose_top_and_bottome) self.window.button_box.connect("expose-event", self.__expose_top_and_bottome) # create slider self.slider = HSlider() self.slider_list = [] self.share_box = gtk.VBox(False, 2) # first page, input context self.web_box = gtk.VBox(False, 10) # second page, login self.result_box = gtk.VBox(False, 10) # third page, share result share_align = gtk.Alignment() share_align.set(0.5, 0.5, 0, 0) share_align.add(self.share_box) share_align.connect("expose-event", self.__slider_expose) # go back button web_left_button = ImageButton( app_theme.get_pixbuf("share/back_normal.png"), app_theme.get_pixbuf("share/back_hover.png"), app_theme.get_pixbuf("share/back_press.png")) web_left_button.connect("clicked", lambda w: self.set_slide_index(0)) web_left_button.set_can_focus(False) utils.set_clickable_cursor(web_left_button) # show url entry self.web_url_entry = InputEntry() self.web_url_entry.set_editable(False) self.web_url_entry.set_size(555, 20) self.web_url_entry.entry.right_menu_visible_flag = False # alig url entry web_navigate_vbox = gtk.VBox(False) web_navigate_vbox.pack_start(self.web_url_entry) web_navigate_t_align = gtk.Alignment() web_navigate_t_align.set(0.0, 0.5, 0, 0) web_navigate_t_align.add(web_navigate_vbox) # pack back button and url entry web_navigate_box = gtk.HBox(False, 7) web_navigate_box.pack_start(web_left_button, False, False) web_navigate_box.pack_start(web_navigate_t_align) web_navigate_align = gtk.Alignment() web_navigate_align.set(0.5, 0.5, 0, 0) web_navigate_align.set_padding(4, 0, 11, 13) web_navigate_align.add(web_navigate_box) # create a webkit self.web_view = WebView(COOKIE_FILE) self.web_view.connect("notify::load-status", self.web_view_load_status) self.web_view.connect("load-error", self.web_view_load_error) self.web_scrolled_window = ScrolledWindow() self.web_scrolled_window.add(self.web_view) self.web_scrolled_window.set_size_request(590, 228) self.web_box.pack_start(web_navigate_align, False, False) self.web_box.pack_start(self.web_scrolled_window) #self.web_box.set_size_request(-1, 258) web_align = gtk.Alignment() web_align.set(0.5, 0.0, 0, 1) web_align.add(self.web_box) web_align.connect("expose-event", self.__slider_expose) res_align = gtk.Alignment() res_align.set(0.5, 0.5, 0, 0) res_align.add(self.result_box) res_align.connect("expose-event", self.__slider_expose) self.slider.set_to_page(share_align) self.slider_list.append(share_align) self.slider_list.append(web_align) self.slider_list.append(res_align) self.__weibo_list = [] self.sina = weibo.Sina(self.web_view) self.qq = weibo.Tencent(self.web_view) self.twitter = weibo.Twitter(self.web_view) self.__weibo_list.append(self.sina) self.__weibo_list.append(self.qq) self.__weibo_list.append(self.twitter) self.__current_weibo = None self.window.body_box.pack_start(self.slider, True, True) self.init_share_box()
def share_to_weibo_result(self): '''result of share to weibo''' font_color = ui_theme.get_color("category_item") res_hbox = gtk.HBox(False) res_hbox.set_size_request(-1, 240) res_left_box = DialogLeftButtonBox() res_right_box = DialogRightButtonBox() res_left_box.button_align.set(0.5, 0.0, 0, 1) res_right_box.button_align.set(0.5, 0.0, 0, 1) res_left_box.button_align.set_padding(5, 9, 19, 0) res_right_box.button_align.set_padding(30, 0, 0, 0) res_left_box.set_size_request(405, -1) res_right_box.set_size_request(195, -1) res_hbox.pack_start(res_left_box) res_hbox.pack_start( VSeparator(app_theme.get_shadow_color("VSeparator").get_color_info(), 0, 0)) res_hbox.pack_start(res_right_box) res_vbox = gtk.VBox(False) follow_vbox = gtk.VBox(False) tmp_img = gtk.Image() # only use as a placeholder tmp_img.set_size_request(-1, 50) res_vbox.pack_start(tmp_img, False, False) follow_tip_hbox = gtk.HBox(False) img = gtk.image_new_from_icon_name("deepin-logo", 16) if img.get_pixel_size() == -1: img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/deepin_logo.png")) follow_tip_hbox.pack_start(img, False, False, 5) follow_tip_hbox.pack_start( Label("%s %s" % (_("Follow"), "Linux Deepin"), text_color=app_theme_get_dynamic_color("#5f5f5f"), text_size=12, enable_select=False), False, False) follow_vbox.pack_start(follow_tip_hbox, False, False, 13) for weibo in self.to_share_weibo_res: vbox = gtk.VBox(False, 1) tip_box = gtk.HBox() error_box = gtk.HBox() vbox.pack_start(tip_box, False, False) vbox.pack_start(error_box, False, False) if self.to_share_weibo_res[weibo][0]: # upload succeed img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/share_succeed.png")) #link = LinkButton(_(weibo.t_type), text_size=13, self.to_share_weibo_res[weibo][1]) link = Label(self.weibo_name_l18n[weibo.t_type], text_size=12, text_color=ui_theme.get_color("link_text")) #, enable_gaussian=True, gaussian_radious=1, border_radious=0) link.add_events(gtk.gdk.BUTTON_PRESS_MASK) link.connect("enter-notify-event", lambda w, e: self.__draw_under_line(w)) link.connect("leave-notify-event", lambda w, e: w.queue_draw()) link.connect("button-press-event", self.goto_weibo_button_clicked, weibo) link_box = gtk.HBox(False) link_box.pack_start(link, False, False) utils.set_clickable_cursor(link) text = _("Share to") label = Label(text, text_size=12, text_color=font_color, enable_select=False) text = _("Successful") label1 = Label(text, text_size=12, text_color=font_color, enable_select=False) tip_box.pack_start(img, False, False, 15) tip_box.pack_start(label, False, False, 3) tip_box.pack_start(link_box, False, False, 3) tip_box.pack_start(label1, False, False) # only use as a placeholder img = gtk.Image() img.set_size_request(20, 1) error_box.pack_start(img, False, False, 16) tmp = Label(" ", text_size=9, label_width=200) tmp.set_size_request(200, 1) error_box.pack_start(tmp, False, False) #print text else: # upload failed img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/share_failed.png")) #text = "% %s %s." % (_(weibo.t_type), _("upload failed")) text = _("Share to") label1 = Label(text, text_size=12, text_color=font_color, enable_select=False) label2 = Label(_(weibo.t_type), text_size=12, text_color=font_color, enable_select=False) text = _("Failed") label3 = Label(text, text_size=12, text_color=font_color, enable_select=False) if weibo.curl.error: error = "(%s)" % _(weibo.curl.error) elif weibo.get_error_msg(): error = "(%s)" % _(weibo.get_error_msg()) else: error = "(%s)" % _("Unknown reason") #print "%s: %s" % (weibo.t_type, error) #print "%s: %s" % (weibo.t_type, weibo.get_error_msg()) label = Label(text, text_size=12, text_color=font_color, enable_select=False) tip_box.pack_start(img, False, False, 15) tip_box.pack_start(label1, False, False, 3) tip_box.pack_start(label2, False, False, 3) tip_box.pack_start(label3, False, False) img = gtk.Image() # only use as a placeholder img.set_size_request(20, 20) error_box.pack_start(img, False, False, 16) error_box.pack_start(Label(error, text_size=9, label_width=200, text_color=font_color, enable_select=False), False, False) #print text res_vbox.pack_start(vbox, False, False, 10) for weibo in self.deepin_info: box = gtk.HBox(False, 15) # followed img = gtk.image_new_from_pixbuf(app_theme.get_pixbuf("share/"+weibo.t_type+".png").get_pixbuf()) box.pack_start(img, False, False) if self.deepin_info[weibo] is not None and self.deepin_info[weibo][3]: if not default_locale.startswith("zh_"): button = gtk.image_new_from_pixbuf( app_theme.get_pixbuf("share/followed_en.png").get_pixbuf()) else: button = gtk.image_new_from_pixbuf( app_theme.get_pixbuf("share/followed.png").get_pixbuf()) else: # to follow if not default_locale.startswith("zh_"): button = ImageButton( app_theme.get_pixbuf("share/follow_normal_en.png"), app_theme.get_pixbuf("share/follow_hover_en.png"), app_theme.get_pixbuf("share/follow_press_en.png")) else: button = ImageButton( app_theme.get_pixbuf("share/follow_normal.png"), app_theme.get_pixbuf("share/follow_hover.png"), app_theme.get_pixbuf("share/follow_press.png")) button.connect("clicked", self.friendships_add_button_clicked, weibo, box) box.pack_start(button, False, False) align = gtk.Alignment() align.set(0.0, 0.5, 0, 0) align.set_padding(0, 0, 30, 0) align.add(box) follow_vbox.pack_start(align, False, False, 8) res_left_box.set_buttons([res_vbox]) res_right_box.set_buttons([follow_vbox]) self.result_box.pack_start(res_hbox, False, False) self.result_box.show_all() self.set_slide_index(2)