Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* db.c generated by valac 0.11.6, the Vala compiler
- * generated from db.vala, do not modify */
- /*
- * Copyright 2010 Colomban Wendling <ban(at)herbesfolles(dot)org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
- #include <glib.h>
- #include <glib-object.h>
- #include <geanyplugin.h>
- #include <gtk/gtk.h>
- #include <postgresql/libpq-fe.h>
- #include <stdlib.h>
- #include <string.h>
- #include <glib/gstdio.h>
- #include <stdio.h>
- #define TYPE_PLUGIN_QUERY_WINDOW (plugin_query_window_get_type ())
- #define PLUGIN_QUERY_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLUGIN_QUERY_WINDOW, PluginQueryWindow))
- #define PLUGIN_QUERY_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLUGIN_QUERY_WINDOW, PluginQueryWindowClass))
- #define IS_PLUGIN_QUERY_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLUGIN_QUERY_WINDOW))
- #define IS_PLUGIN_QUERY_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLUGIN_QUERY_WINDOW))
- #define PLUGIN_QUERY_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLUGIN_QUERY_WINDOW, PluginQueryWindowClass))
- typedef struct _PluginQueryWindow PluginQueryWindow;
- typedef struct _PluginQueryWindowClass PluginQueryWindowClass;
- typedef struct _PluginQueryWindowPrivate PluginQueryWindowPrivate;
- #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
- #define _PQfinish0(var) ((var == NULL) ? NULL : (var = (PQfinish (var), NULL)))
- #define _PQclear0(var) ((var == NULL) ? NULL : (var = (PQclear (var), NULL)))
- #define _g_free0(var) (var = (g_free (var), NULL))
- #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
- struct _PluginQueryWindow {
- GtkWindow parent_instance;
- PluginQueryWindowPrivate * priv;
- };
- struct _PluginQueryWindowClass {
- GtkWindowClass parent_class;
- };
- struct _PluginQueryWindowPrivate {
- GtkTreeView* results;
- GtkTextView* text_view;
- gint col_count;
- gboolean data_loaded;
- PGconn* pgconn;
- PGresult* pgresult;
- };
- extern GeanyPlugin* geany_plugin;
- GeanyPlugin* geany_plugin = NULL;
- extern GeanyData* geany_data;
- GeanyData* geany_data = NULL;
- extern GeanyFunctions* geany_functions;
- GeanyFunctions* geany_functions = NULL;
- extern GSList* G_destroy_widget_stack;
- GSList* G_destroy_widget_stack = NULL;
- static gpointer plugin_query_window_parent_class = NULL;
- GType plugin_query_window_get_type (void) G_GNUC_CONST;
- #define PLUGIN_QUERY_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PLUGIN_QUERY_WINDOW, PluginQueryWindowPrivate))
- enum {
- PLUGIN_QUERY_WINDOW_DUMMY_PROPERTY
- };
- PluginQueryWindow* plugin_query_window_new (void);
- PluginQueryWindow* plugin_query_window_construct (GType object_type);
- static void _lambda0_ (PluginQueryWindow* self);
- static void plugin_query_window_on_open_clicked (PluginQueryWindow* self);
- static void __lambda0__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self);
- static void _lambda1_ (PluginQueryWindow* self);
- static gboolean plugin_query_window_db_connect (PluginQueryWindow* self, const gchar* host, const gchar* user, const gchar* password, const gchar* dbname);
- static void __lambda1__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self);
- static void _lambda2_ (PluginQueryWindow* self);
- static void plugin_query_window_perform_query (PluginQueryWindow* self);
- static void __lambda2__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self);
- static void _lambda3_ (PluginQueryWindow* self);
- static void __lambda3__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self);
- static void _lambda4_ (PluginQueryWindow* self);
- static gint plugin_query_window_plugin_db_disconnect (PluginQueryWindow* self);
- static void __lambda4__gtk_object_destroy (GtkObject* _sender, gpointer self);
- static void plugin_query_window_open_file (PluginQueryWindow* self, const gchar* filename);
- static void plugin_query_window_update_results (PluginQueryWindow* self);
- static void plugin_query_window_finalize (GObject* obj);
- gint plugin_version_check (gint abi_version);
- void plugin_set_info (PluginInfo* info);
- void plugin_init (GeanyData* data);
- static void _lambda5_ (void);
- static void __lambda5__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
- void plugin_cleanup (void);
- static void _lambda0_ (PluginQueryWindow* self) {
- plugin_query_window_on_open_clicked (self);
- }
- static void __lambda0__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
- _lambda0_ (self);
- }
- static void _lambda1_ (PluginQueryWindow* self) {
- plugin_query_window_db_connect (self, "localhost", "webuser", "webuser", "fulcrum");
- }
- static void __lambda1__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
- _lambda1_ (self);
- }
- static void _lambda2_ (PluginQueryWindow* self) {
- plugin_query_window_perform_query (self);
- }
- static void __lambda2__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
- _lambda2_ (self);
- }
- static void _lambda3_ (PluginQueryWindow* self) {
- gtk_object_destroy ((GtkObject*) self);
- }
- static void __lambda3__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
- _lambda3_ (self);
- }
- static void _lambda4_ (PluginQueryWindow* self) {
- plugin_query_window_plugin_db_disconnect (self);
- }
- static void __lambda4__gtk_object_destroy (GtkObject* _sender, gpointer self) {
- _lambda4_ (self);
- }
- PluginQueryWindow* plugin_query_window_construct (GType object_type) {
- PluginQueryWindow * self = NULL;
- GtkToolButton* _tmp0_ = NULL;
- GtkToolButton* open_button;
- GtkToolButton* _tmp1_ = NULL;
- GtkToolButton* connect_button;
- GtkToolButton* _tmp2_ = NULL;
- GtkToolButton* execute_button;
- GtkToolButton* _tmp3_ = NULL;
- GtkToolButton* close_button;
- GtkToolbar* _tmp4_ = NULL;
- GtkToolbar* toolbar;
- GtkTextView* _tmp5_ = NULL;
- GtkTextView* _tmp6_;
- GtkTextBuffer* _tmp7_ = NULL;
- GtkScrolledWindow* _tmp8_ = NULL;
- GtkScrolledWindow* query_scroll;
- GtkTreeView* _tmp9_ = NULL;
- GtkTreeView* _tmp10_;
- GtkScrolledWindow* _tmp11_ = NULL;
- GtkScrolledWindow* result_scroll;
- GtkVBox* _tmp12_ = NULL;
- GtkVBox* vbox;
- self = (PluginQueryWindow*) g_object_new (object_type, NULL);
- gtk_window_set_title ((GtkWindow*) self, "Query Window");
- ((GtkWindow*) self)->position = (guint) GTK_WIN_POS_CENTER;
- gtk_window_set_default_size ((GtkWindow*) self, 800, 500);
- ((GtkWindow*) self)->position = (guint) GTK_WIN_POS_CENTER;
- self->priv->data_loaded = FALSE;
- _tmp0_ = (GtkToolButton*) gtk_tool_button_new_from_stock (GTK_STOCK_OPEN);
- open_button = g_object_ref_sink (_tmp0_);
- gtk_tool_button_set_label (open_button, "Open Query");
- g_signal_connect_object (open_button, "clicked", (GCallback) __lambda0__gtk_tool_button_clicked, self, 0);
- _tmp1_ = (GtkToolButton*) gtk_tool_button_new_from_stock (GTK_STOCK_CONNECT);
- connect_button = g_object_ref_sink (_tmp1_);
- gtk_tool_button_set_label (connect_button, "Connect to DB");
- g_signal_connect_object (connect_button, "clicked", (GCallback) __lambda1__gtk_tool_button_clicked, self, 0);
- _tmp2_ = (GtkToolButton*) gtk_tool_button_new_from_stock (GTK_STOCK_EXECUTE);
- execute_button = g_object_ref_sink (_tmp2_);
- gtk_tool_button_set_label (execute_button, "Execute Query");
- g_signal_connect_object (execute_button, "clicked", (GCallback) __lambda2__gtk_tool_button_clicked, self, 0);
- _tmp3_ = (GtkToolButton*) gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
- close_button = g_object_ref_sink (_tmp3_);
- gtk_tool_button_set_label (close_button, "Close Window");
- g_signal_connect_object (close_button, "clicked", (GCallback) __lambda3__gtk_tool_button_clicked, self, 0);
- _tmp4_ = (GtkToolbar*) gtk_toolbar_new ();
- toolbar = g_object_ref_sink (_tmp4_);
- gtk_toolbar_set_style (toolbar, GTK_TOOLBAR_BOTH);
- gtk_container_add ((GtkContainer*) toolbar, (GtkWidget*) open_button);
- gtk_container_add ((GtkContainer*) toolbar, (GtkWidget*) connect_button);
- gtk_container_add ((GtkContainer*) toolbar, (GtkWidget*) execute_button);
- gtk_container_add ((GtkContainer*) toolbar, (GtkWidget*) close_button);
- _tmp5_ = (GtkTextView*) gtk_text_view_new ();
- _tmp6_ = g_object_ref_sink (_tmp5_);
- _g_object_unref0 (self->priv->text_view);
- self->priv->text_view = _tmp6_;
- _tmp7_ = gtk_text_view_get_buffer (self->priv->text_view);
- g_object_set (_tmp7_, "text", "select * from projects;", NULL);
- _tmp8_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
- query_scroll = g_object_ref_sink (_tmp8_);
- gtk_scrolled_window_set_policy (query_scroll, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add ((GtkContainer*) query_scroll, (GtkWidget*) self->priv->text_view);
- _tmp9_ = (GtkTreeView*) gtk_tree_view_new ();
- _tmp10_ = g_object_ref_sink (_tmp9_);
- _g_object_unref0 (self->priv->results);
- self->priv->results = _tmp10_;
- _tmp11_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
- result_scroll = g_object_ref_sink (_tmp11_);
- gtk_scrolled_window_set_policy (result_scroll, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add ((GtkContainer*) result_scroll, (GtkWidget*) self->priv->results);
- _tmp12_ = (GtkVBox*) gtk_vbox_new (FALSE, 0);
- vbox = g_object_ref_sink (_tmp12_);
- gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) toolbar, FALSE, TRUE, (guint) 0);
- gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) query_scroll, TRUE, TRUE, (guint) 0);
- gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) result_scroll, TRUE, TRUE, (guint) 0);
- gtk_container_add ((GtkContainer*) self, (GtkWidget*) vbox);
- plugin_query_window_db_connect (self, "localhost", "webuser", "webuser", "fulcrum");
- g_signal_connect_object ((GtkObject*) self, "destroy", (GCallback) __lambda4__gtk_object_destroy, self, 0);
- gtk_widget_show_all ((GtkWidget*) self);
- _g_object_unref0 (vbox);
- _g_object_unref0 (result_scroll);
- _g_object_unref0 (query_scroll);
- _g_object_unref0 (toolbar);
- _g_object_unref0 (close_button);
- _g_object_unref0 (execute_button);
- _g_object_unref0 (connect_button);
- _g_object_unref0 (open_button);
- return self;
- }
- PluginQueryWindow* plugin_query_window_new (void) {
- return plugin_query_window_construct (TYPE_PLUGIN_QUERY_WINDOW);
- }
- static void plugin_query_window_on_open_clicked (PluginQueryWindow* self) {
- GtkFileChooserDialog* _tmp0_ = NULL;
- GtkFileChooserDialog* file_chooser;
- gint _tmp1_;
- g_return_if_fail (self != NULL);
- _tmp0_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Open File", (GtkWindow*) self, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
- file_chooser = g_object_ref_sink (_tmp0_);
- _tmp1_ = gtk_dialog_run ((GtkDialog*) file_chooser);
- if (_tmp1_ == GTK_RESPONSE_ACCEPT) {
- gchar* _tmp2_ = NULL;
- gchar* _tmp3_;
- _tmp2_ = gtk_file_chooser_get_filename ((GtkFileChooser*) file_chooser);
- _tmp3_ = _tmp2_;
- plugin_query_window_open_file (self, _tmp3_);
- _g_free0 (_tmp3_);
- }
- gtk_object_destroy ((GtkObject*) file_chooser);
- _g_object_unref0 (file_chooser);
- }
- static void plugin_query_window_open_file (PluginQueryWindow* self, const gchar* filename) {
- gchar* text = NULL;
- gchar* _tmp0_ = NULL;
- GtkTextBuffer* _tmp1_ = NULL;
- GError * _inner_error_ = NULL;
- g_return_if_fail (self != NULL);
- g_return_if_fail (filename != NULL);
- g_file_get_contents (filename, &_tmp0_, NULL, &_inner_error_);
- _g_free0 (text);
- text = _tmp0_;
- if (_inner_error_ != NULL) {
- _g_free0 (text);
- goto __catch0_g_error;
- }
- _tmp1_ = gtk_text_view_get_buffer (self->priv->text_view);
- g_object_set (_tmp1_, "text", text, NULL);
- _g_free0 (text);
- goto __finally0;
- __catch0_g_error:
- {
- GError * e;
- e = _inner_error_;
- _inner_error_ = NULL;
- fprintf (stderr, "Error: %s\n", e->message);
- _g_error_free0 (e);
- }
- __finally0:
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- }
- static void plugin_query_window_perform_query (PluginQueryWindow* self) {
- GtkTextBuffer* _tmp0_ = NULL;
- gchar* _tmp1_ = NULL;
- gchar* query;
- gchar* _tmp2_;
- g_return_if_fail (self != NULL);
- _tmp0_ = gtk_text_view_get_buffer (self->priv->text_view);
- query = (g_object_get (_tmp0_, "text", &_tmp1_, NULL), _tmp1_);
- _tmp2_ = g_strconcat ("trying to execute query: ", query, NULL);
- msgwin_status_add ("%s", _tmp2_);
- _g_free0 (_tmp2_);
- if (g_strcmp0 (query, "") != 0) {
- PGresult* _tmp3_ = NULL;
- PGresult* _tmp4_;
- _tmp3_ = PQexec (self->priv->pgconn, query);
- _tmp4_ = _tmp3_;
- _PQclear0 (self->priv->pgresult);
- self->priv->pgresult = _tmp4_;
- plugin_query_window_update_results (self);
- } else {
- GtkWindow* _tmp5_ = NULL;
- GtkWindow* window;
- GtkButton* _tmp6_ = NULL;
- GtkButton* button;
- _tmp5_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL);
- window = g_object_ref_sink (_tmp5_);
- gtk_window_set_title (window, "Error");
- gtk_window_set_default_size (window, 300, 50);
- window->position = (guint) GTK_WIN_POS_CENTER;
- _tmp6_ = (GtkButton*) gtk_button_new_with_label ("Please enter a query");
- button = g_object_ref_sink (_tmp6_);
- gtk_container_add ((GtkContainer*) window, (GtkWidget*) button);
- gtk_widget_show_all ((GtkWidget*) window);
- _g_object_unref0 (button);
- _g_object_unref0 (window);
- }
- _g_free0 (query);
- }
- static gpointer _g_object_ref0 (gpointer self) {
- return self ? g_object_ref (self) : NULL;
- }
- static void plugin_query_window_update_results (PluginQueryWindow* self) {
- gint _tmp2_;
- gint nFields;
- GType* _tmp3_ = NULL;
- GType* cols;
- gint cols_length1;
- gint _cols_size_;
- GtkListStore* _tmp5_ = NULL;
- GtkListStore* listmodel;
- GtkTreeIter iter = {0};
- g_return_if_fail (self != NULL);
- if (self->priv->data_loaded) {
- {
- gint i;
- i = self->priv->col_count;
- {
- gboolean _tmp0_;
- _tmp0_ = TRUE;
- while (TRUE) {
- GtkTreeViewColumn* _tmp1_ = NULL;
- if (!_tmp0_) {
- i--;
- }
- _tmp0_ = FALSE;
- if (!(i >= 0)) {
- break;
- }
- _tmp1_ = gtk_tree_view_get_column (self->priv->results, i);
- gtk_tree_view_remove_column (self->priv->results, _tmp1_);
- }
- }
- }
- }
- _tmp2_ = PQnfields (self->priv->pgresult);
- nFields = _tmp2_;
- _tmp3_ = g_new0 (GType, nFields);
- cols = _tmp3_;
- cols_length1 = nFields;
- _cols_size_ = nFields;
- {
- gint i;
- i = 0;
- {
- gboolean _tmp4_;
- _tmp4_ = TRUE;
- while (TRUE) {
- if (!_tmp4_) {
- i++;
- }
- _tmp4_ = FALSE;
- if (!(i < nFields)) {
- break;
- }
- cols[i] = G_TYPE_STRING;
- }
- }
- }
- _tmp5_ = gtk_list_store_newv (cols_length1, cols);
- listmodel = _tmp5_;
- gtk_tree_view_set_model (self->priv->results, (GtkTreeModel*) listmodel);
- {
- gint i;
- i = 0;
- {
- gboolean _tmp6_;
- _tmp6_ = TRUE;
- while (TRUE) {
- const gchar* _tmp7_ = NULL;
- GtkCellRendererText* _tmp8_ = NULL;
- GtkCellRendererText* _tmp9_;
- GtkTreeViewColumn* _tmp10_ = NULL;
- GtkTreeViewColumn* _tmp11_;
- GtkTreeViewColumn* column;
- const gchar* _tmp12_ = NULL;
- gchar* _tmp13_;
- gchar* _tmp14_;
- if (!_tmp6_) {
- i++;
- }
- _tmp6_ = FALSE;
- if (!(i < nFields)) {
- break;
- }
- _tmp7_ = PQfname (self->priv->pgresult, i);
- _tmp8_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
- _tmp9_ = g_object_ref_sink (_tmp8_);
- gtk_tree_view_insert_column_with_attributes (self->priv->results, -1, _tmp7_, (GtkCellRenderer*) _tmp9_, "text", 0, NULL);
- _g_object_unref0 (_tmp9_);
- _tmp10_ = gtk_tree_view_get_column (self->priv->results, i);
- _tmp11_ = _g_object_ref0 (_tmp10_);
- column = _tmp11_;
- gtk_tree_view_column_set_resizable (column, TRUE);
- _tmp12_ = gtk_tree_view_column_get_title (column);
- _tmp13_ = g_strconcat ("Setting ", _tmp12_, NULL);
- _tmp14_ = g_strconcat (_tmp13_, " to resizable", NULL);
- msgwin_status_add ("%s", _tmp14_);
- _g_free0 (_tmp14_);
- _g_free0 (_tmp13_);
- _g_object_unref0 (column);
- }
- }
- }
- {
- gint i;
- i = 0;
- {
- gboolean _tmp15_;
- _tmp15_ = TRUE;
- while (TRUE) {
- gint _tmp16_;
- GtkTreeIter _tmp17_ = {0};
- if (!_tmp15_) {
- i++;
- }
- _tmp15_ = FALSE;
- _tmp16_ = PQntuples (self->priv->pgresult);
- if (!(i < _tmp16_)) {
- break;
- }
- gtk_list_store_append (listmodel, &_tmp17_);
- iter = _tmp17_;
- {
- gint j;
- j = 0;
- {
- gboolean _tmp18_;
- _tmp18_ = TRUE;
- while (TRUE) {
- const gchar* _tmp19_ = NULL;
- gchar* _tmp20_;
- gchar* myval;
- gchar* _tmp21_;
- if (!_tmp18_) {
- j++;
- }
- _tmp18_ = FALSE;
- if (!(j < nFields)) {
- break;
- }
- _tmp19_ = PQgetvalue (self->priv->pgresult, i, j);
- _tmp20_ = g_strdup ((const gchar*) _tmp19_);
- myval = _tmp20_;
- _tmp21_ = g_strconcat ("Result:", myval, NULL);
- msgwin_status_add ("%s", _tmp21_);
- // ^^ does work. The value from the db shows up in the status window
- _g_free0 (_tmp21_);
- gtk_list_store_set (listmodel, &iter, j, myval, -1);
- // ^^ doesn't work, puts the column number into the column instead of teh db val
- //gtk_list_store_set (listmodel, &iter, j, "test", -1);
- // ^^ does work. "test" is put into the column
- _g_free0 (myval);
- }
- }
- }
- }
- }
- }
- self->priv->data_loaded = TRUE;
- self->priv->col_count = nFields;
- _g_object_unref0 (listmodel);
- cols = (g_free (cols), NULL);
- }
- static gboolean plugin_query_window_db_connect (PluginQueryWindow* self, const gchar* host, const gchar* user, const gchar* password, const gchar* dbname) {
- gboolean result = FALSE;
- gchar* _tmp0_;
- gchar* conninfo;
- PGconn* _tmp9_ = NULL;
- PGconn* _tmp10_;
- ConnStatusType _tmp11_;
- g_return_val_if_fail (self != NULL, FALSE);
- g_return_val_if_fail (host != NULL, FALSE);
- g_return_val_if_fail (user != NULL, FALSE);
- g_return_val_if_fail (password != NULL, FALSE);
- g_return_val_if_fail (dbname != NULL, FALSE);
- _tmp0_ = g_strdup ("");
- conninfo = _tmp0_;
- if (g_strcmp0 (host, "") != 0) {
- gchar* _tmp1_;
- gchar* _tmp2_;
- _tmp1_ = g_strconcat (" host=", host, NULL);
- _tmp2_ = g_strconcat (conninfo, _tmp1_, NULL);
- _g_free0 (conninfo);
- conninfo = _tmp2_;
- _g_free0 (_tmp1_);
- }
- if (g_strcmp0 (user, "") != 0) {
- gchar* _tmp3_;
- gchar* _tmp4_;
- _tmp3_ = g_strconcat (" user=", user, NULL);
- _tmp4_ = g_strconcat (conninfo, _tmp3_, NULL);
- _g_free0 (conninfo);
- conninfo = _tmp4_;
- _g_free0 (_tmp3_);
- }
- if (g_strcmp0 (password, "") != 0) {
- gchar* _tmp5_;
- gchar* _tmp6_;
- _tmp5_ = g_strconcat (" password=", password, NULL);
- _tmp6_ = g_strconcat (conninfo, _tmp5_, NULL);
- _g_free0 (conninfo);
- conninfo = _tmp6_;
- _g_free0 (_tmp5_);
- }
- if (g_strcmp0 (dbname, "") != 0) {
- gchar* _tmp7_;
- gchar* _tmp8_;
- _tmp7_ = g_strconcat (" dbname=", dbname, NULL);
- _tmp8_ = g_strconcat (conninfo, _tmp7_, NULL);
- _g_free0 (conninfo);
- conninfo = _tmp8_;
- _g_free0 (_tmp7_);
- }
- _tmp9_ = PQconnectdb (conninfo);
- _tmp10_ = _tmp9_;
- _PQfinish0 (self->priv->pgconn);
- self->priv->pgconn = _tmp10_;
- _tmp11_ = PQstatus (self->priv->pgconn);
- if (_tmp11_ != CONNECTION_OK) {
- const gchar* _tmp12_ = NULL;
- _tmp12_ = PQerrorMessage (self->priv->pgconn);
- fprintf (stderr, "Connection to database failed: %s", _tmp12_);
- result = FALSE;
- _g_free0 (conninfo);
- return result;
- }
- result = TRUE;
- _g_free0 (conninfo);
- return result;
- }
- static gint plugin_query_window_plugin_db_disconnect (PluginQueryWindow* self) {
- gint result = 0;
- g_return_val_if_fail (self != NULL, 0);
- result = 1;
- return result;
- }
- static void plugin_query_window_class_init (PluginQueryWindowClass * klass) {
- plugin_query_window_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (PluginQueryWindowPrivate));
- G_OBJECT_CLASS (klass)->finalize = plugin_query_window_finalize;
- }
- static void plugin_query_window_instance_init (PluginQueryWindow * self) {
- self->priv = PLUGIN_QUERY_WINDOW_GET_PRIVATE (self);
- }
- static void plugin_query_window_finalize (GObject* obj) {
- PluginQueryWindow * self;
- self = PLUGIN_QUERY_WINDOW (obj);
- _g_object_unref0 (self->priv->results);
- _g_object_unref0 (self->priv->text_view);
- _PQfinish0 (self->priv->pgconn);
- _PQclear0 (self->priv->pgresult);
- G_OBJECT_CLASS (plugin_query_window_parent_class)->finalize (obj);
- }
- GType plugin_query_window_get_type (void) {
- static volatile gsize plugin_query_window_type_id__volatile = 0;
- if (g_once_init_enter (&plugin_query_window_type_id__volatile)) {
- static const GTypeInfo g_define_type_info = { sizeof (PluginQueryWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) plugin_query_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PluginQueryWindow), 0, (GInstanceInitFunc) plugin_query_window_instance_init, NULL };
- GType plugin_query_window_type_id;
- plugin_query_window_type_id = g_type_register_static (GTK_TYPE_WINDOW, "PluginQueryWindow", &g_define_type_info, 0);
- g_once_init_leave (&plugin_query_window_type_id__volatile, plugin_query_window_type_id);
- }
- return plugin_query_window_type_id__volatile;
- }
- static gint __geany_vala_plugin_VERSION_CHECK (gint abi_version, gint api_required) {
- gint result = 0;
- if (abi_version != GEANY_ABI_VERSION) {
- result = -1;
- return result;
- }
- if (GEANY_API_VERSION < api_required) {
- result = api_required;
- return result;
- }
- result = 0;
- return result;
- }
- gint plugin_version_check (gint abi_version) {
- gint result = 0;
- gint _tmp0_;
- _tmp0_ = __geany_vala_plugin_VERSION_CHECK (abi_version, 185);
- result = _tmp0_;
- return result;
- }
- static void __geany_vala_plugin_SET_INFO (PluginInfo *self, const gchar* name, const gchar* description, const gchar* version, const gchar* author) {
- g_return_if_fail (name != NULL);
- (*self).name = name;
- (*self).description = description;
- (*self).version = version;
- (*self).author = author;
- }
- void plugin_set_info (PluginInfo* info) {
- __geany_vala_plugin_SET_INFO (info, "Database Plugin", "A plugin for Geany to view databases", "0.1", "Mike Thorn");
- }
- static void _lambda5_ (void) {
- PluginQueryWindow* _tmp0_ = NULL;
- PluginQueryWindow* _tmp1_;
- _tmp0_ = plugin_query_window_new ();
- _tmp1_ = g_object_ref_sink (_tmp0_);
- _g_object_unref0 (_tmp1_);
- }
- static void __lambda5__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- _lambda5_ ();
- }
- void plugin_init (GeanyData* data) {
- GtkMenuItem* item = NULL;
- GtkWidget* _tmp0_ = NULL;
- GtkWidget* _tmp1_;
- GtkMenuShell* menu;
- GtkMenuItem* _tmp4_ = NULL;
- GtkMenuItem* _tmp5_;
- g_return_if_fail (data != NULL);
- _tmp0_ = ui_lookup_widget ((GtkWidget*) geany_data->main_widgets->window, "menu_document1_menu");
- menu = (_tmp1_ = _tmp0_, GTK_IS_MENU_SHELL (_tmp1_) ? ((GtkMenuShell*) _tmp1_) : NULL);
- if (menu == NULL) {
- menu = geany_data->main_widgets->tools_menu;
- } else {
- GtkSeparatorMenuItem* _tmp2_ = NULL;
- GtkMenuItem* _tmp3_;
- _tmp2_ = (GtkSeparatorMenuItem*) gtk_separator_menu_item_new ();
- _tmp3_ = (GtkMenuItem*) g_object_ref_sink (_tmp2_);
- _g_object_unref0 (item);
- item = _tmp3_;
- gtk_menu_shell_append (menu, (GtkWidget*) item);
- G_destroy_widget_stack = g_slist_append (G_destroy_widget_stack, (GtkWidget*) item);
- gtk_widget_show ((GtkWidget*) item);
- }
- _tmp4_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Query Window");
- _tmp5_ = g_object_ref_sink (_tmp4_);
- _g_object_unref0 (item);
- item = _tmp5_;
- g_signal_connect (item, "activate", (GCallback) __lambda5__gtk_menu_item_activate, NULL);
- gtk_menu_shell_append (menu, (GtkWidget*) item);
- G_destroy_widget_stack = g_slist_append (G_destroy_widget_stack, (GtkWidget*) item);
- gtk_widget_show ((GtkWidget*) item);
- _g_object_unref0 (item);
- }
- void plugin_cleanup (void) {
- {
- GSList* w_collection;
- GSList* w_it;
- w_collection = G_destroy_widget_stack;
- for (w_it = w_collection; w_it != NULL; w_it = w_it->next) {
- GtkWidget* w;
- w = (GtkWidget*) w_it->data;
- {
- gtk_object_destroy ((GtkObject*) w);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement