KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /usr/lib64/pygtk/2.0/demos/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib64/pygtk/2.0/demos/changedisplay.pyo
mò
e‡8Hc@s»dZdkZdkZedƒ\ZZZedƒ\ZZZ	d„Z
deifd„ƒYZdei
fd„ƒYZdeifd	„ƒYZd
„ZedjoeƒndS(s©Change Display

Demonstrates migrating a window between different displays and
screens. A display is a mouse and keyboard with some number of
associated monitors. A screen is a set of monitors grouped
into a single physical work area. The neat thing about having
multiple displays is that they can be on a completely separate
computers, as long as there is a network connection to the
computer where the application is running.

Only some of the windowing systems where GTK+ runs have the
concept of multiple displays and screens. (The X Window System
is the main example.) Other windowing systems can only
handle one keyboard and mouse, and combine all monitors into
a single screen.

This is a moderately complex example, and demonstrates:

- Tracking the currently open displays and screens
- Changing the screen for a window
- Letting the user choose a window by clicking on it
- Using GtkListStore and GtkTreeView
- Using GtkDialog
NicCs?|iƒd}|o|iƒ}n|o
|iƒpdS(s@ Finds the toplevel window under the mouse pointer, if any.
    iN(tdisplaytget_window_at_pointertpointer_windowt
get_user_datatwidgettget_topleveltNone(RRR((t+/usr/lib64/pygtk/2.0/demos/changedisplay.pytfind_toplevel_at_pointer,s
tQueryForToplevelcBs)tZdZd„Zd„Zd„ZRS(sÄ Asks the user to click on a window, then waits for them click
        the mouse. When the mouse is released, returns the toplevel
        window under the pointer, or NULL, if there is none.
    cCs£tii|tiƒ|i|ƒ|itƒ|i	ti
ƒtiƒ}|i
tiƒ|i|ƒti|ƒ}|iddƒ|i|ƒ|iƒdS(Ni
(tgtktWindowt__init__tselftWINDOW_POPUPt
set_screentscreent	set_modaltTruetset_positiontWIN_POS_CENTERtFrametframetset_shadow_typet
SHADOW_OUTtaddtLabeltprompttlabeltset_paddingtshow_all(R
RRRR((RR?s



cCsð|iƒiƒ}tii|tiiƒ}t	i
ƒ}tii|i
ttiid|ƒtiijoht|_|id|iƒx"|itjo|itƒqŒWt|ƒ}||jo
d}qÕn|iƒtiiƒ|S(Nsbutton-release-event(R
t
get_screentget_displayRR
tgdktCursort	CROSSHAIRtcursortgobjecttmain_context_defaulttmain_contexttpointer_grabtwindowtFalsetBUTTON_RELEASE_MASKRtGRAB_SUCCESSt
query_clickedtconnecttbutton_release_event_cbt	iterationRRttopleveltdestroytflush(R
R$R1R'R((RtrunOs "	


cCs
t|_tS(N(RR
R-(R
twinreftevent((RR/is	(t__name__t
__module__t__doc__RR4R/(((RR	9s		tLeftAlignButtoncBstZdZd„ZRS(s½ If we have a stack of buttons, it often looks better if their contents
        are left-aligned, rather than centered. This class creates a button
        and left-aligns it contents.
    cCs7tii||ƒ|iƒd}|iddƒdS(Nif0.0f0.5(R
tButtonRR
Rtget_childrentchildt
set_alignment(R
RR=((RRss(R7R8R9R(((RR:nstChangeDisplayDemocBsÈtZdZdZdZdZdZdZdd„Z	d„Z
d„Zd„Zd„Z
d„Zd„Zd„Zd	„Zd
„Zd„Zd„Zd
„Zd„Zd„Zd„Zd„ZRS(Nc	Cs>tii|d|tititidtifƒ|i	ddƒy|i
|iƒƒWn&tj
o|i
dd„ƒnX|i
d|iƒ|i
d|iƒtitdƒ}|id	ƒ|ii|ttd
ƒ|iƒ}|i|ttd
ƒ|iƒ}|i|ttd
ƒ|iƒ|iƒdS(NsChange Screen or displaytChangei,iR2cGs
tiƒS(N(R
t	main_quit(tw((Rt<lambda>Žstresponseiii(R
tDialogRR
tparenttDIALOG_NO_SEPARATORtSTOCK_CLOSEtRESPONSE_CLOSEtRESPONSE_OKtset_default_sizeRRtAttributeErrorR.tresponse_cbt
destroy_cbtVBoxR*tvboxtset_border_widtht
pack_startRt(_ChangeDisplayDemo__create_display_frameRt'_ChangeDisplayDemo__create_screen_framet'_ChangeDisplayDemo__initialize_displaysR(R
RFRPR((RR„s&

cCsbtiiƒ}|iƒ}x|D]}|i|ƒq"W|i	d|i
ƒ}|id|ƒdS(sÄ Adds all currently open displays to our list of displays,
            and set up a signal connection so that we'll be notified
            when displays are opened in the future as well.
        tdisplay_openeds
user-callbackN(
R
R!tdisplay_manager_gettmanagert
list_displaystdisplaystitemR
tadd_displayR.tdisplay_opened_cbtidtset_data(R
R[RXRZR^((Rt__initialize_displays¡scCs3ti|ƒ}titdƒ}|idƒ|i|ƒti	ƒ}|ititi
ƒ|itiƒ|i|ttdƒtiƒ}|itƒ|i|ƒ|iƒ}|itiƒtitdƒ}|i|ttdƒ|idjotitiƒ|_n|ii |ƒ|||fS(s This function is used both for creating the "Display" and
            "Screen" frames, since they have a similar structure. The
            caller hooks up the right context for the value returned
            in tree_view, and packs any relevant buttons into button_vbox.
        iiiN(!R
RttitleRtHBoxR*thboxRQRtScrolledWindowt	scrollwint
set_policytPOLICY_NEVERtPOLICY_AUTOMATICRt	SHADOW_INRRRtTreeViewt	tree_viewtset_headers_visiblet
get_selectiont	selectiontset_modetSELECTION_BROWSEROtbutton_vboxR
t
size_groupRt	SizeGrouptSIZE_GROUP_HORIZONTALt
add_widget(R
RaRnRqRkReRRc((Rt__create_frame®s(



cCsõ|idƒ\}}}tdƒ}|id|iƒ|i	|t
t
dƒtdƒ}|id|iƒ|i	|t
t
dƒti
ttƒ|_|i|iƒtidtiƒdtƒ}|i|ƒ|iƒ}|id|iƒ|S(
s9 Creates the "Display" frame in the main window.
        tDisplays_Open...tclickedit_ClosetNamettexttchangedN(R
t _ChangeDisplayDemo__create_frameRRkRqR:tbuttonR.topen_display_cbRRR*tclose_display_cbR
t	ListStoretstrtobjectt
display_modelt	set_modeltTreeViewColumntCellRendererTexttDISPLAY_COLUMN_NAMEtcolumnt
append_columnRmRntdisplay_changed_cb(R
R‰R~RqRkRnR((Rt__create_display_frameÑs 
cCs‘|idƒ\}}}tittƒ|_	|i
|i	ƒtidtiƒdt
ƒ}|i|ƒ|iƒ|_|iid|iƒ|S(s8 Creates the "Screen" frame in the main window.
        tScreentNumberR{R|N(R
R}RRkRqR
RtintRƒtscreen_modelR…R†R‡tSCREEN_COLUMN_NUMBERR‰RŠRmtscreen_selectionR.tscreen_changed_cb(R
R‰RqRkR((Rt__create_screen_frameês
cCsY|iiƒ}t|dƒiƒ}|dj	o|i|i	ƒn|i
ƒiƒdS(s‚ Prompts the user for a toplevel window to move, and then moves
            that window to the currently selected display
        s4Please select the toplevel
to move to the new screenN(R
R)RRR	R4R1RRtcurrent_screenR tbeep(R
R1R((Rtquery_change_displayûs
cCs,|tijo|iƒn|iƒdS(sÇ Called when the user clicks on a button in our dialog or
            closes the dialog through the window manager. Unless the
            "Change" button was clicked, we destroy the dialog.
        N(tresponse_idR
RJR
R—tdialogR2(R
R™R˜((RRM
sc	CsNtid|tititititifƒ}|i	tiƒti
ƒ}|it
ƒtidƒ}|ii|ƒ|ii|ƒ|iƒ|iƒd}x˜|djoŠ|iƒ}|tijoPn|iddƒ}|GH|djoAtii|ƒ}|djod|f}|i|ƒq;q¨q¨W|iƒdS(s¨ Called when the user clicks on "Open..." in the display
            frame. Prompts for a new display, and then opens a connection
            to that display.
        sOpen Displays)Please enter the name of
the new display
iiÿÿÿÿts0Can't open display :
	%s
please try another one
N(R
RER
tDIALOG_MODALtSTOCK_CANCELtRESPONSE_CANCELtSTOCK_OKRJR™tset_default_responsetEntryt
display_entrytset_activates_defaultRRtdialog_labelRPRt
grab_focusRRtresultR4R˜t	get_charstnew_screen_nameR!Rwt	error_msgtset_textR2(	R
R~R¨R¡R˜R¥R™R£R§((RRs2!






cCs|io|iiƒndS(s| Called when the user clicks on the "Close" button in the
            "Display" frame. Closes the selected display.
        N(R
tcurrent_displaytclose(R
R~((RR€8s
cCsO|iƒ\}}|dj	o|i|tƒ|_n
d|_|i	ƒdS(s› Called when the selected row in the display list changes.
            Updates info.current_display, then refills the list of
            screens.
        N(
Rntget_selectedtmodeltiterRt	get_valuetDISPLAY_COLUMN_DISPLAYR
Rªtfill_screens(R
RnR®R­((RR‹@s
	cCs?|iƒ\}}|o|i|tƒ|_n
d|_dS(sk Called when the selected row in the sceen list changes.
            Updates info->current_screen.
        N(	RnR¬R­R®tgettSCREEN_COLUMN_SCREENR
R•R(R
RnR®R­((RR“Ls
cCs)|iƒ|djotiƒndS(N(R
tdestroy_infoRFRR
RA(R
RF((RRNVs

cCs©|iiƒ|idj	oˆ|iiƒ}xvt|ƒD]d}|ii	|ƒ}|iiƒ}|ii
|t|t|ƒ|djo|ii|ƒq9q9WndS(s? Fills in the screen list based on the current display
        iN(R
RtclearRªRt
get_n_screenst	n_screenstrangetiRRtappendR®tsetR‘R³R’tselect_iter(R
R¹R·R®R((RR±\s


cCsh|iiƒ}xR|oJ|ii|tƒ}||jo|ii	|ƒPn|ii
ƒ}qWdS(st Called when one of the currently open displays is closed.
            Remove it from our list of displays.
        N(R
R„tget_iter_firstR®R¯R°ttmp_displayRtinfotremovet	iter_next(R
Rtis_errorR¿R®R¾((Rtdisplay_closed_cbks
cCs`|iƒ}|iiƒ}|ii|t|t	|ƒ|i
d|iƒ}|i
d|ƒdS(s« Adds a new display to our list of displays, and connects
            to the "closed" signal so that we can remove it from the
            list of displays again.
        tcloseds
user-callbackN(Rtget_nametnameR
R„RºR®R»RˆR°R.RÃR^R_(R
RRÆR®R^((RR\wscCs|i|ƒdS(s- Called when a new display is opened
        N(R
R\R(R
RXR((RR]„scCshtiiƒ}|iƒ}|idƒ}|i|ƒx*|D]"}|idƒ}|i|ƒq>WdS(s‚ Cleans up when the toplevel is destroyed; we remove the
            connections we use to track currently open displays.
        s
user-callbackN(
R
R!RWRXRYRZtget_dataR^t
disconnectttmp_list(R
RÉRXRZR^((RR´‰s
(R7R8RRrR„RR’RªR•RRUR}RSRTR—RMRR€R‹R“RNR±RÃR\R]R´(((RR?|s.	
	#				
	$			
				
	cCstƒtiƒdS(N(R?R
tmain(((RRʘst__main__(R9R
R%R¸RˆR°tDISPLAY_NUM_COLUMNSR‘R³tSCREEN_NUM_COLUMNSRRR	R;R:RER?RÊR7(
RˆRÊR?RÍRRÌR:R
R³R	R%R‘R°((Rt?s			
5ÿ	


Anon7 - 2021