예제 #1
0
파일: menu.c 프로젝트: MotoHoss/mate-panel
static void
add_app_to_desktop (GtkWidget      *item,
		    MateMenuTreeEntry *entry)
{
	char       *source_uri;
	const char *source;
	char       *target_dir;
	char       *target_uri;
	char       *target;
	GError     *error;

	g_return_if_fail (entry != NULL);

	if (desktop_is_home_dir ()) {
		target_dir = g_build_filename (g_get_home_dir (), NULL);
	} else {
		target_dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
	}

	source = matemenu_tree_entry_get_desktop_file_path (entry);
	source_uri = g_filename_to_uri (source, NULL, NULL);

	target_uri = panel_make_unique_desktop_uri (target_dir, source_uri);
	g_free (target_dir);
	g_free (source_uri);

	g_return_if_fail (target_uri != NULL);

	target = g_filename_from_uri (target_uri, NULL, NULL);
	g_free (target_uri);

	error = NULL;
	panel_key_file_copy_and_mark_trusted (source, target, &error);

	g_free (target);

	if (error != NULL) {
		g_warning ("Problem while copying launcher to desktop: %s",
			   error->message);
		g_error_free (error);
	}
}
예제 #2
0
static GList *
terminal_nautilus_get_background_items (NautilusMenuProvider *provider,
                                        GtkWidget            *window,
                                        NautilusFileInfo     *file_info)
{
  TerminalNautilus *nautilus = TERMINAL_NAUTILUS (provider);
  gchar *uri;
  GList *items;
  NautilusMenuItem *item;
  TerminalFileInfo terminal_file_info;

  if (terminal_locked_down (nautilus))
    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);

  if (terminal_file_info == FILE_INFO_SFTP ||
      terminal_file_info == FILE_INFO_DESKTOP ||
      uri_has_local_path (uri)) {
    /* local locations or SSH */
    item = terminal_nautilus_menu_item_new (nautilus,
                                            file_info, 
                                            terminal_file_info, 
                                            gtk_widget_get_screen (window),
                                            FALSE, 
                                            terminal_file_info == FILE_INFO_SFTP, 
                                            FALSE);
    items = g_list_append (items, item);
  }

  if ((terminal_file_info == FILE_INFO_SFTP ||
        terminal_file_info == FILE_INFO_OTHER) &&
      uri_has_local_path (uri)) {
    /* remote locations that offer local back-mapping */
    item = terminal_nautilus_menu_item_new (nautilus,
                                            file_info, 
                                            terminal_file_info, 
                                            gtk_widget_get_screen (window),
                                            FALSE, 
                                            FALSE, 
                                            FALSE);
    items = g_list_append (items, item);
  }

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

  g_free (uri);

  return items;
}
예제 #3
0
static void
terminal_nautilus_menu_item_activate (NautilusMenuItem *item)
{
  TerminalNautilusMenuItem *menu_item = TERMINAL_NAUTILUS_MENU_ITEM (item);
  TerminalNautilus *nautilus = menu_item->nautilus;
  char *uri, *path;
  TerminalFileInfo info;
  ExecData *data;

  uri = nautilus_file_info_get_activation_uri (menu_item->file_info);
  if (uri == NULL)
    return;

  path = NULL;
  info = get_terminal_file_info_from_uri (uri);

  switch (info) {
    case FILE_INFO_LOCAL:
      path = g_filename_from_uri (uri, NULL, NULL);
      break;

    case FILE_INFO_DESKTOP:
      if (desktop_is_home_dir (nautilus) || desktop_opens_home_dir (nautilus)) {
        path = g_strdup (g_get_home_dir ());
      } else {
        path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
      }
      break;

    case FILE_INFO_SFTP:
      if (menu_item->remote_terminal)
        break;

      /* fall through */

    case FILE_INFO_OTHER: {
      GFile *file;

      /* map back remote URI to local path */
      file = g_file_new_for_uri (uri);
      path = g_file_get_path (file);
      g_object_unref (file);
      break;
    }

    default:
      g_assert_not_reached ();
  }

  if (path == NULL && (info != FILE_INFO_SFTP || !menu_item->remote_terminal)) {
    g_free (uri);
    return;
  }

  data = g_new (ExecData, 1);
  data->nautilus = g_object_ref (nautilus);
  data->timestamp = gtk_get_current_event_time ();
  data->path = path;
  data->uri = uri;
  data->display = gdk_screen_make_display_name (menu_item->screen);
  data->info = info;
  data->remote = menu_item->remote_terminal;
  data->run_in_mc = menu_item->run_in_mc;

  create_terminal (data);
}