예제 #1
0
    def __init__(self):
        gtk.ToggleButton.__init__(self)
        self.set_relief(gtk.RELIEF_NONE)
        self.set_border_width(0)

        self.label = gtk.Label()
        self.label.set_justify(gtk.JUSTIFY_CENTER)

        self.label.connect('style-set', self.on_label_style_set)
        self.connect('size_allocate', self.on_size_allocate)
        self.connect('button_press_event', self.on_button_press)

        self.add(self.label)

        self.activity, self.duration = None, None
        self.prev_size = 0

        # remove padding, so we fit on small panels (adapted from clock applet)
        gtk.rc_parse_string("""style "hamster-applet-button-style" {
                GtkWidget::focus-line-width=0
                GtkWidget::focus-padding=0
            }

            widget "*.hamster-applet-button" style "hamster-applet-button-style"
        """)
        gtk.Widget.set_name(self, "hamster-applet-button")
예제 #2
0
    def _setup_gtk(self):
        import gtk
        from kiwi.environ import environ

        gtk.gdk.threads_init()
        # Total madness to make sure we can draw treeview lines,
        # this affects the GtkTreeView::grid-line-pattern style property
        #
        # Two bytes are sent in, see gtk_tree_view_set_grid_lines in gtktreeview.c
        # Byte 1 should be as high as possible, gtk+ 0x7F appears to be
        #        the highest allowed for Gtk+ 2.22 while 0xFF worked in
        #        earlier versions
        # Byte 2 should ideally be allowed to be 0, but neither C nor Python
        #        allows that.
        #
        data = environ.get_resource_string("stoq", "misc", "stoq.gtkrc")
        data = data.replace('\\x7f\\x01', '\x7f\x01')

        gtk.rc_parse_string(data)

        # Creating a button as a temporary workaround for bug
        # https://bugzilla.gnome.org/show_bug.cgi?id=632538, until gtk 3.0
        gtk.Button()
        settings = gtk.settings_get_default()
        settings.props.gtk_button_images = True
예제 #3
0
  def _install_label_tree(self):

    filter_view = component.get("FilterTreeView")
    view = filter_view.label_view
    sidebar = filter_view.sidebar

    sidebar.add_tab(self.label_tree, MODULE_NAME, DISPLAY_NAME)

    self.external_handlers.append(
        (view, view.connect("cursor-changed", self.on_cursor_changed)))
    self.external_handlers.append(
        (view, view.connect("focus-in-event", self.on_focus_in)))


    def on_hide(widget):

      row = self.row_map[ID_ALL]

      path = self.store.get_path(row)
      path = self.sorted_store.convert_child_path_to_path(path)

      self.label_tree.set_cursor(path)


    def on_switch_page(widget, page, page_num, treeview):

      # Update view when switching pages with tabs focused (e.g. keyboard)
      if widget.is_focus():
        child = widget.get_nth_page(page_num)
        if treeview.is_ancestor(child):
          treeview.get_selection().emit("changed")


    notebook = sidebar.notebook

    self.external_handlers.append(
      (notebook, notebook.connect("hide", on_hide)))

    self.external_handlers.append((notebook,
      notebook.connect("switch-page", on_switch_page, view)))
    self.external_handlers.append((notebook,
      notebook.connect("switch-page", on_switch_page, self.label_tree)))

    # Hack to make initial drag and drop work properly between tabs
    page = notebook.get_current_page()
    parent_page = notebook.page_num(self.label_tree.parent)
    notebook.set_current_page(parent_page)
    notebook.set_current_page(page)

    # Make sure expanders are indented by overriding default style
    name = self.label_tree.get_name()
    path = self.label_tree.path()

    rc_string = """
        style '%s' { GtkTreeView::indent-expanders = 1 }
        widget '%s' style '%s'
    """ % (name, path, name)

    gtk.rc_parse_string(rc_string)
    gtk.rc_reset_styles(self.label_tree.get_toplevel().get_settings())
예제 #4
0
    def reconfigure(self):
        """Update configuration for the whole application"""

        if self.config['handle_size'] in xrange(0, 6):
            gtk.rc_parse_string("""
                style "terminator-paned-style" {
                    GtkPaned::handle_size = %s 
                }
                class "GtkPaned" style "terminator-paned-style" 
                """ % self.config['handle_size'])
            gtk.rc_reset_styles(gtk.settings_get_default())

        # Cause all the terminals to reconfigure
        for terminal in self.terminals:
            terminal.reconfigure()

        # Reparse our keybindings
        self.keybindings.configure(self.config['keybindings'])

        # Update tab position if appropriate
        maker = Factory()
        for window in self.windows:
            child = window.get_child()
            if maker.isinstance(child, 'Notebook'):
                child.configure()
예제 #5
0
    def attach(self):

        config_home = Common.utils.XDG.CONFIG_HOME

        state_filename = os.path.join(config_home, "gst-debug-viewer", "state")

        self.state = AppState(state_filename)
        self.state_section = self.state.sections["state"]

        self.load_plugins()

        self.windows = []

        # we override expander size because of:
        # https://bugzilla.gnome.org/show_bug.cgi?id=615985
        rcstring = """
        style "no-expander-treeview-style" {
            GtkTreeView::expander_size = 1
            #GtkTreeView::vertical-separator = 0
            GtkWidget::focus-line-width = 0
        }
        
        widget "*.log_view" style "no-expander-treeview-style"
        """
        gtk.rc_parse_string(rcstring)

        self.open_window()
예제 #6
0
    def init(self):
        """
        This do the remain initialize step.
        
        It Initializes the window and some important signal such as "destroy".
        """
        # Init gdk threads, the integrant method for multi-thread GUI application.
        gtk.gdk.threads_init()
        
        # Load customize rc style before any other.
        gtk.rc_parse_string("style 'my_style' {\n    GtkPaned::handle-size = %s\n }\nwidget '*' style 'my_style'" % (PANED_HANDLE_SIZE))

        # Init status.
        self.menu_button_callback = None

        # Init window.
        if self.app_support_colormap:
            self.window = Window(True)
        else:
            self.window = MplayerWindow(True)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.connect("destroy", self.destroy)
        
        # Init main box.
        self.main_box = self.window.window_frame

        # Add titlebar box.
        self.titlebar = None
        self.titlebar_box = gtk.HBox()
        self.main_box.pack_start(self.titlebar_box, False)
예제 #7
0
    def __init__(self, stock):
        '''constructor'''
        gtk.Button.__init__(self)

        # name the button to link it to a style
        self.set_name("close-button")

        self.image = gtk.image_new_from_stock(stock, gtk.ICON_SIZE_MENU)

        self.set_image(self.image)

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
        self.set_size_request(width + 2, height + 2)
        self.image.show()

        self.set_focus_on_click(False)
        self.set_relief(gtk.RELIEF_NONE)

        gtk.rc_parse_string('''
            style "close-button-style" {
                GtkWidget::focus-padding = 0
                GtkWidget::focus-line-width = 0
                xthickness = 0
                ythickness = 0
            }
            widget "*.close-button" style "close-button-style"
        ''')
예제 #8
0
    def __init__(self):
        gtk.ToggleButton.__init__(self)
        self.set_relief(gtk.RELIEF_NONE)
        self.set_border_width(0)

        self.label = gtk.Label()
        self.label.set_justify(gtk.JUSTIFY_CENTER)

        self.label.connect('style-set', self.on_label_style_set)
        self.connect('size_allocate', self.on_size_allocate)
        self.connect('button_press_event', self.on_button_press)

        self.add(self.label)

        self.activity, self.duration = None, None
        self.prev_size = 0


        # remove padding, so we fit on small panels (adapted from clock applet)
        gtk.rc_parse_string ("""style "hamster-applet-button-style" {
                GtkWidget::focus-line-width=0
                GtkWidget::focus-padding=0
            }

            widget "*.hamster-applet-button" style "hamster-applet-button-style"
        """);
        gtk.Widget.set_name (self, "hamster-applet-button");
예제 #9
0
    def attach (self):

        config_home = Common.utils.XDG.CONFIG_HOME

        state_filename = os.path.join (config_home, "gst-debug-viewer", "state")

        self.state = AppState (state_filename)
        self.state_section = self.state.sections["state"]

        self.load_plugins ()

        self.windows = []
        
        # we override expander size because of:
        # https://bugzilla.gnome.org/show_bug.cgi?id=615985
        rcstring = """
        style "no-expander-treeview-style" {
            GtkTreeView::expander_size = 1
            #GtkTreeView::vertical-separator = 0
            GtkWidget::focus-line-width = 0
        }
        
        widget "*.log_view" style "no-expander-treeview-style"
        """
        gtk.rc_parse_string (rcstring)

        self.open_window ()
예제 #10
0
파일: gtkmanhole.py 프로젝트: lhl/songclub
    def console(self, message):
        self.set_point(self.get_length())
        self.freeze()
        previous_kind = None
        style = self.get_style()
        style_cache = {}
        try:
            for element in message:
                if element[0] == "exception":
                    s = traceback.format_list(element[1]["traceback"])
                    s.extend(element[1]["exception"])
                    s = string.join(s, "")
                else:
                    s = element[1]

                if element[0] != previous_kind:
                    style = style_cache.get(element[0], None)
                    if style is None:
                        gtk.rc_parse_string('widget "Manhole.*.Console" ' 'style "Console_%s"\n' % (element[0]))
                        self.set_rc_style()
                        style_cache[element[0]] = style = self.get_style()
                # XXX: You'd think we'd use style.bg instead of 'None'
                # here, but that doesn't seem to match the color of
                # the backdrop.
                self.insert(style.font, style.fg[gtk.STATE_NORMAL], None, s)
                previous_kind = element[0]
            l = self.get_length()
            diff = self.maxBufSz - l
            if diff < 0:
                diff = -diff
                self.delete_text(0, diff)
        finally:
            self.thaw()
        a = self.get_vadjustment()
        a.set_value(a.upper - a.page_size)
예제 #11
0
파일: app.py 프로젝트: gza/pdbg
    def _setup(self):
        config = Config.get_instance()

        logging.basicConfig(
            level=config['logging_level'], 
            format='%(asctime)s %(levelname)s %(message)s')

        # Override some of the theme styles.
        gtk.rc_parse_string(_gtk_styles)

        # Connect application signal handlers.
        app_view = AppView.get_instance()
        app_view['window'].connect('destroy', self.on_quit_app)
        app_view['quit_item'].connect('activate', self.on_quit_app)
        app_view['about_item'].connect('activate', self.on_activate_about)

        # Setup singleton managers.
        ListenerManager.get_instance().setup()
        PagesManager.get_instance().setup()
        ToolbarManager.get_instance().setup()

        # Interpolate the ip address/port into the placeholder label.
        app_view = AppView.get_instance()
        info_lbl = app_view['info_page_label']
        listener = ListenerManager.get_instance().listener
        info_lbl.set_text(info_lbl.get_text() % (listener.ip_address, \
            listener.port))

        # Register a function to poll for incoming connections.
        gobject.timeout_add(config['listener_timeout_ms'], self.on_timeout)
예제 #12
0
def _test():
    STYLE = """
pixmap_path "."
style "wtf" {
fg[NORMAL] = "#02158F"		#0
fg[ACTIVE] = "#91BEF2"		#1
fg[PRELIGHT] = "#4E8EDA"	#2
fg[SELECTED] = "white"		#3
fg[INSENSITIVE] = "green"	#4
bg[NORMAL] = "#150926"
xthickness = 5
ythickness = 5
font_name = "12"
}
widget "*lineclock-widget" style "wtf" 
"""
    gtk.rc_parse_string(STYLE)
    window = gtk.Window()
    timeline = HLineClockWidget()
    timeline.markers = [time.time() + 30]
    timeline.timerange = 60
    timeline.tickgap = 10
    timeline.ntick = 5
    timeline.nowrel = 0.2
    timeline.label_fmt = "%M:%S"
    timeline.now_h = (-25, 0)
    timeline.ltr = 1
    window.add(timeline)
    window.connect("destroy", gtk.main_quit)
    gobject.timeout_add(1000, timeline.update)
    window.show_all()
    gtk.main()
예제 #13
0
    def __init__(self, stock):
        '''constructor'''
        gtk.Button.__init__(self)

        # name the button to link it to a style
        self.set_name("close-button")

        self.image = gtk.image_new_from_stock(stock, gtk.ICON_SIZE_MENU)

        self.set_image(self.image)

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
        self.set_size_request(width + 2, height + 2)
        self.image.show()

        self.set_focus_on_click(False)
        self.set_relief(gtk.RELIEF_NONE)

        gtk.rc_parse_string('''
            style "close-button-style" {
                GtkWidget::focus-padding = 0
                GtkWidget::focus-line-width = 0
                xthickness = 0
                ythickness = 0
            }
            widget "*.close-button" style "close-button-style"
        ''')
예제 #14
0
파일: bootstrap.py 프로젝트: tmaxter/stoq
    def _setup_gtk(self):
        import gtk
        from kiwi.environ import environ

        gtk.gdk.threads_init()
        # Total madness to make sure we can draw treeview lines,
        # this affects the GtkTreeView::grid-line-pattern style property
        #
        # Two bytes are sent in, see gtk_tree_view_set_grid_lines in gtktreeview.c
        # Byte 1 should be as high as possible, gtk+ 0x7F appears to be
        #        the highest allowed for Gtk+ 2.22 while 0xFF worked in
        #        earlier versions
        # Byte 2 should ideally be allowed to be 0, but neither C nor Python
        #        allows that.
        #
        data = environ.get_resource_string("stoq", "misc", "stoq.gtkrc")
        data = data.replace('\\x7f\\x01', '\x7f\x01')

        gtk.rc_parse_string(data)

        # Creating a button as a temporary workaround for bug
        # https://bugzilla.gnome.org/show_bug.cgi?id=632538, until gtk 3.0
        gtk.Button()
        settings = gtk.settings_get_default()
        settings.props.gtk_button_images = True
예제 #15
0
    def initialize_hildon_program(self):
        """ Function creates hildon program and window from
        UI main window (proximate). Function also connects required events
        for using tablet's fullscreen button. """

        # Creates hildon Program
        self.program = hildon.Program()

        # Create the menu
        self.main_menu = gtk.Menu()
        self.main_menu.append(self.version_menu_item)
        self.main_menu.append(self.plugins_menu_item)
        self.main_menu.append(self.preferences_menu_item)
        self.main_menu.append(self.quit_menu_item)
        self.program.set_common_menu(self.main_menu)

        self.main_progress_bar = gtk.ProgressBar()
        self.main_progress_bar.modify_font(pango.FontDescription("normal 20"))
        self.main_progress_bar.set_ellipsize(pango.ELLIPSIZE_END)

        self.tb = gtk.Toolbar()
        item = gtk.ToolItem()
        item.add(self.main_progress_bar)
        item.set_expand(True)
        self.tb.insert(item, -1)
        self.tb.show()
        self.program.set_common_toolbar(self.tb)

        # fix maemos treeview appearance inside a pannablearea
        gtk.rc_parse_string(
            """style "fremantle-touchlist" {
            GtkTreeView::row-height = -1 }"""
        )
예제 #16
0
 def Cells_Refresh(self):
     '''
     Обновление списка файлов
     '''
     #Переписываем стиль для отображения четных и нечетных строк
     rc_string = """
                 style "treeview-style" {
                     GtkTreeView::even-row-color = "%s"
                     GtkTreeView::odd-row-color = "%s"
                 }
                 class "GtkTreeView" style "treeview-style"
                 """ % (
         edna_builtin['configuration']['style']['even_row_bg'],
         edna_builtin['configuration']['style']['odd_row_bg'])
     #self.set_rules_hint(True)
     self.set_model(self.OOF.Model)
     self.__add_columns()
     self.__set_custom_cursor()
     gtk.rc_reset_styles(self.get_settings())
     gtk.rc_parse_string(rc_string)
     self.modify_base(
         gtk.STATE_SELECTED,
         gtk.gdk.Color(
             edna_builtin['configuration']['style']['cursor_row_bg']))
     self.modify_text(
         gtk.STATE_SELECTED,
         gtk.gdk.Color(
             edna_builtin['configuration']['style']['cursor_row_fg']))
예제 #17
0
	def theme_link_color(self,color):
		style='''
		style "label" {
			GtkLabel::link-color="%s"
		}
		widget_class "*GtkLabel" style "label"
		''' % (color)
		gtk.rc_parse_string(style)
예제 #18
0
	def _load_settings(self):

		self.button.set_label(self.applet_label)

		if self.applet_icon:
			button_icon_pixbuf = self.icon_helper.get_icon_pixbuf(self.applet_icon, self._get_best_icon_size_for_panel(), 'start-here')
			button_icon = gtk.image_new_from_pixbuf(button_icon_pixbuf)
			self.button.set_image(button_icon)
		else:
			self.button.set_image(None)

		clean_imagemenuitem = gtk.ImageMenuItem()
		is_horizontal = (self.applet.get_orient() in (mateapplet.ORIENT_UP, mateapplet.ORIENT_DOWN))

		if self.applet_label and self.applet_icon:
			toggle_spacing = clean_imagemenuitem.style_get_property('toggle-spacing')
		else:
			toggle_spacing = 0

		if is_horizontal:
			horizontal_padding = clean_imagemenuitem.style_get_property('horizontal-padding')
		else:
			horizontal_padding = 0

		gtk.rc_parse_string('''
			style "cardapio-applet-style"
			{
				GtkImageMenuItem::toggle-spacing = %d
				GtkImageMenuItem::horizontal-padding = %d
			}
			widget "*CardapioApplet" style:application "cardapio-applet-style"
			''' % (toggle_spacing, horizontal_padding))

		# apparently this happens sometimes (maybe when the parent isn't realized yet?)
		if self.button.parent is None: return

		menubar = self.button.parent 
		menubar.remove(self.button)
		menubar.add(self.button)

		menubar.connect('button-press-event', self._on_panel_button_pressed)

		if self.applet_press_handler is not None:
			try:
				self.button.disconnect(self.applet_press_handler)
				self.button.disconnect(self.applet_enter_handler)
				self.button.disconnect(self.applet_leave_handler)
			except: pass

		if self.open_on_hover:
			self.applet_press_handler = self.button.connect('button-press-event', self._on_panel_button_toggled, True)
			self.applet_enter_handler = self.button.connect('enter-notify-event', self._on_applet_cursor_enter)
			self.applet_leave_handler = self.button.connect('leave-notify-event', self._on_applet_cursor_leave)

		else:
			self.applet_press_handler = self.button.connect('button-press-event', self._on_panel_button_toggled, False)
			self.applet_enter_handler = self.button.connect('enter-notify-event', return_true)
			self.applet_leave_handler = self.button.connect('leave-notify-event', return_true)
예제 #19
0
    def main(self, appklass):

        default_log_level = logging.WARNING
        if 'HOTVTE_DEBUG' in os.environ:
            default_log_level = logging.DEBUG

        import hotwire.logutil
        mods = os.environ.get('HOTVTE_DEBUG_MODULES', '')
        if mods:
            mods = mods.split(',')
        else:
            mods = []
        hotwire.logutil.init(default_log_level, mods, '')

        _logger.debug("logging initialized")

        locale.setlocale(locale.LC_ALL, '')
        import gettext
        gettext.install('hotwire')

        gobject.threads_init()

        app = appklass()
        remote = app.get_remote()
        remote.single_instance()

        def on_about_dialog_url(dialog, link):
            import webbrowser
            webbrowser.open(link)

        gtk.about_dialog_set_url_hook(on_about_dialog_url)
        gtk.rc_parse_string('''
style "hotwire-tab-close" {
  xthickness = 0
  ythickness = 0
}
widget "*hotwire-tab-close" style "hotwire-tab-close"
''')
        if os.getenv('HOTWIRE_UNINSTALLED'):
            theme = gtk.icon_theme_get_default()
            imgpath = os.path.join(os.getenv('HOTWIRE_UNINSTALLED'), 'images')
            _logger.debug("appending to icon theme: %s", imgpath)
            theme.append_search_path(imgpath)

        factory = app.get_factory()
        factory.connect('shutdown', app.on_shutdown)
        w = factory.create_initial_window()
        w.new_tab(sys.argv[1:], os.getcwd())

        uiproxy = remote.get_proxy(factory)

        w.show_all()
        w.present()

        _logger.debug('entering mainloop')
        gtk.gdk.threads_enter()
        gtk.main()
        gtk.gdk.threads_leave()
예제 #20
0
	def _load_settings(self):

		self.button.set_label(self.applet_label)

		if self.applet_icon:
			button_icon_pixbuf = self.icon_helper.get_icon_pixbuf(self.applet_icon, self._get_best_icon_size_for_panel(), 'start-here')
			button_icon = gtk.image_new_from_pixbuf(button_icon_pixbuf)
			self.button.set_image(button_icon)
		else:
			self.button.set_image(None)

		clean_imagemenuitem = gtk.ImageMenuItem()
		is_horizontal = (self.applet.get_orient() in (gnomeapplet.ORIENT_UP, gnomeapplet.ORIENT_DOWN))

		if self.applet_label and self.applet_icon:
			toggle_spacing = clean_imagemenuitem.style_get_property('toggle-spacing')
		else:
			toggle_spacing = 0

		if is_horizontal:
			horizontal_padding = clean_imagemenuitem.style_get_property('horizontal-padding')
		else:
			horizontal_padding = 0

		gtk.rc_parse_string('''
			style "cardapio-applet-style"
			{
				GtkImageMenuItem::toggle-spacing = %d
				GtkImageMenuItem::horizontal-padding = %d
			}
			widget "*CardapioApplet" style:application "cardapio-applet-style"
			''' % (toggle_spacing, horizontal_padding))

		# apparently this happens sometimes (maybe when the parent isn't realized yet?)
		if self.button.parent is None: return

		menubar = self.button.parent 
		menubar.remove(self.button)
		menubar.add(self.button)

		menubar.connect('button-press-event', self._on_panel_button_pressed)

		if self.applet_press_handler is not None:
			try:
				self.button.disconnect(self.applet_press_handler)
				self.button.disconnect(self.applet_enter_handler)
				self.button.disconnect(self.applet_leave_handler)
			except: pass

		if self.open_on_hover:
			self.applet_press_handler = self.button.connect('button-press-event', self._on_panel_button_toggled, True)
			self.applet_enter_handler = self.button.connect('enter-notify-event', self._on_applet_cursor_enter)
			self.applet_leave_handler = self.button.connect('leave-notify-event', self._on_applet_cursor_leave)

		else:
			self.applet_press_handler = self.button.connect('button-press-event', self._on_panel_button_toggled, False)
			self.applet_enter_handler = self.button.connect('enter-notify-event', return_true)
			self.applet_leave_handler = self.button.connect('leave-notify-event', return_true)
예제 #21
0
	def remove_applet_border(self):
      		gtk.rc_parse_string ("""
	               style \"GnoMenu-style\"
	               {
	                 GtkWidget::focus-line-width = 0
	                 GtkWidget::focus-padding = 0
	               }
	               widget \"*.GnoMenu\" style \"GnoMenu-style\"
	               """)
예제 #22
0
    def main(self, appklass):

        default_log_level = logging.WARNING
        if 'HOTVTE_DEBUG' in os.environ:
            default_log_level = logging.DEBUG
 
        import hotwire.logutil
        mods = os.environ.get('HOTVTE_DEBUG_MODULES', '')
        if mods:
            mods = mods.split(',')
        else:
            mods = []
        hotwire.logutil.init(default_log_level, mods, '')

        _logger.debug("logging initialized")

        locale.setlocale(locale.LC_ALL, '')
        import gettext
        gettext.install('hotwire')        
    
        gobject.threads_init()
        
        app = appklass()
        remote = app.get_remote()
        remote.single_instance()

        def on_about_dialog_url(dialog, link):
            import webbrowser
            webbrowser.open(link)    
        gtk.about_dialog_set_url_hook(on_about_dialog_url)
        gtk.rc_parse_string('''
style "hotwire-tab-close" {
  xthickness = 0
  ythickness = 0
}
widget "*hotwire-tab-close" style "hotwire-tab-close"
''')    
        if os.getenv('HOTWIRE_UNINSTALLED'):
            theme = gtk.icon_theme_get_default()
            imgpath = os.path.join(os.getenv('HOTWIRE_UNINSTALLED'), 'images')
            _logger.debug("appending to icon theme: %s", imgpath)
            theme.append_search_path(imgpath)    
    
        factory = app.get_factory()
        factory.connect('shutdown', app.on_shutdown)
        w = factory.create_initial_window()
        w.new_tab(sys.argv[1:], os.getcwd())
    
        uiproxy = remote.get_proxy(factory)    
 
        w.show_all()
        w.present()
    
        _logger.debug('entering mainloop')
        gtk.gdk.threads_enter()
        gtk.main()
        gtk.gdk.threads_leave()    
예제 #23
0
파일: ui.py 프로젝트: rpmcruz/tagmail
def shrink_button (button):
	gtk.rc_parse_string (
		"style \"zero-thickness\"\n" +
		"{\n" +
		"	xthickness = 0\n" +
		"	ythickness = 0\n" +
		"}\n" +
		"widget \"*.smallbutton\" style \"zero-thickness\"")
	button.set_name ("smallbutton")
예제 #24
0
파일: menu.py 프로젝트: fain182/foobnix
 def __init__(self):
     rc_st = '''
         style "menubar-style" {
             GtkMenuBar::shadow_type = none
             GtkMenuBar::internal-padding = 0
             }
         class "GtkMenuBar" style "menubar-style"
     '''
     gtk.rc_parse_string(rc_st)
     gtk.MenuBar.__init__(self)
예제 #25
0
 def __init__(self):
     rc_st = '''
         style "menubar-style" {
             GtkMenuBar::shadow_type = none
             GtkMenuBar::internal-padding = 0
             }
         class "GtkMenuBar" style "menubar-style"
     '''
     gtk.rc_parse_string(rc_st)
     gtk.MenuBar.__init__(self)
예제 #26
0
    def __init__(self, image_name,
        adjustment=None, slider_border=0,
        insensitive_name=None, trough_color="#3D403A",
        snap=False):

        image_name = imagefile(image_name)

        gtk.VScale.__init__(self, adjustment)

        if snap:
            self.snap = 1 / snap

        else:
            self.snap = False

        colormap = self.get_colormap()
        self.troughcolor = colormap.alloc_color(
            trough_color, True, True)

        img = gtk.Image()
        img.set_from_file(image_name)
        self.sliderPixbuf = img.get_pixbuf()

        if insensitive_name == None:
            self.insensitivePixbuf = None
            
        else:
            img = gtk.Image()
            img.set_from_file(insensitive_name)
            self.insensitivePixbuf = img.get_pixbuf()

        name = image_name + "ImageVScale"
        self.set_name(name)

        rc_str = """
style "scale_style" {
    GtkRange::slider_width = %d
    GtkScale::slider_length = %d
}
widget "*%s*" style "scale_style"
        """ % (self.sliderPixbuf.get_width(),
        self.sliderPixbuf.get_height(), name)
        gtk.rc_parse_string(rc_str)

        self.pixbufWidth = self.sliderPixbuf.get_width()
        self.pixbufHeight = self.sliderPixbuf.get_height()
        self.sliderBorder = slider_border
        self.sliderBorderMUL2 = self.sliderBorder * 2

        self.set_draw_value(False)

        self.connect("expose-event", self.expose)
        self.connect("size-allocate", self.size_allocate)
        self.connect("button-release-event", self.button_release)
        adjustment.connect("value-changed", self.value_changed)
예제 #27
0
    def init(self):
        self.set_applet_flags(gnomeapplet.EXPAND_MINOR)
        self.toggle = gtk.ToggleButton()
	self.toggle.set_relief(gtk.RELIEF_NONE)
        self.applet_tooltips = gtk.Tooltips()
        self.setup_menu_from_file (gnome_blog_globals.datadir, "GNOME_BlogApplet.xml",
                                   None, [(_("About"), self._showAboutDialog), ("Pref", self._openPrefs)])

        button_box = gtk.HBox()
        button_box.pack_start(gtk.Label(_("Blog")))
        self.arrow = gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_IN)
        button_box.pack_start(self.arrow)

	gtk.rc_parse_string ("""
style "gnome-blog-applet-button-style"
{
   GtkWidget::focus-line-width=0
   GtkWidget::focus-padding=0
}

widget "*.gnome-blog-applet-button" style "gnome-blog-applet-button-style"
""");

	self.toggle.set_name("gnome-blog-applet-button")

        self.toggle.add(button_box)
        
        self.add(self.toggle)
        self.toggle.connect("toggled", self._onToggle)
        self.toggle.connect("button-press-event", self._onButtonPress)
        
	self.set_background_widget(self)
        self.show_all()

        self.poster_window = aligned_window.AlignedWindow(self.toggle, self.get_orient)
        accel_group = gtk.AccelGroup()
        self.poster_window.add_accel_group(accel_group)
        self.prefs_key = self.get_preferences_key()
        print "Applet prefs located at %s" % (self.prefs_key)
        self.poster = blog_poster.BlogPosterSimple(prefs_key=self.prefs_key,
                                                   on_entry_posted=self._onEntryPosted,
                                                   accel_group=accel_group)
        self.poster_window.add(self.poster)
        self.poster.show()

        client = gconf.client_get_default()
        value = client.get_bool(self.prefs_key + "/initialized")
        if value == None or value == False:
            self.poster._showPrefDialog()
#            self._showPrefDialog()
            client.set_bool(self.prefs_key + "/initialized", True)

        self._createToolTip(client)
        
        return True
예제 #28
0
def force_no_focus_padding(widget):
    gtk.rc_parse_string('\n'
                        '   style "timer-applet-button-style"\n'
                        '   {\n'
                        '      GtkWidget::focus-line-width=0\n'
                        '      GtkWidget::focus-padding=0\n'
                        '   }\n'
                        '\n'
                        '   widget "*.timer-applet-button" style "timer-applet-button-style"\n'
                        '\n')
    widget.set_name('timer-applet-button')
예제 #29
0
파일: gimmie_util.py 프로젝트: orph/gimmie
 def __init__(self, widget, style_name):
     if style_name not in KillFocusPadding._PARSED_STYLE_NAMES:
         gtk.rc_parse_string(
             '''
             style "gimmie-%s-style" {
                GtkWidget::focus-line-width=0
                GtkWidget::focus-padding=0
             }
             widget "*.gimmie-%s" style "gimmie-%s-style"
             ''' % (style_name, style_name, style_name))
         KillFocusPadding._PARSED_STYLE_NAMES.append(style_name)
     widget.set_name("gimmie-%s" % style_name)
예제 #30
0
    def append(self, document):
        """Append the given document as a new tab in the notebook.
        @document: A document instance to append."""

        # Set tab title, short if is too large.
        if document.path:
            title = os.path.basename(document.path)
            title = self.short_title(title)
        else:
            title = '%s %s' % (_('Unsaved'), main.documents.unsaved)

        # Set label widget.
        label = gtk.Label(title)
        label.set_tooltip_text(document.path)
        label.set_padding(4, 0)

        # Set image box, by this way expand parameter is tuned.
        button_box = gtk.HBox(False, 0)
        button_img = gtk.image_new_from_stock('gtk-close', 1)
        button_box.pack_start(button_img, True, False, 0)

        # Set button widget.
        button = gtk.Button()
        button.add(button_box)
        button.set_relief(gtk.RELIEF_NONE)
        button.set_focus_on_click(False)
        button.connect("clicked", lambda w: main.documents.close(document))
        button.set_name('thick')

        # Set button internal padding to zero.
        gtk.rc_parse_string('\
            style "thick"\
            {\
                xthickness = 0\
                ythickness = 0\
            }\
            widget "*.thick" style "thick"')

        # Adjust button size.
        settings = button.get_settings()
        (w,h) = gtk.icon_size_lookup_for_settings(settings, 1)
        button.set_size_request(w+4, h+4)

        # Add all to tab box.
        hbox = gtk.HBox(False, 3)
        hbox.pack_start(label, False, False, 0)
        hbox.pack_start(button, False, False, 0)
        hbox.show_all()

        # Append to notebook and select the new tab.
        self.notebook.append_page(document.canvas.table, hbox)
        self.notebook.set_tab_reorderable(document.canvas.table, True)
        self.notebook.set_current_page(-1)
예제 #31
0
def force_no_focus_padding(widget):
    gtk.rc_parse_string(
        '\n'
        '   style "timer-applet-button-style"\n'
        '   {\n'
        '      GtkWidget::focus-line-width=0\n'
        '      GtkWidget::focus-padding=0\n'
        '   }\n'
        '\n'
        '   widget "*.timer-applet-button" style "timer-applet-button-style"\n'
        '\n')
    widget.set_name('timer-applet-button')
예제 #32
0
    def _determine_edit_colour(self):
        """Determine which colour to use for the editable hint"""
        def _compare_colors(oColor1, oColor2):
            """Compare the RGB values for 2 gtk.gdk.Colors. Return True if
               they're the same, false otherwise."""
            return oColor1.to_string() == oColor2.to_string()

        oCurStyle = self.rc_get_style()
        # Styles don't seem to be applied to TreeView text, so we default
        # to black text for non-editable, and work out editable from the
        # style
        self.oCellColor = gtk.gdk.color_parse('black')
        oCurBackColor = oCurStyle.base[gtk.STATE_NORMAL]
        self.set_name('editable_view')
        oDefaultSutekhStyle = gtk.rc_get_style_by_paths(self.get_settings(),
                '', self.class_path(), self)
        # We want the class style for this widget, ignoring set_name effects
        oSpecificStyle = self.rc_get_style()
        if oSpecificStyle == oDefaultSutekhStyle or \
                oDefaultSutekhStyle is None:
            # No specific style set
            sColour = 'red'
            if _compare_colors(gtk.gdk.color_parse(sColour),
                    oCurStyle.fg[gtk.STATE_NORMAL]):
                sColour = 'green'
            # FIXME: rc_parse_string doesn't play nicely with
            # theme changes, which cause a rcfile reparse.
            sStyleInfo = """
            style "internal_sutekh_editstyle" {
                fg[NORMAL] = "%(colour)s"
                }
            widget "%(path)s" style "internal_sutekh_editstyle"
            """ % {'colour': sColour, 'path': self.path()}
            gtk.rc_parse_string(sStyleInfo)
            # Need to force re-assesment of styles
            self.set_name('editable_view')
        oCurStyle = self.rc_get_style()
        # Force a hint on the number column as well
        oEditColor = oCurStyle.fg[gtk.STATE_NORMAL]
        oEditBackColor = oCurStyle.base[gtk.STATE_NORMAL]
        if not _compare_colors(oEditColor, self.oCellColor) or \
                not _compare_colors(oEditBackColor, oCurBackColor):
            # Visiually distinct, so honour user's choice
            self._oModel.oEditColour = oEditColor
        else:
            # If the theme change isn't visually distinct here, we go
            # with red  as the default - this is safe,
            # since CellRenderers aren't
            # themed, so the default color will not be red
            # (famous last words)
            # If the default background color is red, too bad
            self._oModel.oEditColour = gtk.gdk.color_parse('red')
예제 #33
0
 def force_no_focus_applet(self):
     # Fixes bug #542861: Deskbar applet has a pixel border
     if not self.__style_applied:
         gtk.rc_parse_string ("""
            style \"deskbar-applet-button-style\"
            {
              GtkWidget::focus-line-width = 0
              GtkWidget::focus-padding = 0
            }
            widget \"*.deskbar-applet-button\" style \"deskbar-applet-button-style\"
            """)
         self.__style_applied = False
     self.applet.set_name("deskbar-applet-button")
예제 #34
0
 def force_no_focus_applet(self):
     # Fixes bug #542861: Deskbar applet has a pixel border
     if not self.__style_applied:
         gtk.rc_parse_string ("""
            style \"deskbar-applet-button-style\"
            {
              GtkWidget::focus-line-width = 0
              GtkWidget::focus-padding = 0
            }
            widget \"*.deskbar-applet-button\" style \"deskbar-applet-button-style\"
            """)
         self.__style_applied = False
     self.applet.set_name("deskbar-applet-button")
예제 #35
0
	def _set_bg( self, color ):
		'''
		Set the TreeView's background colors to a solid color given by `color`.
		'''
		gtk.rc_parse_string( """
		style "bg_color"{
			GtkTreeView::allow-rules = 1
			GtkTreeView::even-row-color = "%s"
		}
		widget "*bg_color*" style "bg_color"
		""" % color)
		self.set_rules_hint( False )
		self.set_name( 'bg_color' )
예제 #36
0
파일: iniciar.py 프로젝트: n0tch/pymaestro
    def __init__ (self):
        """Sistema de agendamento de clientes"""
        self.interface = Interface()

        rc_style = '''
	style "editfont" 
	{
	   font_name="courier 13"
	}
	
	widget "edit_window.*" style "editfont"
	
'''
        gtk.rc_parse_string(rc_style)           
예제 #37
0
    def __config_load_custom_font(self):
        use_custom_font = self.__config.get_value("panel", "use_custom_font", False)
        font_name = gtk.settings_get_default().get_property("gtk-font-name")
        font_name = unicode(font_name, "utf-8")
        custom_font = self.__config.get_value("panel", "custom_font", font_name)
        style_string = 'style "custom-font" { font_name="%s" }\n' 'class "IBusCandidateLabel" style "custom-font"\n'
        if use_custom_font:
            style_string = style_string % custom_font
            gtk.rc_parse_string(style_string)
        else:
            style_string = style_string % ""
            gtk.rc_parse_string(style_string)

        settings = gtk.settings_get_default()
        gtk.rc_reset_styles(settings)
예제 #38
0
	def _set_alternating_bg( self, even_color, odd_color ):
		'''
		Set the TreeView's background colors to a color scheme that alternates
		every other row. Color scheme is given by `even_color` and `odd_color`.
		'''
		gtk.rc_parse_string( """
		style "alternate_bg_color"{
			GtkTreeView::allow-rules = 1
			GtkTreeView::even-row-color = "%s"
			GtkTreeView::odd-row-color = "%s"
		}
		widget "*alternate_bg_color*" style "alternate_bg_color"
		"""%(even_color, odd_color))
		self.set_rules_hint( True )
		self.set_name( 'alternate_bg_color' )
예제 #39
0
  def _install_label_tree(self):

    self._filterview.sidebar.add_tab(self._tree, MODULE_NAME, DISPLAY_NAME)

    # Override style so expanders are indented
    name = self._tree.get_name()
    path = self._tree.path()

    rc_string = """
        style '%s' { GtkTreeView::indent-expanders = 1 }
        widget '%s' style '%s'
    """ % (name, path, name)

    gtk.rc_parse_string(rc_string)
    gtk.rc_reset_styles(self._tree.get_toplevel().get_settings())
예제 #40
0
    def _install_label_tree(self):

        self._filterview.sidebar.add_tab(self._tree, MODULE_NAME, DISPLAY_NAME)

        # Override style so expanders are indented
        name = self._tree.get_name()
        path = self._tree.path()

        rc_string = """
        style '%s' { GtkTreeView::indent-expanders = 1 }
        widget '%s' style '%s'
    """ % (name, path, name)

        gtk.rc_parse_string(rc_string)
        gtk.rc_reset_styles(self._tree.get_toplevel().get_settings())
예제 #41
0
 def __init__(self,vector,label=None,callback=None,initial=None,padding=3):
     ''' Initialise with a vector to put in the combobox.
     Optional arguments:
         label - the combobox label
         callback - a tuple with a callback to pass the current value to 
                    after it has been changed and something else that the
                    callback knows how to interpret, e.g. (callback, target)
                    will result in a functional call to callback(target,value).
         initial - is an initial value
         padding - the typical hbox padding.
         '''
     self.callback=callback
     # I think we can afford a copy
     options=[str(i) for i in vector]
     
     super(arrayCombo,self).__init__(options,initial=initial,label=label,
                                     callback=self.__aCcallback)
     # following magic sets the dropdown to use scrollbars (and be much faster)
     style = gtk.rc_parse_string('''
     style "my-style" { GtkComboBox::appears-as-list = 1 }
     widget "*.mycombo" style "my-style" ''')
     self._box.set_name('mycombo')
     self._box.set_style(style)
     
     # the natural size request seems to be (106,25), but
     # it could be much smaller given our smaller text
     self._box.set_size_request(60,20)
예제 #42
0
 def __init__(self):
     """
     Constructor.
     """
     super(Notifier, self).__init__((100/255.0, 100/255.0, 100/255.0),
                                    (245/255.0, 225/255.0, 140/255.0),
                                    (255/255, 240/255.0, 194/255.0),
                                    20.0, 5)
                                    
     # button style (tiny button)
     button_style = ''' 
         style 'custom_button' {
             xthickness = 0
             ythickness = 0
         }
         widget '*.button' style 'custom_button'
     '''
     gtk.rc_parse_string(button_style)
     
     self.set_border_width(3)
     self.set_spacing(12)
     
     self.__image = gtk.Image()
     self.__image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_MENU)
     
     self.__label = gtk.Label()
     self.__label.set_alignment(0, 0.5)
     self.__label.set_ellipsize(pango.ELLIPSIZE_END)
     
     self.buttons_hbox = gtk.HBox()
     self.close_button = gtk.Button()
     close_image = gtk.Image()
     close_image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
     self.close_button.add(close_image)
     
     self.close_button.set_relief(gtk.RELIEF_NONE)
     self.close_button.set_property("can-focus", False)
     self.close_button.set_name("close.button")
     
     self.__custom_widget = None
     
     self.pack_start(self.__image, False, False, 3)
     self.pack_start(self.__label, True, True)
     self.buttons_hbox.pack_end(self.close_button, False, False)
     self.pack_end(self.buttons_hbox, False, False)
     
     self.close_button.connect("clicked", self.close_clicked)
예제 #43
0
파일: toolbar.py 프로젝트: Lomir/foobnix
 def __init__(self):
     rc_st = '''
     style "toolbar-style" {
         GtkToolbar::shadow_type = none                
         }
     class "GtkToolbar" style "toolbar-style"
     '''
     gtk.rc_parse_string(rc_st)
     
     gtk.Toolbar.__init__(self) 
        
     self.show()
     self.set_style(gtk.TOOLBAR_ICONS)
     self.set_show_arrow(False)
     self.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR)
      
     self.i = 0
예제 #44
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_border_width(24)
        self.set_app_paintable(True)
        self.set_decorated(False)
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)

        # setup RGBA colormaps for translucency
        screen = self.get_screen()
        colormap = screen.get_rgba_colormap()
        if colormap:
            gtk.widget_set_default_colormap(colormap)

        # parse the rcdata
        gtk.rc_parse_string(rcdata)

        self.connect('expose-event', self.hud_expose)
예제 #45
0
    def __init__(cls, name, bases, dct):
        """
            Le da estilo al boton cerrar de los tabs.
        """

        type(gtk.Notebook).__init__(cls, name, bases, dct)

        gtk.rc_parse_string("""
        style "editor-close-button-style"
        {
          GtkWidget::focus-padding = 0
          GtkWidget::focus-line-width = 0
          xthickness = 0
          ythickness = 0
        }
        widget "*.editor-close-button" style "editor-close-button-style"
        """)
예제 #46
0
파일: toolbar.py 프로젝트: matttbe/foobnix
    def __init__(self):
        rc_st = '''
        style "toolbar-style" {
            GtkToolbar::shadow_type = none                
            }
        class "GtkToolbar" style "toolbar-style"
        '''
        gtk.rc_parse_string(rc_st)

        gtk.Toolbar.__init__(self)

        self.show()
        self.set_style(gtk.TOOLBAR_ICONS)
        self.set_show_arrow(False)
        self.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR)

        self.i = 0
예제 #47
0
파일: panel.py 프로젝트: nielsdg/ibus
    def __config_load_custom_font(self):
        use_custom_font = self.__config.get_value("panel", "use_custom_font",
                                                  False)
        font_name = gtk.settings_get_default().get_property("gtk-font-name")
        font_name = unicode(font_name, "utf-8")
        custom_font = self.__config.get_value("panel", "custom_font",
                                              font_name)
        style_string = 'style "custom-font" { font_name="%s" }\n' \
            'class "IBusCandidateLabel" style "custom-font"\n'
        if use_custom_font:
            style_string = style_string % custom_font
            gtk.rc_parse_string(style_string)
        else:
            style_string = style_string % ""
            gtk.rc_parse_string(style_string)

        settings = gtk.settings_get_default()
        gtk.rc_reset_styles(settings)
예제 #48
0
    def __init_combo(self):
        self._model = gtk.ListStore(str)
        for trans in self.elem.translations:
            self._model.append([trans])

        self.set_model(self._model)
        self._renderer = gtk.CellRendererText()
        self.pack_start(self._renderer)
        self.add_attribute(self._renderer, 'text', 0)

        # Force the "appears-as-list" style property to 0
        rc_string = """
            style "not-a-list"
            {
                GtkComboBox::appears-as-list = 0
            }
            class "GtkComboBox" style "not-a-list"
            """
        gtk.rc_parse_string(rc_string)
예제 #49
0
    def __init__(self, db, ismain=True):
        vw_layout.LayoutManager.__init__(self)

        self.db = db
        db.gui = self
        self.db.registerNotifier(NOTIFY_ALL, self)
        self.ismain = ismain

        self.winactive = False

        gtk.rc_parse_string(stylerc)

        defgeom = (20, 20, 600, 450)
        self.defgeom = defgeom

        self.addWindowClass(VdbMainWindow, args=(db, self), defgeom=defgeom)
        self.addWindowClass(VdbMemoryWindow, args=(db, self), defgeom=defgeom)
        self.addWindowClass(VdbMemoryMapWindow,
                            args=(db, self),
                            defgeom=defgeom)
        self.addWindowClass(VdbFileDescWindow,
                            args=(db, self),
                            defgeom=defgeom)
        self.addWindowClass(VdbRegisterWindow,
                            args=(db, self),
                            defgeom=defgeom)

        mainwin = None
        if self.db.vdbhome:
            lfile = os.path.join(self.db.vdbhome, "vdb.lyt2")
            if os.path.exists(lfile):
                self.loadLayoutFile(file(lfile, "rb"))

        self.mainwin = self.getOrCreateWindow('VdbMainWindow')

        t = self.db.trace
        if t.isAttached() and not t.isRunning():
            self.setTraceWindowsActive(True)
        else:
            self.setTraceWindowsActive(False)

        vdb.gui.extensions.loadGuiExtensions(db, self)
예제 #50
0
    def force_no_pixmap_background(self, widget):
        if self.rc_parse_first_time:
            gtk.rc_parse_string(
                "\n"
                "   style \"bg-theme-engine-style\"\n"
                "   {\n"
                "      bg_pixmap[NORMAL] = \"<none>\"\n"
                "      bg_pixmap[INSENSITIVE] = \"<none>\"\n"
                "      bg_pixmap[ACTIVE] = \"<none>\"\n"
                "      bg_pixmap[PRELIGHT] = \"<none>\"\n"
                "      bg[NORMAL] = { 0.0, 0.0, 0.0 }\n"
                "      bg[INSENSITIVE] = { 0.0, 0.0, 0.0 }\n"
                "      bg[ACTIVE] = { 0.0, 0.0, 0.0 }\n"
                "      bg[PRELIGHT] = { 0.0, 0.0, 0.0 }\n"
                "   }\n"
                "   widget \"bg-window-drawing-area*\" style : highest \"bg-theme-engine-style\"\n"
                "\n")
            self.rc_parse_first_time = False

        widget.set_name("bg-window-drawing-area")
예제 #51
0
 def __init__(self):
     '''Setting up the view'''
     super(PyMusicView, self).__init__()
     self.set_title("PyMusic")
     gtk.rc_parse_string(theme)
     try:
         self.set_icon_from_file("/usr/share/pixmaps/pymusic.png")
     except:
         pass
     self.set_position(gtk.WIN_POS_CENTER)
     self.set_default_size(800, 500)
     self.realize()
     self.window_style = self.get_style()
     self.add_widgets()
     self.show_all()
     self.separator.set_visible(False)
     self.previous.set_sensitive(False)
     self.next.set_sensitive(False)
     self.play_pause.set_sensitive(False)
     self.active_song.set_sensitive(False)
     self.search_tool.set_sensitive(False)
     self.bookmarks_workaround.set_visible(False)
예제 #52
0
    def console(self, message):
        self.set_point(self.get_length())
        self.freeze()
        previous_kind = None
        style = self.get_style()
        style_cache = {}
        try:
            for element in message:
                if element[0] == 'exception':
                    s = traceback.format_list(element[1]['traceback'])
                    s.extend(element[1]['exception'])
                    s = string.join(s, '')
                else:
                    s = element[1]

                if element[0] != previous_kind:
                    style = style_cache.get(element[0], None)
                    if style is None:
                        gtk.rc_parse_string(
                            'widget \"Manhole.*.Console\" '
                            'style \"Console_%s\"\n'
                            % (element[0]))
                        self.set_rc_style()
                        style_cache[element[0]] = style = self.get_style()
                # XXX: You'd think we'd use style.bg instead of 'None'
                # here, but that doesn't seem to match the color of
                # the backdrop.
                self.insert(style.font, style.fg[gtk.STATE_NORMAL],
                            None, s)
                previous_kind = element[0]
            l = self.get_length()
            diff = self.maxBufSz - l
            if diff < 0:
                diff = - diff
                self.delete_text(0,diff)
        finally:
            self.thaw()
        a = self.get_vadjustment()
        a.set_value(a.upper - a.page_size)
예제 #53
0
def setup_rc ():
    """
    Parse an RC style string
    """
    gtk.rc_parse_string ("""
style "tiny-button-style"
{
  GtkWidget::focus-padding = 0
  xthickness = 0
  ythickness = 0
}
widget "*.tiny-button" style "tiny-button-style"

style "intro-button-style"
{
  GtkWidget::focus-padding = 0
  bg[PRELIGHT] = "#fff8ae"
  xthickness = 0
  ythickness = 0
}
widget "*.intro-button" style "intro-button-style"
""")
예제 #54
0
    def _setup_gtk(self):
        import gtk
        from kiwi.environ import environ

        # Total madness to make sure we can draw treeview lines,
        # this affects the GtkTreeView::grid-line-pattern style property
        #
        # Two bytes are sent in, see gtk_tree_view_set_grid_lines in gtktreeview.c
        # Byte 1 should be as high as possible, gtk+ 0x7F appears to be
        #        the highest allowed for Gtk+ 2.22 while 0xFF worked in
        #        earlier versions
        # Byte 2 should ideally be allowed to be 0, but neither C nor Python
        #        allows that.
        #
        data = environ.get_resource_string("stoq", "misc", "stoq.gtkrc")
        data = data.replace('\\x7f\\x01', '\x7f\x01')

        gtk.rc_parse_string(data)

        # Creating a button as a temporary workaround for bug
        # https://bugzilla.gnome.org/show_bug.cgi?id=632538, until gtk 3.0
        gtk.Button()
        settings = gtk.settings_get_default()
        settings.props.gtk_button_images = True

        from stoqlib.lib.environment import is_developer_mode
        if is_developer_mode() and gtk.gtk_version[0] == 2:
            from gtk import gdk

            # Install a Control-Q handler that forcefully exits
            # the program without saving any kind of state
            def event_handler(event):
                if (event.type == gdk.KEY_PRESS
                        and event.state & gdk.CONTROL_MASK
                        and event.keyval == gtk.keysyms.q):
                    os._exit(0)
                gtk.main_do_event(event)

            gdk.event_handler_set(event_handler)
예제 #55
0
    def _set_colors(self, colors):
        # See gtk.RcStyle docs for all values in RC file
        rc = 'style "zim-colors"\n{\n'
        for i, state in enumerate((
                'NORMAL',
                #'ACTIVE',
                #'PRELIGHT',
                #'SELECTED',
                #'INSENSITIVE',
        )):
            values = colors[i]
            values['state'] = state
            rc +=  '\tbase[%(state)s] = "%(base)s"\n' \
             '\ttext[%(state)s] = "%(text)s"\n' \
             '\tbg[%(state)s] = "%(bg)s"\n' % values
            #'\tfg[%(state)s] = "%(fg)s"\n' % values

        #rc += '}\nclass "GtkWidget" style "zim-colors"'
        rc += '}\nwidget "*.zim-pageview" style "zim-colors"\n'

        logger.debug('Parse RC: >>>\n%s<<<', rc)
        gtk.rc_parse_string(rc)
        gtk.rc_reset_styles(gtk.settings_get_default())
예제 #56
0
### GNU General Public License for more details.

### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

from gettext import gettext as _

import gtk
import pango

gtk.rc_parse_string("""
    style "meld-tab-close-button-style" {
        GtkWidget::focus-padding = 0
        GtkWidget::focus-line-width = 0
        xthickness = 0
        ythickness = 0
    }
    widget "*.meld-tab-close-button" style "meld-tab-close-button-style"
    """)


class NotebookLabel(gtk.HBox):
    tab_width_in_chars = 30

    def __init__(self, iconname, text, onclose):
        gtk.HBox.__init__(self, False, 4)

        label = gtk.Label(text)
        # FIXME: ideally, we would use custom ellipsization that ellipsized the
        # two paths separately, but that requires significant changes to label
예제 #57
0
    if pixbuf:
        icon_set = gtk.IconSet(pixbuf)
        factory.add('terp-' + iname, icon_set)

try:
    win = modules.gui.main.terp_main()
    import release
    win.window.set_title('OpenERP - %s' % release.version)
    color = options.options.get('client.color', None)
    if color:
        eb = gtk.EventBox()
        eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
        vbox = win.glade.get_widget('vbox_main')
        vbox.set_border_width(5)
        win.window.remove(vbox)
        eb.add(vbox)
        eb.show()
        win.window.add(eb)
    if os.name == 'nt':
        from tools.win32 import get_systemfont_style
        gtk.rc_parse_string(get_systemfont_style())
    if not common.terp_survey():
        if options.options.rcexist:
            win.sig_login()
    gtk.main()
except KeyboardInterrupt, e:
    log = logging.getLogger('common')
    log.info(_('Closing OpenERP, KeyboardInterrupt'))

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
예제 #58
0
    def setup(self, cardapio):

        self.icon_helper = cardapio.icon_helper
        self.cardapio = cardapio

        self.context_menu_xml = '''
			<popup name="button3">
				<menuitem name="Item 1" verb="Properties" label="%s" pixtype="stock" pixname="gtk-properties"/>
				<menuitem name="Item 2" verb="Edit" label="%s" pixtype="stock" pixname="gtk-edit"/>
				<separator />
				<menuitem name="Item 3" verb="AboutCardapio" label="%s" pixtype="stock" pixname="gtk-about"/>
				<menuitem name="Item 4" verb="AboutMate" label="%s" pixtype="none"/>
				<menuitem name="Item 5" verb="AboutDistro" label="%s" pixtype="none"/>
			</popup>
			''' % (_('_Properties'), _('_Edit Menus'), _('_About Cardapio'),
          _('_About Mate'), _('_About %(distro_name)s') % {
              'distro_name': cardapio.distro_name
          })

        self.context_menu_verbs = [('Properties', self.open_options_dialog),
                                   ('Edit', self.launch_edit_app),
                                   ('AboutCardapio', self.open_about_dialog),
                                   ('AboutMate', self.open_about_dialog),
                                   ('AboutDistro', self.open_about_dialog)]

        self.button.set_tooltip_text(
            _('Access applications, folders, system settings, etc.'))
        self.button.set_always_show_image(True)
        self.button.set_name('CardapioApplet')

        menubar = gtk.MenuBar()
        menubar.set_name('CardapioAppletMenu')
        menubar.add(self.button)

        gtk.rc_parse_string('''
			style "cardapio-applet-menu-style"
			{
				xthickness = 0
				ythickness = 0
				GtkMenuBar::shadow-type      = GTK_SHADOW_NONE
				GtkMenuBar::internal-padding = 0
				GtkMenuBar::focus-padding    = 0
				GtkWidget::focus-padding     = 0
				GtkWidget::focus-line-width  = 0
				#bg[NORMAL] = "#ff0000"
				engine "murrine" {} # fix background color bug
			}

			style "cardapio-applet-style"
			{
				xthickness = 0
				ythickness = 0
				GtkWidget::focus-line-width = 0
				GtkWidget::focus-padding    = 0
			}

			widget "*CardapioAppletMenu" style:highest "cardapio-applet-menu-style"
			widget "*MatePanelApplet" style:highest "cardapio-applet-style"
			''')

        self.applet.add(menubar)

        self.applet.connect('size-allocate', self._on_panel_size_changed)
        self.applet.connect('change-orient', self._panel_change_orientation)
        self.applet.connect('change-background',
                            self._on_panel_change_background)
        self.applet.connect('destroy', self._on_panel_destroy)

        self.applet.set_applet_flags(mateapplet.EXPAND_MINOR)
        self.applet.show_all()

        return True
예제 #59
0
    def __init__(self):
        component.Component.__init__(self, 'FilterTreeView', interval=2)
        self.config = ConfigManager('gtkui.conf')

        self.tracker_icons = component.get('TrackerIcons')

        self.sidebar = component.get('SideBar')
        self.treeview = gtk.TreeView()
        self.sidebar.add_tab(self.treeview, 'filters', 'Filters')

        # set filter to all when hidden:
        self.sidebar.notebook.connect('hide', self._on_hide)

        # Create the treestore
        # cat, value, label, count, pixmap, visible
        self.treestore = gtk.TreeStore(str, str, str, int, Pixbuf, bool)

        # Create the column and cells
        column = gtk.TreeViewColumn('Filters')
        column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
        # icon cell
        self.cell_pix = gtk.CellRendererPixbuf()
        column.pack_start(self.cell_pix, expand=False)
        column.add_attribute(self.cell_pix, 'pixbuf', 4)
        # label cell
        cell_label = gtk.CellRendererText()
        cell_label.set_property('ellipsize', ELLIPSIZE_END)
        column.pack_start(cell_label, expand=True)
        column.set_cell_data_func(cell_label, self.render_cell_data, None)
        # count cell
        self.cell_count = gtk.CellRendererText()
        self.cell_count.set_property('xalign', 1.0)
        self.cell_count.set_padding(3, 0)
        column.pack_start(self.cell_count, expand=False)

        self.treeview.append_column(column)

        # Style
        self.treeview.set_show_expanders(True)
        self.treeview.set_headers_visible(False)
        self.treeview.set_level_indentation(-21)
        # Force theme to use expander-size so we don't cut out entries due to indentation hack.
        gtk.rc_parse_string(
            """style "treeview-style" {GtkTreeView::expander-size = 7}
                            class "GtkTreeView" style "treeview-style" """)

        self.treeview.set_model(self.treestore)
        self.treeview.get_selection().connect('changed',
                                              self.on_selection_changed)
        self.create_model_filter()

        self.treeview.connect('button-press-event', self.on_button_press_event)

        # colors using current theme.
        style = component.get('MainWindow').window.get_style()
        self.colour_background = style.bg[gtk.STATE_NORMAL]
        self.colour_foreground = style.fg[gtk.STATE_NORMAL]

        # filtertree menu
        builder = gtk.Builder()
        builder.add_from_file(
            resource_filename('deluge.ui.gtkui',
                              os.path.join('glade', 'filtertree_menu.ui')))
        self.menu = builder.get_object('filtertree_menu')
        builder.connect_signals(self)

        self.default_menu_items = self.menu.get_children()