# Path: draobpilc/lib/gpaste_client.py
# class Action():
# class Target():
#     REPLACE = 'REPLACE'
#     REMOVE = 'REMOVE'
#     ALL = 'ALL'
#     POSITION = 'POSITION'
# SCHEMA_ID = common.SETTINGS[common.GPASTE_SCHEMA_ID]
#     SETTINGS = utils.get_settings(SCHEMA_ID)
# def get_prop(property_name):
# def connect(name, callback):
# def disconnect(signal_match):
# def add(text):
# def get_history():
# def get_raw_history():
# def get_element(uuid):
# def get_raw_element(uuid):
# def select(uuid):
# def get_element_kind(uuid):
# def replace(uuid, contents):
# def delete(uuid):
# def list_histories():
# def get_history_size(name):
# def get_history_name():
# def switch_history(name):
# def delete_history(name):
# def empty_history(name):
# def track(t):
# def reexecute():
# def backup_history(history_name, backup_name):
# 
# Path: draobpilc/widgets/backup_history_dialog.py
# class BackupHistoryDialog(Gtk.Dialog):
# 
#     def __init__(self, transient_for=None, current_name=None):
#         super().__init__(use_header_bar=True)
# 
#         self.set_title(_('Backup history'))
#         self.set_resizable(False)
#         if transient_for: self.set_transient_for(transient_for)
#         self.set_position(Gtk.WindowPosition.CENTER)
#         self.set_destroy_with_parent(True)
#         self.set_modal(True)
#         self.add_buttons(
#             _('Backup'),
#             Gtk.ResponseType.OK,
#             _('Cancel'),
#             Gtk.ResponseType.CANCEL
#         )
# 
#         self._current_name = current_name or gpaste_client.get_history_name()
#         backup_name = self._current_name + _('_backup')
# 
#         self._label = Gtk.Label()
#         self._label.set_label (
#             _('Under which name do you want to backup this history?')
#         )
#         self._label.props.margin = 10
# 
#         self._error_label = Gtk.Label()
#         self._error_label.props.margin = 10
#         self._error_label.hide()
# 
#         label_overlay = Gtk.Overlay()
#         label_overlay.add(self._label)
#         label_overlay.add_overlay(self._error_label)
# 
#         self._entry = Gtk.Entry()
#         self._entry.props.margin = 10
#         self._entry.set_text(backup_name)
#         self._entry.connect('activate', self._on_entry_activate)
#         self._entry.props.buffer.connect('notify::text',
#             lambda b, p: self._hide_error()
#         )
# 
#         content_area = self.get_content_area()
#         content_area.add(label_overlay)
#         content_area.add(self._entry)
#         content_area.show_all()
# 
#         self.connect('response', self._on_response)
# 
#     def _on_entry_activate(self, entry):
#         self._backup_history(self._entry.get_text()) and self.destroy()
# 
#     def _on_response(self, dialog, response_id):
#         if response_id == Gtk.ResponseType.OK:
#             self._backup_history(self._entry.get_text()) and self.destroy()
#         else:
#             self.destroy()
# 
#     def _hide_error(self):
#         self._error_label.hide()
#         self._label.set_opacity(1)
# 
#     def _show_error(self):
#         self._label.set_opacity(0)
#         self._error_label.show()
# 
#     def _backup_history(self, name):
#         histories = gpaste_client.list_histories()
# 
#         if name in histories:
#             msg = _('Name "%s" already exists.') % name
#             self._error_label.set_markup('<span fgcolor="red">%s</span>' % msg)
#             self._show_error()
#             return False
# 
#         gpaste_client.backup_history(self._current_name, name)
# 
#         return True


from gi.repository import Gtk
from gi.repository import GObject
from draobpilc.lib import gpaste_client
from draobpilc.widgets.backup_history_dialog import BackupHistoryDialog
        self.set_orientation(Gtk.Orientation.HORIZONTAL)
        self.set_halign(Gtk.Align.END)
        self.set_valign(Gtk.Align.CENTER)
        self.set_hexpand(True)
        self.set_vexpand(False)

        self.link = Gtk.LinkButton()
        self.link.connect('activate-link', self._on_activate_link)
        self.link.set_label('...')
        self.link.set_tooltip_text(_('Open histories manager'))

        self._entry = Gtk.Entry()
        self._entry.set_placeholder_text(_('New history'))
        self._entry.set_icon_from_icon_name(
            Gtk.EntryIconPosition.PRIMARY,
            'list-add-symbolic'
        )
        self._entry.connect('activate', self._on_entry_activate)

        self._box = Gtk.Box()
        self._box.set_orientation(Gtk.Orientation.VERTICAL)
        self._box.add(self._entry)

        self.popover = Gtk.Popover()
        self.popover.set_relative_to(self.link)
        self.popover.add(self._box)

        self.add(self.link)

        gpaste_client.connect('SwitchHistory', self.update)

# Path: draobpilc/lib/gpaste_client.py
# class Action():
# class Target():
#     REPLACE = 'REPLACE'
#     REMOVE = 'REMOVE'
#     ALL = 'ALL'
#     POSITION = 'POSITION'
# SCHEMA_ID = common.SETTINGS[common.GPASTE_SCHEMA_ID]
#     SETTINGS = utils.get_settings(SCHEMA_ID)
# def get_prop(property_name):
# def connect(name, callback):
# def disconnect(signal_match):
# def add(text):
# def get_history():
# def get_raw_history():
# def get_element(uuid):
# def get_raw_element(uuid):
# def select(uuid):
# def get_element_kind(uuid):
# def replace(uuid, contents):
# def delete(uuid):
# def list_histories():
# def get_history_size(name):
# def get_history_name():
# def switch_history(name):
# def delete_history(name):
# def empty_history(name):
# def track(t):
# def reexecute():
# def backup_history(history_name, backup_name):
# 
# Path: draobpilc/widgets/backup_history_dialog.py
# class BackupHistoryDialog(Gtk.Dialog):
# 
#     def __init__(self, transient_for=None, current_name=None):
#         super().__init__(use_header_bar=True)
# 
#         self.set_title(_('Backup history'))
#         self.set_resizable(False)
#         if transient_for: self.set_transient_for(transient_for)
#         self.set_position(Gtk.WindowPosition.CENTER)
#         self.set_destroy_with_parent(True)
#         self.set_modal(True)
#         self.add_buttons(
#             _('Backup'),
#             Gtk.ResponseType.OK,
#             _('Cancel'),
#             Gtk.ResponseType.CANCEL
#         )
# 
#         self._current_name = current_name or gpaste_client.get_history_name()
#         backup_name = self._current_name + _('_backup')
# 
#         self._label = Gtk.Label()
#         self._label.set_label (
#             _('Under which name do you want to backup this history?')
#         )
#         self._label.props.margin = 10
# 
#         self._error_label = Gtk.Label()
#         self._error_label.props.margin = 10
#         self._error_label.hide()
# 
#         label_overlay = Gtk.Overlay()
#         label_overlay.add(self._label)
#         label_overlay.add_overlay(self._error_label)
# 
#         self._entry = Gtk.Entry()
#         self._entry.props.margin = 10
#         self._entry.set_text(backup_name)
#         self._entry.connect('activate', self._on_entry_activate)
#         self._entry.props.buffer.connect('notify::text',
#             lambda b, p: self._hide_error()
#         )
# 
#         content_area = self.get_content_area()
#         content_area.add(label_overlay)
#         content_area.add(self._entry)
#         content_area.show_all()
# 
#         self.connect('response', self._on_response)
# 
#     def _on_entry_activate(self, entry):
#         self._backup_history(self._entry.get_text()) and self.destroy()
# 
#     def _on_response(self, dialog, response_id):
#         if response_id == Gtk.ResponseType.OK:
#             self._backup_history(self._entry.get_text()) and self.destroy()
#         else:
#             self.destroy()
# 
#     def _hide_error(self):
#         self._error_label.hide()
#         self._label.set_opacity(1)
# 
#     def _show_error(self):
#         self._label.set_opacity(0)
#         self._error_label.show()
# 
#     def _backup_history(self, name):
#         histories = gpaste_client.list_histories()
# 
#         if name in histories:
#             msg = _('Name "%s" already exists.') % name
#             self._error_label.set_markup('<span fgcolor="red">%s</span>' % msg)
#             self._show_error()
#             return False
# 
#         gpaste_client.backup_history(self._current_name, name)
# 
#         return True


# Path: draobpilc/widgets/histories_manager.py
from gi.repository import Gtk
from gi.repository import GObject
from draobpilc.lib import gpaste_client
from draobpilc.widgets.backup_history_dialog import BackupHistoryDialog

        self.set_orientation(Gtk.Orientation.HORIZONTAL)
        self.set_halign(Gtk.Align.END)
        self.set_valign(Gtk.Align.CENTER)
        self.set_hexpand(True)
        self.set_vexpand(False)

        self.link = Gtk.LinkButton()
        self.link.connect('activate-link', self._on_activate_link)
        self.link.set_label('...')
        self.link.set_tooltip_text(_('Open histories manager'))

        self._entry = Gtk.Entry()
        self._entry.set_placeholder_text(_('New history'))
        self._entry.set_icon_from_icon_name(
            Gtk.EntryIconPosition.PRIMARY,
            'list-add-symbolic'
        )
        self._entry.connect('activate', self._on_entry_activate)

        self._box = Gtk.Box()
        self._box.set_orientation(Gtk.Orientation.VERTICAL)
        self._box.add(self._entry)

        self.popover = Gtk.Popover()
        self.popover.set_relative_to(self.link)
        self.popover.add(self._box)

        self.add(self.link)

        gpaste_client.connect('SwitchHistory', self.update)

        gpaste_client.connect('DeleteHistory', self.update)