Exemplo n.º 1
0
    def __init__(self):
        super(gtk.VBox, self).__init__()
        self.hbox = gtk.HBox()
        
        self.__init_plugins()

        self.result_window = None
        self.plugin = None

        self.connection_string = gtk.Entry()

        # Just setting defaults for testing
        self.connection_string.set_text(_('sqlite:///test.db'))
        self.hbox.pack_start(self.connection_string, True)

        self.button_connect = gtk.Button(label=_("Connect"))
        self.connect_handler = self.button_connect.connect('clicked', self.connect)
        self.hbox.pack_start(self.button_connect, False, False)

        self.button_execute = gtk.Button(label=_("Execute"))
        self.button_execute.connect('clicked', self.execute)
        self.button_execute.set_sensitive(False)
        self.hbox.pack_start(self.button_execute, False, False)

        self.pack_start(self.hbox, False, False)
        editor_window = gtk.ScrolledWindow()
        self.editor = PyQuilGtkEditor()

        # Just setting defaults for testing
        self.editor.get_buffer().set_text(_("SELECT * FROM memos"))
        editor_window.add(self.editor)
        self.pack_start(editor_window)
        self.tree_view = None

        self.show_all()
Exemplo n.º 2
0
    def execute_query(self, query):
        results = self.connection.execute(query)
        # if cursor is closed, we aren't fetching rows
        if results.closed:
            return [(_('Results', ))], [(_('%d Row(s) modified' % results.rowcount), )]

        data = results.fetchall()

        return results.keys(), data
Exemplo n.º 3
0
    def execute_query(self, query):
        results = self.connection.execute(query)
        # if cursor is closed, we aren't fetching rows
        if results.closed:
            return [(_('Results', ))
                    ], [(_('%d Row(s) modified' % results.rowcount), )]

        data = results.fetchall()

        return results.keys(), data
Exemplo n.º 4
0
def get_plugin(name):
    plugin = None

    if name == _('Sql Alchemy'):
        from plugins.sqlalchemy import SAQueryPlugin
        plugin = SAQueryPlugin()
    elif name == _('MSSQL'):
        from plugins.mssql import MSSQLQueryPlugin
        plugin = MSSQLQueryPlugin()

    return plugin
Exemplo n.º 5
0
def get_plugin(name):
    plugin = None

    if name == _('Sql Alchemy'):
        from plugins.sqlalchemy import SAQueryPlugin
        plugin = SAQueryPlugin()
    elif name == _('MSSQL'):
        from plugins.mssql import MSSQLQueryPlugin
        plugin = MSSQLQueryPlugin()

    return plugin
Exemplo n.º 6
0
    def __init_plugins(self):
        plugin_store = gtk.ListStore(gobject.TYPE_STRING)
        plugin_store.append ([_("Sql Alchemy")])
        plugin_store.append ([_("MSSQL")])

        self.combo_plugin = gtk.ComboBox()
        self.combo_plugin.set_model(plugin_store)
        cell = gtk.CellRendererText()
        self.combo_plugin.pack_start(cell, True)
        self.combo_plugin.add_attribute(cell, 'text', 0)
        self.combo_plugin.set_active(0)

        self.hbox.pack_start(self.combo_plugin, False, False)
Exemplo n.º 7
0
    def __init_plugins(self):
        plugin_store = gtk.ListStore(gobject.TYPE_STRING)
        plugin_store.append([_("Sql Alchemy")])
        plugin_store.append([_("MSSQL")])

        self.combo_plugin = gtk.ComboBox()
        self.combo_plugin.set_model(plugin_store)
        cell = gtk.CellRendererText()
        self.combo_plugin.pack_start(cell, True)
        self.combo_plugin.add_attribute(cell, 'text', 0)
        self.combo_plugin.set_active(0)

        self.hbox.pack_start(self.combo_plugin, False, False)
Exemplo n.º 8
0
    def disconnect(self, *args):
        try:
            self.plugin.disconnect()

            self.button_execute.set_sensitive(False)
            self.button_connect.disconnect(self.disconnect_handler)
            self.button_connect.set_label(_('Connect'))
            self.connect_handler = self.button_connect.connect('clicked', self.connect)
        except Exception as exc:
            self.display_error(str(exc))
Exemplo n.º 9
0
    def disconnect(self, *args):
        try:
            self.plugin.disconnect()

            self.button_execute.set_sensitive(False)
            self.button_connect.disconnect(self.disconnect_handler)
            self.button_connect.set_label(_('Connect'))
            self.connect_handler = self.button_connect.connect(
                'clicked', self.connect)
        except Exception as exc:
            self.display_error(str(exc))
Exemplo n.º 10
0
    def connect(self, *args):
        conn_string = self.connection_string.get_text()
        selected_plugin = self.combo_plugin.get_active_text()

        self.plugin = get_plugin(selected_plugin)

        try:
            self.plugin.connect(conn_string)
            self.button_execute.set_sensitive(True)

            self.button_connect.disconnect(self.connect_handler)
            self.button_connect.set_label(_('Disconnect'))
            self.disconnect_handler = self.button_connect.connect('clicked', self.disconnect)
        except Exception as exc:
            self.display_error(str(exc))
Exemplo n.º 11
0
    def __init__(self):
        super(gtk.VBox, self).__init__()
        self.hbox = gtk.HBox()

        self.__init_plugins()

        self.result_window = None
        self.plugin = None

        self.connection_string = gtk.Entry()

        # Just setting defaults for testing
        self.connection_string.set_text(_('sqlite:///test.db'))
        self.hbox.pack_start(self.connection_string, True)

        self.button_connect = gtk.Button(label=_("Connect"))
        self.connect_handler = self.button_connect.connect(
            'clicked', self.connect)
        self.hbox.pack_start(self.button_connect, False, False)

        self.button_execute = gtk.Button(label=_("Execute"))
        self.button_execute.connect('clicked', self.execute)
        self.button_execute.set_sensitive(False)
        self.hbox.pack_start(self.button_execute, False, False)

        self.pack_start(self.hbox, False, False)
        editor_window = gtk.ScrolledWindow()
        self.editor = PyQuilGtkEditor()

        # Just setting defaults for testing
        self.editor.get_buffer().set_text(_("SELECT * FROM memos"))
        editor_window.add(self.editor)
        self.pack_start(editor_window)
        self.tree_view = None

        self.show_all()
Exemplo n.º 12
0
    def connect(self, *args):
        conn_string = self.connection_string.get_text()
        selected_plugin = self.combo_plugin.get_active_text()

        self.plugin = get_plugin(selected_plugin)

        try:
            self.plugin.connect(conn_string)
            self.button_execute.set_sensitive(True)

            self.button_connect.disconnect(self.connect_handler)
            self.button_connect.set_label(_('Disconnect'))
            self.disconnect_handler = self.button_connect.connect(
                'clicked', self.disconnect)
        except Exception as exc:
            self.display_error(str(exc))
Exemplo n.º 13
0
    def __init_menubar(self):
        self.menubar = gtk.MenuBar()
        self.menus = {}
        self.menubar_items = {}

        self.vbox.pack_start(self.menubar, False, False)

        file_menu = gtk.Menu()
        menu = self.add_menu('file', _('_File'), file_menu)

        new = gtk.ImageMenuItem(gtk.STOCK_NEW)
        new.connect('activate', self.new_tab)
        menu.append(new)

        quit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        quit.connect('activate', self.quit)
        menu.append(quit)

        save = gtk.ImageMenuItem(gtk.STOCK_SAVE)
        save.connect('activate', self.save)
        menu.append(save)
Exemplo n.º 14
0
    def __init__(self):
        super(PyQuilGtkWindow, self).__init__()

        # A decent default size
        self.resize(800, 500)
        self.set_title(_('PyQuil'))

        self.vbox = gtk.VBox()
        self.add(self.vbox)

        # create our file menu
        self.__init_menubar()

        # create the tabbed interface
        self.__init_notebook()

        self.connect('delete-event', lambda *a: gtk.main_quit())

        self.new_tab()

        self.show_all()
Exemplo n.º 15
0
    def __init_menubar(self):
        self.menubar = gtk.MenuBar()
        self.menus = {}
        self.menubar_items = {}

        self.vbox.pack_start(self.menubar, False, False)

        file_menu = gtk.Menu()
        menu = self.add_menu('file', _('_File'), file_menu)

        new = gtk.ImageMenuItem(gtk.STOCK_NEW)
        new.connect('activate', self.new_tab)
        menu.append(new)

        quit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        quit.connect('activate', self.quit)
        menu.append(quit)

        save = gtk.ImageMenuItem(gtk.STOCK_SAVE)
        save.connect('activate', self.save)
        menu.append(save)
Exemplo n.º 16
0
    def __init__(self):
        super(PyQuilGtkWindow, self).__init__()

        # A decent default size
        self.resize(800, 500)
        self.set_title(_('PyQuil'))

        self.vbox = gtk.VBox()
        self.add(self.vbox)

        # create our file menu
        self.__init_menubar()

        # create the tabbed interface
        self.__init_notebook()

        self.connect('delete-event', lambda *a: gtk.main_quit())

        self.new_tab()

        self.show_all()