Package dtk :: Package ui :: Module menu

Source Code for Module dtk.ui.menu

  1  #! /usr/bin/env python 
  2  # -*- coding: utf-8 -*- 
  3   
  4  # Copyright (C) 2011 ~ 2012 Deepin, Inc. 
  5  #               2011 ~ 2012 Wang Yong 
  6  #  
  7  # Author:     Wang Yong <lazycat.manatee@gmail.com> 
  8  # Maintainer: Wang Yong <lazycat.manatee@gmail.com> 
  9  #  
 10  # This program is free software: you can redistribute it and/or modify 
 11  # it under the terms of the GNU General Public License as published by 
 12  # the Free Software Foundation, either version 3 of the License, or 
 13  # any later version. 
 14  #  
 15  # This program is distributed in the hope that it will be useful, 
 16  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 17  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 18  # GNU General Public License for more details. 
 19  #  
 20  # You should have received a copy of the GNU General Public License 
 21  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 22   
 23  from constant import DEFAULT_FONT_SIZE, MENU_ITEM_RADIUS, ALIGN_START, ALIGN_MIDDLE, WIDGET_POS_RIGHT_CENTER, WIDGET_POS_TOP_LEFT 
 24  from draw import draw_vlinear, draw_pixbuf, draw_text, draw_hlinear 
 25  from line import HSeparator 
 26  from theme import ui_theme 
 27  from window import Window 
 28  import gobject 
 29  import gtk 
 30  from utils import (is_in_rect, get_content_size, propagate_expose, 
 31                     get_widget_root_coordinate, get_screen_size,  
 32                     alpha_color_hex_to_cairo, get_window_shadow_size) 
 33   
 34  __all__ = ["Menu", "MenuItem"] 
 35   
 36  menu_grab_window = gtk.Window(gtk.WINDOW_POPUP) 
 37  menu_grab_window.move(0, 0) 
 38  menu_grab_window.set_default_size(0, 0) 
 39  menu_grab_window.show() 
 40  menu_active_item = None 
 41   
 42  root_menus = [] 
 43   
 51       
 65           
66 -def is_press_on_menu_grab_window(window):
67 '''Is press on menu grab window.''' 68 for toplevel in gtk.window_list_toplevels(): 69 if isinstance(window, gtk.Window): 70 if window == toplevel: 71 return True 72 elif isinstance(window, gtk.gdk.Window): 73 if window == toplevel.window: 74 return True 75 76 return False
77 92 120 121 menu_grab_window.connect("button-press-event", menu_grab_window_button_press) 122 menu_grab_window.connect("motion-notify-event", menu_grab_window_motion_notify) 123 433 434 gobject.type_register(Menu) 435 658