diff options
author | Andy Hertzfeld <andy@src.gnome.org> | 2001-04-06 07:43:14 +0000 |
---|---|---|
committer | Andy Hertzfeld <andy@src.gnome.org> | 2001-04-06 07:43:14 +0000 |
commit | 0d2f6814d519e8e835284c50ff983c05601cd72c (patch) | |
tree | 3f33ca23d861be235713834a492954d9977abdcb | |
parent | 2ec8285e2aa9d986b89357ce0112fdd7ba7e11be (diff) | |
download | nautilus-0d2f6814d519e8e835284c50ff983c05601cd72c.tar.gz |
started implementation of optionally sending annotations to the server.
started implementation of optionally sending annotations to the
server. Also, put up error when the user tries to annotate
a directory
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-annotation.c | 12 | ||||
-rw-r--r-- | libnautilus-private/nautilus-annotation.c | 12 | ||||
-rw-r--r-- | src/file-manager/fm-annotation-window.c | 61 |
4 files changed, 88 insertions, 13 deletions
@@ -1,3 +1,19 @@ +2001-04-06 Andy Hertzfeld <andy@eazel.com> + + started implementation of optionally sending annotations to the + server. Also, put up error when the user tries to annotate + a directory + + * libnautilus-extensions/nautilus-annotation.c: + (nautilus_annotation_send_to_server), + (nautilus_annotation_add_annotation): + + * src/file-manager/fm-annotation-window.c: + (fm_annotation_window_initialize), (real_destroy), + (set_access_mode), (add_access_menu_item), (create_options_table), + (annotation_clicked_callback), (create_annotation_window), + (fm_annotation_window_present): + 2001-04-05 Andy Hertzfeld <andy@eazel.com> merged with HEAD to create the post-1_0_10 branch diff --git a/libnautilus-extensions/nautilus-annotation.c b/libnautilus-extensions/nautilus-annotation.c index 211330659..cb6f993dc 100644 --- a/libnautilus-extensions/nautilus-annotation.c +++ b/libnautilus-extensions/nautilus-annotation.c @@ -1035,6 +1035,13 @@ int nautilus_annotation_has_annotation (NautilusFile *file) return 0; } +/* send the local annotations associated with the passed-in digest to the server */ +static void +nautilus_annotation_send_to_server (const char *digest) +{ + g_message ("sending annotations for %s to server", digest); +} + /* add an annotation to a file */ void nautilus_annotation_add_annotation (NautilusFile *file, const char *annotation_type, @@ -1138,7 +1145,10 @@ void nautilus_annotation_add_annotation (NautilusFile *file, nautilus_file_emit_changed (file); /* if the access is global, send it to the server */ - + if (eel_strcmp (access, "global") == 0) { + nautilus_annotation_send_to_server (digest); + } + /* clean up and we're done */ xmlFreeDoc (xml_document); g_free (digest); diff --git a/libnautilus-private/nautilus-annotation.c b/libnautilus-private/nautilus-annotation.c index 211330659..cb6f993dc 100644 --- a/libnautilus-private/nautilus-annotation.c +++ b/libnautilus-private/nautilus-annotation.c @@ -1035,6 +1035,13 @@ int nautilus_annotation_has_annotation (NautilusFile *file) return 0; } +/* send the local annotations associated with the passed-in digest to the server */ +static void +nautilus_annotation_send_to_server (const char *digest) +{ + g_message ("sending annotations for %s to server", digest); +} + /* add an annotation to a file */ void nautilus_annotation_add_annotation (NautilusFile *file, const char *annotation_type, @@ -1138,7 +1145,10 @@ void nautilus_annotation_add_annotation (NautilusFile *file, nautilus_file_emit_changed (file); /* if the access is global, send it to the server */ - + if (eel_strcmp (access, "global") == 0) { + nautilus_annotation_send_to_server (digest); + } + /* clean up and we're done */ xmlFreeDoc (xml_document); g_free (digest); diff --git a/src/file-manager/fm-annotation-window.c b/src/file-manager/fm-annotation-window.c index 867fc5ab2..022cbb0c4 100644 --- a/src/file-manager/fm-annotation-window.c +++ b/src/file-manager/fm-annotation-window.c @@ -75,6 +75,7 @@ struct FMAnnotationWindowDetails { GtkWidget *file_icon; GtkLabel *file_title; GtkWidget *text_field; + char *access_mode; }; @@ -101,6 +102,9 @@ fm_annotation_window_initialize (FMAnnotationWindow *window) { window->details = g_new0 (FMAnnotationWindowDetails, 1); window->details->file = NULL; + + /* default to local access only */ + window->details->access_mode = g_strdup ("local"); } static void @@ -112,6 +116,7 @@ real_destroy (GtkObject *object) nautilus_file_unref (window->details->file); + g_free (window->details->access_mode); g_free (window->details); EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); @@ -194,6 +199,39 @@ update_annotation_window_title (GtkWindow *window, NautilusFile *file) g_free (title); } +/* callback for access menu items */ +static void +set_access_mode (GtkWidget *menu_item, const char* access_mode) +{ + FMAnnotationWindow *window; + window = FM_ANNOTATION_WINDOW (gtk_object_get_user_data (GTK_OBJECT (menu_item))); + g_free (window->details->access_mode); + window->details->access_mode = g_strdup (access_mode); +} + +/* utility to create and append an access menu item */ +static void +add_access_menu_item (FMAnnotationWindow *window, GtkWidget *access_menu, const char *menu_label, const char *id) +{ + GtkWidget *menu_item; + + menu_item = gtk_menu_item_new_with_label (menu_label); + gtk_widget_show (menu_item); + gtk_menu_append (GTK_MENU (access_menu), menu_item); + + gtk_object_set_user_data (GTK_OBJECT (menu_item), window); + + gtk_signal_connect_full (GTK_OBJECT (menu_item), + "activate", + GTK_SIGNAL_FUNC (set_access_mode), + NULL, + g_strdup (id), + g_free, + FALSE, + FALSE); + +} + /* create the option table for the annotation window */ static GtkWidget * create_options_table (FMAnnotationWindow *window) @@ -236,15 +274,12 @@ create_options_table (FMAnnotationWindow *window) gtk_table_attach(GTK_TABLE(table), access_menu_vbox, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 4, 4); new_menu = gtk_menu_new (); - menu_item = gtk_menu_item_new_with_label (_("keep local")); gtk_widget_show (new_menu); - gtk_widget_show (menu_item); - gtk_menu_append (GTK_MENU (new_menu), menu_item); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), new_menu); - menu_item = gtk_menu_item_new_with_label (_("share globally")); - gtk_menu_append (GTK_MENU (new_menu), menu_item); + add_access_menu_item (window, new_menu, _("local only"), "local"); + gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), new_menu); + add_access_menu_item (window, new_menu, _("share globally"), "global"); return table; } @@ -259,12 +294,11 @@ annotation_clicked_callback (GtkWidget *dialog, int which_button, gpointer user_ if (which_button == GNOME_OK) { notes_text = gtk_editable_get_chars (GTK_EDITABLE (window->details->text_field), 0 , -1); - - /* type and access fields hard-wired for now */ + /* type field is hard-wired for now */ nautilus_annotation_add_annotation (window->details->file, "text", notes_text, - "local"); + window->details->access_mode); g_free (notes_text); } gtk_widget_destroy (dialog); @@ -290,11 +324,11 @@ create_annotation_window (NautilusFile *file, FMDirectoryView *directory_view) gtk_container_set_border_width (GTK_CONTAINER (window), GNOME_PAD); gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE); - gnome_dialog_set_default( GNOME_DIALOG (window), GNOME_OK); gtk_window_set_wmclass (GTK_WINDOW (window), "file_annotation", "Nautilus"); /* add the buttons */ gnome_dialog_append_buttons (GNOME_DIALOG (window), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); + gnome_dialog_set_default( GNOME_DIALOG (window), GNOME_OK); gtk_signal_connect (GTK_OBJECT (window), "clicked", (GtkSignalFunc) annotation_clicked_callback, NULL); @@ -355,7 +389,12 @@ fm_annotation_window_present (NautilusFile *file, FMDirectoryView *directory_vie { g_return_if_fail (NAUTILUS_IS_FILE (file)); g_return_if_fail (FM_IS_DIRECTORY_VIEW (directory_view)); - + + if (nautilus_file_is_directory (file)) { + eel_show_error_dialog (_("Sorry, but you currently can't add an annotation to a directory."), _("Can't annotate directory"), NULL); + return; + } + create_annotation_window (file, directory_view); } |