コード例 #1
0
ファイル: scriptures.py プロジェクト: epage/Waters-of-Shiloah
	def _get_columns(cls):
		yield gobject.TYPE_PYOBJECT, None

		textrenderer = gtk.CellRendererText()
		hildonize.set_cell_thumb_selectable(textrenderer)
		column = gtk.TreeViewColumn("Book")
		column.set_property("sizing", gtk.TREE_VIEW_COLUMN_FIXED)
		column.pack_start(textrenderer, expand=True)
		column.add_attribute(textrenderer, "text", 1)
		yield gobject.TYPE_STRING, column
コード例 #2
0
ファイル: magazines.py プロジェクト: epage/Waters-of-Shiloah
	def _get_columns(cls):
		yield gobject.TYPE_PYOBJECT, None

		pixrenderer = gtk.CellRendererPixbuf()
		column = gtk.TreeViewColumn("Covers")
		column.set_property("sizing", gtk.TREE_VIEW_COLUMN_FIXED)
		column.set_property("fixed-width", 96)
		column.pack_start(pixrenderer, expand=True)
		column.add_attribute(pixrenderer, "pixbuf", 1)
		yield gobject.TYPE_OBJECT, column

		textrenderer = gtk.CellRendererText()
		hildonize.set_cell_thumb_selectable(textrenderer)
		column = gtk.TreeViewColumn("Magazine")
		column.set_property("sizing", gtk.TREE_VIEW_COLUMN_FIXED)
		column.pack_start(textrenderer, expand=True)
		column.add_attribute(textrenderer, "text", 2)
		yield gobject.TYPE_STRING, column
コード例 #3
0
	def _get_columns(cls):
		yield gobject.TYPE_PYOBJECT, None

		textrenderer = gtk.CellRendererText()
		textrenderer.set_property("scale", 0.75)
		column = gtk.TreeViewColumn("Date")
		column.set_property("sizing", gtk.TREE_VIEW_COLUMN_FIXED)
		column.set_property("fixed-width", 96)
		column.pack_start(textrenderer, expand=True)
		column.add_attribute(textrenderer, "text", 1)
		yield gobject.TYPE_STRING, column

		textrenderer = gtk.CellRendererText()
		hildonize.set_cell_thumb_selectable(textrenderer)
		column = gtk.TreeViewColumn("Conference")
		column.set_property("sizing", gtk.TREE_VIEW_COLUMN_FIXED)
		column.pack_start(textrenderer, expand=True)
		column.add_attribute(textrenderer, "text", 2)
		yield gobject.TYPE_STRING, column
コード例 #4
0
ファイル: gonvert_glade.py プロジェクト: epage/gonvert-gtk
	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()
コード例 #5
0
ファイル: gonvert_glade.py プロジェクト: unihedron/Gonvert
	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()