Python gi.repository.Gtk.STOCK_CLOSE Examples

The following are 28 code examples of gi.repository.Gtk.STOCK_CLOSE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gtk , or try the search function .
Example #1
Source File: asktext.py    From textext with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def window_deleted_cb(self, widget, event, view):
        if (self._gui_config.get("confirm_close", self.DEFAULT_CONFIRM_CLOSE)
                and self._source_buffer.get_text(self._source_buffer.get_start_iter(),
                                                 self._source_buffer.get_end_iter(), True) != self.text):
            dlg = Gtk.MessageDialog(self._window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.NONE)
            dlg.set_markup(
                "<b>Do you want to close TexText without save?</b>\n\n"
                "Your changes will be lost if you don't save them."
            )
            dlg.add_button("Continue editing", Gtk.ResponseType.CLOSE) \
                .set_image(Gtk.Image.new_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.BUTTON))
            dlg.add_button("Close without save", Gtk.ResponseType.YES) \
                .set_image(Gtk.Image.new_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.BUTTON))

            dlg.set_title("Close without save?")
            res = dlg.run()
            dlg.destroy()
            if res in (Gtk.ResponseType.CLOSE, Gtk.ResponseType.DELETE_EVENT):
                return True

        Gtk.main_quit()
        return False 
Example #2
Source File: customwidgets.py    From rednotebook with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self):
        Gtk.InfoBar.__init__(self)
        self.title_label = Gtk.Label()
        self.msg_label = Gtk.Label()
        self.title_label.set_alignment(0.0, 0.5)
        self.msg_label.set_alignment(0.0, 0.5)

        vbox = Gtk.VBox(spacing=5)
        vbox.pack_start(self.title_label, False, False, 0)
        vbox.pack_start(self.msg_label, False, False, 0)

        self.image = Gtk.Image()

        content = self.get_content_area()
        content.pack_start(self.image, False, False, 0)
        content.pack_start(vbox, False, False, 0)

        self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
        self.connect("close", lambda x: self.hide())
        self.connect("response", self.on_response) 
Example #3
Source File: rightnotebook.py    From bokken with GNU General Public License v2.0 6 votes vote down vote up
def create_tab(self, title, tab_child, icon=''):
        tab_box = Gtk.HBox(False, 3)
        close_button = Gtk.Button()

        image = Gtk.Image()
        image.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)

        label = Gtk.Label(label=title)
        if icon:
            i = Gtk.Image()
            i.set_from_stock(eval('Gtk.STOCK_' + icon), Gtk.IconSize.MENU)
            tab_box.pack_start(i, False, False, 0)

        close_button.connect("clicked", self.close_tab, tab_child)
        close_button.set_image(image)
        close_button.set_relief(Gtk.ReliefStyle.NONE)
        tab_box.pack_start(label, True, True, 0)
        tab_box.pack_end(close_button, False, False, 0)

        tab_box.show_all()
        if title in ['Loading dasm...', 'Code', 'Callgraph', 'Flowgraph', 'Interactive', 'Strings', "Sections", 'Hexdump', 'Bindiff', 'File info']:
            close_button.hide()

        return tab_box 
Example #4
Source File: docview.py    From runsqlrun with MIT License 6 votes vote down vote up
def _get_notebook_label(self, worksheet):
        # Label from worksheet
        label = worksheet.get_tab_label()
        # FIXME: This should be handled by the editor, not the docviewer.
        worksheet.editor.buffer.connect(
            'changed', partial(self.on_buffer_changed, label))
        # Close button
        img = Gtk.Image.new_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
        _, w, h = Gtk.IconSize.lookup(Gtk.IconSize.MENU)
        btn = Gtk.Button()
        btn.set_relief(Gtk.ReliefStyle.NONE)
        btn.set_focus_on_click(False)
        btn.add(img)
        btn.connect(
            'clicked', lambda b, w: self.remove_worksheet(w), worksheet)
        # Put it together
        hbox = Gtk.HBox()
        hbox.pack_start(label, True, True, 3)
        hbox.pack_end(btn, False, False, 0)
        hbox.show_all()
        return hbox 
Example #5
Source File: alttoolbar_plugins.py    From alternative-toolbar with GNU General Public License v3.0 6 votes vote down vote up
def _preferences_button_clicked(self, *args):
        row = self._listbox.get_selected_row()

        widget = self._get_preference_widget(row)

        if not widget:
            return

        if self._has_headerbar:
            dlg = Gtk.Dialog(use_header_bar=True, flags=Gtk.DialogFlags.MODAL)
            dlg.get_header_bar().set_show_close_button(True)
        else:
            dlg = Gtk.Dialog(flags=Gtk.DialogFlags.MODAL)
            dlg.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)

        dlg.props.title = row.plugin.get_name()
        area = dlg.get_content_area()
        area.add(widget)
        dlg.set_resizable(False)
        dlg.run()
        dlg.destroy() 
Example #6
Source File: gamewidget.py    From pychess with GNU General Public License v3.0 6 votes vote down vote up
def player_lagged(self, bm, player):
        if player in self.gamemodel.ficsplayers:
            content = get_infobarmessage_content(
                player, _(" has lagged for 30 seconds"),
                self.gamemodel.ficsgame.game_type)

            def response_cb(infobar, response, message):
                message.dismiss()
                return False

            message = InfoBarMessage(Gtk.MessageType.INFO, content,
                                     response_cb)
            message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                    Gtk.ResponseType.CANCEL))
            self.showMessage(message)
        return False 
Example #7
Source File: Human.py    From pychess with GNU General Public License v3.0 6 votes vote down vote up
def offerWithdrawn(self, offer):
        log.debug("Human.offerWithdrawn: self=%s %s" % (self, offer))
        assert offer.type in ACTION_NAMES
        heading = _("%s was withdrawn by your opponent") % ACTION_NAMES[
            offer.type]
        text = _("Your opponent seems to have changed their mind.")
        content = InfoBar.get_message_content(heading, text,
                                              Gtk.STOCK_DIALOG_INFO)

        def response_cb(infobar, response, message):
            message.dismiss()

        message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.gmwidg.showMessage(message) 
Example #8
Source File: Human.py    From pychess with GNU General Public License v3.0 6 votes vote down vote up
def offerDeclined(self, offer):
        log.debug("Human.offerDeclined: self=%s %s" % (self, offer))
        assert offer.type in ACTION_NAMES
        heading = _("%s was declined by your opponent") % ACTION_NAMES[
            offer.type]
        text = _("Resend %s?" % ACTION_NAMES[offer.type].lower())
        content = InfoBar.get_message_content(heading, text,
                                              Gtk.STOCK_DIALOG_INFO)

        def response_cb(infobar, response, message):
            if response == Gtk.ResponseType.ACCEPT:
                self.emit("offer", offer)
            message.dismiss()

        message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
        message.add_button(InfoBarMessageButton(
            _("Resend"), Gtk.ResponseType.ACCEPT))
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.gmwidg.replaceMessages(message) 
Example #9
Source File: customwidgets.py    From rednotebook with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        GObject.GObject.__init__(self)
        self.set_spacing(2)
        label = Gtk.Label(label="<b>%s</b>:" % _("Template"))
        label.set_use_markup(True)
        self.pack_start(label, False, False, 0)
        self.save_insert_button = Gtk.Button(_("Save and insert"))
        self.pack_start(self.save_insert_button, False, False, 0)
        self.save_button = Gtk.Button(stock=Gtk.STOCK_SAVE)
        self.pack_start(self.save_button, False, False, 0)
        self.close_button = Gtk.Button(stock=Gtk.STOCK_CLOSE)
        self.pack_start(self.close_button, False, False, 0)
        self.show_all() 
Example #10
Source File: cheatsheet_dialog.py    From bokken with GNU General Public License v2.0 5 votes vote down vote up
def popup_registers(self, widget):
        dialog = Gtk.Dialog('16-bit and 8-bit registers', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE,Gtk.ResponseType.CLOSE))
        ui.gtk3.common.set_bokken_icon(dialog)
        reg_img = Gtk.Image()
        reg_img.set_from_file(datafile_path('registers.png'))
        reg_label = Gtk.Label("The four primary general purpose registers (EAX, EBX, ECX and EDX)\nhave 16 and 8 bit overlapping aliases.")
        reg_label.set_alignment(0.1, 0.1)
        reg_label.set_padding (0, 3)
        dialog.vbox.pack_start(reg_label, False, False, 2)
        dialog.vbox.pack_start(reg_img, True, True, 2)
        dialog.show_all()
        dialog.run()
        dialog.destroy() 
Example #11
Source File: cheatsheet_dialog.py    From bokken with GNU General Public License v2.0 5 votes vote down vote up
def popup_stack(self, widget):
        dialog = Gtk.Dialog('The stack', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE,Gtk.ResponseType.CLOSE))
        ui.gtk3.common.set_bokken_icon(dialog)
        stack_img = Gtk.Image()
        stack_img.set_from_file(datafile_path('stack.png'))
        dialog.vbox.pack_start(self.create_h1_label("The stack"), False, False, 2)
        dialog.vbox.pack_start(stack_img, True, True, 2)
        dialog.show_all()
        dialog.run()
        dialog.destroy() 
Example #12
Source File: extras.py    From pympress with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent):
        super(TimingReport, self).__init__()
        self.load_ui('time_report_dialog')
        self.time_report_dialog.set_transient_for(parent.p_win)
        self.time_report_dialog.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
        self.connect_signals(self) 
Example #13
Source File: ui.py    From pympress with GNU General Public License v2.0 5 votes vote down vote up
def error_opening_file(self, filename):
        """ Remove the current document.
        """
        # Check if the path is valid
        if not os.path.exists(filename):
            msg = _('Could not find the file "{}"').format(filename)
        else:
            msg = _('Error opening the file "{}"').format(filename)
        dialog = Gtk.MessageDialog(transient_for = self.p_win, flags = Gtk.DialogFlags.MODAL,
                                   message_type = Gtk.MessageType.ERROR, message_format = msg)
        dialog.add_buttons(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
        dialog.set_position(Gtk.WindowPosition.CENTER)
        dialog.run()
        dialog.destroy() 
Example #14
Source File: Human.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def offerError(self, offer, error):
        log.debug("Human.offerError: self=%s error=%s %s" %
                  (self, error, offer))
        assert offer.type in ACTION_NAMES
        actionName = ACTION_NAMES[offer.type]
        if error == ACTION_ERROR_NONE_TO_ACCEPT:
            heading = _("Unable to accept %s") % actionName.lower()
            text = _("Probably because it has been withdrawn.")
        elif error == ACTION_ERROR_NONE_TO_DECLINE or \
                error == ACTION_ERROR_NONE_TO_WITHDRAW:
            # If the offer was not there, it has probably already been either
            # declined or withdrawn.
            return
        else:
            heading = _("%s returns an error") % actionName
            text = ERROR_MESSAGES[error]

        content = InfoBar.get_message_content(heading, text,
                                              Gtk.STOCK_DIALOG_WARNING)

        def response_cb(infobar, response, message):
            message.dismiss()

        message = InfoBarMessage(Gtk.MessageType.WARNING, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.gmwidg.showMessage(message) 
Example #15
Source File: Human.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def offer(self, offer):
        log.debug("Human.offer: self=%s %s" % (self, offer))
        assert offer.type in OFFER_MESSAGES

        if self.gamemodel.players[1 - self.color].__type__ is LOCAL:
            self.emit("accept", offer)
            return

        heading, text, takes_param = OFFER_MESSAGES[offer.type]
        if takes_param:
            heading = heading % offer.param
            text = text % offer.param

        def response_cb(infobar, response, message):
            if response == Gtk.ResponseType.ACCEPT:
                if offer.type == TAKEBACK_OFFER:
                    self.gamemodel.undoMoves(offer.param)
                self.emit("accept", offer)
            elif response == Gtk.ResponseType.NO:
                self.emit("decline", offer)
            message.dismiss()

        content = InfoBar.get_message_content(heading, text,
                                              Gtk.STOCK_DIALOG_QUESTION)
        message = InfoBarMessage(Gtk.MessageType.QUESTION, content,
                                 response_cb)
        message.add_button(InfoBarMessageButton(
            _("Accept"), Gtk.ResponseType.ACCEPT))
        message.add_button(InfoBarMessageButton(
            _("Decline"), Gtk.ResponseType.NO))
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.gmwidg.showMessage(message) 
Example #16
Source File: ArchiveListPanel.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def _infobar_adjourned_message(self, game, player):
        if player not in self.messages:
            text = _(" with whom you have an adjourned <b>%(timecontrol)s</b> " +
                     "<b>%(gametype)s</b> game is online.") % \
                {"timecontrol": game.display_timecontrol,
                 "gametype": game.game_type.display_text}
            content = get_infobarmessage_content(player,
                                                 text,
                                                 gametype=game.game_type)

            def callback(infobar, response, message):
                log.debug(
                    "%s" % player,
                    extra={"task": (self.connection.username,
                                    "_infobar_adjourned_message.callback")})
                if response == Gtk.ResponseType.ACCEPT:
                    self.connection.client.run_command("match %s" %
                                                       player.name)
                elif response == Gtk.ResponseType.HELP:
                    self.connection.adm.queryMoves(game)
                else:
                    try:
                        self.messages[player].dismiss()
                        del self.messages[player]
                    except KeyError:
                        pass
                return False

            message = InfoBarMessage(Gtk.MessageType.QUESTION, content,
                                     callback)
            message.add_button(InfoBarMessageButton(
                _("Request Continuation"), Gtk.ResponseType.ACCEPT))
            message.add_button(InfoBarMessageButton(
                _("Examine Adjourned Game"), Gtk.ResponseType.HELP))
            message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                    Gtk.ResponseType.CANCEL))
            make_sensitive_if_available(message.buttons[0], player)
            self.messages[player] = message
            self.infobar.push_message(message) 
Example #17
Source File: __init__.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def _add_notification_message(self, player, text, chat=False, replace=False):
        if replace:
            for message in self.messages:
                if isinstance(message, PlayerNotificationMessage) and message.player == player:
                    message.dismiss()

        content = get_infobarmessage_content(player, text)

        def response_cb(infobar, response, message):
            if response == 1:
                if player is None:
                    return
                self.chat.openChatWithPlayer(player.name)
            if response == 2:
                if player is None:
                    return
                self.connection.client.run_command("follow %s" % player.name)
            message.dismiss()
            #             self.messages.remove(message)
            return False

        message = PlayerNotificationMessage(Gtk.MessageType.INFO, content,
                                            response_cb, player, text)
        if chat:
            message.add_button(InfoBarMessageButton(_("Chat"), 1))
            message.add_button(InfoBarMessageButton(_("Follow"), 2))
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message) 
Example #18
Source File: __init__.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def our_seeks_removed(self, glm):
        label = Gtk.Label(label=_("Your seeks have been removed"))

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, label, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message) 
Example #19
Source File: __init__.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def req_not_fit_formula(self, bm, player, formula):
        content = get_infobarmessage_content2(
            player, _(" uses a formula not fitting your match request:"),
            formula)

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message) 
Example #20
Source File: __init__.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def player_on_noplay(self, bm, player):
        text = _(" noplay listing you")
        content = get_infobarmessage_content(player, text)

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message) 
Example #21
Source File: __init__.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def player_on_censor(self, bm, player):
        text = _(" is censoring you")
        content = get_infobarmessage_content(player, text)

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message) 
Example #22
Source File: __init__.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def matchDeclined(self, bm, player):
        text = _(" has declined your offer for a match")
        content = get_infobarmessage_content(player, text)

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message) 
Example #23
Source File: __init__.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def nonoWhileExamine(self, bm):
        label = Gtk.Label(_("You can't touch this! You are examining a game."))

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, label, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message) 
Example #24
Source File: message.py    From epoptes with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, text, title="Epoptes", markup=True,
                 icon_name="dialog-information"):
        super().__init__(title=title, icon_name=icon_name)
        self.set_position(Gtk.WindowPosition.CENTER)

        grid = Gtk.Grid(column_spacing=10, row_spacing=10, margin=10)
        self.add(grid)

        image = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.DIALOG)
        grid.add(image)

        # Always load the plain text first in case the markup parsing fails
        label = Gtk.Label(
            label=text, selectable=True, hexpand=True, vexpand=True,
            halign=Gtk.Align.START, valign=Gtk.Align.START)
        if markup:
            label.set_markup(text)
        grid.add(label)

        button = Gtk.Button.new_from_stock(Gtk.STOCK_CLOSE)
        button.set_hexpand(False)
        button.set_halign(Gtk.Align.END)
        button.connect("clicked", Gtk.main_quit)
        grid.attach(button, 1, 1, 2, 1)
        self.set_focus_child(button)

        accelgroup = Gtk.AccelGroup()
        key, modifier = Gtk.accelerator_parse('Escape')
        accelgroup.connect(
            key, modifier, Gtk.AccelFlags.VISIBLE, Gtk.main_quit)
        self.add_accel_group(accelgroup) 
Example #25
Source File: SeekListPanel.py    From pychess with GNU General Public License v3.0 4 votes vote down vote up
def onChallengeAdd(self, challenges, challenge):
        log.debug("%s" % challenge,
                  extra={"task": (self.connection.username, "onChallengeAdd")})
        SoundTab.playAction("aPlayerChecks")

        # TODO: differentiate between challenges and manual-seek-accepts
        # (wait until seeks are comparable FICSSeek objects to do this)
        # Related: http://code.google.com/p/pychess/issues/detail?id=206
        if challenge.adjourned:
            text = _(" would like to resume your adjourned <b>%(time)s</b> " +
                     "<b>%(gametype)s</b> game.") % \
                {"time": challenge.display_timecontrol,
                 "gametype": challenge.game_type.display_text}
        else:
            text = _(" challenges you to a <b>%(time)s</b> %(rated)s <b>%(gametype)s</b> game") \
                % {"time": challenge.display_timecontrol,
                   "rated": challenge.display_rated.lower(),
                   "gametype": challenge.game_type.display_text}
            if challenge.color:
                text += _(" where <b>%(player)s</b> plays <b>%(color)s</b>.") \
                    % {"player": challenge.player.name,
                       "color": _("white") if challenge.color == "white" else _("black")}
            else:
                text += "."
        content = get_infobarmessage_content(challenge.player,
                                             text,
                                             gametype=challenge.game_type)

        def callback(infobar, response, message):
            if response == Gtk.ResponseType.ACCEPT:
                self.connection.om.acceptIndex(challenge.index)
            elif response == Gtk.ResponseType.NO:
                self.connection.om.declineIndex(challenge.index)
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.QUESTION, content, callback)
        message.add_button(InfoBarMessageButton(
            _("Accept"), Gtk.ResponseType.ACCEPT))
        message.add_button(InfoBarMessageButton(
            _("Decline"), Gtk.ResponseType.NO))
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages[hash(challenge)] = message
        self.infobar.push_message(message)

        txi = self.store.prepend(
            [challenge, challenge.player.getIcon(gametype=challenge.game_type),
             self.chaPix, challenge.player.name +
             challenge.player.display_titles(), challenge.player_rating,
             challenge.display_rated, challenge.game_type.display_text,
             challenge.display_timecontrol, challenge.sortable_time,
             self.textcolor_normal(), get_challenge_tooltip_text(challenge)])
        self.challenges[hash(challenge)] = txi
        self.__updateActiveSeeksLabel()
        self.widgets["seektreeview"].scroll_to_cell(self.store.get_path(txi)) 
Example #26
Source File: notifier.py    From autokey with GNU General Public License v3.0 4 votes vote down vote up
def rebuild_menu(self):
        # Main Menu items
        self.errorItem = Gtk.MenuItem(_("View script error"))
        
        enableMenuItem = Gtk.CheckMenuItem(_("Enable Expansions"))
        enableMenuItem.set_active(self.app.service.is_running())
        enableMenuItem.set_sensitive(not self.app.serviceDisabled)
        
        configureMenuItem = Gtk.ImageMenuItem(_("Show Main Window"))
        configureMenuItem.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU))
        
        
        
        removeMenuItem = Gtk.ImageMenuItem(_("Remove icon"))
        removeMenuItem.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU))
        
        quitMenuItem = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, None)
                
        # Menu signals
        enableMenuItem.connect("toggled", self.on_enable_toggled)
        configureMenuItem.connect("activate", self.on_show_configure)
        removeMenuItem.connect("activate", self.on_remove_icon)
        quitMenuItem.connect("activate", self.on_destroy_and_exit)
        self.errorItem.connect("activate", self.on_show_error)
        
        # Get phrase folders to add to main menu
        folders = []
        items = []

        for folder in self.configManager.allFolders:
            if folder.show_in_tray_menu:
                folders.append(folder)
        
        for item in self.configManager.allItems:
            if item.show_in_tray_menu:
                items.append(item)
                    
        # Construct main menu
        self.menu = popupmenu.PopupMenu(self.app.service, folders, items, False)
        if len(items) > 0:
            self.menu.append(Gtk.SeparatorMenuItem())
        self.menu.append(self.errorItem)
        self.menu.append(enableMenuItem)
        self.menu.append(configureMenuItem)
        self.menu.append(removeMenuItem)
        self.menu.append(quitMenuItem)
        self.menu.show_all()
        self.errorItem.hide()
        self.indicator.set_menu(self.menu) 
Example #27
Source File: searchable.py    From bokken with GNU General Public License v2.0 4 votes vote down vote up
def _build_search(self, widget):
        '''Builds the search bar.'''
        self.srchtab = Gtk.HBox()
        # close button
        close = Gtk.Image()
        close.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
        eventbox = Gtk.EventBox()
        eventbox.add(close)
        eventbox.connect("button-release-event", self._close)
        self.srchtab.pack_start(eventbox, False, False, 3)
        # label
        label = Gtk.Label(label="Find:")
        self.srchtab.pack_start(label, False, False, 3)
        # entry
        self.search_entry = Gtk.Entry()
        self.search_entry.set_tooltip_text("Type here the phrase you want to find")
        self.search_entry.connect("activate", self._find, "next")
        self.search_entry.connect("changed", self._find_cb, "find")
        self.srchtab.pack_start(self.search_entry, False, False, 3)
        # find next button
        if self.small:
            but_text = ''
        else:
            but_text = 'Next'
        butn = SemiStockButton(but_text, Gtk.STOCK_GO_DOWN)
        butn.set_relief(Gtk.ReliefStyle.NONE)
        butn.connect("clicked", self._find, "next")
        butn.set_tooltip_text("Find the next ocurrence of the phrase")
        self.srchtab.pack_start(butn, False, False, 3)
        # find previous button
        if self.small:
            but_text = ''
        else:
            but_text = ('Previous')
        butp = SemiStockButton(but_text, Gtk.STOCK_GO_UP)
        butp.set_relief(Gtk.ReliefStyle.NONE)
        butp.connect("clicked", self._find, "previous")
        butp.set_tooltip_text("Find the previous ocurrence of the phrase")
        self.srchtab.pack_start(butp, False, False, 3)
        # make last two buttons equally width
        # MEOW
        wn,hn = butn.get_preferred_size()
        wp,hp = butp.get_preferred_size()
        newwidth = max(wn.width, wp.width)
        butn.set_size_request(newwidth, hn.height)
        butp.set_size_request(newwidth, hp.height)
        # Match case CheckButton
        butCase = Gtk.CheckButton(('Match case'))
        butCase.set_active(self._matchCaseValue)
        butCase.connect("clicked", self._matchCase)
        # FIXME
        # current version of Gtk.TextIter doesn't support SEARCH_CASE_INSENSITIVE
        #butCase.show()
        #self.srchtab.pack_start(butCase, expand=False, fill=False, padding=3)
        self.pack_start(self.srchtab, False, False, 0)
        # Results
        self._resultsLabel = Gtk.Label(label="")
        self.srchtab.pack_start(self._resultsLabel, False, False, 3)
        self.searching = False 
Example #28
Source File: PropertiesDialog.py    From bcloud with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, icon_window, app, path):
        file_path, file_name = os.path.split(path)
        # modify file_name if path is '/'
        if not file_name:
            file_name = '/'
        super().__init__(file_name + _(' Properties'), app.window,
                         Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
        self.set_border_width(15)

        box = self.get_content_area()

        grid = Gtk.Grid()
        grid.props.row_spacing = 8
        if Config.GTK_GE_312:
            grid.props.margin_start = 15
        else:
            grid.props.margin_left = 15
        grid.props.column_spacing = 15
        box.pack_start(grid, True, True, 10)

        name_label = LeftLabel(_('Name:'))
        grid.attach(name_label, 0, 0, 1, 1)
        name_label2 = SelectableLeftLabel(file_name)
        grid.attach(name_label2, 1, 0, 1, 1)

        location_label = LeftLabel(_('Location:'))
        grid.attach(location_label, 0, 1, 1, 1)
        location_label2 = SelectableLeftLabel(file_path)
        grid.attach(location_label2, 1, 1, 1, 1)

        file_count = 0
        folder_count = 0
        for row in icon_window.liststore:
            if row[ISDIR_COL]:
                folder_count = folder_count + 1
            else:
                file_count = file_count + 1
        contents = _('{0} folders, {1} files').format(folder_count, file_count)
        content_label = LeftLabel(_('Contents:'))
        grid.attach(content_label, 0, 2, 1, 1)
        content_label2 = SelectableLeftLabel(contents)
        grid.attach(content_label2, 1, 2, 1, 1)

        box.show_all()