Esempio n. 1
0
	def __init__(self, app, player, store):
		gobject.GObject.__init__(self)
		self._isDestroyed = False
		self._isPortrait = hildonize.IS_FREMANTLE_SUPPORTED

		self._app = app
		self._player = player
		self._store = store

		self._clipboard = gtk.clipboard_get()
		self._windowInFullscreen = False

		self._errorBanner = banners.StackingBanner()

		self._layout = gtk.VBox()

		self._window = gtk.Window()
		self._window.add(self._layout)
		self._window = hildonize.hildonize_window(self._app, self._window)
		go_utils.AutoSignal.__init__(self, self.window)

		self._window.set_icon(self._store.get_pixbuf_from_store(self._store.STORE_LOOKUP["icon"]))
		self._window.connect("key-press-event", self._on_key_press)
		self._window.connect("window-state-event", self._on_window_state_change)
		self._window.connect("destroy", self._on_destroy)

		if hildonize.GTK_MENU_USED:
			aboutMenuItem = gtk.MenuItem("About")
			aboutMenuItem.connect("activate", self._on_about)

			helpMenu = gtk.Menu()
			helpMenu.append(aboutMenuItem)

			helpMenuItem = gtk.MenuItem("Help")
			helpMenuItem.set_submenu(helpMenu)

			menuBar = gtk.MenuBar()
			menuBar.append(helpMenuItem)

			self._layout.pack_start(menuBar, False, False)
			menuBar = hildonize.hildonize_menu(
				self._window,
				menuBar,
			)
		else:
			aboutMenuItem = gtk.Button("About")
			aboutMenuItem.connect("clicked", self._on_about)

			appMenu = hildonize.hildon.AppMenu()
			appMenu.append(aboutMenuItem)
			appMenu.show_all()
			self._window.set_app_menu(appMenu)

		self._layout.pack_start(self._errorBanner.toplevel, False, True)
Esempio n. 2
0
	def _on_settings(self, *args):
		if self.__settingsWindow is None:
			vbox = gtk.VBox()
			self.__settingsManager = settings.SettingsDialog(vbox, self.db, self.liststorehandler)

			self.__settingsWindow = gtk.Window()
			self.__settingsWindow.add(vbox)
			self.__settingsWindow = hildonize.hildonize_window(self, self.__settingsWindow)

			self.__settingsWindow.set_title(_("Settings"))
			self.__settingsWindow.set_transient_for(self.window)
			self.__settingsWindow.set_default_size(*self.window.get_size())
			self.__settingsWindow.connect("delete-event", self._on_settings_delete)
		self.__settingsManager.set_portrait_state(self.__isPortrait)
		self.__settingsWindow.set_modal(True)
		self.__settingsWindow.show_all()
Esempio n. 3
0
File: Gui.py Progetto: epage/nqaap
    def _on_settings(self, *args):
        if self.__settingsWindow is None:
            vbox = gtk.VBox()
            self.__settingsManager = settings.SettingsDialog(vbox)

            self.__settingsWindow = gtk.Window()
            self.__settingsWindow.add(vbox)
            self.__settingsWindow = hildonize.hildonize_window(self._app, self.__settingsWindow)
            self.__settingsManager.window = self.__settingsWindow

            self.__settingsWindow.set_title("Settings")
            self.__settingsWindow.set_transient_for(self.win)
            self.__settingsWindow.set_default_size(*self.win.get_size())
            self.__settingsWindow.connect("delete-event", self._on_settings_delete)
        self.__settingsManager.set_portrait_state(self.__isPortrait)
        self.__settingsManager.set_audiobook_path(self.controller.get_books_path())
        self.__settingsWindow.set_modal(True)
        self.__settingsWindow.show_all()
Esempio n. 4
0
	def __init__(self):
		self._unitDataInCategory = None
		self._unit_sort_direction = False
		self._value_sort_direction = False
		self._units_sort_direction = False
		self.__isPortrait = False
		self._isFullScreen = False
		self._clipboard = gtk.clipboard_get()

		self._find_result = [] # empty find result list
		self._findIndex = 0 # default to find result number zero

		self._selectedCategoryName = '' # preset to no selected category
		self._defaultUnitForCategory = {} # empty dictionary for later use

		#check to see if glade file is in current directory (user must be
		# running from download untar directory)
		for gladePath in self._glade_files:
			if os.path.isfile(gladePath):
				homepath = os.path.dirname(gladePath)
				pixmapspath = "/".join((homepath, "pixmaps"))
				widgets = gtk.glade.XML(gladePath)
				break
		else:
			_moduleLogger.error("UI Descriptor not found!")
			gtk.main_quit()
			return

		self._mainWindow = widgets.get_widget('mainWindow')
		self._app = hildonize.get_app_class()()
		self._mainWindow = hildonize.hildonize_window(self._app, self._mainWindow)

		change_menu_label(widgets, 'fileMenuItem', _('File'))
		change_menu_label(widgets, 'exitMenuItem', _('Exit'))
		change_menu_label(widgets, 'helpMenuItem', _('Help'))
		change_menu_label(widgets, 'aboutMenuItem', _('About'))

		self._categorySelectionButton = widgets.get_widget("categorySelectionButton")
		self._categoryView = widgets.get_widget('categoryView')

		self._unitsView = widgets.get_widget('unitsView')
		self._unitsView.set_property('rules_hint', 1)
		self._unitsView_selection = self._unitsView.get_selection()

		self._unitName = widgets.get_widget('unitName')
		self._unitValue = widgets.get_widget('unitValue')
		self._previousUnitName = widgets.get_widget('previousUnitName')
		self._previousUnitValue = widgets.get_widget('previousUnitValue')

		self._unitSymbol = widgets.get_widget('unitSymbol')
		self._previousUnitSymbol = widgets.get_widget('previousUnitSymbol')

		self._unitDescription = widgets.get_widget('unitDescription')

		self._searchLayout = widgets.get_widget('searchLayout')
		self._searchLayout.hide()
		self._findEntry = widgets.get_widget('findEntry')
		self._findLabel = widgets.get_widget('findLabel')
		self._findButton = widgets.get_widget('findButton')
		self._closeSearchButton = widgets.get_widget('closeSearchButton')

		self._unitsNameRenderer = gtk.CellRendererText()
		self._unitsNameRenderer.set_property("scale", 0.75)
		if constants.FORCE_HILDON_LIKE:
			self._unitsNameRenderer.set_property("ellipsize", pango.ELLIPSIZE_END)
			self._unitsNameRenderer.set_property("width-chars", 5)
		self._unitNameColumn = gtk.TreeViewColumn(_('Name'), self._unitsNameRenderer)
		self._unitNameColumn.set_property('resizable', True)
		self._unitNameColumn.add_attribute(self._unitsNameRenderer, 'text', self.UNITS_NAME_IDX)
		self._unitNameColumn.set_clickable(True)
		self._unitNameColumn.connect("clicked", self._on_click_unit_column)
		self._unitsView.append_column(self._unitNameColumn)

		renderer = gtk.CellRendererText()
		renderer.set_property("xalign", 1.0)
		renderer.set_property("alignment", pango.ALIGN_RIGHT)
		hildonize.set_cell_thumb_selectable(renderer)
		self._unitIntegerColumn = gtk.TreeViewColumn(_('Value'), renderer)
		self._unitIntegerColumn.set_property('resizable', True)
		self._unitIntegerColumn.add_attribute(renderer, 'text', self.UNITS_INTEGER_IDX)
		self._unitIntegerColumn.set_clickable(True)
		self._unitIntegerColumn.connect("clicked", self._on_click_unit_column)
		self._unitsView.append_column(self._unitIntegerColumn)

		renderer = gtk.CellRendererText()
		renderer.set_property("xalign", 0.0)
		renderer.set_property("alignment", pango.ALIGN_LEFT)
		renderer.set_property("scale", 0.75)
		self._unitFractionalColumn = gtk.TreeViewColumn(_(''), renderer)
		self._unitFractionalColumn.set_property('resizable', True)
		self._unitFractionalColumn.add_attribute(renderer, 'text', self.UNITS_FRACTION_IDX)
		self._unitFractionalColumn.set_clickable(True)
		self._unitFractionalColumn.connect("clicked", self._on_click_unit_column)
		self._unitsView.append_column(self._unitFractionalColumn)

		renderer = gtk.CellRendererText()
		renderer.set_property("ellipsize", pango.ELLIPSIZE_END)
		#renderer.set_property("scale", 0.5)
		self._unitSymbolColumn = gtk.TreeViewColumn(_('Units'), renderer)
		self._unitSymbolColumn.set_property('resizable', True)
		self._unitSymbolColumn.add_attribute(renderer, 'text', self.UNITS_SYMBOL_IDX)
		self._unitSymbolColumn.set_clickable(True)
		self._unitSymbolColumn.connect("clicked", self._on_click_unit_column)
		self._unitsView.append_column(self._unitSymbolColumn)

		self._unitModel = gtk.ListStore(
			gobject.TYPE_STRING, # UNITS_NAME_IDX
			gobject.TYPE_STRING, # UNITS_VALUE_IDX
			gobject.TYPE_STRING, # UNITS_SYMBOL_IDX
			gobject.TYPE_STRING, # UNITS_INTEGER_IDX
			gobject.TYPE_STRING, # UNITS_FRACTION_IDX
		)
		self._sortedUnitModel = gtk.TreeModelSort(self._unitModel)
		columns = self._get_column_sort_stuff()
		for columnIndex, (column, sortDirection, col_cmp) in enumerate(columns):
			self._sortedUnitModel.set_sort_func(columnIndex, col_cmp)
		self._unitsView.set_model(self._sortedUnitModel)

		#Insert a column into the category list even though the heading will not be seen
		renderer = gtk.CellRendererText()
		self._categoryColumn = gtk.TreeViewColumn('Title', renderer)
		self._categoryColumn.set_property('resizable', 1)
		self._categoryColumn.add_attribute(renderer, 'text', 0)
		self._categoryView.append_column(self._categoryColumn)

		self._categoryModel = gtk.ListStore(gobject.TYPE_STRING)
		self._categoryView.set_model(self._categoryModel)
		#colourize each row differently for easier reading
		self._categoryView.set_property('rules_hint', 1)

		#Populate the catagories list
		for key in unit_data.UNIT_CATEGORIES:
			row = (key, )
			self._categoryModel.append(row)

		#--------- connections to GUI ----------------
		self._mainWindow.connect("destroy", self._on_user_exit)
		self._mainWindow.connect("key-press-event", self._on_key_press)
		self._mainWindow.connect("window-state-event", self._on_window_state_change)
		self._categorySelectionButton.connect("clicked", self._on_category_selector_clicked)
		self._categoryView.connect("cursor-changed", self._on_click_category)
		self._findButton.connect("clicked", self._on_find_activate)
		self._findEntry.connect("activate", self._on_find_activate)
		self._findEntry.connect("changed", self._on_findEntry_changed)
		self._closeSearchButton.connect("clicked", self._on_toggle_search)
		self._previousUnitValue.connect("changed", self._on_previous_unit_value_changed)
		self._unitValue.connect("changed", self._on_unit_value_changed)
		self._unitValue.connect("key-press-event", self._on_browse_key_press)
		self._unitsView.connect("cursor-changed", self._on_click_unit)
		self._unitsView.connect("key-press-event", self._on_browse_key_press)
		if hildonize.GTK_MENU_USED:
			widgets.get_widget("aboutMenuItem").connect("activate", self._on_about_clicked)
			widgets.get_widget("searchMenuItem").connect("activate", self._on_toggle_search)
			widgets.get_widget("exitMenuItem").connect("activate", self._on_user_exit)

		for scrollingWidgetName in (
			"unitsViewScrolledWindow",
		):
			scrollingWidget = widgets.get_widget(scrollingWidgetName)
			assert scrollingWidget is not None, scrollingWidgetName
			scroller = hildonize.hildonize_scrollwindow(scrollingWidget)
			scroller.show_all()

		# Simplify the UI
		if hildonize.IS_HILDON_SUPPORTED or constants.FORCE_HILDON_LIKE:
			self._categoryView.get_parent().hide()
			self._unitsView.set_headers_visible(False)
			self._previousUnitName.get_parent().hide()
			self._unitDescription.get_parent().get_parent().hide()
		else:
			self._categorySelectionButton.hide()

		menu = hildonize.hildonize_menu(
			self._mainWindow,
			widgets.get_widget("mainMenuBar"),
		)
		if not hildonize.GTK_MENU_USED:
			button = gtk.Button("Search")
			button.connect("clicked", self._on_toggle_search)
			menu.append(button)

			button = hildonize.hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, None)
			button.set_label("Name")
			menu.add_filter(button)
			button.connect("clicked", self._on_click_menu_filter, self._unitNameColumn)
			button.set_mode(False)
			filterGroup = button

			button = hildonize.hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, filterGroup)
			button.set_label("Value")
			menu.add_filter(button)
			button.connect("clicked", self._on_click_menu_filter, self._unitIntegerColumn)
			button.set_mode(False)

			button = hildonize.hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, filterGroup)
			button.set_label("Unit")
			menu.add_filter(button)
			button.connect("clicked", self._on_click_menu_filter, self._unitSymbolColumn)
			button.set_mode(False)

			menu.show_all()

		if not hildonize.IS_HILDON_SUPPORTED:
			_moduleLogger.info("No hildonization support")

		hildonize.set_application_title(
			self._mainWindow, "%s - Unit Conversion Utility" % constants.__pretty_app_name__
		)
		iconPath = pixmapspath + '/gonvert.png'
		if os.path.exists(iconPath):
			self._mainWindow.set_icon(gtk.gdk.pixbuf_new_from_file(iconPath))
		else:
			_moduleLogger.warn("Error: Could not find gonvert icon: %s" % iconPath)

		self._load_settings()
		self._mainWindow.show()
Esempio n. 5
0
	def __init__(self):
		self._unitDataInCategory = None
		self._unit_sort_direction = False
		self._value_sort_direction = False
		self._units_sort_direction = False
		self._isFullScreen = False

		self._find_result = [] # empty find result list
		self._findIndex = 0 # default to find result number zero

		self._selectedCategoryName = '' # preset to no selected category
		self._defaultUnitForCategory = {} # empty dictionary for later use

		#check to see if glade file is in current directory (user must be
		# running from download untar directory)
		for gladePath in self._glade_files:
			if os.path.isfile(gladePath):
				homepath = os.path.dirname(gladePath)
				pixmapspath = "/".join((homepath, "pixmaps"))
				widgets = gtk.glade.XML(gladePath)
				break
		else:
			_moduleLogger.error("UI Descriptor not found!")
			gtk.main_quit()
			return

		self._mainWindow = widgets.get_widget('mainWindow')
		self._app = hildonize.get_app_class()()
		self._mainWindow = hildonize.hildonize_window(self._app, self._mainWindow)

		change_menu_label(widgets, 'fileMenuItem', _('File'))
		change_menu_label(widgets, 'exitMenuItem', _('Exit'))
		change_menu_label(widgets, 'toolsMenuItem', _('Tools'))
		change_menu_label(widgets, 'clearSelectionMenuItem', _('Clear selections'))
		change_menu_label(widgets, 'helpMenuItem', _('Help'))
		change_menu_label(widgets, 'aboutMenuItem', _('About'))
		change_menu_label(widgets, 'findButton', _('Find'))

		self._shortlistcheck = widgets.get_widget('shortlistcheck')
		self._toggleShortList = widgets.get_widget('toggleShortList')

		self._categorySelectionButton = widgets.get_widget("categorySelectionButton")
		self._categoryView = widgets.get_widget('categoryView')

		self._unitsView = widgets.get_widget('unitsView')
		self._unitsView.set_property('rules_hint', 1)
		self._unitsView_selection = self._unitsView.get_selection()

		self._unitName = widgets.get_widget('unitName')
		self._unitValue = widgets.get_widget('unitValue')
		self._previousUnitName = widgets.get_widget('previousUnitName')
		self._previousUnitValue = widgets.get_widget('previousUnitValue')

		self._unitSymbol = widgets.get_widget('unitSymbol')
		self._previousUnitSymbol = widgets.get_widget('previousUnitSymbol')

		self._unitDescription = widgets.get_widget('unitDescription')

		self._searchLayout = widgets.get_widget('searchLayout')
		self._searchLayout.hide()
		self._findEntry = widgets.get_widget('findEntry')
		self._findLabel = widgets.get_widget('findLabel')
		self._findButton = widgets.get_widget('findButton')

		#insert a self._categoryColumnumn into the units list even though the heading will not be seen
		renderer = gtk.CellRendererText()
		renderer.set_property("ellipsize", pango.ELLIPSIZE_END)
		renderer.set_property("width-chars", len("grams per cubic cm plus some"))
		hildonize.set_cell_thumb_selectable(renderer)
		self._unitNameColumn = gtk.TreeViewColumn(_('Name'), renderer)
		self._unitNameColumn.set_property('resizable', 1)
		self._unitNameColumn.add_attribute(renderer, 'text', self.UNITS_NAME_IDX)
		self._unitNameColumn.set_clickable(True)
		self._unitNameColumn.connect("clicked", self._on_click_unit_column)
		self._unitsView.append_column(self._unitNameColumn)

		renderer = gtk.CellRendererText()
		hildonize.set_cell_thumb_selectable(renderer)
		self._unitValueColumn = gtk.TreeViewColumn(_('Value'), renderer)
		self._unitValueColumn.set_property('resizable', 1)
		self._unitValueColumn.add_attribute(renderer, 'text', self.UNITS_VALUE_IDX)
		self._unitValueColumn.set_clickable(True)
		self._unitValueColumn.connect("clicked", self._on_click_unit_column)
		self._unitsView.append_column(self._unitValueColumn)

		renderer = gtk.CellRendererText()
		renderer.set_property("ellipsize", pango.ELLIPSIZE_END)
		renderer.set_property("width-chars", len("G ohm plus some"))
		hildonize.set_cell_thumb_selectable(renderer)
		self._unitSymbolColumn = gtk.TreeViewColumn(_('Units'), renderer)
		self._unitSymbolColumn.set_property('resizable', 1)
		self._unitSymbolColumn.add_attribute(renderer, 'text', self.UNITS_SYMBOL_IDX)
		self._unitSymbolColumn.set_clickable(True)
		self._unitSymbolColumn.connect("clicked", self._on_click_unit_column)
		self._unitsView.append_column(self._unitSymbolColumn)

		self._unitModel = gtk.ListStore(
			gobject.TYPE_STRING, # UNITS_NAME_IDX
			gobject.TYPE_STRING, # UNITS_VALUE_IDX
			gobject.TYPE_STRING, # UNITS_SYMBOL_IDX
		)
		self._sortedUnitModel = gtk.TreeModelSort(self._unitModel)
		columns = self._get_column_sort_stuff()
		for columnIndex, (column, sortDirection, col_cmp) in enumerate(columns):
			self._sortedUnitModel.set_sort_func(columnIndex, col_cmp)
		self._unitsView.set_model(self._sortedUnitModel)

		#Insert a column into the category list even though the heading will not be seen
		renderer = gtk.CellRendererText()
		self._categoryColumn = gtk.TreeViewColumn('Title', renderer)
		self._categoryColumn.set_property('resizable', 1)
		self._categoryColumn.add_attribute(renderer, 'text', 0)
		self._categoryView.append_column(self._categoryColumn)

		self._categoryModel = gtk.ListStore(gobject.TYPE_STRING)
		self._categoryView.set_model(self._categoryModel)
		#colourize each row differently for easier reading
		self._categoryView.set_property('rules_hint', 1)

		#Populate the catagories list
		for key in unit_data.UNIT_CATEGORIES:
			row = (key, )
			self._categoryModel.append(row)

		#--------- connections to GUI ----------------
		dic = {
			"on_exit_menu_activate": self._on_user_exit,
			"on_categoryView_select_row": self._on_click_category,
			"on_unitValue_changed": self._on_unit_value_changed,
			"on_previousUnitValue_changed": self._on_previous_unit_value_changed,
			"on_findButton_clicked": self._on_find_activate,
			"on_findEntry_activated": self._on_find_activate,
			"on_findEntry_changed": self._on_findEntry_changed,
			"on_aboutMenuItem_activate": self._on_about_clicked,
			"on_clearSelectionMenuItem_activate": self._on_user_clear_selections,
			"on_unitsView_cursor_changed": self._on_click_unit,
			"on_shortlistcheck_toggled": self._on_shortlist_changed,
			"on_toggleShortList_activate": self._on_edit_shortlist,
		}
		widgets.signal_autoconnect(dic)
		self._mainWindow.connect("delete-event", self._on_user_exit)
		self._mainWindow.connect("key-press-event", self._on_key_press)
		self._mainWindow.connect("window-state-event", self._on_window_state_change)
		self._categorySelectionButton.connect("clicked", self._on_category_selector_clicked)

		for scrollingWidgetName in (
			"unitsViewScrolledWindow",
		):
			scrollingWidget = widgets.get_widget(scrollingWidgetName)
			assert scrollingWidget is not None, scrollingWidgetName
			hildonize.hildonize_scrollwindow_with_viewport(scrollingWidget)

		if hildonize.IS_HILDON_SUPPORTED or FORCE_HILDON_LIKE:
			self._categoryView.get_parent().hide()
			self._unitsView.set_headers_visible(False)
			self._previousUnitName.get_parent().hide()
			self._unitDescription.get_parent().get_parent().hide()
		else:
			self._categorySelectionButton.hide()

		replacementButtons = []
		menu = hildonize.hildonize_menu(
			self._mainWindow,
			widgets.get_widget("mainMenuBar"),
			replacementButtons
		)
		if not hildonize.IS_HILDON_SUPPORTED:
			_moduleLogger.info("No hildonization support")

		hildonize.set_application_title(
			self._mainWindow, "%s - Unit Conversion Utility" % constants.__pretty_app_name__
		)
		iconPath = pixmapspath + '/gonvert.png'
		if os.path.exists(iconPath):
			self._mainWindow.set_icon(gtk.gdk.pixbuf_new_from_file(iconPath))
		else:
			_moduleLogger.warn("Error: Could not find gonvert icon: %s" % iconPath)

		self._load_settings()
		self._mainWindow.show()
Esempio n. 6
0
class QuicknoteProgram(hildonize.get_app_class()):

	_user_data = os.path.join(os.path.expanduser("~"), ".%s" % constants.__app_name__)
	_user_settings = "%s/settings.ini" % _user_data

	def __init__(self):
		super(QuicknoteProgram, self).__init__()
		self._clipboard = gtk.clipboard_get()

		_moduleLogger.info('Starting quicknote')
		self._wordWrapEnabled = False

		self._window_in_fullscreen = False #The window isn't in full screen mode initially.

		self._db = speichern.Speichern()

		#Create GUI main vbox
		vbox = gtk.VBox(homogeneous = False, spacing = 0)

		if hildonize.GTK_MENU_USED:
			#Create Menu and apply it for hildon
			filemenu = gtk.Menu()

			menu_items = gtk.MenuItem(_("Set DB file"))
			filemenu.append(menu_items)
			menu_items.connect("activate", self.set_db_file, None)

			menu_items = gtk.MenuItem(_("SQL History"))
			filemenu.append(menu_items)
			menu_items.connect("activate", self._on_view_sql_history, None)

			menu_items = gtk.MenuItem(_("Sync notes"))
			filemenu.append(menu_items)
			menu_items.connect("activate", self._on_sync_notes, None)

			menu_items = gtk.MenuItem(_("Quit"))
			filemenu.append(menu_items)
			menu_items.connect("activate", self._on_destroy, None)

			file_menu = gtk.MenuItem(_("File"))
			file_menu.show()
			file_menu.set_submenu(filemenu)

			categorymenu = gtk.Menu()

			menu_items = gtk.MenuItem(_("Search"))
			categorymenu.append(menu_items)
			menu_items.connect("activate", self._on_toggle_search)

			menu_items = gtk.MenuItem(_("Delete"))
			categorymenu.append(menu_items)
			menu_items.connect("activate", self._on_delete_category)

			category_menu = gtk.MenuItem(_("Category"))
			category_menu.show()
			category_menu.set_submenu(categorymenu)

			viewmenu = gtk.Menu()

			menu_items = gtk.MenuItem(_("Move To Category"))
			viewmenu.append(menu_items)
			menu_items.connect("activate", self._on_move_category)

			menu_items = gtk.MenuItem(_("History"))
			viewmenu.append(menu_items)
			menu_items.connect("activate", self._on_show_history)

			menu_items = gtk.MenuItem(_("Word Wrap"))
			viewmenu.append(menu_items)
			menu_items.connect("activate", self._on_toggle_word_wrap)

			view_menu = gtk.MenuItem(_("Note"))
			view_menu.show()
			view_menu.set_submenu(viewmenu)

			helpmenu = gtk.Menu()

			menu_items = gtk.MenuItem(_("About"))
			helpmenu.append(menu_items)
			menu_items.connect("activate", self._on_show_about, None)

			help_menu = gtk.MenuItem(_("Help"))
			help_menu.show()
			help_menu.set_submenu(helpmenu)

			menuBar = gtk.MenuBar()
			menuBar.show()
			menuBar.append (file_menu)
			menuBar.append (category_menu)
			menuBar.append (view_menu)
			menuBar.append (help_menu)

			vbox.pack_start(menuBar, False, False, 0)
		else:
			menuBar = gtk.MenuBar()
			menuBar.show()
			vbox.pack_start(menuBar, False, False, 0)

		#Create GUI elements
		self._category = kopfzeile.Kopfzeile(self._db)
		self._search = search.Search()
		self._notizen = notizen.Notizen(self._db, self._category, self._search)

		# notizen packs in the category
		vbox.pack_start(self._notizen, expand = True, fill = True)
		vbox.pack_start(self._search, expand = False, fill = True)

		#Get the Main Window, and connect the "destroy" event
		self._window = gtk.Window()
		self._window.add(vbox)

		self._on_toggle_word_wrap()

		try:
			os.makedirs(self._user_data)
		except OSError, e:
			if e.errno != 17:
				raise

		self._window = hildonize.hildonize_window(self, self._window)
		hildonize.set_application_title(self._window, "%s" % constants.__pretty_app_name__)
		menuBar = hildonize.hildonize_menu(
			self._window,
			menuBar,
		)
		if hildonize.IS_FREMANTLE_SUPPORTED:
			moveToCategoryButton = gtk.Button(_("Move Note"))
			moveToCategoryButton.connect("clicked", self._on_move_category)
			menuBar.append(moveToCategoryButton)

			historyButton = gtk.Button(_("Note History"))
			historyButton.connect("clicked", self._on_show_history)
			menuBar.append(historyButton)

			searchButton= gtk.Button(_("Search Category"))
			searchButton.connect("clicked", self._on_toggle_search)
			menuBar.append(searchButton)

			deleteCategoryButton = gtk.Button(_("Delete Category"))
			deleteCategoryButton.connect("clicked", self._on_delete_category)
			menuBar.append(deleteCategoryButton)

			menuBar.show_all()

		if not hildonize.IS_HILDON_SUPPORTED:
			_moduleLogger.info("No hildonization support")

		if osso is not None:
			self._osso_c = osso.Context(constants.__app_name__, constants.__version__, False)
			self._deviceState = osso.DeviceState(self._osso_c)
			self._deviceState.set_device_state_callback(self._on_device_state_change, 0)
		else:
			_moduleLogger.info("No osso support")
			self._osso_c = None
			self._deviceState = None

		self._window.connect("delete-event", self._on_delete_event)
		self._window.connect("destroy", self._on_destroy)
		self._window.connect("key-press-event", self._on_key_press)
		self._window.connect("window-state-event", self._on_window_state_change)

		self._window.show_all()
		self._search.hide()
		self._load_settings()
Esempio n. 7
0
	def __init__(self):
		self._initDone = False
		self._connection = None
		self._osso = None
		self._deviceState = None
		self._clipboard = gtk.clipboard_get()

		self._credentials = ("", "")
		self._selectedBackendId = self.NULL_BACKEND
		self._defaultBackendId = self.GV_BACKEND
		self._phoneBackends = None
		self._dialpads = None
		self._accountViews = None
		self._messagesViews = None
		self._historyViews = None
		self._contactsViews = None
		self._alarmHandler = None
		self._ledHandler = None
		self._originalCurrentLabels = []
		self._fsContactsPath = os.path.join(constants._data_path_, "contacts")

		for path in self._glade_files:
			if os.path.isfile(path):
				self._widgetTree = gtk.glade.XML(path)
				break
		else:
			display_error_message("Cannot find dialcentral.glade")
			gtk.main_quit()
			return

		self._window = self._widgetTree.get_widget("mainWindow")
		self._notebook = self._widgetTree.get_widget("notebook")
		errorBox = self._widgetTree.get_widget("errorEventBox")
		errorDescription = self._widgetTree.get_widget("errorDescription")
		errorClose = self._widgetTree.get_widget("errorClose")
		self._errorDisplay = gtk_toolbox.ErrorDisplay(errorBox, errorDescription, errorClose)
		self._credentialsDialog = gtk_toolbox.LoginWindow(self._widgetTree)
		self._smsEntryWindow = None

		self._isFullScreen = False
		self.__isPortrait = False
		self._app = hildonize.get_app_class()()
		self._window = hildonize.hildonize_window(self._app, self._window)
		hildonize.hildonize_text_entry(self._widgetTree.get_widget("usernameentry"))
		hildonize.hildonize_password_entry(self._widgetTree.get_widget("passwordentry"))

		for scrollingWidgetName in (
			'history_scrolledwindow',
			'message_scrolledwindow',
			'contacts_scrolledwindow',
			"smsMessages_scrolledwindow",
		):
			scrollingWidget = self._widgetTree.get_widget(scrollingWidgetName)
			assert scrollingWidget is not None, scrollingWidgetName
			hildonize.hildonize_scrollwindow(scrollingWidget)
		for scrollingWidgetName in (
			"smsMessage_scrolledEntry",
		):
			scrollingWidget = self._widgetTree.get_widget(scrollingWidgetName)
			assert scrollingWidget is not None, scrollingWidgetName
			hildonize.hildonize_scrollwindow_with_viewport(scrollingWidget)

		for buttonName in (
			"back",
			"addressbookSelectButton",
			"sendSmsButton",
			"dialButton",
			"callbackSelectButton",
			"minutesEntryButton",
			"clearcookies",
			"phoneTypeSelection",
		):
			button = self._widgetTree.get_widget(buttonName)
			assert button is not None, buttonName
			hildonize.set_button_thumb_selectable(button)

		menu = hildonize.hildonize_menu(
			self._window,
			self._widgetTree.get_widget("dialpad_menubar"),
		)
		if not hildonize.GTK_MENU_USED:
			button = gtk.Button("New Login")
			button.connect("clicked", self._on_clearcookies_clicked)
			menu.append(button)

			button = gtk.Button("Refresh")
			button.connect("clicked", self._on_menu_refresh)
			menu.append(button)

			menu.show_all()

		self._window.connect("key-press-event", self._on_key_press)
		self._window.connect("window-state-event", self._on_window_state_change)
		if not hildonize.IS_HILDON_SUPPORTED:
			_moduleLogger.warning("No hildonization support")

		hildonize.set_application_name("%s" % constants.__pretty_app_name__)

		self._window.connect("destroy", self._on_close)
		self._window.set_default_size(800, 300)
		self._window.show_all()

		self._loginSink = gtk_toolbox.threaded_stage(
			gtk_toolbox.comap(
				self._attempt_login,
				gtk_toolbox.null_sink(),
			)
		)

		if not PROFILE_STARTUP:
			backgroundSetup = threading.Thread(target=self._idle_setup)
			backgroundSetup.setDaemon(True)
			backgroundSetup.start()
		else:
			self._idle_setup()
Esempio n. 8
0
File: Gui.py Progetto: epage/nqaap
    def setup(self):
        self._app = hildonize.get_app_class()()
        self.win = gtk.Window()
        self.win = hildonize.hildonize_window(self._app, self.win)
        self.win.set_title(constants.__pretty_app_name__)

        # Cover image
        self.cover = gtk.Image()

        # Controls:

        # Label that hold the title of the book,and maybe the chapter
        self.title = gtk.Label()
        self.title.set_justify(gtk.JUSTIFY_CENTER)
        self._set_display_title("Select a book to start listening")

        self.chapter = gtk.Label()
        self.chapter.set_justify(gtk.JUSTIFY_CENTER)

        # Seekbar
        if hildonize.IS_FREMANTLE_SUPPORTED:
            self.seek = hildon.Seekbar()
            self.seek.set_range(0.0, 100)
            self.seek.set_draw_value(False)
            self.seek.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
            self.seek.connect("change-value", self.seek_changed)  # event
            # self.seek.connect('value-changed',self.seek_changed) # event
        else:
            adjustment = gtk.Adjustment(0, 0, 101, 1, 5, 1)
            self.seek = gtk.HScale(adjustment)
            self.seek.set_draw_value(False)
            self.seek.connect("change-value", self.seek_changed)  # event

            # Pause button
        if hildonize.IS_FREMANTLE_SUPPORTED:
            self.backButton = hildon.Button(
                gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL
            )
            image = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PREVIOUS, gtk.HILDON_SIZE_FINGER_HEIGHT)
            self.backButton.set_image(image)

            self.button = hildon.Button(
                gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL
            )

            self.forwardButton = hildon.Button(
                gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL
            )
            image = gtk.image_new_from_stock(gtk.STOCK_MEDIA_NEXT, gtk.HILDON_SIZE_FINGER_HEIGHT)
            self.forwardButton.set_image(image)
        else:
            self.backButton = gtk.Button(stock=gtk.STOCK_MEDIA_PREVIOUS)
            self.button = gtk.Button()
            self.forwardButton = gtk.Button(stock=gtk.STOCK_MEDIA_NEXT)
        self.set_button_text("Play", "Start playing the audiobook")
        self.backButton.connect("clicked", self._on_previous_chapter)
        self.button.connect("clicked", self.play_pressed)  # event
        self.forwardButton.connect("clicked", self._on_next_chapter)

        self._toolbar = gtk.HBox()
        self._toolbar.pack_start(self.backButton, False, False, 0)
        self._toolbar.pack_start(self.button, True, True, 0)
        self._toolbar.pack_start(self.forwardButton, False, False, 0)

        # Box to hold the controls:
        self._controlLayout = gtk.VBox()
        self._controlLayout.pack_start(gtk.Label(), True, True, 0)
        self._controlLayout.pack_start(self.title, False, True, 0)
        self._controlLayout.pack_start(self.chapter, False, True, 0)
        self._controlLayout.pack_start(gtk.Label(), True, True, 0)
        self._controlLayout.pack_start(self.seek, False, True, 0)
        self._controlLayout.pack_start(self._toolbar, False, True, 0)

        # Box that divides the layout in two: cover on the lefta
        # and controls on the right
        self._viewLayout = gtk.HBox()
        self._viewLayout.pack_start(self.cover, True, True, 0)
        self._viewLayout.add(self._controlLayout)

        self._menuBar = gtk.MenuBar()
        self._menuBar.show()

        self._mainLayout = gtk.VBox()
        self._mainLayout.pack_start(self._menuBar, False, False, 0)
        self._mainLayout.pack_start(self._viewLayout)

        # Add hbox to the window
        self.win.add(self._mainLayout)

        # Menu:
        # Create menu
        self._populate_menu()

        self.win.connect("delete_event", self.quit)  # Add shutdown event
        self.win.connect("key-press-event", self.on_key_press)
        self.win.connect("window-state-event", self._on_window_state_change)

        self.win.show_all()

        # Run update timer
        self.setup_timers()