Ejemplo n.º 1
0
static GList *
nsc_extension_get_file_items (CajaMenuProvider *provider,
			      GtkWidget            *window,
			      GList                *files)
{
	CajaMenuItem *item;
	GList            *scan = NULL;
	GList            *items = NULL;

	if (files == NULL)
		return NULL;

	for (scan = files; scan; scan = scan->next) {
		if (file_is_sound (scan->data)) {
			item = caja_menu_item_new ("CajaSoundConverter::convert",
                                                       dgettext (GETTEXT_PACKAGE, "_Convert..."),
                                                       dgettext (GETTEXT_PACKAGE,
								 "Convert each selected audio file"),
                                                       "audio-x-generic");

			g_signal_connect (item, "activate",
					  G_CALLBACK (sound_convert_callback),
					  caja_file_info_list_copy (files));

			items = g_list_prepend (items, item);
			items = g_list_reverse (items);

			return items;
		}
	}

	return NULL;
}
Ejemplo n.º 2
0
static GList*
get_file_items (CajaMenuProvider *provider,
		GtkWidget            *window,
		GList                *files)
{
  CajaShares *shares;
  gboolean one_item, is_local, is_dir;
  CajaFileInfo *info;
  CajaMenuItem *menu_item;

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

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

  if (!is_dir)
    return NULL;

  is_local = is_directory_local (info);

  if (!is_local)
    return NULL;

  menu_item = caja_menu_item_new ("CajaShares::share",
				      _("_Share Folder..."),
				      _("Share this folder with other computers"),
				      "mate-fs-share");

  /* do not allow running more than one instance from caja 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);
}
Ejemplo n.º 3
0
static GList *
caja_fr_get_file_items (CajaMenuProvider *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 ((CajaFileInfo *) files->data))
		return NULL;

	for (scan = files; scan; scan = scan->next) {
		CajaFileInfo *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) {
			CajaFileInfo *parent;

			parent = caja_file_info_get_parent_info (file);
 			can_write = caja_file_info_can_write (parent);
			g_object_unref (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) {
		CajaMenuItem *item;

		item = caja_menu_item_new ("CajaFr::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",
					caja_file_info_list_copy (files),
					(GDestroyNotify) caja_file_info_list_free);

		items = g_list_append (items, item);
	}
	if (all_archives) {
		CajaMenuItem *item;

		item = caja_menu_item_new ("CajaFr::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",
					caja_file_info_list_copy (files),
					(GDestroyNotify) caja_file_info_list_free);

		items = g_list_append (items, item);

	}

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

		item = caja_menu_item_new ("CajaFr::add",
					       _("Compress..."),
					       _("Create a compressed archive with the selected objects"),
					       "mate-mime-application-x-archive");
		g_signal_connect (item,
				  "activate",
				  G_CALLBACK (add_callback),
				  provider);
		g_object_set_data_full (G_OBJECT (item),
					"files",
					caja_file_info_list_copy (files),
					(GDestroyNotify) caja_file_info_list_free);

		items = g_list_append (items, item);
	}

	return items;
}