Пример #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;
}
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);
}
static gboolean
file_get_share_status_file (NautilusShares   *shares,
			    NautilusFileInfo *file)
{
  char *path;
  gboolean status;

  if (!nautilus_file_info_is_directory(file) || !is_directory_local (file))
    status = FALSE;
  else
    {
      path = get_path_from_file_info (file);
      g_return_val_if_fail (path != NULL, FALSE);

      status = (g_hash_table_lookup (shares->paths, path) != NULL);
      g_free (path);
    }

  return status;
}
Пример #4
0
static GList *
terminal_nautilus_get_file_items (NautilusMenuProvider *provider,
                                  GtkWidget            *window,
                                  GList                *files)
{
  TerminalNautilus *nautilus = TERMINAL_NAUTILUS (provider);
  gchar *uri;
  GList *items;
  NautilusMenuItem *item;
  NautilusFileInfo *file_info;
  GFileType file_type;
  TerminalFileInfo terminal_file_info;

  if (terminal_locked_down (nautilus))
    return NULL;

  /* Only add items when passed exactly one file */
  if (files == NULL || files->next != NULL)
    return NULL;

  file_info = (NautilusFileInfo *) files->data;
  file_type = nautilus_file_info_get_file_type (file_info);
  if (!nautilus_file_info_is_directory (file_info) &&
      file_type != G_FILE_TYPE_SHORTCUT &&
      file_type != G_FILE_TYPE_MOUNTABLE)
    return NULL;

  uri = nautilus_file_info_get_activation_uri (file_info);
  if (uri == NULL)
    return NULL;

  items = NULL;

  terminal_file_info = get_terminal_file_info_from_uri (uri);

  switch (terminal_file_info) {
    case FILE_INFO_LOCAL:
    case FILE_INFO_SFTP:
    case FILE_INFO_OTHER:
      if (terminal_file_info == FILE_INFO_SFTP || 
          uri_has_local_path (uri)) {
        item = terminal_nautilus_menu_item_new (nautilus,
                                                file_info,
                                                terminal_file_info, 
                                                gtk_widget_get_screen (window),
                                                FALSE, 
                                                terminal_file_info == FILE_INFO_SFTP, 
                                                TRUE);
        items = g_list_append (items, item);
      }

      if (terminal_file_info == FILE_INFO_SFTP &&
          uri_has_local_path (uri)) {
        item = terminal_nautilus_menu_item_new (nautilus,
                                                file_info, 
                                                terminal_file_info, 
                                                gtk_widget_get_screen (window), 
                                                FALSE, 
                                                FALSE, 
                                                TRUE);
        items = g_list_append (items, item);
      }

      if (display_mc_item (nautilus) &&
          nautilus->have_mc &&
          uri_has_local_path (uri)) {
        item = terminal_nautilus_menu_item_new (nautilus,
                                                file_info, 
                                                terminal_file_info, 
                                                gtk_widget_get_screen (window), 
                                                TRUE, 
                                                TRUE, 
                                                FALSE);
        items = g_list_append (items, item);
      }
      break;

    case FILE_INFO_DESKTOP:
      break;

    default:
      g_assert_not_reached ();
  }

  g_free (uri);

  return items;
}
Пример #5
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;
    }
  }