def favorite_action(self, widget, event): if not widget.get_active(): record_info.record_favorite(self.appid, self.conf_db) else: record_info.remove_favorite(self.appid, self.conf_db)
def webview_message_handler(self, info): info = info.split('://') if len(info) == 2: order, data = info if order == 'play': self.show_play(data) elif order == 'star': self.toggle_favorite(data) elif order == 'local': if data == 'recent': self.show_recent_page() elif data == 'star': self.show_favorite_page() elif order == 'document_ready' and data == 'game_gallery': self.document_ready() elif order == 'onload' and data == 'game_gallery': gtk.timeout_add(200, self.fresh_favotite_status) elif order == 'onload' and data == 'local_game_gallery': self.webview.execute_script('$("#game-gallery").get(0).contentWindow.set_right_menu()') gtk.timeout_add(200, self.fresh_favotite_status) elif order == 'onload' and data == 'main_frame': gtk.timeout_add(200, self.show_favorite_page) elif order == 'onload' and data == 'footer': self.webview.execute_script('if(infos){append_data_to_gallery(infos);}') elif order == 'favorite': record_info.record_favorite(data, self.conf_db) FetchInfo(data).start() favorite_animation(self.application.window) elif order == 'unfavorite': record_info.remove_favorite(data, self.conf_db) elif order == 'local_action': info = data.split('-') if len(info) == 2: action_type= info[0] appid = info[1] if action_type == 'favorite': record_info.remove_favorite(appid, self.conf_db) utils.ThreadMethod(utils.send_analytics, ('unfavorite', appid)).start() #var favorite_url = 'http://' + location.host + '/game/analytics/?type=unfavorite&appid=' + id; self.webview.execute_script('if(infos){infos_remove(%s);}else{gallery_change(%s);}' % ( json.dumps(appid, encoding="UTF-8", ensure_ascii=False), json.dumps(self.no_favorite_html_path, encoding="UTF-8", ensure_ascii=False), )) elif action_type == 'recent': record_info.remove_recent_play(appid, self.conf_db) self.webview.execute_script('if(infos){infos_remove(%s);}else{gallery_change(%s);}' % ( json.dumps(appid, encoding="UTF-8", ensure_ascii=False), json.dumps(self.no_recent_html_path, encoding="UTF-8", ensure_ascii=False), )) elif order == 'scroll_top': self.send_event(data)