コード例 #1
0
ファイル: starcal.py プロジェクト: greyzero/starcal
 def __init__(self, statusIconMode=2):
     #from gi.repository import Gio
     #self.app = gtk.Application(application_id="apps.starcal")
     #self.app.register(Gio.Cancellable.new())
     #gtk.ApplicationWindow.__init__(self, application=self.app)
     gtk.Window.__init__(self)
     self.add_events(gdk.EventMask.ALL_EVENTS_MASK)
     self.initVars()
     ud.windowList.appendItem(self)
     ui.mainWin = self
     ##################
     ## statusIconMode:
         ## ('none', 'none')
         ## ('statusIcon', 'normal')
         ## ('applet', 'gnome')
         ## ('applet', 'kde')
         ##
         ## 0: none (simple window)
         ## 1: applet
         ## 2: standard status icon
     self.statusIconMode = statusIconMode
     ###
     #ui.eventManDialog = None
     #ui.timeLineWin = None
     ###
     #ui.weekCalWin = WeekCalWindow()
     #ud.windowList.appendItem(ui.weekCalWin)
     ###
     self.dayInfoDialog = None
     #print('windowList.items', [item._name for item in ud.windowList.items])
     ###########
     ##self.connect('window-state-event', selfStateEvent)
     self.set_title('%s %s'%(core.APP_DESC, core.VERSION))
     #self.connect('main-show', lambda arg: self.present())
     #self.connect('main-hide', lambda arg: self.hide())
     self.set_decorated(False)
     self.set_property('skip-taskbar-hint', not ui.winTaskbar) ## self.set_skip_taskbar_hint  ## FIXME
     self.set_role('starcal')
     #self.set_focus_on_map(True)#????????
     #self.set_type_hint(gdk.WindowTypeHint.NORMAL)
     #self.connect('realize', self.onRealize)
     self.set_default_size(ui.winWidth, 1)
     try:
         self.move(ui.winX, ui.winY)
     except:
         pass
     #############################################################
     self.connect('focus-in-event', self.focusIn, 'Main')
     self.connect('focus-out-event', self.focusOut, 'Main')
     self.connect('button-press-event', self.buttonPress)
     self.connect('key-press-event', self.keyPress)
     self.connect('configure-event', self.configureEvent)
     self.connect('destroy', self.quit)
     #############################################################
     """
     #self.add_events(gdk.EventMask.VISIBILITY_NOTIFY_MASK)
     #self.connect('frame-event', show_event)
     ## Compiz does not send configure-event(or any event) when MOVING window(sends in last point,
     ## when moving completed)
     #self.connect('drag-motion', show_event)
     ud.rootWindow.set_events(...
     ud.rootWindow.add_filter(self.onRootWinEvent)
     #self.realize()
     #gdk.flush()
     #self.configureEvent(None, None)
     #self.connect('drag-motion', show_event)
     ######################
     ## ????????????????????????????????????????????????
     ## when button is down(before button-release-event), motion-notify-event does not recived!
     """
     ##################################################################
     self.focus = False
     #self.focusOutTime = 0
     #self.clockTr = None
     ############################################################################
     self.winCon = None
     ############
     self.vbox = MainWinVbox()
     ui.checkMainWinItems()
     itemsPkg = 'scal3.ui_gtk.mainwin_items'
     for (name, enable) in ui.mainWinItems:
         #print(name, enable)
         if enable:
             try:
                 module = __import__(
                     '.'.join([
                         itemsPkg,
                         name,
                     ]),
                     fromlist=['CalObj'],
                 )
                 CalObj = module.CalObj
             except:
                 myRaise()
                 continue
             item = CalObj()
             item.enable = enable
             item.connect('size-allocate', self.childSizeAllocate)
             #modify_bg_all(item, gtk.StateType.NORMAL, rgbToGdkColor(*ui.bgColor))
         else:
             desc = mainWinItemsDesc[name]
             item = DummyCalObj(name, desc, itemsPkg, True)
         self.vbox.appendItem(item)
     self.appendItem(self.vbox)
     self.vbox.show()
     self.customizeDialog = None
     #######
     self.add(self.vbox)
     ####################
     self.isMaximized = False
     ####################
     #ui.prefDialog = None
     self.exportDialog = None
     self.selectDateDialog = None
     ############### Building About Dialog
     self.aboutDialog = None
     ###############
     self.menuMain = None
     #####
     check = gtk.CheckMenuItem(label=_('_On Top'))
     check.set_use_underline(True)
     check.connect('activate', self.keepAboveClicked)
     check.set_active(ui.winKeepAbove)
     self.set_keep_above(ui.winKeepAbove)
     self.checkAbove = check
     #####
     check = gtk.CheckMenuItem(label=_('_Sticky'))
     check.set_use_underline(True)
     check.connect('activate', self.stickyClicked)
     check.set_active(ui.winSticky)
     if ui.winSticky:
         self.stick()
     self.checkSticky = check
     ############################################################
     self.statusIconInit()
     listener.dateChange.add(self)
     #if self.statusIconMode!=1:
     #    gobject.timeout_add_seconds(self.timeout, self.statusIconUpdate)
     #########
     self.connect('delete-event', self.onDeleteEvent)
     #########################################
     for plug in core.allPlugList:
         if plug.external:
             try:
                 plug.set_dialog(self)
             except AttributeError:
                 pass
     ###########################
     self.onConfigChange()
コード例 #2
0
ファイル: starcal.py プロジェクト: ubuntu-ir/starcal
	def __init__(self, statusIconMode=2):
		#from gi.repository import Gio
		#self.app = gtk.Application(application_id="apps.starcal")
		#self.app.register(Gio.Cancellable.new())
		#gtk.ApplicationWindow.__init__(self, application=self.app)
		gtk.Window.__init__(self)
		self.add_events(gdk.EventMask.ALL_EVENTS_MASK)
		self.initVars()
		ud.windowList.appendItem(self)
		ui.mainWin = self
		##################
		## statusIconMode:
			## ('none', 'none')
			## ('statusIcon', 'normal')
			## ('applet', 'gnome')
			## ('applet', 'kde')
			##
			## 0: none (simple window)
			## 1: applet
			## 2: standard status icon
		self.statusIconMode = statusIconMode
		###
		#ui.eventManDialog = None
		#ui.timeLineWin = None
		###
		#ui.weekCalWin = WeekCalWindow()
		#ud.windowList.appendItem(ui.weekCalWin)
		###
		self.dayInfoDialog = None
		#print('windowList.items', [item._name for item in ud.windowList.items])
		###########
		##self.connect('window-state-event', selfStateEvent)
		self.set_title('%s %s'%(core.APP_DESC, core.VERSION))
		#self.connect('main-show', lambda arg: self.present())
		#self.connect('main-hide', lambda arg: self.hide())
		self.set_decorated(False)
		self.set_property('skip-taskbar-hint', not ui.winTaskbar) ## self.set_skip_taskbar_hint  ## FIXME
		self.set_role('starcal')
		#self.set_focus_on_map(True)#????????
		#self.set_type_hint(gdk.WindowTypeHint.NORMAL)
		#self.connect('realize', self.onRealize)
		self.set_default_size(ui.winWidth, 1)
		try:
			self.move(ui.winX, ui.winY)
		except:
			pass
		#############################################################
		self.connect('focus-in-event', self.focusIn, 'Main')
		self.connect('focus-out-event', self.focusOut, 'Main')
		self.connect('button-press-event', self.buttonPress)
		self.connect('key-press-event', self.keyPress)
		self.connect('configure-event', self.configureEvent)
		self.connect('destroy', self.quit)
		#############################################################
		"""
		#self.add_events(gdk.EventMask.VISIBILITY_NOTIFY_MASK)
		#self.connect('frame-event', show_event)
		## Compiz does not send configure-event(or any event) when MOVING window(sends in last point,
		## when moving completed)
		#self.connect('drag-motion', show_event)
		ud.rootWindow.set_events(...
		ud.rootWindow.add_filter(self.onRootWinEvent)
		#self.realize()
		#gdk.flush()
		#self.configureEvent(None, None)
		#self.connect('drag-motion', show_event)
		######################
		## ????????????????????????????????????????????????
		## when button is down(before button-release-event), motion-notify-event does not recived!
		"""
		##################################################################
		self.focus = False
		#self.focusOutTime = 0
		#self.clockTr = None
		############################################################################
		self.winCon = None
		############
		self.vbox = MainWinVbox()
		ui.checkMainWinItems()
		itemsPkg = 'scal3.ui_gtk.mainwin_items'
		for (name, enable) in ui.mainWinItems:
			#print(name, enable)
			if enable:
				try:
					module = __import__(
						'.'.join([
							itemsPkg,
							name,
						]),
						fromlist=['CalObj'],
					)
					CalObj = module.CalObj
				except:
					myRaise()
					continue
				item = CalObj()
				item.enable = enable
				item.connect('size-allocate', self.childSizeAllocate)
				#modify_bg_all(item, gtk.StateType.NORMAL, rgbToGdkColor(*ui.bgColor))
			else:
				desc = mainWinItemsDesc[name]
				item = DummyCalObj(name, desc, itemsPkg, True)
			self.vbox.appendItem(item)
		self.appendItem(self.vbox)
		self.vbox.show()
		self.customizeDialog = None
		#######
		self.add(self.vbox)
		####################
		self.isMaximized = False
		####################
		#ui.prefDialog = None
		self.exportDialog = None
		self.selectDateDialog = None
		############### Building About Dialog
		self.aboutDialog = None
		###############
		self.menuMain = None
		#####
		check = gtk.CheckMenuItem(label=_('_On Top'))
		check.set_use_underline(True)
		check.connect('activate', self.keepAboveClicked)
		check.set_active(ui.winKeepAbove)
		self.set_keep_above(ui.winKeepAbove)
		self.checkAbove = check
		#####
		check = gtk.CheckMenuItem(label=_('_Sticky'))
		check.set_use_underline(True)
		check.connect('activate', self.stickyClicked)
		check.set_active(ui.winSticky)
		if ui.winSticky:
			self.stick()
		self.checkSticky = check
		############################################################
		self.statusIconInit()
		listener.dateChange.add(self)
		#if self.statusIconMode!=1:
		#	gobject.timeout_add_seconds(self.timeout, self.statusIconUpdate)
		#########
		self.connect('delete-event', self.onDeleteEvent)
		#########################################
		for plug in core.allPlugList:
			if plug.external:
				try:
					plug.set_dialog(self)
				except AttributeError:
					pass
		###########################
		self.onConfigChange()