Пример #1
0
/**
 * gdaui_data_entry_set_reference_current:
 * @de: a #GtkWidget object which implements the #GdauiDataEntry interface
 *
 * Tells that the current value in @de is to be considered as the reference value
 *
 * Since: 4.2
 */
void
gdaui_data_entry_set_reference_current (GdauiDataEntry *de)
{
	GValue *value;
	g_return_if_fail (GDAUI_IS_DATA_ENTRY (de));

	value = gdaui_data_entry_get_value (de);
	gdaui_data_entry_set_reference_value (de, value);
	if (value)
		gda_value_free (value);
}
Пример #2
0
static void
set_preview_widget (TablePreferences *tpref)
{
	GtkWidget *preview = NULL;
	GtkTreeIter iter;

	if (!tpref->priv->current_column)
		return;

	if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (tpref->priv->plugins_combo), &iter)) {
		GdauiPlugin *plugin;
		GtkTreeModel *model;
		GType gtype;

		gtype = tpref->priv->current_column->gtype;
		
		model = tpref->priv->plugins_model;
		gtk_tree_model_get (model, &iter, PL_COLUMN_PLUGIN, &plugin, -1);
		if (plugin) {
			GString *string = NULL;
			if (tpref->priv->options_wid) {
				GdaSet *plist;
				GSList *list;
				
				plist = gdaui_basic_form_get_data_set (GDAUI_BASIC_FORM (tpref->priv->options_wid));
				for (list = plist->holders; list; list = list->next) {
					GdaHolder *holder;
					holder = GDA_HOLDER (list->data);
					if (gda_holder_is_valid (holder)) {
						const GValue *cvalue;
						cvalue = gda_holder_get_value (holder);
						if (cvalue && (G_VALUE_TYPE (cvalue) != GDA_TYPE_NULL)) {
							gchar *str = gda_value_stringify (cvalue);
							gchar *r1, *r2;
							if (!string)
								string = g_string_new ("");
							else
								g_string_append_c (string, ';');
							r1 = gda_rfc1738_encode (gda_holder_get_id (holder));
							r2 = gda_rfc1738_encode (str);
							g_free (str);
							g_string_append_printf (string, "%s=%s", r1, r2);
							g_free (r1);
							g_free (r2);
						}
					}
				}
			}
			if (string) {
				g_string_prepend_c (string, ':');
				g_string_prepend (string, plugin->plugin_name);
				preview = GTK_WIDGET (gdaui_new_data_entry (gtype, string->str));
				g_string_free (string, TRUE);
			}
			else
				preview = GTK_WIDGET (gdaui_new_data_entry (gtype, plugin->plugin_name));
		}
		else
			preview = GTK_WIDGET (gdaui_new_data_entry (gtype, NULL));
	}

	GValue *prev_value = NULL;
	if (tpref->priv->preview_wid) {
		prev_value = gdaui_data_entry_get_value (GDAUI_DATA_ENTRY (tpref->priv->preview_wid));
		gtk_widget_destroy (tpref->priv->preview_wid);
		gtk_widget_show (tpref->priv->preview_none);
		tpref->priv->preview_wid = NULL;
	}
	if (preview) {
		if (prev_value &&
		    (G_VALUE_TYPE (prev_value) == gdaui_data_entry_get_value_type (GDAUI_DATA_ENTRY (preview))))
			gdaui_data_entry_set_value (GDAUI_DATA_ENTRY (preview), prev_value);
		gdaui_data_entry_set_attributes (GDAUI_DATA_ENTRY (preview),
						 0, GDA_VALUE_ATTR_ACTIONS_SHOWN);
		tpref->priv->preview_wid = preview;
		gtk_box_pack_start (GTK_BOX (tpref->priv->preview_vbox), preview, TRUE, TRUE, 0);
		gtk_widget_hide (tpref->priv->preview_none);
		gtk_widget_show (tpref->priv->preview_wid);
	}
	if (prev_value)
		gda_value_free (prev_value);
}