Logo Search packages:      
Sourcecode: valatoys version File versions  Download package

vtgsourceoutliner.c

/* vtgsourceoutliner.c generated by valac 0.10.0, the Vala compiler
 * generated from vtgsourceoutliner.vala, do not modify */

/*
 *  vtgsourceoutliner.vala - Vala developer toys for GEdit
 *  
 *  Copyright (C) 2009 - Andrea Del Signore <sejerpz@tin.it>
 *  
 *  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., 59 Temple Place, Suite 330,
 *  Boston, MA 02111-1307, USA.
 */

#include <glib.h>
#include <glib-object.h>
#include <gedit/gedit-view.h>
#include <gedit/gedit-document.h>
#include <gtk/gtk.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <afrodite.h>
#include <stdlib.h>


#define VTG_TYPE_SOURCE_OUTLINER (vtg_source_outliner_get_type ())
#define VTG_SOURCE_OUTLINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_TYPE_SOURCE_OUTLINER, VtgSourceOutliner))
#define VTG_SOURCE_OUTLINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_TYPE_SOURCE_OUTLINER, VtgSourceOutlinerClass))
#define VTG_IS_SOURCE_OUTLINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_TYPE_SOURCE_OUTLINER))
#define VTG_IS_SOURCE_OUTLINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_TYPE_SOURCE_OUTLINER))
#define VTG_SOURCE_OUTLINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_TYPE_SOURCE_OUTLINER, VtgSourceOutlinerClass))

typedef struct _VtgSourceOutliner VtgSourceOutliner;
typedef struct _VtgSourceOutlinerClass VtgSourceOutlinerClass;
typedef struct _VtgSourceOutlinerPrivate VtgSourceOutlinerPrivate;

#define VTG_TYPE_PLUGIN_INSTANCE (vtg_plugin_instance_get_type ())
#define VTG_PLUGIN_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_TYPE_PLUGIN_INSTANCE, VtgPluginInstance))
#define VTG_PLUGIN_INSTANCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_TYPE_PLUGIN_INSTANCE, VtgPluginInstanceClass))
#define VTG_IS_PLUGIN_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_TYPE_PLUGIN_INSTANCE))
#define VTG_IS_PLUGIN_INSTANCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_TYPE_PLUGIN_INSTANCE))
#define VTG_PLUGIN_INSTANCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_TYPE_PLUGIN_INSTANCE, VtgPluginInstanceClass))

typedef struct _VtgPluginInstance VtgPluginInstance;
typedef struct _VtgPluginInstanceClass VtgPluginInstanceClass;

#define VTG_TYPE_SOURCE_OUTLINER_VIEW (vtg_source_outliner_view_get_type ())
#define VTG_SOURCE_OUTLINER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_TYPE_SOURCE_OUTLINER_VIEW, VtgSourceOutlinerView))
#define VTG_SOURCE_OUTLINER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_TYPE_SOURCE_OUTLINER_VIEW, VtgSourceOutlinerViewClass))
#define VTG_IS_SOURCE_OUTLINER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_TYPE_SOURCE_OUTLINER_VIEW))
#define VTG_IS_SOURCE_OUTLINER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_TYPE_SOURCE_OUTLINER_VIEW))
#define VTG_SOURCE_OUTLINER_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_TYPE_SOURCE_OUTLINER_VIEW, VtgSourceOutlinerViewClass))

typedef struct _VtgSourceOutlinerView VtgSourceOutlinerView;
typedef struct _VtgSourceOutlinerViewClass VtgSourceOutlinerViewClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))

#define VTG_TYPE_SYMBOL_COMPLETION (vtg_symbol_completion_get_type ())
#define VTG_SYMBOL_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_TYPE_SYMBOL_COMPLETION, VtgSymbolCompletion))
#define VTG_SYMBOL_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_TYPE_SYMBOL_COMPLETION, VtgSymbolCompletionClass))
#define VTG_IS_SYMBOL_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_TYPE_SYMBOL_COMPLETION))
#define VTG_IS_SYMBOL_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_TYPE_SYMBOL_COMPLETION))
#define VTG_SYMBOL_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_TYPE_SYMBOL_COMPLETION, VtgSymbolCompletionClass))

typedef struct _VtgSymbolCompletion VtgSymbolCompletion;
typedef struct _VtgSymbolCompletionClass VtgSymbolCompletionClass;
#define _afrodite_ast_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_ast_unref (var), NULL)))
#define _afrodite_query_result_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_query_result_unref (var), NULL)))
#define _afrodite_query_options_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_query_options_unref (var), NULL)))

00083 struct _VtgSourceOutliner {
      GObject parent_instance;
      VtgSourceOutlinerPrivate * priv;
};

00088 struct _VtgSourceOutlinerClass {
      GObjectClass parent_class;
};

00092 struct _VtgSourceOutlinerPrivate {
      VtgPluginInstance* _plugin_instance;
      GeditView* _active_view;
      GeditDocument* _active_doc;
      VtgSourceOutlinerView* _outliner_view;
      guint idle_id;
      GStaticRecMutex __lock_idle_id;
      gboolean completion_setup;
};


static gpointer vtg_source_outliner_parent_class = NULL;
static GType vtg_source_outliner_type_id = 0;

GType vtg_source_outliner_get_type (void) G_GNUC_CONST;
GType vtg_source_outliner_register_type (GTypeModule * module);
GType vtg_plugin_instance_get_type (void) G_GNUC_CONST;
GType vtg_plugin_instance_register_type (GTypeModule * module);
GType vtg_source_outliner_view_get_type (void) G_GNUC_CONST;
GType vtg_source_outliner_view_register_type (GTypeModule * module);
#define VTG_SOURCE_OUTLINER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VTG_TYPE_SOURCE_OUTLINER, VtgSourceOutlinerPrivate))
enum  {
      VTG_SOURCE_OUTLINER_DUMMY_PROPERTY,
      VTG_SOURCE_OUTLINER_PLUGIN_INSTANCE,
      VTG_SOURCE_OUTLINER_ACTIVE_VIEW
};
VtgSourceOutliner* vtg_source_outliner_new (VtgPluginInstance* plugin_instance);
VtgSourceOutliner* vtg_source_outliner_construct (GType object_type, VtgPluginInstance* plugin_instance);
VtgSourceOutlinerView* vtg_source_outliner_view_new (VtgPluginInstance* plugin_instance);
VtgSourceOutlinerView* vtg_source_outliner_view_construct (GType object_type, VtgPluginInstance* plugin_instance);
static void vtg_source_outliner_on_goto_source (VtgSourceOutliner* self, VtgSourceOutlinerView* sender, gint line, gint start_column, gint end_column);
static void _vtg_source_outliner_on_goto_source_vtg_source_outliner_view_goto_source (VtgSourceOutlinerView* _sender, gint line, gint start_column, gint end_column, gpointer self);
static void vtg_source_outliner_on_filter_changed (VtgSourceOutliner* self, VtgSourceOutlinerView* sender);
static void _vtg_source_outliner_on_filter_changed_vtg_source_outliner_view_filter_changed (VtgSourceOutlinerView* _sender, gpointer self);
static void vtg_source_outliner_setup_idle (VtgSourceOutliner* self);
static GtkTextIter* _gtk_text_iter_dup (GtkTextIter* self);
static void vtg_source_outliner_setup_document (VtgSourceOutliner* self, GeditDocument* doc);
static void vtg_source_outliner_on_notify_language (VtgSourceOutliner* self, GeditDocument* sender, GParamSpec* pspec);
static void _vtg_source_outliner_on_notify_language_g_object_notify (GeditDocument* _sender, GParamSpec* pspec, gpointer self);
void vtg_source_outliner_cleanup_document (VtgSourceOutliner* self);
static void vtg_source_outliner_setup_completion_with_view (VtgSourceOutliner* self, GeditView* view);
GType vtg_symbol_completion_get_type (void) G_GNUC_CONST;
GType vtg_symbol_completion_register_type (GTypeModule * module);
VtgSymbolCompletion* vtg_plugin_instance_scs_find_from_view (VtgPluginInstance* self, GeditView* view);
AfroditeCompletionEngine* vtg_symbol_completion_get_completion_engine (VtgSymbolCompletion* self);
void vtg_source_outliner_setup_completion_engine (VtgSourceOutliner* self, AfroditeCompletionEngine* engine);
static void vtg_source_outliner_on_end_parsing (VtgSourceOutliner* self, AfroditeCompletionEngine* sender);
static void _vtg_source_outliner_on_end_parsing_afrodite_completion_engine_end_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self);
static void vtg_source_outliner_cleanup_completion_with_view (VtgSourceOutliner* self, GeditView* view);
void vtg_source_outliner_cleanup_completion_engine (VtgSourceOutliner* self, AfroditeCompletionEngine* engine);
gboolean vtg_utils_is_vala_doc (GeditDocument* doc);
static gboolean vtg_source_outliner_update_source_outliner_view (VtgSourceOutliner* self);
void vtg_utils_trace (const char* format, ...);
static gboolean vtg_source_outliner_on_idle_update (VtgSourceOutliner* self);
static gboolean _vtg_source_outliner_on_idle_update_gsource_func (gpointer self);
char* vtg_utils_get_document_name (GeditDocument* doc);
void vtg_source_outliner_view_update_view (VtgSourceOutlinerView* self, AfroditeQueryResult* _result_);
void vtg_source_outliner_view_clear_view (VtgSourceOutlinerView* self);
VtgPluginInstance* vtg_source_outliner_get_plugin_instance (VtgSourceOutliner* self);
static void vtg_source_outliner_set_plugin_instance (VtgSourceOutliner* self, VtgPluginInstance* value);
GeditView* vtg_source_outliner_get_active_view (VtgSourceOutliner* self);
void vtg_source_outliner_set_active_view (VtgSourceOutliner* self, GeditView* value);
void vtg_source_outliner_view_deactivate (VtgSourceOutlinerView* self);
static void vtg_source_outliner_finalize (GObject* obj);
static void vtg_source_outliner_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void vtg_source_outliner_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);



static void _vtg_source_outliner_on_goto_source_vtg_source_outliner_view_goto_source (VtgSourceOutlinerView* _sender, gint line, gint start_column, gint end_column, gpointer self) {
      vtg_source_outliner_on_goto_source (self, _sender, line, start_column, end_column);
}


static void _vtg_source_outliner_on_filter_changed_vtg_source_outliner_view_filter_changed (VtgSourceOutlinerView* _sender, gpointer self) {
      vtg_source_outliner_on_filter_changed (self, _sender);
}


VtgSourceOutliner* vtg_source_outliner_construct (GType object_type, VtgPluginInstance* plugin_instance) {
      VtgSourceOutliner * self;
      VtgSourceOutlinerView* _tmp0_;
      g_return_val_if_fail (plugin_instance != NULL, NULL);
      self = (VtgSourceOutliner*) g_object_new (object_type, "plugin-instance", plugin_instance, NULL);
      self->priv->_outliner_view = (_tmp0_ = vtg_source_outliner_view_new (plugin_instance), _g_object_unref0 (self->priv->_outliner_view), _tmp0_);
      g_signal_connect_object (self->priv->_outliner_view, "goto-source", (GCallback) _vtg_source_outliner_on_goto_source_vtg_source_outliner_view_goto_source, self, 0);
      g_signal_connect_object (self->priv->_outliner_view, "filter-changed", (GCallback) _vtg_source_outliner_on_filter_changed_vtg_source_outliner_view_filter_changed, self, 0);
      return self;
}


VtgSourceOutliner* vtg_source_outliner_new (VtgPluginInstance* plugin_instance) {
      return vtg_source_outliner_construct (VTG_TYPE_SOURCE_OUTLINER, plugin_instance);
}


static void vtg_source_outliner_on_filter_changed (VtgSourceOutliner* self, VtgSourceOutlinerView* sender) {
      g_return_if_fail (self != NULL);
      g_return_if_fail (sender != NULL);
      vtg_source_outliner_setup_idle (self);
}


static gpointer _g_object_ref0 (gpointer self) {
      return self ? g_object_ref (self) : NULL;
}


static GtkTextIter* _gtk_text_iter_dup (GtkTextIter* self) {
      GtkTextIter* dup;
      dup = g_new0 (GtkTextIter, 1);
      memcpy (dup, self, sizeof (GtkTextIter));
      return dup;
}


static gpointer __gtk_text_iter_dup0 (gpointer self) {
      return self ? _gtk_text_iter_dup (self) : NULL;
}


static void vtg_source_outliner_on_goto_source (VtgSourceOutliner* self, VtgSourceOutlinerView* sender, gint line, gint start_column, gint end_column) {
      GeditDocument* doc;
      GtkTextIter* iter = NULL;
      GtkTextIter _tmp0_ = {0};
      GtkTextIter* _tmp1_;
      g_return_if_fail (self != NULL);
      g_return_if_fail (sender != NULL);
      doc = _g_object_ref0 (GEDIT_DOCUMENT (gtk_text_view_get_buffer ((GtkTextView*) self->priv->_active_view)));
      gtk_text_buffer_get_iter_at_line_offset ((GtkTextBuffer*) doc, &_tmp0_, line - 1, 0);
      iter = (_tmp1_ = __gtk_text_iter_dup0 (&_tmp0_), _g_free0 (iter), _tmp1_);
      if (iter != NULL) {
            gtk_text_buffer_place_cursor ((GtkTextBuffer*) doc, iter);
            gtk_text_view_scroll_to_iter ((GtkTextView*) self->priv->_active_view, iter, (double) 0, TRUE, (double) 0, 0.5);
            gtk_widget_grab_focus ((GtkWidget*) self->priv->_active_view);
      }
      _g_free0 (iter);
      _g_object_unref0 (doc);
}


static void _vtg_source_outliner_on_notify_language_g_object_notify (GeditDocument* _sender, GParamSpec* pspec, gpointer self) {
      vtg_source_outliner_on_notify_language (self, _sender, pspec);
}


static void vtg_source_outliner_setup_document (VtgSourceOutliner* self, GeditDocument* doc) {
      GeditDocument* _tmp0_;
      g_return_if_fail (self != NULL);
      g_return_if_fail (doc != NULL);
      self->priv->_active_doc = (_tmp0_ = _g_object_ref0 (doc), _g_object_unref0 (self->priv->_active_doc), _tmp0_);
      g_signal_connect_object ((GObject*) doc, "notify::language", (GCallback) _vtg_source_outliner_on_notify_language_g_object_notify, self, 0);
}


void vtg_source_outliner_cleanup_document (VtgSourceOutliner* self) {
      g_return_if_fail (self != NULL);
      if (self->priv->_active_doc != NULL) {
            guint _tmp0_;
            GQuark _tmp1_;
            GeditDocument* _tmp2_;
            g_signal_parse_name ("notify::language", G_TYPE_OBJECT, &_tmp0_, &_tmp1_, TRUE);
            g_signal_handlers_disconnect_matched ((GObject*) self->priv->_active_doc, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, _tmp1_, NULL, (GCallback) _vtg_source_outliner_on_notify_language_g_object_notify, self);
            self->priv->_active_doc = (_tmp2_ = NULL, _g_object_unref0 (self->priv->_active_doc), _tmp2_);
      }
}


static void vtg_source_outliner_setup_completion_with_view (VtgSourceOutliner* self, GeditView* view) {
      VtgSymbolCompletion* scs;
      gboolean _tmp0_ = FALSE;
      g_return_if_fail (self != NULL);
      g_return_if_fail (view != NULL);
      scs = vtg_plugin_instance_scs_find_from_view (self->priv->_plugin_instance, view);
      if (scs == NULL) {
            _tmp0_ = TRUE;
      } else {
            _tmp0_ = vtg_symbol_completion_get_completion_engine (scs) == NULL;
      }
      if (_tmp0_) {
            _g_object_unref0 (scs);
            return;
      }
      vtg_source_outliner_setup_completion_engine (self, vtg_symbol_completion_get_completion_engine (scs));
      _g_object_unref0 (scs);
}


static void _vtg_source_outliner_on_end_parsing_afrodite_completion_engine_end_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self) {
      vtg_source_outliner_on_end_parsing (self, sender);
}


void vtg_source_outliner_setup_completion_engine (VtgSourceOutliner* self, AfroditeCompletionEngine* engine) {
      g_return_if_fail (self != NULL);
      g_return_if_fail (engine != NULL);
      self->priv->completion_setup = TRUE;
      g_signal_connect_object (engine, "end-parsing", (GCallback) _vtg_source_outliner_on_end_parsing_afrodite_completion_engine_end_parsing, self, 0);
}


static void vtg_source_outliner_cleanup_completion_with_view (VtgSourceOutliner* self, GeditView* view) {
      VtgSymbolCompletion* scs;
      gboolean _tmp0_ = FALSE;
      g_return_if_fail (self != NULL);
      g_return_if_fail (view != NULL);
      scs = vtg_plugin_instance_scs_find_from_view (self->priv->_plugin_instance, view);
      if (scs == NULL) {
            _tmp0_ = TRUE;
      } else {
            _tmp0_ = vtg_symbol_completion_get_completion_engine (scs) == NULL;
      }
      if (_tmp0_) {
            _g_object_unref0 (scs);
            return;
      }
      vtg_source_outliner_cleanup_completion_engine (self, vtg_symbol_completion_get_completion_engine (scs));
      _g_object_unref0 (scs);
}


void vtg_source_outliner_cleanup_completion_engine (VtgSourceOutliner* self, AfroditeCompletionEngine* engine) {
      guint _tmp0_;
      g_return_if_fail (self != NULL);
      g_return_if_fail (engine != NULL);
      g_signal_parse_name ("end-parsing", AFRODITE_TYPE_COMPLETION_ENGINE, &_tmp0_, NULL, FALSE);
      g_signal_handlers_disconnect_matched (engine, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _vtg_source_outliner_on_end_parsing_afrodite_completion_engine_end_parsing, self);
      self->priv->completion_setup = FALSE;
}


static void vtg_source_outliner_on_notify_language (VtgSourceOutliner* self, GeditDocument* sender, GParamSpec* pspec) {
      g_return_if_fail (self != NULL);
      g_return_if_fail (sender != NULL);
      g_return_if_fail (pspec != NULL);
      if (vtg_utils_is_vala_doc (sender)) {
            vtg_source_outliner_update_source_outliner_view (self);
            vtg_source_outliner_setup_completion_with_view (self, self->priv->_active_view);
      }
}


static void vtg_source_outliner_on_end_parsing (VtgSourceOutliner* self, AfroditeCompletionEngine* sender) {
      g_return_if_fail (self != NULL);
      g_return_if_fail (sender != NULL);
      vtg_source_outliner_setup_idle (self);
}


static gboolean _vtg_source_outliner_on_idle_update_gsource_func (gpointer self) {
      gboolean result;
      result = vtg_source_outliner_on_idle_update (self);
      return result;
}


static void vtg_source_outliner_setup_idle (VtgSourceOutliner* self) {
      GError * _inner_error_ = NULL;
      g_return_if_fail (self != NULL);
      vtg_utils_trace ("vtgsourceoutliner.vala:177: Idle setup");
      {
            g_static_rec_mutex_lock (&self->priv->__lock_idle_id);
            {
                  if (self->priv->idle_id == 0) {
                        vtg_utils_trace ("vtgsourceoutliner.vala:180: Idle setup real");
                        self->priv->idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _vtg_source_outliner_on_idle_update_gsource_func, g_object_ref (self), g_object_unref);
                  }
            }
            __finally56:
            {
                  g_static_rec_mutex_unlock (&self->priv->__lock_idle_id);
            }
            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 gboolean vtg_source_outliner_on_idle_update (VtgSourceOutliner* self) {
      gboolean result = FALSE;
      GError * _inner_error_ = NULL;
      g_return_val_if_fail (self != NULL, FALSE);
      {
            g_static_rec_mutex_lock (&self->priv->__lock_idle_id);
            {
                  gboolean success;
                  success = vtg_source_outliner_update_source_outliner_view (self);
                  if (success) {
                        self->priv->idle_id = (guint) 0;
                  }
                  result = !success;
                  {
                        g_static_rec_mutex_unlock (&self->priv->__lock_idle_id);
                  }
                  return result;
            }
            __finally57:
            {
                  g_static_rec_mutex_unlock (&self->priv->__lock_idle_id);
            }
            {
                  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 FALSE;
            }
      }
}


static gboolean vtg_source_outliner_update_source_outliner_view (VtgSourceOutliner* self) {
      gboolean result = FALSE;
      VtgSymbolCompletion* scs;
      gboolean _tmp0_ = FALSE;
      GeditDocument* doc;
      char* name;
      AfroditeQueryResult* _result_;
      AfroditeAst* ast;
      AfroditeAst* _tmp1_ = NULL;
      gboolean _tmp2_;
      AfroditeAst* _tmp3_;
      gboolean res;
      gboolean _tmp5_ = FALSE;
      g_return_val_if_fail (self != NULL, FALSE);
      scs = vtg_plugin_instance_scs_find_from_view (self->priv->_plugin_instance, self->priv->_active_view);
      if (scs == NULL) {
            _tmp0_ = TRUE;
      } else {
            _tmp0_ = vtg_symbol_completion_get_completion_engine (scs) == NULL;
      }
      if (_tmp0_) {
            vtg_utils_trace ("vtgsourceoutliner.vala:201: symbol completion helper is null for view");
            result = TRUE;
            _g_object_unref0 (scs);
            return result;
      }
      doc = _g_object_ref0 (GEDIT_DOCUMENT (gtk_text_view_get_buffer ((GtkTextView*) self->priv->_active_view)));
      name = vtg_utils_get_document_name (doc);
      _result_ = NULL;
      ast = NULL;
      res = (_tmp2_ = afrodite_completion_engine_try_acquire_ast (vtg_symbol_completion_get_completion_engine (scs), &_tmp1_, 0), ast = (_tmp3_ = _tmp1_, _afrodite_ast_unref0 (ast), _tmp3_), _tmp2_);
      if (res) {
            AfroditeQueryOptions* options;
            AfroditeQueryResult* _tmp4_;
            vtg_utils_trace ("vtgsourceoutliner.vala:211: ast acquired");
            options = afrodite_query_options_standard ();
            options->all_symbols = TRUE;
            _result_ = (_tmp4_ = afrodite_ast_get_symbols_for_path (ast, options, name), _afrodite_query_result_unref0 (_result_), _tmp4_);
            vtg_source_outliner_view_update_view (self->priv->_outliner_view, _result_);
            afrodite_completion_engine_release_ast (vtg_symbol_completion_get_completion_engine (scs), ast);
            _afrodite_query_options_unref0 (options);
      }
      if (_result_ == NULL) {
            _tmp5_ = TRUE;
      } else {
            _tmp5_ = afrodite_query_result_get_is_empty (_result_);
      }
      if (_tmp5_) {
            vtg_source_outliner_view_clear_view (self->priv->_outliner_view);
      }
      result = res;
      _afrodite_ast_unref0 (ast);
      _afrodite_query_result_unref0 (_result_);
      _g_free0 (name);
      _g_object_unref0 (doc);
      _g_object_unref0 (scs);
      return result;
}


VtgPluginInstance* vtg_source_outliner_get_plugin_instance (VtgSourceOutliner* self) {
      VtgPluginInstance* result;
      g_return_val_if_fail (self != NULL, NULL);
      result = self->priv->_plugin_instance;
      return result;
}


static void vtg_source_outliner_set_plugin_instance (VtgSourceOutliner* self, VtgPluginInstance* value) {
      g_return_if_fail (self != NULL);
      self->priv->_plugin_instance = value;
      g_object_notify ((GObject *) self, "plugin-instance");
}


GeditView* vtg_source_outliner_get_active_view (VtgSourceOutliner* self) {
      GeditView* result;
      g_return_val_if_fail (self != NULL, NULL);
      result = self->priv->_active_view;
      return result;
}


void vtg_source_outliner_set_active_view (VtgSourceOutliner* self, GeditView* value) {
      g_return_if_fail (self != NULL);
      if (self->priv->_active_view != value) {
            GeditView* _tmp0_;
            if (self->priv->_active_view != NULL) {
                  vtg_source_outliner_cleanup_document (self);
                  if (self->priv->completion_setup) {
                        vtg_source_outliner_cleanup_completion_with_view (self, self->priv->_active_view);
                  }
                  vtg_source_outliner_view_clear_view (self->priv->_outliner_view);
            }
            self->priv->_active_view = (_tmp0_ = _g_object_ref0 (value), _g_object_unref0 (self->priv->_active_view), _tmp0_);
            if (self->priv->_active_view != NULL) {
                  GeditDocument* doc;
                  doc = _g_object_ref0 (GEDIT_DOCUMENT (gtk_text_view_get_buffer ((GtkTextView*) self->priv->_active_view)));
                  vtg_source_outliner_setup_document (self, doc);
                  if (vtg_utils_is_vala_doc (doc)) {
                        vtg_source_outliner_setup_idle (self);
                        vtg_source_outliner_setup_completion_with_view (self, self->priv->_active_view);
                  }
                  _g_object_unref0 (doc);
            }
      }
      g_object_notify ((GObject *) self, "active-view");
}


static void vtg_source_outliner_class_init (VtgSourceOutlinerClass * klass) {
      vtg_source_outliner_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (VtgSourceOutlinerPrivate));
      G_OBJECT_CLASS (klass)->get_property = vtg_source_outliner_get_property;
      G_OBJECT_CLASS (klass)->set_property = vtg_source_outliner_set_property;
      G_OBJECT_CLASS (klass)->finalize = vtg_source_outliner_finalize;
      g_object_class_install_property (G_OBJECT_CLASS (klass), VTG_SOURCE_OUTLINER_PLUGIN_INSTANCE, g_param_spec_object ("plugin-instance", "plugin-instance", "plugin-instance", VTG_TYPE_PLUGIN_INSTANCE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
      g_object_class_install_property (G_OBJECT_CLASS (klass), VTG_SOURCE_OUTLINER_ACTIVE_VIEW, g_param_spec_object ("active-view", "active-view", "active-view", GEDIT_TYPE_VIEW, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void vtg_source_outliner_instance_init (VtgSourceOutliner * self) {
      self->priv = VTG_SOURCE_OUTLINER_GET_PRIVATE (self);
      self->priv->_plugin_instance = NULL;
      self->priv->_active_view = NULL;
      self->priv->_active_doc = NULL;
      self->priv->_outliner_view = NULL;
      g_static_rec_mutex_init (&self->priv->__lock_idle_id);
      self->priv->idle_id = (guint) 0;
      self->priv->completion_setup = FALSE;
}


static void vtg_source_outliner_finalize (GObject* obj) {
      VtgSourceOutliner * self;
      self = VTG_SOURCE_OUTLINER (obj);
      {
            if (self->priv->_outliner_view != NULL) {
                  guint _tmp0_;
                  VtgSourceOutlinerView* _tmp1_;
                  g_signal_parse_name ("goto-source", VTG_TYPE_SOURCE_OUTLINER_VIEW, &_tmp0_, NULL, FALSE);
                  g_signal_handlers_disconnect_matched (self->priv->_outliner_view, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _vtg_source_outliner_on_goto_source_vtg_source_outliner_view_goto_source, self);
                  vtg_source_outliner_view_clear_view (self->priv->_outliner_view);
                  vtg_source_outliner_view_deactivate (self->priv->_outliner_view);
                  self->priv->_outliner_view = (_tmp1_ = NULL, _g_object_unref0 (self->priv->_outliner_view), _tmp1_);
            }
            if (self->priv->idle_id != 0) {
                  g_source_remove (self->priv->idle_id);
            }
            if (self->priv->_active_view != NULL) {
                  GeditView* _tmp2_;
                  vtg_source_outliner_cleanup_document (self);
                  if (self->priv->completion_setup) {
                        vtg_source_outliner_cleanup_completion_with_view (self, self->priv->_active_view);
                  }
                  self->priv->_active_view = (_tmp2_ = NULL, _g_object_unref0 (self->priv->_active_view), _tmp2_);
            }
      }
      _g_object_unref0 (self->priv->_active_view);
      _g_object_unref0 (self->priv->_active_doc);
      _g_object_unref0 (self->priv->_outliner_view);
      g_static_rec_mutex_free (&self->priv->__lock_idle_id);
      G_OBJECT_CLASS (vtg_source_outliner_parent_class)->finalize (obj);
}


GType vtg_source_outliner_get_type (void) {
      return vtg_source_outliner_type_id;
}


GType vtg_source_outliner_register_type (GTypeModule * module) {
      static const GTypeInfo g_define_type_info = { sizeof (VtgSourceOutlinerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vtg_source_outliner_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (VtgSourceOutliner), 0, (GInstanceInitFunc) vtg_source_outliner_instance_init, NULL };
      vtg_source_outliner_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "VtgSourceOutliner", &g_define_type_info, 0);
      return vtg_source_outliner_type_id;
}


static void vtg_source_outliner_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
      VtgSourceOutliner * self;
      self = VTG_SOURCE_OUTLINER (object);
      switch (property_id) {
            case VTG_SOURCE_OUTLINER_PLUGIN_INSTANCE:
            g_value_set_object (value, vtg_source_outliner_get_plugin_instance (self));
            break;
            case VTG_SOURCE_OUTLINER_ACTIVE_VIEW:
            g_value_set_object (value, vtg_source_outliner_get_active_view (self));
            break;
            default:
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
            break;
      }
}


static void vtg_source_outliner_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
      VtgSourceOutliner * self;
      self = VTG_SOURCE_OUTLINER (object);
      switch (property_id) {
            case VTG_SOURCE_OUTLINER_PLUGIN_INSTANCE:
            vtg_source_outliner_set_plugin_instance (self, g_value_get_object (value));
            break;
            case VTG_SOURCE_OUTLINER_ACTIVE_VIEW:
            vtg_source_outliner_set_active_view (self, g_value_get_object (value));
            break;
            default:
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
            break;
      }
}





Generated by  Doxygen 1.6.0   Back to index