コード例 #1
0
static void
add_callback (NautilusMenuItem *item,
	      gpointer          user_data)
{
	GList            *files, *scan;
	NautilusFileInfo *file;
	char             *uri, *dir;
	GString          *cmd;

	files = g_object_get_data (G_OBJECT (item), "files");
	file = files->data;

	uri = nautilus_file_info_get_uri (file);
	dir = g_path_get_dirname (uri);

	cmd = g_string_new ("file-roller");
	g_string_append (cmd, " --notify");
	g_string_append_printf (cmd," --default-dir=%s", g_shell_quote (dir));
	g_string_append (cmd," --add");

	g_free (dir);
	g_free (uri);

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

		uri = nautilus_file_info_get_uri (file);
		g_string_append_printf (cmd, " %s", g_shell_quote (uri));
		g_free (uri);
	}

	g_spawn_command_line_async (cmd->str, NULL);

	g_string_free (cmd, TRUE);
}
コード例 #2
0
ファイル: nautilus-easytag.c プロジェクト: GNOME/easytag
static void
on_open_with_easytag (NautilusMenuItem *item,
                      gpointer data)
{
    GList *files;
    GDesktopAppInfo *appinfo;

    files = g_object_get_data (G_OBJECT (item), "files");

    appinfo = g_desktop_app_info_new ("easytag.desktop");

    if (appinfo)
    {
        GdkAppLaunchContext *context;
        GList *l;
        GList *uris = NULL;

        for (l = files; l != NULL; l = g_list_next (l))
        {
            uris = g_list_append (uris,
                                  nautilus_file_info_get_uri (l->data));
        }

        context = gdk_display_get_app_launch_context (gdk_display_get_default ());

        g_app_info_launch_uris (G_APP_INFO (appinfo), uris,
                                G_APP_LAUNCH_CONTEXT (context), NULL);
    }
}
コード例 #3
0
static void
extract_to_callback (NautilusMenuItem *item,
		     gpointer          user_data)
{
	GList            *files;
	NautilusFileInfo *file;
	char             *uri, *default_dir;
	GString          *cmd;

	files = g_object_get_data (G_OBJECT (item), "files");
	file = files->data;

	uri = nautilus_file_info_get_uri (file);
	default_dir = nautilus_file_info_get_parent_uri (file);

	cmd = g_string_new ("file-roller");
	g_string_append_printf (cmd,
				" --default-dir=%s --extract %s",
				g_shell_quote (default_dir),
				g_shell_quote (uri));

#ifdef DEBUG
	g_print ("EXEC: %s\n", cmd->str);
#endif

	g_spawn_command_line_async (cmd->str, NULL);

	g_string_free (cmd, TRUE);
	g_free (default_dir);
	g_free (uri);
}
コード例 #4
0
static GList *gtkhash_properties_get_pages(
#if IN_NAUTILUS_EXTENSION
	G_GNUC_UNUSED NautilusPropertyPageProvider *provider,
#elif IN_CAJA_EXTENSION
	G_GNUC_UNUSED CajaPropertyPageProvider *provider,
#elif IN_NEMO_EXTENSION
	G_GNUC_UNUSED NemoPropertyPageProvider *provider,
#elif IN_THUNAR_EXTENSION
	G_GNUC_UNUSED ThunarxPropertyPageProvider *provider,
#endif
	GList *files)
{
	// Only display page for a single file
	if (!files || files->next)
		return NULL;

#if IN_NAUTILUS_EXTENSION
	GFileType type = nautilus_file_info_get_file_type(files->data);
	char *uri = nautilus_file_info_get_uri(files->data);
#elif IN_CAJA_EXTENSION
	GFileType type = caja_file_info_get_file_type(files->data);
	char *uri = caja_file_info_get_uri(files->data);
#elif IN_NEMO_EXTENSION
	GFileType type = nemo_file_info_get_file_type(files->data);
	char *uri = nemo_file_info_get_uri(files->data);
#elif IN_THUNAR_EXTENSION
	GFileInfo *info = thunarx_file_info_get_file_info(files->data);
	GFileType type = g_file_info_get_file_type(info);
	g_object_unref(info);

	char *uri = thunarx_file_info_get_uri(files->data);
#endif

	// Only display page for regular files
	if (type != G_FILE_TYPE_REGULAR)
		return NULL;

	struct page_s *page = gtkhash_properties_new_page(uri);
	if (!page)
		return NULL;

#if IN_NAUTILUS_EXTENSION
	NautilusPropertyPage *ppage = nautilus_property_page_new(
		"GtkHash::properties", gtk_label_new(_("Digests")), page->box);
#elif IN_CAJA_EXTENSION
	CajaPropertyPage *ppage = caja_property_page_new(
		"GtkHash::properties", gtk_label_new(_("Digests")), page->box);
#elif IN_NEMO_EXTENSION
	NemoPropertyPage *ppage = nemo_property_page_new(
		"GtkHash::properties", gtk_label_new(_("Digests")), page->box);
#elif IN_THUNAR_EXTENSION
	GtkWidget *ppage = thunarx_property_page_new(_("Digests"));
	gtk_container_add(GTK_CONTAINER(ppage), page->box);
#endif

	GList *pages = g_list_append(NULL, ppage);

	return pages;
}
コード例 #5
0
ファイル: NautilusExtension.c プロジェクト: feiying/Deja-dup
static void
make_file_list(NautilusFileInfo *info, GString *str)
{
  gchar *uri = nautilus_file_info_get_uri(info);
  if (!str->len)
    g_string_assign(str, uri);
  else
    g_string_append_printf(str, " %s", uri);
  g_free(uri);
}
コード例 #6
0
ファイル: ev-properties-main.c プロジェクト: 4eremuxa/evince
static GList *
ev_properties_get_pages (NautilusPropertyPageProvider *provider,
			 GList *files)
{
	GError *error = NULL;
	EvDocument *document = NULL;
	GList *pages = NULL;
	NautilusFileInfo *file;
	gchar *uri = NULL;
	gchar *mime_type = NULL;
	GtkWidget *page, *label;
	NautilusPropertyPage *property_page;

	/* only add properties page if a single file is selected */
	if (files == NULL || files->next != NULL)
		goto end;
	file = files->data;

	/* okay, make the page */
	uri = nautilus_file_info_get_uri (file);
	mime_type = nautilus_file_info_get_mime_type (file);
	
	document = ev_backends_manager_get_document (mime_type);
	if (!document)
		goto end;

	ev_document_load (document, uri, &error);
	if (error) {
		g_error_free (error);
		goto end;
	}
	
	label = gtk_label_new (_("Document"));
	page = ev_properties_view_new (uri);
	ev_properties_view_set_info (EV_PROPERTIES_VIEW (page),
				     ev_document_get_info (document));
	gtk_widget_show (page);
	property_page = nautilus_property_page_new ("document-properties",
			label, page);

	pages = g_list_prepend (pages, property_page);

end:
	g_free (uri);
	g_free (mime_type);

	if (document != NULL)
		g_object_unref (document);

	return pages;
}
コード例 #7
0
ファイル: NautilusExtension.c プロジェクト: feiying/Deja-dup
static void
restore_missing_files_callback(NautilusMenuItem *item)
{
  gchar *cmd;
  NautilusFileInfo *info;

  info = g_object_get_data(G_OBJECT(item), "deja_dup_extension_file");

  cmd = g_strdup_printf("deja-dup --restore-missing %s",
                        nautilus_file_info_get_uri(info));

  g_spawn_command_line_async(cmd, NULL);

  g_free(cmd);
}
コード例 #8
0
static char *
get_path_from_file_info (NautilusFileInfo *info)
{
  GFile *file;
  gchar *str, *path;

  str = nautilus_file_info_get_uri (info);
  file = g_file_new_for_uri (str);

  path = g_file_get_path (file);

  g_object_unref (file);
  g_free (str);

  return path;
}
コード例 #9
0
static gboolean
is_directory_local (NautilusFileInfo *info)
{
  gchar    *str;
  GFile    *file;
  gboolean  is_local;

  str = nautilus_file_info_get_uri (info);
  file = g_file_new_for_uri (str);

  is_local = g_file_is_native (file);

  g_object_unref (file);
  g_free (str);

  return is_local;
}
コード例 #10
0
static GList *
totem_properties_get_pages (NautilusPropertyPageProvider *provider,
			     GList *files)
{
	NautilusFileInfo *file;
	char *uri;
	GtkWidget *page, *label;
	NautilusPropertyPage *property_page;
	guint i;
	gboolean found;

	/* only add properties page if a single file is selected */
	if (files == NULL || files->next != NULL)
		return NULL;
	file = files->data;

	/* only add the properties page to these mime types */
	found = FALSE;
	for (i = 0; mime_types[i] != NULL; i++) {
		if (nautilus_file_info_is_mime_type (file, mime_types[i])) {
			found = TRUE;
			break;
		}
	}
	if (found == FALSE)
		return NULL;

	/* okay, make the page, init'ing the backend first if necessary */
	if (backend_inited == FALSE) {
		gst_init (NULL, NULL);
		backend_inited = TRUE;
	}

	uri = nautilus_file_info_get_uri (file);
	label = gtk_label_new (_("Audio/Video"));
	page = totem_properties_view_new (uri, label);
	g_free (uri);

	gtk_container_set_border_width (GTK_CONTAINER (page), 6);
	property_page = nautilus_property_page_new ("video-properties",
			label, page);

	return g_list_prepend (NULL, property_page);
}
コード例 #11
0
static void
write_iso_activate_cb (NautilusMenuItem *item,
                       gpointer          user_data)
{
	BraseroTrackImageCfg	*track;
        NautilusFileInfo	*file_info;
        char			*uri;

	ensure_initialized();

        file_info = g_object_get_data (G_OBJECT (item), "file_info");
        uri = nautilus_file_info_get_uri (file_info);

	track = brasero_track_image_cfg_new ();
	brasero_track_image_cfg_set_source (track, uri);

	g_signal_connect (track, "changed",
			  G_CALLBACK (brasero_nautilus_track_changed_cb), user_data);
}
コード例 #12
0
ファイル: fm-ditem-page.c プロジェクト: Spheerys/nautilus
static GList *
fm_ditem_page_get_pages (NautilusPropertyPageProvider *provider,
			 GList *files)
{
	GList *pages;
	NautilusPropertyPage *page;
	NautilusFileInfo *info;
	char *uri;
	GtkWidget *box;
	GtkWidget *label;

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

	info = NAUTILUS_FILE_INFO (files->data);

	if (!nautilus_file_info_is_mime_type (info, "application/x-desktop")) {
		return NULL;
	}

	box = gtk_vbox_new (FALSE, 6);
	label = gtk_label_new ("");
	g_object_set_data (G_OBJECT (box), "label", label);
	
	uri = nautilus_file_info_get_uri (info);
	fm_ditem_page_create_begin (FM_DITEM_PAGE (provider),
				    uri, box);
	g_free (uri);
	
	page = nautilus_property_page_new ("Desktop Item Page",
					   label,
					   box);
	
		
	pages = g_list_prepend (NULL, page);

	return pages;
}
コード例 #13
0
GtkWidget *
fm_ditem_page_make_box (GtkSizeGroup *label_size_group,
			GList *files)
{
	NautilusFileInfo *info;
	char *uri;
	GtkWidget *box;

	g_assert (fm_ditem_page_should_show (files));

	box = gtk_vbox_new (FALSE, 6);
	g_object_set_data_full (G_OBJECT (box), "label-size-group",
				label_size_group, (GDestroyNotify) g_object_unref);

	info = NAUTILUS_FILE_INFO (files->data);

	uri = nautilus_file_info_get_uri (info);
	fm_ditem_page_create_begin (uri, box);
	g_free (uri);

	return box;
}
コード例 #14
0
static GList *gnome_mplayer_properties_get_pages(NautilusPropertyPageProvider * provider, GList * files)
{
    GList *pages = NULL;
    NautilusFileInfo *file;
    GtkWidget *page, *label;
    NautilusPropertyPage *property_page;
    guint i;
    gboolean found = FALSE;
    gchar *uri;

    /* only add properties page if a single file is selected */
    if (files == NULL || files->next != NULL)
        return pages;

    file = files->data;

    /* only add the properties page to these mime types */
    for (i = 0; i < G_N_ELEMENTS(mime_types); i++) {
        if (nautilus_file_info_is_mime_type(file, mime_types[i])) {
            found = TRUE;
            break;
        }
    }

    if (found) {
        uri = nautilus_file_info_get_uri(file);
        label = gtk_label_new(dgettext(GETTEXT_PACKAGE, "Audio/Video"));
        page = gtk_table_new(20, 2, FALSE);
        gtk_container_set_border_width(GTK_CONTAINER(page), 6);
        if (get_properties(page, uri)) {
            gtk_widget_show_all(page);
            property_page = nautilus_property_page_new("video-properties", label, page);
            pages = g_list_prepend(pages, property_page);
        }
        g_free(uri);
    }
    return pages;
}
コード例 #15
0
ファイル: nautilus-nste.c プロジェクト: Abdillah/nautilus
static void
sendto_callback (NautilusMenuItem *item,
		 gpointer          user_data)
{
	GList            *files, *scan;
	gchar            *uri;
	GString          *cmd;

	files = g_object_get_data (G_OBJECT (item), "files");
	cmd = g_string_new ("nautilus-sendto");

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

		uri = nautilus_file_info_get_uri (file);
		g_string_append_printf (cmd, " \"%s\"", uri);
		g_free (uri);
	}

	g_spawn_command_line_async (cmd->str, NULL);

	g_string_free (cmd, TRUE);
}
コード例 #16
0
ファイル: nautilus-easytag.c プロジェクト: GNOME/easytag
static void
on_open_in_easytag (NautilusMenuItem *item,
                    gpointer data)
{
    NautilusFileInfo *dir;
    GDesktopAppInfo *appinfo;

    dir = g_object_get_data (G_OBJECT (item), "dir");

    appinfo = g_desktop_app_info_new ("easytag.desktop");

    if (appinfo)
    {
        GdkAppLaunchContext *context;
        GList *uris = NULL;

        uris = g_list_append (uris, nautilus_file_info_get_uri (dir));
        context = gdk_display_get_app_launch_context (gdk_display_get_default ());

        g_app_info_launch_uris (G_APP_INFO (appinfo), uris,
                                G_APP_LAUNCH_CONTEXT (context), NULL);
    }
}
コード例 #17
0
static void
extract_here_callback (NautilusMenuItem *item,
		       gpointer          user_data)
{
	GList            *files, *scan;
	NautilusFileInfo *file;
	char             *dir;
	GString          *cmd;

	files = g_object_get_data (G_OBJECT (item), "files");
	file = files->data;

	dir = nautilus_file_info_get_parent_uri (file);

	cmd = g_string_new ("file-roller");
	g_string_append_printf (cmd," --extract-here");

	g_free (dir);

	for (scan = files; scan; scan = scan->next) {
		NautilusFileInfo *file = scan->data;
		char             *uri;

		uri = nautilus_file_info_get_uri (file);
		g_string_append_printf (cmd, " %s", g_shell_quote (uri));
		g_free (uri);
	}

	g_spawn_command_line_async (cmd->str, NULL);

#ifdef DEBUG
	g_print ("EXEC: %s\n", cmd->str);
#endif

	g_string_free (cmd, TRUE);
}
コード例 #18
0
static void
do_file_info_command(GIOChannel *chan, SkypeFileInfoCommand *dfic, GError **gerr) {
  /* we need to send two requests to skype:
     file status, and folder_tags */
  GError *tmp_gerr = NULL;
  SkypeFileInfoCommandResponse *dficr;
  GHashTable *file_status_response = NULL, *args, *folder_tag_response = NULL, *emblems_response = NULL;
  gchar *filename = NULL;

  {
    gchar *filename_un, *uri;
    uri = nautilus_file_info_get_uri(dfic->file);
    filename_un = uri ? g_filename_from_uri(uri, NULL, NULL): NULL;
    g_free(uri);
    if (filename_un) {
      filename = g_filename_to_utf8(filename_un, -1, NULL, NULL, NULL);
      g_free(filename_un);
      if (filename == NULL) {
        /* oooh, filename wasn't correctly encoded. mark as  */
	debug("file wasn't correctly encoded %s", filename_un);
      }
    }
  }

  if (filename == NULL) {
    /* We couldn't get the filename.  Just return empty. */
    goto exit;
  }

  args = g_hash_table_new_full((GHashFunc) g_str_hash,
			       (GEqualFunc) g_str_equal,
			       (GDestroyNotify) g_free,
			       (GDestroyNotify) g_strfreev);
  {
    gchar **path_arg;
    path_arg = g_new(gchar *, 2);
    path_arg[0] = g_strdup(filename);
    path_arg[1] = NULL;
    g_hash_table_insert(args, g_strdup("path"), path_arg);
  }

  emblems_response = send_command_to_db(chan, "get_emblems", args, NULL);
  if (emblems_response) {
      /* Don't need to do the other calls. */
      g_hash_table_unref(args);
      goto exit;
  }

  /* send status command to server */
  file_status_response = send_command_to_db(chan, "icon_overlay_file_status",
					    args, &tmp_gerr);
  g_hash_table_unref(args);
  args = NULL;
  if (tmp_gerr != NULL) {
    g_free(filename);
    g_assert(file_status_response == NULL);
    g_propagate_error(gerr, tmp_gerr);
    return;
  }

  if (nautilus_file_info_is_directory(dfic->file)) {
    args = g_hash_table_new_full((GHashFunc) g_str_hash,
				 (GEqualFunc) g_str_equal,
				 (GDestroyNotify) g_free,
				 (GDestroyNotify) g_strfreev);
    {
      gchar **paths_arg;
      paths_arg = g_new(gchar *, 2);
      paths_arg[0] = g_strdup(filename);
      paths_arg[1] = NULL;
      g_hash_table_insert(args, g_strdup("path"), paths_arg);
    }
    
    folder_tag_response =
      send_command_to_db(chan, "get_folder_tag", args, &tmp_gerr);
    g_hash_table_unref(args);
    args = NULL;
    if (tmp_gerr != NULL) {
      if (file_status_response != NULL)
	g_hash_table_destroy(file_status_response);
      g_assert(folder_tag_response == NULL);
      g_propagate_error(gerr, tmp_gerr);
      return;
    }
  }