#include <sql-parser/gda-sql-parser.h>
-#include <libgdaex.h>
+#include <libgdaex/libgdaex.h>
#include "gtkformdecoder.h"
PROP_0,
PROP_GDAEX,
PROP_SQL,
- PROP_SHOW_CLEAN
+ PROP_SHOW_CLEAN,
+ PROP_SHOW_OPEN
};
static void gtk_form_decoder_class_init (GtkFormDecoderClass *klass);
GValue *value,
GParamSpec *pspec);
-static void gtk_form_decoder_on_btn_browse_clicked (GtkButton *button,
- gpointer user_data);
-
static void gtk_form_decoder_on_btn_clean_clicked (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
GdkEvent *event,
gpointer user_data);
+static void gtk_form_decoder_on_btn_open_clicked (GtkButton *button,
+ gpointer user_data);
+
+static void gtk_form_decoder_on_btn_browse_clicked (GtkButton *button,
+ gpointer user_data);
+
static GtkWidgetClass *parent_class = NULL;
{
GtkWidget *hbox;
GtkWidget *txt_decoded;
+ GtkWidget *btn_open;
GtkWidget *btn_browse;
GtkWidget *lbl_key;
FALSE,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_SHOW_OPEN,
+ g_param_spec_boolean ("show-btn-open",
+ "Show open button",
+ "Whether to show the open button",
+ FALSE,
+ G_PARAM_READWRITE));
+
/**
- * GtkFormDecoder::btn_browse_clicked:
+ * GtkFormDecoder::btn_clean_clicked:
* @gtk_form_decoder:
*
*/
- klass->btn_browse_clicked_signal_id = g_signal_new ("btn-browse-clicked",
+ klass->btn_clean_clicked_signal_id = g_signal_new ("btn-clean-clicked",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ g_cclosure_marshal_BOOLEAN__FLAGS,
+ G_TYPE_BOOLEAN,
+ 1, G_TYPE_INT);
/**
- * GtkFormDecoder::btn_clean_clicked:
+ * GtkFormDecoder::btn_open_clicked:
* @gtk_form_decoder:
*
*/
- klass->btn_clean_clicked_signal_id = g_signal_new ("btn-clean-clicked",
+ klass->btn_open_clicked_signal_id = g_signal_new ("btn-open-clicked",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
g_cclosure_marshal_BOOLEAN__FLAGS,
G_TYPE_BOOLEAN,
1, G_TYPE_INT);
+
+ /**
+ * GtkFormDecoder::btn_browse_clicked:
+ * @gtk_form_decoder:
+ *
+ */
+ klass->btn_browse_clicked_signal_id = g_signal_new ("btn-browse-clicked",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
{
GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
- priv->hbox = gtk_hbox_new (FALSE, 5);
+ GtkWidget *icon;
+
+ priv->hbox = gtk_hbox_new (FALSE, 3);
gtk_container_add (GTK_CONTAINER (decoder), priv->hbox);
gtk_widget_show (priv->hbox);
g_signal_connect (G_OBJECT (priv->txt_decoded), "icon-press",
G_CALLBACK (gtk_form_decoder_on_btn_clean_clicked), (gpointer)decoder);
+ priv->btn_open = gtk_button_new ();
+ gtk_widget_set_tooltip_text (priv->btn_open, "Open");
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->btn_open, FALSE, FALSE, 0);
+ gtk_widget_set_no_show_all (priv->btn_open, TRUE);
+ icon = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (priv->btn_open), icon);
+ gtk_widget_show (icon);
+ gtk_widget_show (priv->btn_open);
+
+ g_signal_connect (G_OBJECT (priv->btn_open), "clicked",
+ G_CALLBACK (gtk_form_decoder_on_btn_open_clicked), (gpointer)decoder);
+
priv->btn_browse = gtk_button_new_with_label ("...");
+ gtk_widget_set_tooltip_text (priv->btn_browse, "Find");
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->btn_browse, FALSE, FALSE, 0);
gtk_widget_set_no_show_all (priv->btn_browse, TRUE);
gtk_widget_show (priv->btn_browse);
gtk_entry_set_icon_sensitive (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, visible);
}
+static void
+gtk_form_decoder_show_btn_open (GtkFormDecoder *decoder, gboolean visible)
+{
+ GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+ gtk_widget_set_visible (priv->btn_open, visible);
+}
+
/* CALLBACKS */
static void
gtk_form_decoder_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
gtk_form_decoder_show_btn_clean (decoder, g_value_get_boolean (value));
break;
+ case PROP_SHOW_OPEN:
+ gtk_form_decoder_show_btn_open (decoder, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
g_value_set_boolean (value, gtk_entry_get_icon_stock (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY) != NULL);
break;
+ case PROP_SHOW_OPEN:
+ g_value_set_boolean (value, gtk_widget_get_visible (priv->btn_open));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
-static void
-gtk_form_decoder_on_btn_browse_clicked (GtkButton *button,
- gpointer user_data)
-{
- GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS ((GtkFormDecoder *)user_data);
-
- g_signal_emit (G_OBJECT (user_data), klass->btn_browse_clicked_signal_id, 0);
-}
-
static void
gtk_form_decoder_on_btn_clean_clicked (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
gtk_form_decoder_set_key (decoder, "0");
}
}
+
+static void
+gtk_form_decoder_on_btn_open_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS ((GtkFormDecoder *)user_data);
+
+ g_signal_emit (G_OBJECT (user_data), klass->btn_open_clicked_signal_id, 0);
+}
+
+static void
+gtk_form_decoder_on_btn_browse_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS ((GtkFormDecoder *)user_data);
+
+ g_signal_emit (G_OBJECT (user_data), klass->btn_browse_clicked_signal_id, 0);
+}
#include <gtk/gtk.h>
-#include <libgdaex.h>
+#include <libgdaex/libgdaex.h>
#include "gtkformdecoder.h"
GdaEx *gdaex;
+static gboolean
+on_btn_clean_clicked (gpointer instance, gint arg1, gpointer user_data)
+{
+ return FALSE;
+}
+
static void
-on_btn_browse_clicked (gpointer instance, gpointer user_data)
+on_btn_open_clicked (gpointer instance, gpointer user_data)
{
- gtk_form_decoder_set_key (GTK_FORM_DECODER (decoder), "1");
+ g_debug ("Open clicked.");
}
-static gboolean
-on_btn_clean_clicked (gpointer instance, gint arg1, gpointer user_data)
+static void
+on_btn_browse_clicked (gpointer instance, gpointer user_data)
{
- return FALSE;
+ gtk_form_decoder_set_key (GTK_FORM_DECODER (decoder), "1");
}
gboolean
" FROM customers"
" WHERE id = ##key0::gint",
"show-btn-clean", TRUE,
+ "show-btn-open", TRUE,
NULL);
- g_signal_connect (G_OBJECT (decoder), "btn_browse_clicked",
- G_CALLBACK (on_btn_browse_clicked), NULL);
g_signal_connect (G_OBJECT (decoder), "btn_clean_clicked",
G_CALLBACK (on_btn_clean_clicked), NULL);
+ g_signal_connect (G_OBJECT (decoder), "btn_open_clicked",
+ G_CALLBACK (on_btn_open_clicked), NULL);
+ g_signal_connect (G_OBJECT (decoder), "btn_browse_clicked",
+ G_CALLBACK (on_btn_browse_clicked), NULL);
gtk_widget_show_all (w);