วันพุธที่ 6 กุมภาพันธ์ พ.ศ. 2551

Show windows contents while dragging (linux)

ใน MS Windows จะมี option ในการเปิด/ปิด การแสดงผลของ windows แต่ละตัว ในช่วงขณะที่มีการลาก windows ไปมาบน desktop
ซึ่งก็คือ option: Show windows contents while dragging
นี่เป็นวิธีหนึ่งในการช่วยให้การแสดงผลง่ายและเนียนขึ้น การประมวลผลทำได้เร็ว ภาพไม่กระตุก ลดความงาม(มั้ง)ลงนิดนึง แต่งานโดยรวมดีขึ้น

ใน Linux Fedora (GNOME) ก็มีสิ่งคล้ายๆกัน เรียกว่า Reduce Resource - อือม ชื่อไม่ได้สื่อความหมายเลยนะ

โดยสามารถเข้าพบได้ที่ Applications - System tools - Configuration editor
จากนั้นให้เข้าไปที่ /apps/metacity/general/ แล้วหา reduced_resources
จากนั้นคลิกเลือกให้มันทำงาน ลองทดสอบย้าย ลาก วาง windows ต่างๆ จะพบว่า จะไม่มี render ในส่วนที่เป็น windows contents แต่จะมีเส้นสีดำตีเป็นกรอบเอาไว้ เพื่อเป็นตัวแทน ในการย้าย windows

ส่วนอันนี้เป็น description ที่อยู่ข้างใน
Keyname:
  • /apps/metacity/general/reduced_resources
Key owner:
  • metacity
Short description:
  • If true, trade off usability for less resource usage
Long description:
  • If true, metacity will give the user less feedback and less sense of "direct manipulation", by using wireframes, avoiding animations, or other means. This is a significant reduction in usability for many users, but may allow legacy applications and terminal servers to function when they would otherwise be impractical. However, the wireframe feature is disabled when accessibility is on to avoid weird desktop breakages.

จบข่าว

ใช้ mouse ในการ active windows ที่ต้องการ (ไม่ต้องคลิก)

ใน Linux เราสามารถ set windows preference เผื่อทำให้เราสามารถใช้ mouse ในการ activate windows ที่ต้องการได้
โดยไม่จำเป็นต้องคลิกไปที่ windows นั้นๆ

วิธี set ก็ไม่ยาก โดยไปที่ Menu Bar - System - Preferences - Windows
ก็จะได้หน้าจอดังรูป


ให้เรา enable ตรงที่ select windows when the mouse moves over them
นอกจากนั้นยังสามารถดึง windows นั้นมาอยู่บนสุดได้โดยไม่ต้องคลิก (เช่นกัน) โดย enable ที่ raise selected windows after an interval แล้วกำหนดช่วงเวลาที่ต้องการ ไม่เร็วหรือช้าเกินไป
(เร็วไปจะเศร้า ช้าก็รอนาน)

zenity - display GTK+ dialogs [2]

ลองเล่น zenity หน่อย
เพราะมีแนวโน้มเอาไปใช้งานได้ง่าย
แถมทำให้ดูเป็นโปรมากขึ้นด้วย หุหุ

/*
ไม่รู้จะวางไว้ตรงไหน เลยโยนลงตรงนี้ละกัน
ทั้ง 11 หน้าต่างจะมี general option หรือ properties เดียวกันอยู่ 4 ตัวดังนี้

--title=TITLE
--window-icon=icon_path
--width=WIDTH
--height=HEIGHT

อ่ะนะ มันก็คือ ไตเติ้ล / ไอคอน / ความกว้าง / ความสูง ของกรอบ zenity นั่นเอง
*/

1. ปฎิทิน --calendar
มี option เพิ่มเติม คือ
  • --text=STRING
  • --day=INT
  • --month=INT
  • --year=INT
  • --date-format=STRING (เอาไว้ตั้งรูปแบบวันที่ ที่จะส่งกลับมาตอน user เลือกวัน)

zenity --title="Test Zenity" --calendar --text="Select the date" --day=26 --month=12 --year=2008


2. รับข้อมูล --entry
  • --text=STRING
  • --entry-text=STRING
  • --hide-text

zenity --title="Test Zenity" --entry --text="Please input any thing" --entry-text="Default Answer"


zenity --title="Test Zenity" --entry --text="Please input any thing" --entry-text="Default Answer" --hide-text

3. แจ้งปัญหา --error
  • --text=STRING

4. เลือกไฟล์สิ --file-selection
  • --filename=FILENAME (ตั้งค่าเริ่มต้นมั้ย)
  • --multiple (แล้วจะเลือกพร้อมกันหลายๆไฟล์ดีป่าว)
  • --separator=SEPARATOR (ถ้าเลือกหลายไฟล์พร้อมกัน จะเอาอะไรคั่นระหว่างชื่อไฟล์ดีคับ)
zenity --title="Test Zenity" --file-selection --multiple --separator=";"
ส่วนผลลัพธ์ก็ประมาณนี้
/home/thada/002.png;/home/thada/100cans.jpg;

5. อ่ะ ข้อมูล --info
--text=STRING
6. รายการ --list
  • --text=STRING
  • --column=STRING (ชื่อของแต่ละ column)
  • --checklist (จะเป็น checklist เลือกได้หลายอัน...)
  • --radiolist (...หรือเป็น radiolist เลือกได้อันเดียว)
  • --separator=STRING (เอาอะไรกั้น ถ้าเลือกมากกว่า 1)
  • --editable (แก้ไขตัวอักษรได้หรือไม่ ถ้าใส่มาก็คือได้)
  • --print-column=STRING
zenity --title="Test Zenity" --list --column="check" --column="col1" --column="col2" --checklist FALSE "001" "test001" FALSE "002" "test002" TRUE "003" "test003"
7. ประกาศ (มั้ง) --notification
  • --text=STRING

8. ความก้าวหน้า --progress
  • --text=STRING
  • --percentage=INT (เริ่มต้นกี่ % ดีล่ะ)
  • --auto-close (ครบ 100% ก็ปิดซะ)
  • --pulsate (โปรเกรสจะเด้งไปเด้งมา บอกให้รู้ว่าทำงานอยู่ เพราะไม่รู้ 100% อยู่ที่ใหน)
(tar cvf a.tar 100_FUJI; gzip a.tar) | zenity --title="Test Zenity" --progress --percentage=0 --text="progress"

9. ตอบคำถาม --question
  • --text=STRING
zenity --title="Test Zenity" --question --text="Proceed?"
ถ้ากด OK - เช็คคำตอบจาก $? จะได้เท่ากับ 0
ถ้ากด Cancle - เช็คคำตอบจาก $? จะได้เท่ากับ 1

10. ข้อความอีกแระ --text-info
เอาไว้แสดงข้อมูลภายในไฟล์
  • --filename=FILENAME
  • --editable
zenity --title="Test Zenity" --text-info --filename="/home/thada/test.csh"

11. เตือน!! --warning
  • --text=STRING
เหมือนกับ question เลยแฮะ
เป็น warning box ที่สามารถตอบ cancle ได้ด้วย - -"
กด OK - $? = 0
กด Cancle - $? = 1
zenity --title="Test Zenity" --warning --text="warn you"

เยอะจริงๆ