Re: [Nautilus-list] [patch] - hierarchical script menus - done?
- From: Seth Nickell <snickell stanford edu>
- To: David Emory Watson <dwatson cs ucr edu>
- Cc: Darin Adler <darin bentspoon com>, nautilus-list lists eazel com
- Subject: Re: [Nautilus-list] [patch] - hierarchical script menus - done?
- Date: 03 Jun 2001 00:20:29 -0700
Can you please send unified diffs? (cvs diff -up is the preferred
command, it also tags on function names).
-Seth
On 02 Jun 2001 23:52:51 -0700, David Emory Watson wrote:
>
> I would be intrestd in hearing comments, especially from testers...
>
> On 28 May 2001 14:02:36 -0700, Darin Adler wrote:
> > > There are a few for loops, as well as an if statement in
> > > call_when_ready_on_scripts_directory which depend on this. I am using
> > > this value to determine whether or not the scripts directory was
> > > found/created.
> >
> > All details fields start as NULL (0, whatever). Setting it to NULL again
> > seems unnecessary to me, but I guess it's OK.
> OK I removed this line. :)
>
>
> --=-AJ5Ff78vYZ4zjcYzLenI
> 25,26c25,27
> < * Darin Adler <darin eazel com>
> < * Pavel Cisler <pavel eazel com>
> ---
> > * Darin Adler <darin eazel com>,
> > * Pavel Cisler <pavel eazel com>,
> > * David Emory Watson <dwatson cs ucr edu>
> 137a139,140
> > #define MAX_MENU_LEVELS 5
> >
> 169,171c172,181
> < NautilusDirectory *scripts_directory;
> < guint scripts_added_handler_id;
> < guint scripts_changed_handler_id;
> ---
> > /* The first link in this list is reserved for the top level scripts
> > * directory. This means that new links are always appended to the
> > * list. In addition, lower level script directories must always occur
> > * after higher level ones so if you remove a directory, you must remove
> > * its subdirectories as well. This is done to preserve the ordering of
> > * the callbacks when we rebuild the script menus.
> > */
> > GList *scripts_directory_list;
> > GList *scripts_uri_list;
> > guint scripts_directory_length;
> 290c300,302
> < static void disconnect_script_handlers (FMDirectoryView *view);
> ---
> > static void disconnect_scripts_directory_list (FMDirectoryView *view);
> > static void disconnect_scripts_directory (FMDirectoryView *view,
> > NautilusDirectory *directory);
> 1141,1142c1153,1154
> < GList *files,
> < gpointer callback_data)
> ---
> > GList *files,
> > gpointer callback_data)
> 1148c1160
> < g_assert (directory == view->details->scripts_directory);
> ---
> > g_assert (g_list_find (view->details->scripts_directory_list, directory) != NULL);
> 1155c1167,1168
> < connect_script_handlers (FMDirectoryView *view)
> ---
> > connect_script_handlers (FMDirectoryView *view,
> > NautilusDirectory *directory)
> 1157,1159c1170
> < if (view->details->scripts_directory == NULL) {
> < return;
> < }
> ---
> > g_assert(directory != NULL);
> 1161,1162c1172
> < nautilus_directory_file_monitor_add (view->details->scripts_directory,
> < &view->details->scripts_directory,
> ---
> > nautilus_directory_file_monitor_add (directory, &view->details->scripts_directory_list,
> 1165,1169c1175,1178
> < view->details->scripts_added_handler_id = gtk_signal_connect
> < (GTK_OBJECT (view->details->scripts_directory),
> < "files_added",
> < scripts_added_or_changed_callback,
> < view);
> ---
> > gtk_signal_connect (GTK_OBJECT (directory),
> > "files_added",
> > scripts_added_or_changed_callback,
> > view);
> 1171,1175c1180,1183
> < view->details->scripts_changed_handler_id = gtk_signal_connect
> < (GTK_OBJECT (view->details->scripts_directory),
> < "files_changed",
> < scripts_added_or_changed_callback,
> < view);
> ---
> > gtk_signal_connect (GTK_OBJECT (directory),
> > "files_changed",
> > scripts_added_or_changed_callback,
> > view);
> 1180a1189,1191
> > NautilusDirectory *scripts_directory;
> > char *scripts_directory_uri;
> >
> 1199,1200c1210,1222
> < view->details->scripts_directory = get_scripts_directory ();
> < connect_script_handlers (view);
> ---
> > scripts_directory = get_scripts_directory ();
> >
> > if (scripts_directory != NULL) {
> > view->details->scripts_directory_list = g_list_append (view->details->scripts_directory_list,
> > scripts_directory);
> >
> > scripts_directory_uri = nautilus_directory_get_uri (scripts_directory);
> > view->details->scripts_uri_list = g_list_append (view->details->scripts_uri_list,
> > scripts_directory_uri);
> > view->details->scripts_directory_length = strlen (scripts_directory_uri);
> >
> > connect_script_handlers (view, scripts_directory);
> > }
> 1299a1322
> > GList *node1, *node2;
> 1317,1318c1340,1350
> < disconnect_script_handlers (view);
> < nautilus_directory_unref (view->details->scripts_directory);
> ---
> > disconnect_scripts_directory_list (view);
> >
> > for (node1 = view->details->scripts_directory_list, node2 = view->details->scripts_uri_list;
> > node1 != NULL;
> > node1 = node1->next, node2 = node2->next) {
> > nautilus_directory_unref (node1->data);
> > g_free (node2->data);
> > }
> >
> > g_list_free(view->details->scripts_directory_list);
> > g_list_free(view->details->scripts_uri_list);
> 3179c3211,3228
> < }
> ---
> > }
> >
> > /* FIXME: Allow the icon to be set. */
> > static void
> > add_menu (BonoboUIComponent *ui,
> > const char *parent_path,
> > const char *label)
> > {
> > char *escaped_label;
> >
> > escaped_label = eel_str_double_underscores (label);
> >
> > nautilus_bonobo_add_submenu (ui,
> > parent_path,
> > escaped_label);
> >
> > g_free (escaped_label);
> > }
> 3524c3573
> < }
> ---
> > }
> 3527,3529c3576,3580
> < add_script_to_menus (FMDirectoryView *directory_view,
> < NautilusFile *file,
> < int index)
> ---
> > add_script_to_script_menus (FMDirectoryView *directory_view,
> > NautilusFile *file,
> > int index,
> > const char *menu_path,
> > const char *popup_path)
> 3538c3589
> <
> ---
> >
> 3543,3544c3594,3595
> < add_numbered_menu_item (directory_view->details->ui,
> < FM_DIRECTORY_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER,
> ---
> > add_numbered_menu_item (directory_view->details->ui,
> > menu_path,
> 3556,3557c3607,3608
> < add_numbered_menu_item (directory_view->details->ui,
> < FM_DIRECTORY_VIEW_POPUP_PATH_SCRIPTS_PLACEHOLDER,
> ---
> > add_numbered_menu_item (directory_view->details->ui,
> > popup_path,
> 3571a3623,3740
> > add_menu_to_script_menus (FMDirectoryView *directory_view,
> > NautilusFile *file,
> > const char *menu_path,
> > const char *popup_path)
> > {
> > ScriptLaunchParameters *launch_parameters;
> > char *tip;
> > char *name;
> > GdkPixbuf *pixbuf;
> >
> > name = nautilus_file_get_name (file);
> > tip = g_strdup_printf (_("Run \"%s\" on any selected items"), name);
> >
> > launch_parameters = script_launch_parameters_new (file, directory_view);
> > pixbuf = nautilus_icon_factory_get_pixbuf_for_file
> > (file, NULL, NAUTILUS_ICON_SIZE_FOR_MENUS, TRUE);
> >
> > add_menu (directory_view->details->ui,
> > menu_path,
> > name);
> >
> > add_menu (directory_view->details->ui,
> > popup_path,
> > name);
> >
> > gdk_pixbuf_unref (pixbuf);
> > g_free (name);
> > g_free (tip);
> > }
> >
> > static gboolean
> > add_directory_to_scripts_directory_list (FMDirectoryView *view, NautilusFile *file)
> > {
> > char *uri;
> > NautilusDirectory *directory;
> > int num_levels;
> > int i;
> >
> > uri = nautilus_file_get_uri (file);
> >
> > num_levels = 0;
> > for (i = view->details->scripts_directory_length; uri[i] != '\0'; i++) {
> > if (uri[i] == '/') {
> > num_levels++;
> > }
> > }
> >
> > if (num_levels > MAX_MENU_LEVELS) {
> > g_free (uri);
> > return FALSE;
> > }
> >
> > directory = nautilus_directory_get (uri);
> >
> > if (g_list_find(view->details->scripts_directory_list, directory) == NULL) {
> > connect_script_handlers(view, directory);
> >
> > view->details->scripts_directory_list = g_list_append (view->details->scripts_directory_list,
> > directory);
> > view->details->scripts_uri_list = g_list_append (view->details->scripts_uri_list,
> > uri);
> > } else {
> > nautilus_directory_unref(directory);
> > g_free (uri);
> > }
> >
> > return TRUE;
> > }
> >
> > /**
> > * clean_scripts_directory_list
> > *
> > * Verify that a given directory has not changed. If it has, remove references to
> > * it from both scripts_directory_list and scripts_uri_list.
> > * @view: FMDirectoryView of interest.
> > * @directory: The directory that we are verifying.
> > *
> > * Return value: True if the directory was removed, false otherwise.
> > *
> > **/
> > static gboolean
> > clean_scripts_directory_list (FMDirectoryView *view, NautilusDirectory *directory)
> > {
> > GList *node1, *node2;
> > char *uri;
> >
> > uri = nautilus_directory_get_uri (directory);
> >
> > for (node1 = view->details->scripts_directory_list, node2 = view->details->scripts_uri_list;
> > node1 != NULL;
> > node1 = node1->next, node2 = node2->next) {
> > if (directory == node1->data) {
> > if (strcmp(uri, node2->data) == 0) {
> > g_free (uri);
> > return FALSE;
> > } else {
> > view->details->scripts_directory_list = g_list_remove_link (view->details->scripts_directory_list, node1);
> > view->details->scripts_uri_list = g_list_remove_link (view->details->scripts_uri_list, node2);
> >
> > disconnect_scripts_directory (view, node1->data);
> > nautilus_directory_unref (node1->data);
> > g_free (node2->data);
> >
> > g_list_free (node1);
> > g_list_free (node2);
> >
> > g_free (uri);
> > return TRUE;
> > }
> > }
> > }
> >
> > /* This should never happen. */
> > g_free (uri);
> > return TRUE;
> > }
> >
> > static void
> 3578,3582c3747,3769
> <
> < nautilus_bonobo_remove_menu_items_and_commands
> < (view->details->ui, FM_DIRECTORY_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER);
> < nautilus_bonobo_remove_menu_items_and_commands
> < (view->details->ui, FM_DIRECTORY_VIEW_POPUP_PATH_SCRIPTS_PLACEHOLDER);
> ---
> > char *parent_path;
> > char *menu_path, *popup_path;
> >
> > if (all_files == NULL) {
> > view->details->scripts_invalid = FALSE;
> > return;
> > }
> >
> > parent_path = nautilus_file_get_parent_uri (all_files->data);
> >
> > menu_path = g_strdup_printf ("%s%s", FM_DIRECTORY_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER,
> > parent_path + view->details->scripts_directory_length);
> > popup_path = g_strdup_printf ("%s%s", FM_DIRECTORY_VIEW_POPUP_PATH_SCRIPTS_PLACEHOLDER,
> > parent_path + view->details->scripts_directory_length);
> >
> > /* We rebuild the entire scripts menu each time so we only need to remove the
> > top level menu since it contains all other menus and is rebuilt first. */
> > if (strcmp(parent_path, view->details->scripts_uri_list->data) == 0) {
> > nautilus_bonobo_remove_menu_items_and_commands (view->details->ui, menu_path);
> > nautilus_bonobo_remove_menu_items_and_commands (view->details->ui, popup_path);
> > }
> >
> > g_free (parent_path);
> 3591c3778
> < add_script_to_menus (view, file, index);
> ---
> > add_script_to_script_menus (view, file, index, menu_path, popup_path);
> 3592a3780,3784
> > } else if (nautilus_file_is_directory (file)) {
> > if (add_directory_to_scripts_directory_list (view, file)) {
> > add_menu_to_script_menus (view, file, menu_path, popup_path);
> > any_scripts = TRUE;
> > }
> 3595a3788,3790
> > g_free (popup_path);
> > g_free (menu_path);
> >
> 3616c3811
> < g_assert (view->details->scripts_directory == directory);
> ---
> > g_assert (g_list_find (view->details->scripts_directory_list, directory) != NULL);
> 3625a3821
> > GList *node, *next_node;
> 3627c3823
> < if (view->details->scripts_directory == NULL) {
> ---
> > if (view->details->scripts_directory_list == NULL) {
> 3631,3633c3827,3831
> < nautilus_directory_cancel_callback (view->details->scripts_directory,
> < scripts_directory_callback,
> < view);
> ---
> > for (node = view->details->scripts_directory_list; node != NULL; node = node->next) {
> > nautilus_directory_cancel_callback (node->data,
> > scripts_directory_callback,
> > view);
> > }
> 3639,3642c3837,3854
> < nautilus_directory_call_when_ready (view->details->scripts_directory,
> < attributes,
> < scripts_directory_callback,
> < view);
> ---
> >
> > node = view->details->scripts_directory_list;
> > while (node != NULL) {
> >
> > /* It is important that we remember the next link in the list because
> > clean_scripts_directory_list() may remove links from underneath us. */
> > next_node = node->next;
> >
> > if (!clean_scripts_directory_list (view, node->data)) {
> > nautilus_directory_call_when_ready (node->data,
> > attributes,
> > scripts_directory_callback,
> > view);
> > }
> >
> > node = next_node;
> > }
> >
> 3662,3663c3874,3875
> < if (view->details->scripts_directory != NULL) {
> < uri = nautilus_directory_get_uri (view->details->scripts_directory);
> ---
> > if (view->details->scripts_directory_list != NULL) {
> > uri = nautilus_directory_get_uri (view->details->scripts_directory_list->data);
> 4895c5107
> < disconnect_scripts_directory_handler (FMDirectoryView *view, int *id)
> ---
> > disconnect_scripts_directory (FMDirectoryView *view, NautilusDirectory *directory)
> 4897c5109,5117
> < disconnect_handler (GTK_OBJECT (view->details->scripts_directory), id);
> ---
> > gtk_signal_disconnect_by_func (GTK_OBJECT (directory),
> > scripts_added_or_changed_callback,
> > view);
> >
> > nautilus_directory_file_monitor_remove (directory, &view->details->scripts_directory_list);
> >
> > nautilus_directory_cancel_callback (directory,
> > reset_scripts_menu_callback,
> > view);
> 4930c5150
> < disconnect_script_handlers (FMDirectoryView *view)
> ---
> > disconnect_scripts_directory_list (FMDirectoryView *view)
> 4932,4940c5152
> < if (view->details->scripts_directory == NULL) {
> < return;
> < }
> <
> < disconnect_scripts_directory_handler (view, &view->details->scripts_added_handler_id);
> < disconnect_scripts_directory_handler (view, &view->details->scripts_changed_handler_id);
> <
> < nautilus_directory_file_monitor_remove (view->details->scripts_directory,
> < &view->details->scripts_directory);
> ---
> > GList *node;
> 4942,4944c5154,5156
> < nautilus_directory_cancel_callback (view->details->scripts_directory,
> < reset_scripts_menu_callback,
> < view);
> ---
> > for (node = view->details->scripts_directory_list; node != NULL; node = node->next) {
> > disconnect_scripts_directory (view, node->data);
> > }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]