Пример #1
0
static GList *
nautilus_nste_get_file_items (NautilusMenuProvider *provider,
                              GtkWidget            *window,
                              GList                *files)
{
    GList *items = NULL;
    gboolean one_item;
    NautilusMenuItem *item;
    NautilusNste *nste;

    nste = NAUTILUS_NSTE (provider);
    if (!nste->nst_present)
    {
        return NULL;
    }

    if (files == NULL)
    {
        return NULL;
    }

    if (!check_available_mailer ())
    {
        return NULL;
    }

    one_item = (files != NULL) && (files->next == NULL);
    if (one_item &&
        !nautilus_file_info_is_directory ((NautilusFileInfo *) files->data))
    {
        item = nautilus_menu_item_new ("NautilusNste::sendto",
                                       _("Send to…"),
                                       _("Send file by mail…"),
                                       "document-send");
    }
    else
    {
        item = nautilus_menu_item_new ("NautilusNste::sendto",
                                       _("Send to…"),
                                       _("Send files by mail…"),
                                       "document-send");
    }
    g_signal_connect (item,
                      "activate",
                      G_CALLBACK (sendto_callback),
                      provider);
    g_object_set_data_full (G_OBJECT (item),
                            "files",
                            nautilus_file_info_list_copy (files),
                            (GDestroyNotify) nautilus_file_info_list_free);

    items = g_list_append (items, item);

    return items;
}
Пример #2
0
static GList* relax_plugin_get_background_items(NautilusMenuProvider* provider,
                                              GtkWidget *window,
                                              NautilusFileInfo* current_folder)
{
    NautilusMenu *sub_menu;

    NautilusMenuItem *item;
    NautilusMenuItem *add_item;
    NautilusMenuItem *refresh_item;
    NautilusMenuItem *refresh_folder_item;

    GList* ret_val = NULL;
    GFile* a_file;

    add_item = nautilus_menu_item_new("RelaxPlugin::add",
                           "add folder to relax",
                           "adds the current folder as a folder to be monitored on relax",
                           NULL);

    g_signal_connect (add_item, "activate", add_to_relax_callback, provider);

    a_file = nautilus_file_info_get_location(current_folder);
    g_object_set_data(G_OBJECT(add_item), "folder", (gpointer)g_file_get_path(a_file));

    refresh_item = nautilus_menu_item_new("RelaxPlugin::refresh",
                                          "refresh relax",
                                          "refreshes Relax! app",
                                          NULL);
    g_signal_connect (refresh_item, "activate", refresh_relax_callback, provider);

    refresh_folder_item = nautilus_menu_item_new("RelaxPlugin::refresh-folder",
                                      "refresh current folder",
                                      "refreshes the current folder without adding it to relax",
                                      NULL);

    g_signal_connect (refresh_folder_item, "activate", refresh_current_folder_callback, provider);
    GFile* s_file = nautilus_file_info_get_location(current_folder);
    g_object_set_data(G_OBJECT(refresh_folder_item), "folder", (gpointer)g_file_get_path(s_file));

    sub_menu = nautilus_menu_new();
    nautilus_menu_append_item(sub_menu, add_item);
    nautilus_menu_append_item(sub_menu, refresh_item);
    nautilus_menu_append_item(sub_menu, refresh_folder_item);

    item = nautilus_menu_item_new("Relax::Plugin",
                                  "relax-file-manager",
                                  "show operations to be done on relax",
                                  NULL);

    nautilus_menu_item_set_submenu(item, sub_menu);

    ret_val = g_list_append(ret_val, item);

    return ret_val;
}
Пример #3
0
static GList *
deja_dup_nautilus_extension_get_background_items(NautilusMenuProvider *provider,
                                                 GtkWidget *window,
                                                 NautilusFileInfo *file)
{
  NautilusMenuItem *item;
  guint length;
  GList *file_copies;
  gchar *path;

  if (file == NULL)
    return NULL;

  path = g_find_program_in_path("deja-dup");
  if (!path)
    return NULL;
  g_free(path);

  if (!is_dir_included(nautilus_file_info_get_location(file)))
    return NULL;

  item = nautilus_menu_item_new("DejaDupNautilusExtension::restore_missing_item",
                                dgettext(GETTEXT_PACKAGE, "Restore Missing Files…"),
                                dgettext(GETTEXT_PACKAGE, "Restore deleted files from backup"),
                                "deja-dup");

  g_signal_connect(item, "activate", G_CALLBACK(restore_missing_files_callback), NULL);
  g_object_set_data_full (G_OBJECT(item), "deja_dup_extension_file",
                          g_object_ref(file),
                          (GDestroyNotify)g_object_unref);

  return g_list_append(NULL, item);
}
Пример #4
0
static GList *
nautilus_disc_burn_get_background_items (NautilusMenuProvider *provider,
                                         GtkWidget            *window,
                                         NautilusFileInfo     *current_folder)
{
        GList *items;
        char  *scheme;

        items = NULL;

        scheme = nautilus_file_info_get_uri_scheme (current_folder);

        if (strcmp (scheme, "burn") == 0) {
                NautilusMenuItem *item;

                item = nautilus_menu_item_new ("NautilusDiscBurn::write_menu",
                                               _("_Write to Disc…"),
                                               _("Write contents to a CD or DVD"),
                                               "brasero");
		g_object_set_data (G_OBJECT (item), WINDOW_KEY, window);
                g_signal_connect (item, "activate",
                                  G_CALLBACK (write_activate_cb),
                                  NAUTILUS_DISC_BURN (provider));
                items = g_list_append (items, item);

                g_object_set (item, "sensitive", ! NAUTILUS_DISC_BURN (provider)->priv->empty, NULL);
        }

        g_free (scheme);

        return items;
}
Пример #5
0
static NautilusMenuItem *
create_fill_menu_item (NautilusMenuProvider *provider,
                       const gchar          *item_name,
                       GtkWidget            *window,
                       GList                *files)
{
  NautilusMenuItem *item        = NULL;
  GList            *mountpoints = NULL;
  GList            *folders     = NULL;
  GError           *err         = NULL;
  
  if (! nw_fill_operation_filter_files (files, &folders, &mountpoints, &err)) {
    g_warning (_("File filtering failed: %s"), err->message);
    g_error_free (err);
  } else {
    item = nautilus_menu_item_new (item_name,
                                   _("Wipe available diskspace"),
                                   _("Overwrite available diskspace in this device(s)"),
                                   GTK_STOCK_CLEAR);
    g_object_set_data (G_OBJECT (item), ITEM_DATA_WINDOW_KEY, window);
    g_object_set_data_full (G_OBJECT (item), ITEM_DATA_PATHS_KEY,
                            folders,
                            (GDestroyNotify) nw_path_list_free);
    g_object_set_data_full (G_OBJECT (item), ITEM_DATA_MOUNTPOINTS_KEY,
                            mountpoints,
                            (GDestroyNotify) nw_path_list_free);
    g_signal_connect (item, "activate",
                      G_CALLBACK (fill_menu_item_activate_handler), NULL);
  }
  
  return item;
}
static NautilusMenuItem *nautilus_makepkg_menu_item_new (NautilusMakepkg *self, GtkWidget *window, const gchar *path) {
	NautilusMenuItem *item = nautilus_menu_item_new ("makepkg", _("_Make Package"), _("Build a package from this PKGBUILD"), "gnome-terminal");

	MenuItemActivateData *data = g_new0 (MenuItemActivateData, 1);
	data->self = g_object_ref (self);
	data->screen = g_object_ref (gtk_widget_get_screen (window));
	data->path = g_strdup (path);

	g_signal_connect_data (item, "activate", G_CALLBACK (nautilus_makepkg_menu_item_activate_cb), data, menu_item_activate_data_free, 0);

	return item;
}
Пример #7
0
static GList *
deja_dup_nautilus_extension_get_file_items(NautilusMenuProvider *provider,
                                           GtkWidget *window,
                                           GList *files)
{
  NautilusMenuItem *item;
  guint length;
  GList *file_copies;
  gchar *path;

  if (files == NULL)
    return NULL;

  path = g_find_program_in_path("deja-dup");
  if (!path)
    return NULL;
  g_free(path);

  gboolean is_one_included = FALSE;
  GList *p;
  for (p = files; p; p = p->next) {
    GFile *gfile = nautilus_file_info_get_location((NautilusFileInfo *)p->data);
    if (is_dir_included(gfile))
      is_one_included = TRUE;
  }
  if (!is_one_included)
    return NULL;

  length = g_list_length(files);
  item = nautilus_menu_item_new("DejaDupNautilusExtension::restore_item",
                                dngettext(GETTEXT_PACKAGE,
                                          "Revert to Previous Version…",
                                          "Revert to Previous Versions…",
                                          length),
                                dngettext(GETTEXT_PACKAGE,
                                          "Restore file from backup",
                                          "Restore files from backup",
                                          length),
                                "deja-dup");

  g_signal_connect(item, "activate", G_CALLBACK(restore_files_callback), NULL);
  g_object_set_data_full (G_OBJECT(item), "deja_dup_extension_files", 
                          nautilus_file_info_list_copy(files),
                          (GDestroyNotify)nautilus_file_info_list_free);

  return g_list_append(NULL, item);
}
static GList*
get_file_items (NautilusMenuProvider *provider,
		GtkWidget            *window,
		GList                *files)
{
  NautilusShares *shares;
  gboolean one_item, is_local, is_dir;
  NautilusFileInfo *info;
  NautilusMenuItem *menu_item;
  GList            *items = NULL;

  shares = NAUTILUS_SHARES (provider);
  one_item = (files && !files->next);

  if (!one_item)
    return NULL;
  
  info = files->data;
  is_dir = nautilus_file_info_is_directory (info);

  if (!is_dir)
    return NULL;

  is_local = is_directory_local (info);

  if (!is_local)
    return NULL;

  menu_item = nautilus_menu_item_new ("NautilusShares::share",
				      _("_Share Folder..."),
				      _("Share this folder with other computers"),
				      "gnome-fs-share");

  /* do not allow running more than one instance from nautilus at the same time */
  g_object_set (menu_item, "sensitive", (shares->pid == 0), NULL);
  g_signal_connect (G_OBJECT (menu_item),
		    "activate",
		    G_CALLBACK (on_menu_item_activate), NULL);

  g_object_set_data (G_OBJECT (menu_item), "file", info);
  g_object_set_data (G_OBJECT (menu_item), "shares", provider);

  return g_list_append (NULL, menu_item);
}
Пример #9
0
static NautilusMenuItem *
create_wipe_menu_item (NautilusMenuProvider *provider,
                       const gchar          *item_name,
                       GtkWidget            *window,
                       GList                *paths)
{
  NautilusMenuItem *item;
  
  item = nautilus_menu_item_new (item_name,
                                 _("Wipe"),
                                 _("Delete each selected item and overwrite its data"),
                                 GTK_STOCK_DELETE);
  g_object_set_data (G_OBJECT (item), ITEM_DATA_WINDOW_KEY, window);
  g_object_set_data_full (G_OBJECT (item), ITEM_DATA_PATHS_KEY,
                          nw_path_list_copy (paths),
                          (GDestroyNotify) nw_path_list_free);
  g_signal_connect (item, "activate",
                    G_CALLBACK (wipe_menu_item_activate_handler), NULL);
  
  return item;
}
static GList *
nautilus_fr_get_file_items (NautilusMenuProvider *provider,
			    GtkWidget            *window,
			    GList                *files)
{
	GList    *items = NULL;
	GList    *scan;
	gboolean  can_write = TRUE;
	gboolean  one_item;
	gboolean  one_archive = FALSE;
	gboolean  one_derived_archive = FALSE;
	gboolean  one_compressed_archive = FALSE;
	gboolean  all_archives = TRUE;
	gboolean  all_archives_derived = TRUE;
	gboolean  all_archives_compressed = TRUE;

	if (files == NULL)
		return NULL;

	if (unsupported_scheme ((NautilusFileInfo *) files->data))
		return NULL;

	for (scan = files; scan; scan = scan->next) {
		NautilusFileInfo *file = scan->data;
		FileMimeInfo      file_mime_info;

		file_mime_info = get_file_mime_info (file);

		if (all_archives && ! file_mime_info.is_archive)
			all_archives = FALSE;

		if (all_archives_compressed && file_mime_info.is_archive && ! file_mime_info.is_compressed_archive)
			all_archives_compressed = FALSE;

		if (all_archives_derived && file_mime_info.is_archive && ! file_mime_info.is_derived_archive)
			all_archives_derived = FALSE;

		if (can_write) {
			NautilusFileInfo *parent;

			parent = nautilus_file_info_get_parent_info (file);
 			can_write = nautilus_file_info_can_write (parent);
		}
	}

	/**/

	one_item = (files != NULL) && (files->next == NULL);
	one_archive = one_item && all_archives;
	one_derived_archive = one_archive && all_archives_derived;
	one_compressed_archive = one_archive && all_archives_compressed;

	if (all_archives && can_write) {
		NautilusMenuItem *item;

		item = nautilus_menu_item_new ("NautilusFr::extract_here",
					       _("Extract Here"),
					       /* Translators: the current position is the current folder */
					       _("Extract the selected archive to the current position"),
					       "drive-harddisk");
		g_signal_connect (item,
				  "activate",
				  G_CALLBACK (extract_here_callback),
				  provider);
		g_object_set_data_full (G_OBJECT (item),
					"files",
					nautilus_file_info_list_copy (files),
					(GDestroyNotify) nautilus_file_info_list_free);

		items = g_list_append (items, item);
	}
	else if (all_archives && ! can_write) {
		NautilusMenuItem *item;

		item = nautilus_menu_item_new ("NautilusFr::extract_to",
					       _("Extract To..."),
					       _("Extract the selected archive"),
					       "drive-harddisk");
		g_signal_connect (item,
				  "activate",
				  G_CALLBACK (extract_to_callback),
				  provider);
		g_object_set_data_full (G_OBJECT (item),
					"files",
					nautilus_file_info_list_copy (files),
					(GDestroyNotify) nautilus_file_info_list_free);

		items = g_list_append (items, item);

	}

	if (! one_compressed_archive || one_derived_archive) {
		NautilusMenuItem *item;

		item = nautilus_menu_item_new ("NautilusFr::add",
					       _("Compress..."),
					       _("Create a compressed archive with the selected objects"),
					       "gnome-mime-application-x-archive");
		g_signal_connect (item,
				  "activate",
				  G_CALLBACK (add_callback),
				  provider);
		g_object_set_data_full (G_OBJECT (item),
					"files",
					nautilus_file_info_list_copy (files),
					(GDestroyNotify) nautilus_file_info_list_free);

		items = g_list_append (items, item);
	}

	return items;
}
Пример #11
0
static GList *
nautilus_easytag_get_file_items (NautilusMenuProvider *provider,
                                 GtkWidget *window,
                                 GList *files)
{
    GList *items = NULL;
    GList *l;
    gboolean one_item;
    gboolean one_directory = TRUE;
    gboolean all_files = TRUE;

    if (files == NULL)
    {
        return NULL;
    }

    if (unsupported_scheme ((NautilusFileInfo *)files->data))
    {
        return NULL;
    }

    for (l = files; l != NULL; l = g_list_next (l))
    {
        FileMimeInfo file_mime_info;
        NautilusFileInfo *file = l->data;

        file_mime_info = get_file_mime_info (file);

        if (all_files && !file_mime_info.is_file)
        {
            all_files = FALSE;
        }

        if (one_directory && !file_mime_info.is_directory)
        {
            one_directory = FALSE;
        }
    }

    one_item = (files != NULL) && (files->next == NULL);

    if (one_directory && one_item)
    {
        NautilusMenuItem *item;

        item = nautilus_menu_item_new ("NautilusEasytag::open_directory",
                                       _("Open in EasyTAG"),
                                       _("Open the selected directory in EasyTAG"),
                                       "easytag");
        g_signal_connect (item,
                          "activate",
                          G_CALLBACK (on_open_in_easytag),
                          provider);
        g_object_set_data (G_OBJECT (item),
                           "dir",
                           files->data);

        items = g_list_append (items, item);
    }
    else if (all_files)
    {
        NautilusMenuItem *item;

        item = nautilus_menu_item_new ("NautilusEasytag::open_files",
                                       _("Open with EasyTAG"),
                                       _("Open the selected files in EasyTAG"),
                                       "easytag");
        g_signal_connect (item,
                          "activate",
                          G_CALLBACK (on_open_with_easytag),
                          provider);
        g_object_set_data_full (G_OBJECT (item),
                                "files",
                                nautilus_file_info_list_copy (files),
                                (GDestroyNotify) nautilus_file_info_list_free);

        items = g_list_append (items, item);
    }

    return items;
}
Пример #12
0
static GList *
nautilus_disc_burn_get_file_items (NautilusMenuProvider *provider,
                                   GtkWidget            *window,
                                   GList                *selection)
{
        GList            *items = NULL;
        NautilusMenuItem *item;
        NautilusFileInfo *file_info;
        GFile            *file;
        GMount           *mount;
        GVolume          *volume;
        GDrive           *drive;
        char             *mime_type;
        gboolean          is_iso;

        DEBUG_PRINT ("Getting file items\n");

        if (!selection || selection->next != NULL) {
                return NULL;
        }

        file_info = NAUTILUS_FILE_INFO (selection->data);

        if (nautilus_file_info_is_gone (file_info)) {
                return NULL;
        }

        file = nautilus_file_info_get_location (file_info);

        if (file == NULL) {
                DEBUG_PRINT ("No file found\n");
                return NULL;
        }

        mime_type = nautilus_file_info_get_mime_type (file_info);
        DEBUG_PRINT ("Mime type: %s\n", mime_type);
        if (! mime_type) {
                g_object_unref (file);
                return NULL;
        }

        is_iso = (strcmp (mime_type, "application/x-iso-image") == 0)
                || (strcmp (mime_type, "application/x-cd-image") == 0)
                || (strcmp (mime_type, "application/x-cue") == 0)
                || (strcmp (mime_type, "application/x-toc") == 0)
                || (strcmp (mime_type, "application/x-cdrdao-toc") == 0);

        if (is_iso) {
                /* Whether or not this file is local is not a problem */
                item = nautilus_menu_item_new ("NautilusDiscBurn::write_iso",
                                               _("_Write to Disc…"),
                                               _("Write disc image to a CD or DVD"),
                                               "media-optical-data-new");
                g_object_set_data (G_OBJECT (item), "file_info", file_info);
                g_object_set_data (G_OBJECT (item), "window", window);
                g_signal_connect (item, "activate",
                                  G_CALLBACK (write_iso_activate_cb), window);
                items = g_list_append (items, item);
        }

        /*
         * We handle two cases here.  The selection is:
         *  A) a volume
         *  B) a drive
         *
         * This is because there is very little distinction between
         * the two for CD/DVD media
         */

        drive = NULL;
        volume = NULL;

        mount = nautilus_file_info_get_mount (file_info);
        if (mount != NULL) {
                drive = g_mount_get_drive (mount);
                volume = g_mount_get_volume (mount);
        } else {
                char *uri = g_file_get_uri (file);
                DEBUG_PRINT ("Mount not found: %s\n", uri);
                g_free (uri);
        }

        if (drive == NULL && volume != NULL) {
                /* case A */
                drive = g_volume_get_drive (volume);
        } else if (volume == NULL && drive != NULL) {
                /* case B */
                volume = drive_get_first_volume (drive);
                if (volume == NULL) {
                        DEBUG_PRINT ("Volume not found\n");
                }
        }

        if (drive != NULL
            && volume != NULL
            && drive_is_cd_device (drive)
            && ! volume_is_blank (volume)) {
                char			*device_path;
		BraseroMediumMonitor	*monitor;
		BraseroDrive		*bdrive;
		BraseroMedium		*medium;
		BraseroMedia		 media;
		BraseroTrackType	*type;

		/* Reminder: the following is not needed since it is already 
		 * called in drive_is_cd_device ().
		 * ensure_initialized();
		 */

                device_path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
		monitor = brasero_medium_monitor_get_default ();
		bdrive = brasero_medium_monitor_get_drive (monitor, device_path);
		g_object_unref (monitor);

		medium = brasero_drive_get_medium (bdrive);
		media = brasero_medium_get_status (medium);
		g_object_unref (bdrive);

		type = brasero_track_type_new ();
		brasero_track_type_set_has_medium (type);
		brasero_track_type_set_medium_type (type, media);
		if (brasero_burn_library_input_supported (type) == BRASERO_BURN_OK) {
			/* user may want to copy it ... */
			item = nautilus_menu_item_new ("NautilusDiscBurn::copy_disc",
						       _("_Copy Disc…"),
						       _("Create a copy of this CD or DVD"),
						       "media-optical-copy");
			g_object_set_data (G_OBJECT (item), "file_info", file_info);
			g_object_set_data (G_OBJECT (item), "window", window);
			g_object_set_data_full (G_OBJECT (item), "drive_device_path", g_strdup (device_path), g_free);
			g_signal_connect (item, "activate", G_CALLBACK (copy_disc_activate_cb), window);
			items = g_list_append (items, item);
		}
		brasero_track_type_free (type);

		if (brasero_burn_library_get_media_capabilities (media) & BRASERO_MEDIUM_REWRITABLE) {
			/* ... or if it's a rewritable medium to blank it ... */
			item = nautilus_menu_item_new ("NautilusDiscBurn::blank_disc",
						       _("_Blank Disc…"),
						       _("Blank this CD or DVD"),
						       "media-optical-blank");
			g_object_set_data (G_OBJECT (item), "file_info", file_info);
			g_object_set_data (G_OBJECT (item), "window", window);
			g_object_set_data_full (G_OBJECT (item), "drive_device_path", g_strdup (device_path), g_free);
			g_signal_connect (item, "activate",
					  G_CALLBACK (blank_disc_activate_cb), window);
			items = g_list_append (items, item);
		}

		/* - library should be able to checksum
		 * - disc must have a data session */
		if (brasero_burn_library_can_checksum ()
		&& (media & BRASERO_MEDIUM_HAS_DATA)) {
			/* ... or verify medium. */
			item = nautilus_menu_item_new ("NautilusDiscBurn::check_disc",
						       _("_Check Disc…"),
						       _("Check the data integrity on this CD or DVD"),
						       NULL);
			g_object_set_data (G_OBJECT (item), "file_info", file_info);
			g_object_set_data (G_OBJECT (item), "window", window);
			g_object_set_data_full (G_OBJECT (item), "drive_device_path", g_strdup (device_path), g_free);
			g_signal_connect (item, "activate",
					  G_CALLBACK (check_disc_activate_cb),
			                  window);
			items = g_list_append (items, item);
		}

                g_free (device_path);
        }

        g_object_unref (file);

        if (drive != NULL) {
                g_object_unref (drive);
        }
        if (volume != NULL) {
                g_object_unref (volume);
        }

        g_free (mime_type);

        DEBUG_PRINT ("Items returned\n");
        return items;
}