Ejemplo n.º 1
0
    def __init__(self, guakeinstance):
        super(PrefsDialog, self).__init__(common.gladefile('prefs.glade'),
                                          root='config-window')

        self.guake = guakeinstance
        self.client = gconf.client_get_default()

        # images
        ipath = common.pixmapfile('guake.png')
        self.get_widget('image_logo').set_from_file(ipath)
        ipath = common.pixmapfile('tabdown.svg')
        self.get_widget('image1').set_from_file(ipath)
        ipath = common.pixmapfile('tabup.svg')
        self.get_widget('image2').set_from_file(ipath)

        # the first position in tree will store the keybinding path in gconf,
        # and the user doesn't worry with this, lest hide that =D
        model = gtk.TreeStore(str, str, str, bool)
        treeview = self.get_widget('treeview-keys')
        treeview.set_model(model)
        treeview.set_rules_hint(True)

        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn('keypath', renderer, text=0)
        column.set_visible(False)
        treeview.append_column(column)

        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Action'), renderer, text=1)
        column.set_property('expand', True)
        treeview.append_column(column)

        renderer = gtk.CellRendererText()
        renderer.set_data('column', 1)
        renderer.connect('edited', self.on_key_edited, model)
        column = gtk.TreeViewColumn(_('Shortcut'),
                                    renderer,
                                    text=2,
                                    editable=3)
        column.set_property('expand', False)
        treeview.append_column(column)

        self.populate_shell_combo()
        self.populate_keys_tree()
        self.load_configs()
        self.get_widget('config-window').hide()

        # Preview when selecting a bgimage
        self.selection_preview = gtk.Image()
        self.file_filter = gtk.FileFilter()
        self.file_filter.add_pattern("*.jp[e]?g")
        self.file_filter.add_pattern("*.png")
        self.file_filter.add_pattern("*.svg")
        self.bgfilechooser = self.get_widget('bgimage-filechooserbutton')
        self.bgfilechooser.set_preview_widget(self.selection_preview)
        self.bgfilechooser.set_filter(self.file_filter)
        self.bgfilechooser.connect('update-preview', self.update_preview_cb,
                                   self.selection_preview)
Ejemplo n.º 2
0
    def __init__(self):
        super(Guake, self).__init__(common.gladefile('guake.glade'))
        self.client = gconf.client_get_default()

        # default option in case of gconf fails:
        self.use_bgimage = False

        # setting global hotkey!
        globalhotkeys.init()
        key = self.client.get_string(GHOTKEYS[0][0])
        globalhotkeys.bind(key, self.show_hide)

        # trayicon!
        tray_icon = GuakeStatusIcon()
        tray_icon.connect('popup-menu', self.show_menu)
        tray_icon.connect('activate', self.show_hide)
        tray_icon.show_all()

        # adding images from a different path.
        ipath = common.pixmapfile('new_guakelogo.png')
        self.get_widget('image1').set_from_file(ipath)
        ipath = common.pixmapfile('add_tab.png')
        self.get_widget('image2').set_from_file(ipath)

        self.window = self.get_widget('window-root')
        self.notebook = self.get_widget('notebook-teminals')
        self.toolbar = self.get_widget('toolbar')
        self.mainframe = self.get_widget('mainframe')

        self.accel_group = gtk.AccelGroup()
        self.last_pos = -1
        self.term_list = []
        self.animation_speed = 30
        self.visible = False

        self.window.add_accel_group(self.accel_group)
        self.window.set_keep_above(True)
        self.window.set_geometry_hints(min_width=1, min_height=1)
        self.window.connect('focus-out-event', self.on_window_lostfocus)

        self.load_config()
        self.load_accelerators()
        self.refresh()
        self.add_tab()
Ejemplo n.º 3
0
    def __init__(self):
        super(AboutDialog, self).__init__(common.gladefile('about.glade'),
                                          root='aboutdialog')
        # the terminal window can be opened and the user *must* see this window
        self.get_widget('aboutdialog').set_keep_above(True)

        # images
        ipath = common.pixmapfile('guake.png')
        img = gtk.gdk.pixbuf_new_from_file(ipath)
        self.get_widget('aboutdialog').set_property('logo', img)
Ejemplo n.º 4
0
    def __init__(self):
        super(AboutDialog, self).__init__(gladefile("about.glade"), root="aboutdialog")
        dialog = self.get_widget("aboutdialog")

        # images
        ipath = pixmapfile("guake-notification.png")
        img = gtk.gdk.pixbuf_new_from_file(ipath)
        dialog.set_property("logo", img)

        dialog.set_name("Guake!")
        dialog.set_version(VERSION)
Ejemplo n.º 5
0
Archivo: guake.py Proyecto: aligo/guake
    def __init__(self):
        super(AboutDialog, self).__init__(gladefile('about.glade'),
                                          root='aboutdialog')
        dialog = self.get_widget('aboutdialog')

        # images
        ipath = pixmapfile('guake-notification.png')
        img = gtk.gdk.pixbuf_new_from_file(ipath)
        dialog.set_property('logo', img)

        dialog.set_name('Guake!')
        dialog.set_version(VERSION)
Ejemplo n.º 6
0
    def add_tab(self):
        last_added = len(self.term_list)
        self.term_list.append(vte.Terminal())
        self.term_list[last_added].set_sensitive(False)
        # TODO: make new terminal opens in the same dir of the already in use.
        shell_name = self.client.get_string(GCONF_PATH +
                                            'general/default_shell')
        self.term_list[last_added].fork_command(
            shell_name or "bash", directory=os.path.expanduser('~'))

        image = gtk.Image()
        image.set_from_file(common.pixmapfile('close.svg'))

        label = gtk.Label(_('Terminal %s') % (last_added + 1))
        label.connect('button-press-event', self.set_terminal_focus)

        button = gtk.Button()
        button.set_image(image)
        button.set_relief(gtk.RELIEF_NONE)
        button.connect('clicked', self.on_close_button_close_clicked,
                       last_added)

        hbox = gtk.HBox(False, False)
        hbox.set_border_width(1)
        hbox.pack_start(label)
        hbox.pack_start(button)
        hbox.show_all()

        mhbox = gtk.HBox()
        mhbox.pack_start(self.term_list[last_added], True, True)

        # showing scrollbar based in gconf setting:
        scrollbar_visible = self.client.get_bool(GCONF_PATH +
                                                 'general/use_scrollbar')
        if scrollbar_visible:
            adj = self.term_list[last_added].get_adjustment()
            scroll = gtk.VScrollbar(adj)
            mhbox.pack_start(scroll, False, False)

        mhbox.show_all()

        self.term_list[last_added].set_background_transparent(
            not self.use_bgimage)
        # TODO: maybe the better way is give these choices to the user...
        self.term_list[last_added].set_audible_bell(
            False)  # without boring beep
        self.term_list[last_added].set_visible_bell(
            False)  # without visible beep
        self.term_list[last_added].set_scroll_on_output(True)  # auto scroll
        self.term_list[last_added].set_scroll_on_keystroke(True)  # auto scroll
        #self.term_list[last_added].set_scroll_background(True)
        history_size = self.client.get_int(GCONF_PATH + 'general/history_size')
        self.term_list[last_added].set_scrollback_lines(
            history_size)  # history size
        self.term_list[last_added].set_sensitive(True)

        self.term_list[last_added].set_flags(gtk.CAN_DEFAULT)
        self.term_list[last_added].set_flags(gtk.CAN_FOCUS)
        self.term_list[last_added].connect('child-exited',
                                           self.on_terminal_exited, mhbox)
        self.term_list[last_added].grab_focus()

        self.notebook.append_page(mhbox, hbox)
        self.notebook.connect('switch-page', self.set_last_pos)
        self.notebook.connect('focus-tab', self.set_terminal_focus)

        self.set_tabs_visible()
        self.load_config()
        self.term_list[last_added].show()
        self.notebook.set_current_page(last_added)
        self.last_pos = last_added
Ejemplo n.º 7
0
    def __init__(self):
        super(Guake, self).__init__(gladefile("guake.glade"))
        self.client = gconf.client_get_default()

        # setting global hotkey and showing a pretty notification =)
        globalhotkeys.init()

        # trayicon!
        img = pixmapfile("guake-tray.png")
        self.tray_icon = gtk.status_icon_new_from_file(img)
        self.tray_icon.set_tooltip(_("Guake Terminal"))
        self.tray_icon.connect("popup-menu", self.show_menu)
        self.tray_icon.connect("activate", self.show_hide)

        # adding images from a different path.
        ipath = pixmapfile("guake.png")
        self.get_widget("image1").set_from_file(ipath)
        ipath = pixmapfile("add_tab.png")
        self.get_widget("image2").set_from_file(ipath)

        # important widgets
        self.window = self.get_widget("window-root")
        self.notebook = self.get_widget("notebook-teminals")
        self.tabs = self.get_widget("hbox-tabs")
        self.toolbar = self.get_widget("toolbar")
        self.mainframe = self.get_widget("mainframe")
        self.resizer = self.get_widget("resizer")

        # check and set ARGB for real transparency
        screen = self.window.get_screen()
        colormap = screen.get_rgba_colormap()
        if colormap != None and screen.is_composited():
            self.window.set_colormap(colormap)
            self.has_argb = True
        else:
            self.has_argb = False

        # List of vte.Terminal widgets, it will be useful when needed
        # to get a widget by the current page in self.notebook
        self.term_list = []

        # This is the pid of shells forked by each terminal. Will be
        # used to kill the process when closing a tab
        self.pid_list = []

        # It's intended to know which tab was selected to
        # close/rename. This attribute will be set in
        # self.show_tab_menu
        self.selected_tab = None

        # holds the number of created tabs. This counter will not be
        # reset to avoid problems of repeated tab names.
        self.tab_counter = 0

        # holds fullscreen status
        self.fullscreen = False

        # holds the timestamp of the losefocus event
        self.losefocus_time = 0

        # double click stuff
        def double_click(hbox, event):
            """Handles double clicks on tabs area and when receive
            one, calls add_tab.
            """
            if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
                self.add_tab()

        evtbox = self.get_widget("event-tabs")
        evtbox.connect("button-press-event", double_click)

        # Flag to prevent guake hide when window_losefocus is true and
        # user tries to use the context menu.
        self.showing_context_menu = False

        def hide_context_menu(menu):
            """Turn context menu flag off to make sure it is not being
            shown.
            """
            self.showing_context_menu = False

        self.get_widget("context-menu").connect("hide", hide_context_menu)
        self.get_widget("tab-menu").connect("hide", hide_context_menu)
        self.window.connect("focus-out-event", self.on_window_losefocus)

        # this line is important to resize the main window and make it
        # smaller.
        self.window.set_geometry_hints(min_width=1, min_height=1)

        # resizer stuff
        self.resizer.connect("motion-notify-event", self.on_resizer_drag)

        # adding the first tab on guake
        self.add_tab()

        # loading and setting up configuration stuff
        GConfHandler(self)
        GConfKeyHandler(self)
        self.hotkeys = globalhotkeys.GlobalHotkey()
        self.load_config()

        key = self.client.get_string(GKEY("show_hide"))
        keyval, mask = gtk.accelerator_parse(key)
        label = gtk.accelerator_get_label(keyval, mask)
        filename = pixmapfile("guake-notification.png")

        if not self.hotkeys.bind(key, self.show_hide):
            notification = pynotify.Notification(
                _("Guake!"),
                _(
                    "A problem happened when binding <b>%s</b> key.\n"
                    "Please use Guake Preferences dialog to choose another "
                    "key (The trayicon was enabled)"
                )
                % label,
                filename,
            )
            self.client.set_bool(KEY("/general/use_trayicon"), True)
            notification.show()

        elif self.client.get_bool(KEY("/general/use_popup")):
            # Pop-up that shows that guake is working properly (if not
            # unset in the preferences windows)
            notification = pynotify.Notification(
                _("Guake!"), _("Guake is now running,\n" "press <b>%s</b> to use it.") % label, filename
            )
            notification.show()
Ejemplo n.º 8
0
    def __init__(self):
        super(Guake, self).__init__(gladefile('guake.glade'))
        self.client = gconf.client_get_default()

        # setting global hotkey and showing a pretty notification =)
        globalhotkeys.init()

        # trayicon!
        img = pixmapfile('guake-tray.png')
        self.tray_icon = gtk.status_icon_new_from_file(img)
        self.tray_icon.set_tooltip(_('Guake-Terminal'))
        self.tray_icon.connect('popup-menu', self.show_menu)
        self.tray_icon.connect('activate', self.show_hide)

        # adding images from a different path.
        ipath = pixmapfile('guake.png')
        self.get_widget('image1').set_from_file(ipath)
        ipath = pixmapfile('add_tab.png')
        self.get_widget('image2').set_from_file(ipath)

        # important widgets
        self.window = self.get_widget('window-root')
        self.notebook = self.get_widget('notebook-teminals')
        self.tabs = self.get_widget('hbox-tabs')
        self.toolbar = self.get_widget('toolbar')
        self.mainframe = self.get_widget('mainframe')
        self.resizer = self.get_widget('resizer')

        # check and set ARGB for real transparency
        screen = self.window.get_screen()
        colormap = screen.get_rgba_colormap()
        if colormap != None and screen.is_composited():
            self.window.set_colormap(colormap)
            self.has_argb = True
        else:
            self.has_argb = False

        # List of vte.Terminal widgets, it will be useful when needed
        # to get a widget by the current page in self.notebook
        self.term_list = []

        # This is the pid of shells forked by each terminal. Will be
        # used to kill the process when closing a tab
        self.pid_list = []

        # It's intended to know which tab was selected to
        # close/rename. This attribute will be set in
        # self.show_tab_menu
        self.selected_tab = None

        # holds the number of created tabs. This counter will not be
        # reset to avoid problems of repeated tab names.
        self.tab_counter = 0

        # holds fullscreen status
        self.fullscreen = False

        # holds the timestamp of the losefocus event
        self.losefocus_time = 0

        # double click stuff
        def double_click(hbox, event):
            """Handles double clicks on tabs area and when receive
            one, calls add_tab.
            """
            if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
                self.add_tab()
        evtbox = self.get_widget('event-tabs')
        evtbox.connect('button-press-event', double_click)

        # Flag to prevent guake hide when window_losefocus is true and
        # user tries to use the context menu.
        self.showing_context_menu = False
        def hide_context_menu(menu):
            """Turn context menu flag off to make sure it is not being
            shown.
            """
            self.showing_context_menu = False
        self.get_widget('context-menu').connect('hide', hide_context_menu)
        self.get_widget('tab-menu').connect('hide', hide_context_menu)
        self.window.connect('focus-out-event', self.on_window_losefocus)

        # this line is important to resize the main window and make it
        # smaller.
        self.window.set_geometry_hints(min_width=1, min_height=1)

        # resizer stuff
        self.resizer.connect('motion-notify-event', self.on_resizer_drag)

        # loading and setting up configuration stuff
        GConfHandler(self)
        GConfKeyHandler(self)
        self.hotkeys = globalhotkeys.GlobalHotkey()
        self.load_config()

        key = self.client.get_string(GKEY('show_hide'))
        keyval, mask = gtk.accelerator_parse(key)
        self.notification_label = gtk.accelerator_get_label(keyval, mask)
        self.notification_pixmapfile = pixmapfile('guake-notification.png')

        if not self.hotkeys.bind(key, self.show_hide):
            self.show_notification('A problem happened when binding <b>%s</b> key.\n'
                  'Please use Guake Preferences dialog to choose another '
                  'key (The trayicon was enabled)')
            self.client.set_bool(KEY('/general/use_trayicon'), True)
            
        # add tabs remembered from last session
        try:
            guake_tabs = open(os.path.expanduser('~/.guake_tabs'), 'r')
            for line in guake_tabs:
                tname, tdir = line.rstrip('\n').split('\t')
                self.add_tab(tdir, tname)
            guake_tabs.close()
        except:
            # not there? not readable? add failed?
            pass
        
        if not self.term_list:
            self.add_tab()