{
PROP_0,
PROP_GDAEX,
- PROP_SQL
+ PROP_SQL,
+ PROP_SHOW_CLEAN
};
static void gtk_form_decoder_class_init (GtkFormDecoderClass *klass);
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 GtkWidgetClass *parent_class = NULL;
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_SHOW_CLEAN,
+ g_param_spec_boolean ("show-btn-clean",
+ "Show clean icon",
+ "Whether to show the clean icon",
+ FALSE,
+ G_PARAM_READWRITE));
+
/**
* GtkFormDecoder::btn_browse_clicked:
* @gtk_form_decoder:
gtk_editable_set_editable (GTK_EDITABLE (priv->txt_decoded), FALSE);
gtk_widget_show (priv->txt_decoded);
+ g_signal_connect (G_OBJECT (priv->txt_decoded), "icon-press",
+ G_CALLBACK (gtk_form_decoder_on_btn_clean_clicked), (gpointer)decoder);
+
priv->btn_browse = gtk_button_new_with_label ("...");
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->btn_browse, FALSE, FALSE, 0);
gtk_widget_set_no_show_all (priv->btn_browse, TRUE);
}
}
+static void
+gtk_form_decoder_show_btn_clean (GtkFormDecoder *decoder, gboolean visible)
+{
+ GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, "gtk-clear");
+ gtk_entry_set_icon_activatable (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, TRUE);
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, TRUE);
+}
+
/* CALLBACKS */
static void
gtk_form_decoder_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
}
break;
+ case PROP_SHOW_CLEAN:
+ gtk_form_decoder_show_btn_clean (decoder, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
g_value_set_string (value, priv->sql);
break;
+ case PROP_SHOW_CLEAN:
+ g_value_set_boolean (value, gtk_entry_get_icon_stock (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY) != NULL);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
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,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ GtkFormDecoder *decoder = (GtkFormDecoder *)user_data;
+ GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+ GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS (decoder);
+
+ gtk_form_decoder_set_key (decoder, "0");
+}