[gnumeric] Allow document properties to be added.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Allow document properties to be added.
- Date: Wed, 29 Jun 2011 20:24:24 +0000 (UTC)
commit 25e9b90c1283f313ea628a2bc69aab89b720295f
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Wed Jun 29 14:22:47 2011 -0600
Allow document properties to be added.
2011-06-29 Andreas J. Guelzow <aguelzow pyrshep ca>
* doc-meta-data.ui: add value entry and warning label
* dialog-doc-metadata.c (cb_dialog_doc_metadata_value_edited): new
(cb_dialog_doc_metadata_add_clicked): implement
(cb_dialog_doc_metadata_ppt_changed): new
(dialog_doc_metadata_init_properties_page): connect callbacks
(dialog_doc_metadata_init_widgets): handle new widgets
NEWS | 2 +-
src/dialogs/ChangeLog | 9 +++++
src/dialogs/dialog-doc-metadata.c | 71 +++++++++++++++++++++++++++++++++---
src/dialogs/doc-meta-data.ui | 61 +++++++++++++++++++++++++++----
4 files changed, 128 insertions(+), 15 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3526ab7..c239b5f 100644
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,7 @@ Andreas:
* Write and read some document properties to and from XLSX.
* Fix xlsx schema violations.
* Fix keyword handling in properties dialog. [#653378]
- * Allow document properties to be edited.
+ * Allow document properties to be edited and added.
Morten:
* Fix --with-gnome compilation: [#652802]
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 82b8207..5937f86 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,5 +1,14 @@
2011-06-29 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * doc-meta-data.ui: add value entry and warning label
+ * dialog-doc-metadata.c (cb_dialog_doc_metadata_value_edited): new
+ (cb_dialog_doc_metadata_add_clicked): implement
+ (cb_dialog_doc_metadata_ppt_changed): new
+ (dialog_doc_metadata_init_properties_page): connect callbacks
+ (dialog_doc_metadata_init_widgets): handle new widgets
+
+2011-06-29 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* doc-meta-data.ui: really remove keywords from description tab
* dialog-doc-metadata.c (dialog_doc_metadata_get_value_type): new
(dialog_doc_metadata_get_value_type_from_name): new
diff --git a/src/dialogs/dialog-doc-metadata.c b/src/dialogs/dialog-doc-metadata.c
index 20ee01f..b9081e6 100644
--- a/src/dialogs/dialog-doc-metadata.c
+++ b/src/dialogs/dialog-doc-metadata.c
@@ -114,6 +114,7 @@ typedef struct {
GtkTreeStore *properties_store;
GtkEntry *ppt_name;
+ GtkEntry *ppt_value;
GtkComboBox *ppt_type;
GtkListStore *type_store;
@@ -121,6 +122,7 @@ typedef struct {
GtkButton *remove_button;
GtkLabel *instruction;
+ GtkLabel *warning;
/* Keyword Page */
GtkTreeView *key_tree_view;
@@ -1140,8 +1142,6 @@ cb_dialog_doc_metadata_value_edited (GtkCellRendererText *renderer,
}
}
-
-
/**
* cb_dialog_doc_metadata_add_clicked
*
@@ -1155,10 +1155,15 @@ static void
cb_dialog_doc_metadata_add_clicked (GtkWidget *w,
DialogDocMetaData *state)
{
- g_return_if_fail (state->metadata != NULL);
+ const gchar *name = gtk_entry_get_text (state->ppt_name);
+ const gchar *value = gtk_entry_get_text (state->ppt_value);
+ gchar *name_trimmed = pango_trim_string (name);
+ GType t;
- /* Create a new entry in Tree View and Combo Box */
- dialog_doc_metadata_add_prop (state, "<Name>", "<Value>", "", G_TYPE_INVALID);
+ t = dialog_doc_metadata_get_value_type_from_name (name_trimmed);
+ dialog_doc_metadata_add_prop (state, name_trimmed, value, NULL, t);
+
+ g_free (name_trimmed);
}
/**
@@ -1171,6 +1176,7 @@ cb_dialog_doc_metadata_add_clicked (GtkWidget *w,
* Updates a label or a entry text with the new value.
*
**/
+
static void
dialog_doc_metadata_update_prop (DialogDocMetaData *state,
const gchar *prop_name,
@@ -1421,6 +1427,50 @@ dialog_doc_metadata_populate_tree_view (gchar *name,
g_free (str_value);
}
+static gboolean
+cb_dialog_doc_metadata_ppt_changed (GtkEntry *entry,
+ GdkEventFocus *event,
+ DialogDocMetaData *state)
+{
+ const gchar *name = gtk_entry_get_text (state->ppt_name);
+ const gchar *value = gtk_entry_get_text (state->ppt_value);
+ gchar *name_trimmed = pango_trim_string (name);
+ gboolean enable = !(strlen (name_trimmed) == 0
+ || strlen (value) == 0);
+ gchar *str = NULL;
+ GsfDocProp *prop = NULL;
+
+ prop = gsf_doc_meta_data_lookup (state->metadata, name_trimmed);
+
+ if (enable) {
+ if (prop != NULL) {
+ str = g_strdup_printf
+ (_("A document property with the name \'%s\' already exists."),
+ name_trimmed);
+ enable = FALSE;
+ } else {
+ GType t = dialog_doc_metadata_get_value_type_from_name (name_trimmed);
+ if (t == GSF_DOCPROP_VECTOR_TYPE) {
+ str = g_strdup_printf
+ (_("Use the keywords tab to create this property."));
+ enable = FALSE;
+ } else if (t != G_TYPE_STRING) {
+ str = g_strdup_printf
+ (_("The document property named \'%s\' is not "
+ "of string type."),
+ name_trimmed );
+ enable = FALSE;
+ }
+ }
+ }
+
+ gtk_widget_set_sensitive (GTK_WIDGET (state->add_button), enable);
+ gtk_label_set_text (state->warning, str ? str : "");
+ g_free (str);
+ g_free (name_trimmed);
+ return FALSE;
+}
+
/**
* dialog_doc_metadata_init_properties_page
@@ -1443,7 +1493,6 @@ dialog_doc_metadata_init_properties_page (DialogDocMetaData *state)
gtk_widget_set_sensitive (GTK_WIDGET (state->add_button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (state->remove_button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (state->ppt_type), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (state->ppt_name), FALSE);
/* Intialize Combo Box */
/* gtk_combo_box_set_id_column (state->ppt_type, 0); */
@@ -1504,6 +1553,14 @@ dialog_doc_metadata_init_properties_page (DialogDocMetaData *state)
state);
/* Entries */
+ g_signal_connect (G_OBJECT (state->ppt_name),
+ "focus-out-event",
+ G_CALLBACK (cb_dialog_doc_metadata_ppt_changed),
+ state);
+ g_signal_connect (G_OBJECT (state->ppt_value),
+ "focus-out-event",
+ G_CALLBACK (cb_dialog_doc_metadata_ppt_changed),
+ state);
/* 'Add', 'Remove' and 'Apply' Button Signals */
g_signal_connect (G_OBJECT (state->add_button),
@@ -1715,12 +1772,14 @@ dialog_doc_metadata_init_widgets (DialogDocMetaData *state)
state->properties = GTK_TREE_VIEW (go_gtk_builder_get_widget (state->gui, "properties"));
state->ppt_name = GTK_ENTRY (go_gtk_builder_get_widget (state->gui, "property-name"));
+ state->ppt_value = GTK_ENTRY (go_gtk_builder_get_widget (state->gui, "property-value"));
state->ppt_type = GTK_COMBO_BOX (go_gtk_builder_get_widget (state->gui, "type-combo"));
state->type_store = GTK_LIST_STORE (gtk_combo_box_get_model (state->ppt_type));
state->add_button = GTK_BUTTON (go_gtk_builder_get_widget (state->gui, "add_button"));
state->remove_button = GTK_BUTTON (go_gtk_builder_get_widget (state->gui, "remove_button"));
state->instruction = GTK_LABEL (go_gtk_builder_get_widget (state->gui, "instruction-label"));
+ state->warning = GTK_LABEL (go_gtk_builder_get_widget (state->gui, "warning"));
/* Keyword Page */
state->key_tree_view = GTK_TREE_VIEW (go_gtk_builder_get_widget (state->gui, "keyview"));
diff --git a/src/dialogs/doc-meta-data.ui b/src/dialogs/doc-meta-data.ui
index 7fa82fc..ef66cf7 100644
--- a/src/dialogs/doc-meta-data.ui
+++ b/src/dialogs/doc-meta-data.ui
@@ -1184,7 +1184,7 @@
<object class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">2</property>
+ <property name="n_rows">4</property>
<property name="n_columns">3</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
@@ -1197,7 +1197,7 @@
<property name="label" translatable="yes">Name: </property>
</object>
<packing>
- <property name="x_options">GTK_FILL</property>
+ <property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
@@ -1210,9 +1210,9 @@
<property name="label" translatable="yes">Type: </property>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options">GTK_SHRINK</property>
</packing>
</child>
@@ -1230,7 +1230,7 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
- <property name="y_options"></property>
+ <property name="y_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
<child>
@@ -1246,8 +1246,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
@@ -1261,8 +1261,53 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options">GTK_SHRINK | GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Value:</property>
+ </object>
+ <packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
+ <property name="x_options">GTK_SHRINK | GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="property-value">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options">GTK_SHRINK | GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="warning">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="yalign">0.4699999988079071</property>
+ </object>
+ <packing>
+ <property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="y_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]