mozilla-kde.patch
branchfirefox56
changeset 999 932b3ad009d5
parent 994 9fc447b00040
child 1005 6d716caa6abe
equal deleted inserted replaced
998:6c6109948e35 999:932b3ad009d5
     1 # HG changeset patch
     1 # HG changeset patch
     2 # Parent  faadbf89d1cb02eefec4c5dfd3ab86bc20d815d5
     2 # Parent  a930d4c1c3fba77f61071becdc51e3232e0b72ca
     3 Description: Add KDE integration to Firefox (toolkit parts)
     3 Description: Add KDE integration to Firefox (toolkit parts)
     4 Author: Wolfgang Rosenauer <wolfgang@rosenauer.org>
     4 Author: Wolfgang Rosenauer <wolfgang@rosenauer.org>
     5 Author: Lubos Lunak <lunak@suse.com>
     5 Author: Lubos Lunak <lunak@suse.com>
     6 Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=140751
     6 Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=140751
     7      https://bugzilla.novell.com/show_bug.cgi?id=170055
     7      https://bugzilla.novell.com/show_bug.cgi?id=170055
  3274    CopyUTF16toUTF8(aFilter, filter);
  3274    CopyUTF16toUTF8(aFilter, filter);
  3275    CopyUTF16toUTF8(aTitle, name);
  3275    CopyUTF16toUTF8(aTitle, name);
  3276  
  3276  
  3277    mFilters.AppendElement(filter);
  3277    mFilters.AppendElement(filter);
  3278    mFilterNames.AppendElement(name);
  3278    mFilterNames.AppendElement(name);
  3279 @@ -371,16 +375,34 @@ nsFilePicker::Show(int16_t *aReturn)
  3279 @@ -371,16 +375,37 @@ nsFilePicker::Show(int16_t *aReturn)
  3280  
  3280  
  3281  NS_IMETHODIMP
  3281  NS_IMETHODIMP
  3282  nsFilePicker::Open(nsIFilePickerShownCallback *aCallback)
  3282  nsFilePicker::Open(nsIFilePickerShownCallback *aCallback)
  3283  {
  3283  {
  3284    // Can't show two dialogs concurrently with the same filepicker
  3284    // Can't show two dialogs concurrently with the same filepicker
  3285    if (mRunning)
  3285    if (mRunning)
  3286      return NS_ERROR_NOT_AVAILABLE;
  3286      return NS_ERROR_NOT_AVAILABLE;
  3287  
  3287  
  3288 +  // KDE file picker is not handled via callback
  3288 +  // KDE file picker is not handled via callback
  3289 +  if( nsKDEUtils::kdeSupport()) {
  3289 +  if( nsKDEUtils::kdeSupport()) {
  3290 +    int16_t result;
       
  3291 +    mCallback = aCallback;
  3290 +    mCallback = aCallback;
  3292 +    mRunning = true;
  3291 +    mRunning = true;
  3293 +    NS_ADDREF_THIS();
  3292 +    g_idle_add([](gpointer data) -> gboolean {
  3294 +    kdeFileDialog(&result);
  3293 +      nsFilePicker* queuedPicker = (nsFilePicker*) data;
  3295 +    if (mCallback) {
  3294 +      int16_t result;
  3296 +      mCallback->Done(result);
  3295 +      queuedPicker->kdeFileDialog(&result);
  3297 +      mCallback = nullptr;
  3296 +      if (queuedPicker->mCallback) {
  3298 +    } else {
  3297 +        queuedPicker->mCallback->Done(result);
  3299 +      mResult = result;
  3298 +        queuedPicker->mCallback = nullptr;
  3300 +    }
  3299 +      } else {
  3301 +    mRunning = false;
  3300 +        queuedPicker->mResult = result;
  3302 +    NS_RELEASE_THIS();
  3301 +      }
       
  3302 +      queuedPicker->mRunning = false;
       
  3303 +      return G_SOURCE_REMOVE;
       
  3304 +    }, this);
       
  3305 +
  3303 +    return NS_OK;
  3306 +    return NS_OK;
  3304 +  }
  3307 +  }
  3305 +
  3308 +
  3306    nsXPIDLCString title;
  3309    nsXPIDLCString title;
  3307    title.Adopt(ToNewUTF8String(mTitle));
  3310    title.Adopt(ToNewUTF8String(mTitle));
  3309    GtkWindow *parent_widget =
  3312    GtkWindow *parent_widget =
  3310      GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
  3313      GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
  3311  
  3314  
  3312    GtkFileChooserAction action = GetGtkFileChooserAction(mMode);
  3315    GtkFileChooserAction action = GetGtkFileChooserAction(mMode);
  3313  
  3316  
  3314 @@ -603,8 +625,235 @@ nsFilePicker::Done(GtkWidget* file_choos
  3317 @@ -603,8 +628,233 @@ nsFilePicker::Done(GtkWidget* file_choos
  3315    if (mCallback) {
  3318    if (mCallback) {
  3316      mCallback->Done(result);
  3319      mCallback->Done(result);
  3317      mCallback = nullptr;
  3320      mCallback = nullptr;
  3318    } else {
  3321    } else {
  3319      mResult = result;
  3322      mResult = result;
  3406 +      startdir += ToNewUTF8String(mDefault);
  3409 +      startdir += ToNewUTF8String(mDefault);
  3407 +      }
  3410 +      }
  3408 +    else
  3411 +    else
  3409 +      startdir = ToNewUTF8String(mDefault);
  3412 +      startdir = ToNewUTF8String(mDefault);
  3410 +  }
  3413 +  }
  3411 +  if( startdir.IsEmpty())
       
  3412 +      startdir = ".";
       
  3413 +
  3414 +
  3414 +    nsAutoCString filters;
  3415 +    nsAutoCString filters;
  3415 +    PRInt32 count = mFilters.Length();
  3416 +    PRInt32 count = mFilters.Length();
  3416 +    if( count == 0 ) //just in case
  3417 +    if( count == 0 ) //just in case
  3417 +        filters = "*";
  3418 +        filters = "*";