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

vtgparametersdialog.c

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

/*
 *  vtgparametersdialog.vala - Vala developer toys for GEdit
 *  
 *  Copyright (C) 2008 - 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 <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.h>


#define VTG_INTERACTION_TYPE_PARAMETERS_DIALOG (vtg_interaction_parameters_dialog_get_type ())
#define VTG_INTERACTION_PARAMETERS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, VtgInteractionParametersDialog))
#define VTG_INTERACTION_PARAMETERS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, VtgInteractionParametersDialogClass))
#define VTG_INTERACTION_IS_PARAMETERS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG))
#define VTG_INTERACTION_IS_PARAMETERS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG))
#define VTG_INTERACTION_PARAMETERS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, VtgInteractionParametersDialogClass))

typedef struct _VtgInteractionParametersDialog VtgInteractionParametersDialog;
typedef struct _VtgInteractionParametersDialogClass VtgInteractionParametersDialogClass;
typedef struct _VtgInteractionParametersDialogPrivate VtgInteractionParametersDialogPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (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)))
typedef struct _VtgInteractionParamSpecParametersDialog VtgInteractionParamSpecParametersDialog;

00048 struct _VtgInteractionParametersDialog {
      GTypeInstance parent_instance;
      volatile int ref_count;
      VtgInteractionParametersDialogPrivate * priv;
};

00054 struct _VtgInteractionParametersDialogClass {
      GTypeClass parent_class;
      void (*finalize) (VtgInteractionParametersDialog *self);
};

00059 struct _VtgInteractionParametersDialogPrivate {
      GtkEntryCompletion* _completion;
      GtkDialog* _dialog;
};

00064 struct _VtgInteractionParamSpecParametersDialog {
      GParamSpec parent_instance;
};


static gpointer vtg_interaction_parameters_dialog_parent_class = NULL;
static GType vtg_interaction_parameters_dialog_type_id = 0;

gpointer vtg_interaction_parameters_dialog_ref (gpointer instance);
void vtg_interaction_parameters_dialog_unref (gpointer instance);
GParamSpec* vtg_interaction_param_spec_parameters_dialog (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void vtg_interaction_value_set_parameters_dialog (GValue* value, gpointer v_object);
void vtg_interaction_value_take_parameters_dialog (GValue* value, gpointer v_object);
gpointer vtg_interaction_value_get_parameters_dialog (const GValue* value);
GType vtg_interaction_parameters_dialog_get_type (void) G_GNUC_CONST;
GType vtg_interaction_parameters_dialog_register_type (GTypeModule * module);
#define VTG_INTERACTION_PARAMETERS_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, VtgInteractionParametersDialogPrivate))
enum  {
      VTG_INTERACTION_PARAMETERS_DIALOG_DUMMY_PROPERTY
};
VtgInteractionParametersDialog* vtg_interaction_parameters_dialog_new (const char* title, GtkWindow* parent, GtkListStore* completions);
VtgInteractionParametersDialog* vtg_interaction_parameters_dialog_construct (GType object_type, const char* title, GtkWindow* parent, GtkListStore* completions);
static void vtg_interaction_parameters_dialog_initialize_ui (VtgInteractionParametersDialog* self, const char* title, GtkWindow* parent, GtkListStore* completions);
char* vtg_utils_get_ui_path (const char* id);
gint vtg_interaction_parameters_dialog_run (VtgInteractionParametersDialog* self);
const char* vtg_interaction_parameters_dialog_get_parameters (VtgInteractionParametersDialog* self);
static void vtg_interaction_parameters_dialog_finalize (VtgInteractionParametersDialog* obj);



VtgInteractionParametersDialog* vtg_interaction_parameters_dialog_construct (GType object_type, const char* title, GtkWindow* parent, GtkListStore* completions) {
      VtgInteractionParametersDialog* self;
      g_return_val_if_fail (title != NULL, NULL);
      g_return_val_if_fail (parent != NULL, NULL);
      g_return_val_if_fail (completions != NULL, NULL);
      self = (VtgInteractionParametersDialog*) g_type_create_instance (object_type);
      vtg_interaction_parameters_dialog_initialize_ui (self, title, parent, completions);
      return self;
}


VtgInteractionParametersDialog* vtg_interaction_parameters_dialog_new (const char* title, GtkWindow* parent, GtkListStore* completions) {
      return vtg_interaction_parameters_dialog_construct (VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, title, parent, completions);
}


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


static void vtg_interaction_parameters_dialog_initialize_ui (VtgInteractionParametersDialog* self, const char* title, GtkWindow* parent, GtkListStore* completions) {
      GtkBuilder* builder;
      GtkDialog* _tmp1_;
      GtkEntryCompletion* _tmp2_;
      GtkEntry* entry;
      GtkTreeIter iter = {0};
      GError * _inner_error_ = NULL;
      g_return_if_fail (self != NULL);
      g_return_if_fail (title != NULL);
      g_return_if_fail (parent != NULL);
      g_return_if_fail (completions != NULL);
      builder = gtk_builder_new ();
      {
            char* _tmp0_;
            gtk_builder_add_from_file (builder, _tmp0_ = vtg_utils_get_ui_path ("vtg.ui"), &_inner_error_);
            _g_free0 (_tmp0_);
            if (_inner_error_ != NULL) {
                  goto __catch40_g_error;
            }
      }
      goto __finally40;
      __catch40_g_error:
      {
            GError * err;
            err = _inner_error_;
            _inner_error_ = NULL;
            {
                  g_warning ("vtgparametersdialog.vala:50: initialize_ui: %s", err->message);
                  _g_error_free0 (err);
            }
      }
      __finally40:
      if (_inner_error_ != NULL) {
            _g_object_unref0 (builder);
            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;
      }
      self->priv->_dialog = (_tmp1_ = _g_object_ref0 (GTK_DIALOG (gtk_builder_get_object (builder, "dialog-ask-params"))), _g_object_unref0 (self->priv->_dialog), _tmp1_);
      g_assert (self->priv->_dialog != NULL);
      gtk_window_set_title ((GtkWindow*) self->priv->_dialog, title);
      gtk_window_set_transient_for ((GtkWindow*) self->priv->_dialog, parent);
      self->priv->_completion = (_tmp2_ = gtk_entry_completion_new (), _g_object_unref0 (self->priv->_completion), _tmp2_);
      gtk_entry_completion_set_model (self->priv->_completion, (GtkTreeModel*) completions);
      gtk_entry_completion_set_text_column (self->priv->_completion, 0);
      entry = _g_object_ref0 (GTK_ENTRY (gtk_builder_get_object (builder, "entry-params")));
      gtk_entry_set_completion (entry, self->priv->_completion);
      if (gtk_tree_model_get_iter_first ((GtkTreeModel*) completions, &iter)) {
            char* val;
            val = NULL;
            gtk_tree_model_get ((GtkTreeModel*) completions, &iter, 0, &val, -1);
            gtk_entry_set_text (entry, val);
            gtk_editable_select_region ((GtkEditable*) entry, 0, -1);
            _g_free0 (val);
      }
      _g_object_unref0 (entry);
      _g_object_unref0 (builder);
}


gint vtg_interaction_parameters_dialog_run (VtgInteractionParametersDialog* self) {
      gint result = 0;
      g_return_val_if_fail (self != NULL, 0);
      result = gtk_dialog_run (self->priv->_dialog);
      return result;
}


const char* vtg_interaction_parameters_dialog_get_parameters (VtgInteractionParametersDialog* self) {
      const char* result;
      GtkEntry* en;
      g_return_val_if_fail (self != NULL, NULL);
      en = _g_object_ref0 (GTK_ENTRY (gtk_entry_completion_get_entry (self->priv->_completion)));
      result = gtk_entry_get_text (en);
      _g_object_unref0 (en);
      return result;
}


static void vtg_interaction_value_parameters_dialog_init (GValue* value) {
      value->data[0].v_pointer = NULL;
}


static void vtg_interaction_value_parameters_dialog_free_value (GValue* value) {
      if (value->data[0].v_pointer) {
            vtg_interaction_parameters_dialog_unref (value->data[0].v_pointer);
      }
}


static void vtg_interaction_value_parameters_dialog_copy_value (const GValue* src_value, GValue* dest_value) {
      if (src_value->data[0].v_pointer) {
            dest_value->data[0].v_pointer = vtg_interaction_parameters_dialog_ref (src_value->data[0].v_pointer);
      } else {
            dest_value->data[0].v_pointer = NULL;
      }
}


static gpointer vtg_interaction_value_parameters_dialog_peek_pointer (const GValue* value) {
      return value->data[0].v_pointer;
}


static gchar* vtg_interaction_value_parameters_dialog_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
      if (collect_values[0].v_pointer) {
            VtgInteractionParametersDialog* object;
            object = collect_values[0].v_pointer;
            if (object->parent_instance.g_class == NULL) {
                  return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
            } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
                  return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
            }
            value->data[0].v_pointer = vtg_interaction_parameters_dialog_ref (object);
      } else {
            value->data[0].v_pointer = NULL;
      }
      return NULL;
}


static gchar* vtg_interaction_value_parameters_dialog_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
      VtgInteractionParametersDialog** object_p;
      object_p = collect_values[0].v_pointer;
      if (!object_p) {
            return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
      }
      if (!value->data[0].v_pointer) {
            *object_p = NULL;
      } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
            *object_p = value->data[0].v_pointer;
      } else {
            *object_p = vtg_interaction_parameters_dialog_ref (value->data[0].v_pointer);
      }
      return NULL;
}


GParamSpec* vtg_interaction_param_spec_parameters_dialog (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
      VtgInteractionParamSpecParametersDialog* spec;
      g_return_val_if_fail (g_type_is_a (object_type, VTG_INTERACTION_TYPE_PARAMETERS_DIALOG), NULL);
      spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
      G_PARAM_SPEC (spec)->value_type = object_type;
      return G_PARAM_SPEC (spec);
}


gpointer vtg_interaction_value_get_parameters_dialog (const GValue* value) {
      g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VTG_INTERACTION_TYPE_PARAMETERS_DIALOG), NULL);
      return value->data[0].v_pointer;
}


void vtg_interaction_value_set_parameters_dialog (GValue* value, gpointer v_object) {
      VtgInteractionParametersDialog* old;
      g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VTG_INTERACTION_TYPE_PARAMETERS_DIALOG));
      old = value->data[0].v_pointer;
      if (v_object) {
            g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VTG_INTERACTION_TYPE_PARAMETERS_DIALOG));
            g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
            value->data[0].v_pointer = v_object;
            vtg_interaction_parameters_dialog_ref (value->data[0].v_pointer);
      } else {
            value->data[0].v_pointer = NULL;
      }
      if (old) {
            vtg_interaction_parameters_dialog_unref (old);
      }
}


void vtg_interaction_value_take_parameters_dialog (GValue* value, gpointer v_object) {
      VtgInteractionParametersDialog* old;
      g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VTG_INTERACTION_TYPE_PARAMETERS_DIALOG));
      old = value->data[0].v_pointer;
      if (v_object) {
            g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VTG_INTERACTION_TYPE_PARAMETERS_DIALOG));
            g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
            value->data[0].v_pointer = v_object;
      } else {
            value->data[0].v_pointer = NULL;
      }
      if (old) {
            vtg_interaction_parameters_dialog_unref (old);
      }
}


static void vtg_interaction_parameters_dialog_class_init (VtgInteractionParametersDialogClass * klass) {
      vtg_interaction_parameters_dialog_parent_class = g_type_class_peek_parent (klass);
      VTG_INTERACTION_PARAMETERS_DIALOG_CLASS (klass)->finalize = vtg_interaction_parameters_dialog_finalize;
      g_type_class_add_private (klass, sizeof (VtgInteractionParametersDialogPrivate));
}


static void vtg_interaction_parameters_dialog_instance_init (VtgInteractionParametersDialog * self) {
      self->priv = VTG_INTERACTION_PARAMETERS_DIALOG_GET_PRIVATE (self);
      self->ref_count = 1;
}


static void vtg_interaction_parameters_dialog_finalize (VtgInteractionParametersDialog* obj) {
      VtgInteractionParametersDialog * self;
      self = VTG_INTERACTION_PARAMETERS_DIALOG (obj);
      {
            gtk_object_destroy ((GtkObject*) self->priv->_dialog);
      }
      _g_object_unref0 (self->priv->_completion);
      _g_object_unref0 (self->priv->_dialog);
}


GType vtg_interaction_parameters_dialog_get_type (void) {
      return vtg_interaction_parameters_dialog_type_id;
}


GType vtg_interaction_parameters_dialog_register_type (GTypeModule * module) {
      static const GTypeValueTable g_define_type_value_table = { vtg_interaction_value_parameters_dialog_init, vtg_interaction_value_parameters_dialog_free_value, vtg_interaction_value_parameters_dialog_copy_value, vtg_interaction_value_parameters_dialog_peek_pointer, "p", vtg_interaction_value_parameters_dialog_collect_value, "p", vtg_interaction_value_parameters_dialog_lcopy_value };
      static const GTypeInfo g_define_type_info = { sizeof (VtgInteractionParametersDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vtg_interaction_parameters_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (VtgInteractionParametersDialog), 0, (GInstanceInitFunc) vtg_interaction_parameters_dialog_instance_init, &g_define_type_value_table };
      static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
      vtg_interaction_parameters_dialog_type_id = g_type_register_fundamental (g_type_fundamental_next (), "VtgInteractionParametersDialog", &g_define_type_info, &g_define_type_fundamental_info, 0);
      return vtg_interaction_parameters_dialog_type_id;
}


gpointer vtg_interaction_parameters_dialog_ref (gpointer instance) {
      VtgInteractionParametersDialog* self;
      self = instance;
      g_atomic_int_inc (&self->ref_count);
      return instance;
}


void vtg_interaction_parameters_dialog_unref (gpointer instance) {
      VtgInteractionParametersDialog* self;
      self = instance;
      if (g_atomic_int_dec_and_test (&self->ref_count)) {
            VTG_INTERACTION_PARAMETERS_DIALOG_GET_CLASS (self)->finalize (self);
            g_type_free_instance ((GTypeInstance *) self);
      }
}





Generated by  Doxygen 1.6.0   Back to index