def __init__(self, *args, **kwargs):
		self.label = Gtk.Label(self.label_text)
		super(CampaignViewDashboardTab, self).__init__(*args, **kwargs)
		self.last_load_time = float('-inf')
		self.load_lifetime = utilities.timedef_to_seconds('3m')
		self.loader_thread = None
		self.loader_thread_lock = threading.RLock()
		self.graphs = []

		# Position: (DefaultGraphName, Size)
		dash_ports = {
			'top_left': (380, 200),
			'top_right': (380, 200),
			'bottom': None
		}
		for dash_port, details in dash_ports.items():
			graph_name = self.config['dashboard.' + dash_port]
			Klass = graphs.get_graph(graph_name)
			if not Klass:
				self.logger.warning('could not get graph: ' + graph_name)
				continue
			graph_inst = Klass(self.config, self.parent, details)
			self.gobjects['scrolledwindow_' + dash_port].add_with_viewport(graph_inst.canvas)
			self.gobjects['box_' + dash_port].pack_end(graph_inst.navigation_toolbar, False, False, 0)
			self.graphs.append(graph_inst)
		GLib.timeout_add_seconds(self.load_lifetime, self.loader_idle_routine)
Ejemplo n.º 2
0
	def __init__(self, *args, **kwargs):
		self.label = Gtk.Label(label=self.label_text)
		"""The :py:class:`Gtk.Label` representing this tab with text from :py:attr:`~.CampaignViewGenericTab.label_text`."""
		super(CampaignViewGenericTab, self).__init__(*args, **kwargs)
		self.is_destroyed = threading.Event()
		getattr(self, self.top_gobject).connect('destroy', self.signal_destroy)

		self.last_load_time = float('-inf')
		"""The last time the data was loaded from the server."""
		self.refresh_frequency = utilities.timedef_to_seconds(str(self.config.get('gui.refresh_frequency', '5m')))
		"""The lifetime in seconds to wait before refreshing the data from the server."""
		self.loader_thread = None
		"""The thread object which loads the data from the server."""
		self.loader_thread_lock = threading.Lock()
		"""The :py:class:`threading.Lock` object used for synchronization between the loader and main threads."""
	def __init__(self, *args, **kwargs):
		self.label = Gtk.Label(self.label_text)
		super(CampaignViewGenericTab, self).__init__(*args, **kwargs)
		treeview = self.gobjects['treeview_campaign']
		treeview.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
		popup_copy_submenu = Gtk.Menu.new()
		self.view_column_renderers = {}
		columns = self.view_columns
		for column_id in range(1, len(columns) + 1):
			column_name = columns[column_id]
			column = Gtk.TreeViewColumn(column_name, Gtk.CellRendererText(), text=column_id)
			column.set_sort_column_id(column_id)
			treeview.append_column(column)
			self.view_column_renderers[column_id] = column

			menu_item = Gtk.MenuItem.new_with_label(column_name)
			menu_item.connect('activate', self.signal_activate_popup_menu_copy, column_id)
			popup_copy_submenu.append(menu_item)
		self.last_load_time = float('-inf')
		self.load_lifetime = utilities.timedef_to_seconds('3m')
		self.row_loader_thread = None
		self.row_loader_thread_lock = threading.Lock()
		self.is_destroyed = threading.Event()
		getattr(self, self.top_gobject).connect('destroy', self.signal_destroy)

		self.popup_menu = Gtk.Menu.new()
		menu_item = Gtk.MenuItem.new_with_label('Copy')
		menu_item.set_submenu(popup_copy_submenu)
		self.popup_menu.append(menu_item)

		menu_item = Gtk.SeparatorMenuItem()
		self.popup_menu.append(menu_item)

		menu_item = Gtk.MenuItem.new_with_label('Delete')
		menu_item.connect('activate', self.signal_activate_popup_menu_delete)
		self.popup_menu.append(menu_item)
		self.popup_menu.show_all()