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

vtgprojectsearchdialog.c

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

/*
 *  vtgprojectsearchdialog.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 <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>


#define VTG_TYPE_PROJECT_SEARCH_DIALOG (vtg_project_search_dialog_get_type ())
#define VTG_PROJECT_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_TYPE_PROJECT_SEARCH_DIALOG, VtgProjectSearchDialog))
#define VTG_PROJECT_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_TYPE_PROJECT_SEARCH_DIALOG, VtgProjectSearchDialogClass))
#define VTG_IS_PROJECT_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_TYPE_PROJECT_SEARCH_DIALOG))
#define VTG_IS_PROJECT_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_TYPE_PROJECT_SEARCH_DIALOG))
#define VTG_PROJECT_SEARCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_TYPE_PROJECT_SEARCH_DIALOG, VtgProjectSearchDialogClass))

typedef struct _VtgProjectSearchDialog VtgProjectSearchDialog;
typedef struct _VtgProjectSearchDialogClass VtgProjectSearchDialogClass;
typedef struct _VtgProjectSearchDialogPrivate VtgProjectSearchDialogPrivate;
#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)))

struct _VtgProjectSearchDialog {
      GObject parent_instance;
      VtgProjectSearchDialogPrivate * priv;
      char* search_text;
      gboolean match_case;
};

struct _VtgProjectSearchDialogClass {
      GObjectClass parent_class;
};

00057 struct _VtgProjectSearchDialogPrivate {
      GtkDialog* _dialog;
      GtkEntry* _entry;
      GtkButton* _button_find;
      GtkCheckButton* _check_match_case;
};


static gpointer vtg_project_search_dialog_parent_class = NULL;
static GType vtg_project_search_dialog_type_id = 0;

GType vtg_project_search_dialog_get_type (void) G_GNUC_CONST;
GType vtg_project_search_dialog_register_type (GTypeModule * module);
#define VTG_PROJECT_SEARCH_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VTG_TYPE_PROJECT_SEARCH_DIALOG, VtgProjectSearchDialogPrivate))
enum  {
      VTG_PROJECT_SEARCH_DIALOG_DUMMY_PROPERTY
};
VtgProjectSearchDialog* vtg_project_search_dialog_new (GtkWindow* parent, const char* proposed_text);
VtgProjectSearchDialog* vtg_project_search_dialog_construct (GType object_type, GtkWindow* parent, const char* proposed_text);
static void vtg_project_search_dialog_initialize_ui (VtgProjectSearchDialog* self, GtkWindow* parent);
char* vtg_utils_get_ui_path (const char* id);
static void vtg_project_search_dialog_on_entry_text_changed (VtgProjectSearchDialog* self, GObject* pspec, GParamSpec* gobject);
static void _vtg_project_search_dialog_on_entry_text_changed_g_object_notify (GtkEntry* _sender, GParamSpec* pspec, gpointer self);
gint vtg_project_search_dialog_run (VtgProjectSearchDialog* self);
static void vtg_project_search_dialog_finalize (GObject* obj);



VtgProjectSearchDialog* vtg_project_search_dialog_construct (GType object_type, GtkWindow* parent, const char* proposed_text) {
      VtgProjectSearchDialog * self;
      g_return_val_if_fail (parent != NULL, NULL);
      g_return_val_if_fail (proposed_text != NULL, NULL);
      self = (VtgProjectSearchDialog*) g_object_new (object_type, NULL);
      vtg_project_search_dialog_initialize_ui (self, parent);
      gtk_entry_set_text (self->priv->_entry, proposed_text);
      return self;
}


VtgProjectSearchDialog* vtg_project_search_dialog_new (GtkWindow* parent, const char* proposed_text) {
      return vtg_project_search_dialog_construct (VTG_TYPE_PROJECT_SEARCH_DIALOG, parent, proposed_text);
}


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


static void _vtg_project_search_dialog_on_entry_text_changed_g_object_notify (GtkEntry* _sender, GParamSpec* pspec, gpointer self) {
      vtg_project_search_dialog_on_entry_text_changed (self, _sender, pspec);
}


static void vtg_project_search_dialog_initialize_ui (VtgProjectSearchDialog* self, GtkWindow* parent) {
      GtkBuilder* builder;
      GtkDialog* _tmp1_;
      GtkButton* _tmp2_;
      GtkEntry* _tmp3_;
      GtkCheckButton* _tmp4_;
      char* _tmp5_;
      GError * _inner_error_ = NULL;
      g_return_if_fail (self != NULL);
      g_return_if_fail (parent != 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 __catch29_g_error;
            }
      }
      goto __finally29;
      __catch29_g_error:
      {
            GError * err;
            err = _inner_error_;
            _inner_error_ = NULL;
            {
                  g_warning ("vtgprojectsearchdialog.vala:51: initialize_ui: %s", err->message);
                  _g_error_free0 (err);
            }
      }
      __finally29:
      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-search"))), _g_object_unref0 (self->priv->_dialog), _tmp1_);
      g_assert (self->priv->_dialog != NULL);
      gtk_window_set_transient_for ((GtkWindow*) self->priv->_dialog, parent);
      self->priv->_button_find = (_tmp2_ = _g_object_ref0 (GTK_BUTTON (gtk_builder_get_object (builder, "button_find"))), _g_object_unref0 (self->priv->_button_find), _tmp2_);
      g_assert (self->priv->_button_find != NULL);
      self->priv->_entry = (_tmp3_ = _g_object_ref0 (GTK_ENTRY (gtk_builder_get_object (builder, "entry_search"))), _g_object_unref0 (self->priv->_entry), _tmp3_);
      g_assert (self->priv->_entry != NULL);
      g_signal_connect_object ((GObject*) self->priv->_entry, "notify::text", (GCallback) _vtg_project_search_dialog_on_entry_text_changed_g_object_notify, self, 0);
      self->priv->_check_match_case = (_tmp4_ = _g_object_ref0 (GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "checkbutton_match_case"))), _g_object_unref0 (self->priv->_check_match_case), _tmp4_);
      g_assert (self->priv->_check_match_case != NULL);
      self->search_text = (_tmp5_ = g_strdup (""), _g_free0 (self->search_text), _tmp5_);
      self->match_case = FALSE;
      gtk_entry_set_text (self->priv->_entry, self->search_text);
      gtk_toggle_button_set_active ((GtkToggleButton*) self->priv->_check_match_case, self->match_case);
      _g_object_unref0 (builder);
}


gint vtg_project_search_dialog_run (VtgProjectSearchDialog* self) {
      gint result = 0;
      gint dialog_result;
      g_return_val_if_fail (self != NULL, 0);
      gtk_window_set_modal ((GtkWindow*) self->priv->_dialog, TRUE);
      gtk_widget_show_all ((GtkWidget*) self->priv->_dialog);
      dialog_result = gtk_dialog_run (self->priv->_dialog);
      if (dialog_result == GTK_RESPONSE_OK) {
            char* _tmp0_;
            self->search_text = (_tmp0_ = g_strdup (gtk_entry_get_text (self->priv->_entry)), _g_free0 (self->search_text), _tmp0_);
            self->match_case = gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->_check_match_case);
      }
      gtk_object_destroy ((GtkObject*) self->priv->_dialog);
      result = dialog_result;
      return result;
}


static void vtg_project_search_dialog_on_entry_text_changed (VtgProjectSearchDialog* self, GObject* pspec, GParamSpec* gobject) {
      g_return_if_fail (self != NULL);
      g_return_if_fail (pspec != NULL);
      g_return_if_fail (gobject != NULL);
      gtk_widget_set_sensitive ((GtkWidget*) self->priv->_button_find, gtk_entry_get_text_length (self->priv->_entry) > 0);
}


static void vtg_project_search_dialog_class_init (VtgProjectSearchDialogClass * klass) {
      vtg_project_search_dialog_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (VtgProjectSearchDialogPrivate));
      G_OBJECT_CLASS (klass)->finalize = vtg_project_search_dialog_finalize;
}


static void vtg_project_search_dialog_instance_init (VtgProjectSearchDialog * self) {
      self->priv = VTG_PROJECT_SEARCH_DIALOG_GET_PRIVATE (self);
      self->search_text = NULL;
      self->match_case = FALSE;
}


static void vtg_project_search_dialog_finalize (GObject* obj) {
      VtgProjectSearchDialog * self;
      self = VTG_PROJECT_SEARCH_DIALOG (obj);
      _g_object_unref0 (self->priv->_dialog);
      _g_object_unref0 (self->priv->_entry);
      _g_object_unref0 (self->priv->_button_find);
      _g_object_unref0 (self->priv->_check_match_case);
      _g_free0 (self->search_text);
      G_OBJECT_CLASS (vtg_project_search_dialog_parent_class)->finalize (obj);
}


GType vtg_project_search_dialog_get_type (void) {
      return vtg_project_search_dialog_type_id;
}


GType vtg_project_search_dialog_register_type (GTypeModule * module) {
      static const GTypeInfo g_define_type_info = { sizeof (VtgProjectSearchDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vtg_project_search_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (VtgProjectSearchDialog), 0, (GInstanceInitFunc) vtg_project_search_dialog_instance_init, NULL };
      vtg_project_search_dialog_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "VtgProjectSearchDialog", &g_define_type_info, 0);
      return vtg_project_search_dialog_type_id;
}





Generated by  Doxygen 1.6.0   Back to index