[Goodies-commits] r5495 - xfbib/branches/gobject/src
David Gustafsson
tssj at xfce.org
Wed Oct 1 15:48:15 CEST 2008
Author: tssj
Date: 2008-10-01 13:48:15 +0000 (Wed, 01 Oct 2008)
New Revision: 5495
Modified:
xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
xfbib/branches/gobject/src/xfbib-menu-bar.c
Log:
Add entry edit functionality
Modified: xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c 2008-09-30 22:10:55 UTC (rev 5494)
+++ xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c 2008-10-01 13:48:15 UTC (rev 5495)
@@ -292,6 +292,7 @@
GtkWidget *
xfbib_entry_edit_dialog_new(XfbibEntry *entry)
{
+ XfbibField *field;
const gchar *bibtype;
int n;
@@ -314,13 +315,20 @@
gtk_entry_set_text(GTK_ENTRY (entry_edit_dialog->key_entry), xfbib_strbuf_get_str(xfbib_entry_get_key(entry)));
+
for (n = 0; n < XFBIB_FIELD_N_FIELDS; n++) {
if (n == XFBIB_FIELD_AUTHOR || n == XFBIB_FIELD_EDITOR) {
+ field = xfbib_entry_get_field_by_column(XFBIB_ENTRY(entry), n);
+ if (field == NULL)
+ continue;
xfbib_multiple_input_set_text (XFBIB_MULTIPLE_INPUT (entry_edit_dialog->inputs[n]),
- xfbib_field_get_value_str(xfbib_entry_get_field_by_column(entry, n)));
+ xfbib_field_get_value_str(field));
} else {
+ field = xfbib_entry_get_field_by_column(XFBIB_ENTRY(entry), n);
+ if (field == NULL)
+ continue;
xfbib_single_input_set_entry_text (XFBIB_SINGLE_INPUT (entry_edit_dialog->inputs[n]),
- xfbib_field_get_value_str(xfbib_entry_get_field_by_column(entry, n)));
+ xfbib_field_get_value_str(field));
}
}
}
Modified: xfbib/branches/gobject/src/xfbib-menu-bar.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-menu-bar.c 2008-09-30 22:10:55 UTC (rev 5494)
+++ xfbib/branches/gobject/src/xfbib-menu-bar.c 2008-10-01 13:48:15 UTC (rev 5495)
@@ -137,6 +137,46 @@
}
static void
+cb_entry_edit_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ XfbibState *state;
+ XfbibEntry *entry;
+ GtkWidget *tree_view, *dialog;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ g_printf("Entry/Edit\n");
+
+ state = xfbib_state_new();
+ tree_view = GTK_WIDGET(xfbib_window_get_tree_view(XFBIB_WINDOW(xfbib_state_get_window(state))));
+
+ /* This will only work in single or browse selection mode! */
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ /*
+ * Get the XfbibEntry pointer and pass it to the
+ * entry edit dialog
+ */
+ path = gtk_tree_model_get_path(model, &iter);
+
+ if ((entry = xfbib_elements_get_nth_entry(xfbib_state_get_bibtex_elements(state),
+ gtk_tree_path_get_indices(path)[0])) == NULL) {
+ xfce_err("Could not find the selected entry to edit");
+ return;
+ }
+ dialog = xfbib_entry_edit_dialog_new(entry);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ /* TODO: Save the entry */
+ }
+ gtk_widget_destroy(dialog);
+ } else {
+ xfce_err("No row has been selected for edit");
+ }
+}
+
+static void
cb_variable_add_activate (GtkMenuItem *menuitem, gpointer user_data)
{
g_printf("Variable/add\n");
@@ -267,7 +307,14 @@
gtk_menu_shell_append(GTK_MENU_SHELL(instance->entry), item);
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (cb_entry_remove_activate), instance);
+
+ /* Edit */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_EDIT, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->entry), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_entry_edit_activate), instance);
+
item = gtk_menu_item_new_with_label("Entry");
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), instance->entry);
gtk_menu_shell_append(GTK_MENU_SHELL(instance), item);
More information about the Goodies-commits
mailing list