Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Enumerations | Functions
nsFilePicker.cpp File Reference
#include <gtk/gtkwindow.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkmessagedialog.h>
#include "nsIFileURL.h"
#include "nsIURI.h"
#include "nsIWidget.h"
#include "nsILocalFile.h"
#include "nsIStringBundle.h"
#include "nsArrayEnumerator.h"
#include "nsMemory.h"
#include "nsEnumeratorUtils.h"
#include "nsNetUtil.h"
#include "nsReadableUtils.h"
#include "mozcontainer.h"
#include "prmem.h"
#include "prlink.h"
#include "nsFilePicker.h"

Go to the source code of this file.

Defines

#define DECL_FUNC_PTR(func)   static _##func##_fn _##func
#define GTK_FILE_CHOOSER(widget)   ((GtkFileChooser*) widget)
#define GET_LIBGTK_FUNC_BASE(func, onerr)
#define GET_LIBGTK_FUNC(func)   GET_LIBGTK_FUNC_BASE(func, return NS_ERROR_NOT_AVAILABLE;)
#define GET_LIBGTK_FUNC_OPT(func)   GET_LIBGTK_FUNC_BASE(func, ;)

Typedefs

typedef struct _GtkFileChooser
typedef struct _GtkFileFilter
typedef gchar *(* _gtk_file_chooser_get_filename_fn )(GtkFileChooser *chooser)
typedef GSList *(* _gtk_file_chooser_get_filenames_fn )(GtkFileChooser *chooser)
typedef GtkWidget *(* _gtk_file_chooser_dialog_new_fn )(const gchar *title, GtkWindow *parent, GtkFileChooserAction action, const gchar *first_button_text,...)
typedef void(* _gtk_file_chooser_set_select_multiple_fn )(GtkFileChooser *chooser, gboolean truth)
typedef void(* _gtk_file_chooser_set_do_overwrite_confirmation_fn )(GtkFileChooser *chooser, gboolean do_confirm)
typedef void(* _gtk_file_chooser_set_current_name_fn )(GtkFileChooser *chooser, const gchar *name)
typedef void(* _gtk_file_chooser_set_current_folder_fn )(GtkFileChooser *chooser, const gchar *folder)
typedef void(* _gtk_file_chooser_add_filter_fn )(GtkFileChooser *chooser, GtkFileFilter *filter)
typedef void(* _gtk_file_chooser_set_filter_fn )(GtkFileChooser *chooser, GtkFileFilter *filter)
typedef GtkFileFilter *(* _gtk_file_chooser_get_filter_fn )(GtkFileChooser *chooser)
typedef GSList *(* _gtk_file_chooser_list_filters_fn )(GtkFileChooser *chooser)
typedef GtkFileFilter *(* _gtk_file_filter_new_fn )()
typedef void(* _gtk_file_filter_add_pattern_fn )(GtkFileFilter *filter, const gchar *pattern)
typedef void(* _gtk_file_filter_set_name_fn )(GtkFileFilter *filter, const gchar *name)

Enumerations

enum  GtkFileChooserAction { GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER }

Functions

 DECL_FUNC_PTR (gtk_file_chooser_get_filename)
 DECL_FUNC_PTR (gtk_file_chooser_get_filenames)
 DECL_FUNC_PTR (gtk_file_chooser_dialog_new)
 DECL_FUNC_PTR (gtk_file_chooser_set_select_multiple)
 DECL_FUNC_PTR (gtk_file_chooser_set_do_overwrite_confirmation)
 DECL_FUNC_PTR (gtk_file_chooser_set_current_name)
 DECL_FUNC_PTR (gtk_file_chooser_set_current_folder)
 DECL_FUNC_PTR (gtk_file_chooser_add_filter)
 DECL_FUNC_PTR (gtk_file_chooser_set_filter)
 DECL_FUNC_PTR (gtk_file_chooser_get_filter)
 DECL_FUNC_PTR (gtk_file_chooser_list_filters)
 DECL_FUNC_PTR (gtk_file_filter_new)
 DECL_FUNC_PTR (gtk_file_filter_add_pattern)
 DECL_FUNC_PTR (gtk_file_filter_set_name)
static GtkWindow * get_gtk_window_for_nsiwidget (nsIWidget *widget)
static PRLibraryLoadVersionedLibrary (const char *libName, const char *libVersion)
static GtkFileChooserAction GetGtkFileChooserAction (PRInt16 aMode)
void ReadMultipleFiles (gpointer filename, gpointer array)
PRBool confirm_overwrite_file (GtkWidget *parent, nsILocalFile *file)

Define Documentation

#define DECL_FUNC_PTR (   func)    static _##func##_fn _##func

Definition at line 61 of file nsFilePicker.cpp.

#define GET_LIBGTK_FUNC_BASE (   func,
  onerr 
)
Value:
PR_BEGIN_MACRO \
    _##func = (_##func##_fn) PR_FindFunctionSymbol(mGTK24, #func); \
    if (!_##func) { \
      NS_WARNING("Can't load gtk symbol " #func); \
      onerr \
    } \
    PR_END_MACRO
#define GTK_FILE_CHOOSER (   widget)    ((GtkFileChooser*) widget)

Definition at line 62 of file nsFilePicker.cpp.


Typedef Documentation

typedef void(* _gtk_file_chooser_add_filter_fn)(GtkFileChooser *chooser, GtkFileFilter *filter)

Definition at line 96 of file nsFilePicker.cpp.

typedef GtkWidget*(* _gtk_file_chooser_dialog_new_fn)(const gchar *title, GtkWindow *parent, GtkFileChooserAction action, const gchar *first_button_text,...)

Definition at line 87 of file nsFilePicker.cpp.

typedef gchar*(* _gtk_file_chooser_get_filename_fn)(GtkFileChooser *chooser)

Definition at line 85 of file nsFilePicker.cpp.

typedef GSList*(* _gtk_file_chooser_get_filenames_fn)(GtkFileChooser *chooser)

Definition at line 86 of file nsFilePicker.cpp.

typedef GtkFileFilter*(* _gtk_file_chooser_get_filter_fn)(GtkFileChooser *chooser)

Definition at line 98 of file nsFilePicker.cpp.

typedef GSList*(* _gtk_file_chooser_list_filters_fn)(GtkFileChooser *chooser)

Definition at line 99 of file nsFilePicker.cpp.

typedef void(* _gtk_file_chooser_set_current_folder_fn)(GtkFileChooser *chooser, const gchar *folder)

Definition at line 95 of file nsFilePicker.cpp.

typedef void(* _gtk_file_chooser_set_current_name_fn)(GtkFileChooser *chooser, const gchar *name)

Definition at line 94 of file nsFilePicker.cpp.

typedef void(* _gtk_file_chooser_set_do_overwrite_confirmation_fn)(GtkFileChooser *chooser, gboolean do_confirm)

Definition at line 93 of file nsFilePicker.cpp.

typedef void(* _gtk_file_chooser_set_filter_fn)(GtkFileChooser *chooser, GtkFileFilter *filter)

Definition at line 97 of file nsFilePicker.cpp.

typedef void(* _gtk_file_chooser_set_select_multiple_fn)(GtkFileChooser *chooser, gboolean truth)

Definition at line 92 of file nsFilePicker.cpp.

typedef void(* _gtk_file_filter_add_pattern_fn)(GtkFileFilter *filter, const gchar *pattern)

Definition at line 101 of file nsFilePicker.cpp.

typedef GtkFileFilter*(* _gtk_file_filter_new_fn)()

Definition at line 100 of file nsFilePicker.cpp.

typedef void(* _gtk_file_filter_set_name_fn)(GtkFileFilter *filter, const gchar *name)

Definition at line 102 of file nsFilePicker.cpp.

typedef struct _GtkFileChooser

Definition at line 72 of file nsFilePicker.cpp.

typedef struct _GtkFileFilter

Definition at line 73 of file nsFilePicker.cpp.


Enumeration Type Documentation

Enumerator:
GTK_FILE_CHOOSER_ACTION_OPEN 
GTK_FILE_CHOOSER_ACTION_SAVE 
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER 
GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER 

Definition at line 76 of file nsFilePicker.cpp.


Function Documentation

PRBool confirm_overwrite_file ( GtkWidget *  parent,
nsILocalFile file 
)

Definition at line 452 of file nsFilePicker.cpp.

{
  nsCOMPtr<nsIStringBundleService> sbs = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
  nsCOMPtr<nsIStringBundle> bundle;
  nsresult rv = sbs->CreateBundle("chrome://global/locale/filepicker.properties",
                                  getter_AddRefs(bundle));
  if (NS_FAILED(rv)) {
    return PR_FALSE;
  }

  nsAutoString leafName;
  file->GetLeafName(leafName);
  const PRUnichar *formatStrings[] =
  {
    leafName.get()
  };

  nsXPIDLString title, message;
  bundle->GetStringFromName(NS_LITERAL_STRING("confirmTitle").get(),
                            getter_Copies(title));
  bundle->FormatStringFromName(NS_LITERAL_STRING("confirmFileReplacing").get(),
                               formatStrings, NS_ARRAY_LENGTH(formatStrings),
                               getter_Copies(message));

  GtkWindow *parent_window = GTK_WINDOW(parent);
  GtkWidget *dialog;
  
  dialog = gtk_message_dialog_new(parent_window,
                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                  GTK_MESSAGE_QUESTION,
                                  GTK_BUTTONS_YES_NO,
                                  NS_ConvertUTF16toUTF8(message).get());
  gtk_window_set_title(GTK_WINDOW(dialog), NS_ConvertUTF16toUTF8(title).get());
  if (parent_window && parent_window->group) {
    gtk_window_group_add_window(parent_window->group, GTK_WINDOW(dialog));
  }

  PRBool result = (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES);
  gtk_widget_destroy (dialog);

  return result;
}

Here is the call graph for this function:

DECL_FUNC_PTR ( gtk_file_chooser_get_filename  )
DECL_FUNC_PTR ( gtk_file_chooser_get_filenames  )
DECL_FUNC_PTR ( gtk_file_chooser_dialog_new  )
DECL_FUNC_PTR ( gtk_file_chooser_set_select_multiple  )
DECL_FUNC_PTR ( gtk_file_chooser_set_do_overwrite_confirmation  )
DECL_FUNC_PTR ( gtk_file_chooser_set_current_name  )
DECL_FUNC_PTR ( gtk_file_chooser_set_current_folder  )
DECL_FUNC_PTR ( gtk_file_chooser_add_filter  )
DECL_FUNC_PTR ( gtk_file_chooser_set_filter  )
DECL_FUNC_PTR ( gtk_file_chooser_get_filter  )
DECL_FUNC_PTR ( gtk_file_chooser_list_filters  )
DECL_FUNC_PTR ( gtk_file_filter_new  )
DECL_FUNC_PTR ( gtk_file_filter_add_pattern  )
DECL_FUNC_PTR ( gtk_file_filter_set_name  )
static GtkWindow* get_gtk_window_for_nsiwidget ( nsIWidget widget) [static]

Definition at line 121 of file nsFilePicker.cpp.

{
  // Get native GdkWindow
  GdkWindow *gdk_win = GDK_WINDOW(widget->GetNativeData(NS_NATIVE_WIDGET));
  if (!gdk_win)
    return NULL;

  // Get the container
  gpointer user_data = NULL;
  gdk_window_get_user_data(gdk_win, &user_data);
  if (!user_data)
    return NULL;

  // Make sure its really a container
  MozContainer *parent_container = MOZ_CONTAINER(user_data);
  if (!parent_container)
    return NULL;

  // Get its toplevel
  return GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(parent_container)));
}

Here is the call graph for this function:

Definition at line 224 of file nsFilePicker.cpp.

{
  GtkFileChooserAction action;

  switch (aMode) {
    case nsIFilePicker::modeSave:
    action = GTK_FILE_CHOOSER_ACTION_SAVE;
    break;

    case nsIFilePicker::modeGetFolder:
    action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
    break;

    default:
    NS_WARNING("Unknown nsIFilePicker mode");
    // fall through

    case nsIFilePicker::modeOpen:
    case nsIFilePicker::modeOpenMultiple:
    action = GTK_FILE_CHOOSER_ACTION_OPEN;
    break;
  }

  return action;
}
static PRLibrary* LoadVersionedLibrary ( const char *  libName,
const char *  libVersion 
) [static]

Definition at line 144 of file nsFilePicker.cpp.

{
  char *platformLibName = PR_GetLibraryName(nsnull, libName);
  nsCAutoString versionLibName(platformLibName);
  versionLibName.Append(libVersion);
  PR_FreeLibraryName(platformLibName);
  return PR_LoadLibrary(versionLibName.get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ReadMultipleFiles ( gpointer  filename,
gpointer  array 
)

Definition at line 264 of file nsFilePicker.cpp.

Here is the call graph for this function:

Here is the caller graph for this function: