Thunar tree-view/shortcuts-view patches
Nikolas Arend
Nikolas.Arend at gmx.net
Sat Mar 3 15:51:29 CET 2007
Nikolas Arend wrote:
> Hi,
>
> attached please find two small patches for thunar-tree-view.c and
> thunar-shortcuts-view.c. They add a "Remove Safely" action to the
> volume action list in the side pane for devices like usb sticks or
> removable media. It also adds the "Unmount Volume" entry in addition
> to "Eject Volume"/"Remove Safely" since I thought they are not exactly
> mutually exclusive.
>
> Maybe I should explain why I find this usable: After mounting and
> later unmounting my mp3 player (a Samsung YP-Z5F) in Thunar, the
> player still showed "Connected" as the USB status. Konqueror had an
> additional option called "Safely Remove", which actually removed the
> device from the tree of listed devices. The player then showed
> "Finishing" (USB connection) and returned to its main menu. With
> Thunar, I had to actually unplug the device to achieve this. Although
> I thought this additional option in konqueror is a good thing, I liked
> Thunar's way of handling devices much better and implemented it using
> Thunar's built-in functions.
> Long story short... that's why I added it.
>
> Cheers, Nick.
>
>
> PS: Maybe FLOPPY Volumes should be excluded from this "Remove Safely"
> option (as check in (thunar_vfs_volume_is_removable()). To be honest,
> I don't exactly know how modern floppy drives work/look like.
>
So, this is considered a bad idea, I take it?
Best, Nick.
> ------------------------------------------------------------------------
>
> --- thunar-shortcuts-view.c_orig 2007-02-20 15:45:34.000000000 +0100
> +++ thunar-shortcuts-view.c 2007-02-20 16:06:56.000000000 +0100
> @@ -834,7 +834,14 @@
> gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
> gtk_widget_show (item);
>
> - /* check if the volume is a disc */
> + /* append the "Unmount Volume" menu item */
> + item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount Volume"));
> + gtk_widget_set_sensitive (item, thunar_vfs_volume_is_mounted (volume));
> + g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_unmount), view);
> + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
> + gtk_widget_show (item);
> +
> + /* check if the volume is ejectable/removable */
> if (thunar_vfs_volume_is_disc (volume))
> {
> /* append the "Eject Volume" menu action */
> @@ -843,16 +850,17 @@
> gtk_widget_set_sensitive (item, thunar_vfs_volume_is_ejectable (volume));
> gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
> gtk_widget_show (item);
> - }
> - else
> +
> + }
> + else if (thunar_vfs_volume_is_removable (volume))
> {
> - /* append the "Unmount Volume" menu item */
> - item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount Volume"));
> - gtk_widget_set_sensitive (item, thunar_vfs_volume_is_mounted (volume));
> - g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_unmount), view);
> + /* append the "Remove Safely" menu action */
> + item = gtk_image_menu_item_new_with_mnemonic (_("Remove _Safely"));
> + g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_eject), view);
> + gtk_widget_set_sensitive (item, thunar_vfs_volume_is_ejectable (volume));
> gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
> gtk_widget_show (item);
> - }
> + }
>
> /* append a menu separator */
> item = gtk_separator_menu_item_new ();
>
> ------------------------------------------------------------------------
>
> --- thunar-tree-view.c_orig 2007-02-20 15:45:24.000000000 +0100
> +++ thunar-tree-view.c 2007-02-20 16:07:57.000000000 +0100
> @@ -1040,8 +1040,15 @@
> g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_mount), view);
> gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
> gtk_widget_show (item);
> +
> + /* append the "Unmount Volume" menu item */
> + item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount Volume"));
> + gtk_widget_set_sensitive (item, thunar_vfs_volume_is_mounted (volume));
> + g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_unmount), view);
> + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
> + gtk_widget_show (item);
>
> - /* check if the volume is a disc */
> + /* check if the volume is ejectable/removable */
> if (thunar_vfs_volume_is_disc (volume))
> {
> /* append the "Eject Volume" menu action */
> @@ -1050,16 +1057,17 @@
> gtk_widget_set_sensitive (item, thunar_vfs_volume_is_ejectable (volume));
> gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
> gtk_widget_show (item);
> - }
> - else
> +
> + }
> + else if (thunar_vfs_volume_is_removable (volume))
> {
> - /* append the "Unmount Volume" menu item */
> - item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount Volume"));
> - gtk_widget_set_sensitive (item, thunar_vfs_volume_is_mounted (volume));
> - g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_unmount), view);
> + /* append the "Remove Safely" menu action */
> + item = gtk_image_menu_item_new_with_mnemonic (_("Remove _Safely"));
> + g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_eject), view);
> + gtk_widget_set_sensitive (item, thunar_vfs_volume_is_ejectable (volume));
> gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
> gtk_widget_show (item);
> - }
> + }
>
> /* append a menu separator */
> item = gtk_separator_menu_item_new ();
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at xfce.org
> http://foo-projects.org/mailman/listinfo/xfce4-dev
More information about the Xfce4-dev
mailing list