mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-22 06:05:33 -06:00
CtrlLib: Added some methods to gtk FileSelNative to streamline the interface with Win32
This commit is contained in:
parent
a5f6307a49
commit
1cd7636f00
5 changed files with 20 additions and 3 deletions
|
|
@ -25,7 +25,7 @@ bool FileSelNative::Execute0(int open, const char *title)
|
||||||
Ctrl::ReleaseCtrlCapture();
|
Ctrl::ReleaseCtrlCapture();
|
||||||
if(!title)
|
if(!title)
|
||||||
title = open ? t_("Open") : t_("Save as");
|
title = open ? t_("Open") : t_("Save as");
|
||||||
CFRef<CFStringRef> mmtitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingUTF8);
|
CFRef<CFStringRef> mmtitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingUTF8);
|
||||||
|
|
||||||
NSWindow *window = nil;
|
NSWindow *window = nil;
|
||||||
Ctrl *win = Ctrl::GetActiveWindow();
|
Ctrl *win = Ctrl::GetActiveWindow();
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,12 @@ class FileSelNative {
|
||||||
bool Execute0(int mode, const char *title);
|
bool Execute0(int mode, const char *title);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Execute(bool open, const char *title = NULL) { return Execute0(open, title); }
|
void Serialize(Stream& s);
|
||||||
|
|
||||||
|
void New() { path.Clear(); }
|
||||||
|
bool IsNew() const { return path.IsEmpty(); }
|
||||||
|
|
||||||
|
bool Execute(bool open, const char *title = NULL) { return Execute0(open, title); }
|
||||||
bool ExecuteOpen(const char *title = NULL) { return Execute(true, title); }
|
bool ExecuteOpen(const char *title = NULL) { return Execute(true, title); }
|
||||||
bool ExecuteSaveAs(const char *title = NULL) { return Execute(false, title); }
|
bool ExecuteSaveAs(const char *title = NULL) { return Execute(false, title); }
|
||||||
bool ExecuteSelectDir(const char *title = NULL) { return Execute0(2, title); }
|
bool ExecuteSelectDir(const char *title = NULL) { return Execute0(2, title); }
|
||||||
|
|
@ -357,6 +362,8 @@ public:
|
||||||
int GetCount() const { return path.GetCount(); }
|
int GetCount() const { return path.GetCount(); }
|
||||||
const String& operator[](int i) const { return path[i]; }
|
const String& operator[](int i) const { return path[i]; }
|
||||||
|
|
||||||
|
String GetActiveDir() const { return ipath; }
|
||||||
|
|
||||||
FileSelNative& Type(const char *name, const char *ext) { type.Add(MakeTuple(String(name), String(ext))); return *this; }
|
FileSelNative& Type(const char *name, const char *ext) { type.Add(MakeTuple(String(name), String(ext))); return *this; }
|
||||||
FileSelNative& AllFilesType();
|
FileSelNative& AllFilesType();
|
||||||
FileSelNative& Asking(bool b = true) { confirm = b; return *this; }
|
FileSelNative& Asking(bool b = true) { confirm = b; return *this; }
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,12 @@ FileSelNative& FileSelNative::AllFilesType() {
|
||||||
return Type(t_("All files"), "*.*");
|
return Type(t_("All files"), "*.*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileSelNative::Serialize(Stream& s) {
|
||||||
|
int version = 1;
|
||||||
|
s / version;
|
||||||
|
s / activetype % ipath;
|
||||||
|
}
|
||||||
|
|
||||||
bool FileSelNative::Execute0(int mode, const char *title)
|
bool FileSelNative::Execute0(int mode, const char *title)
|
||||||
{
|
{
|
||||||
Ctrl::ReleaseCtrlCapture();
|
Ctrl::ReleaseCtrlCapture();
|
||||||
|
|
@ -70,6 +76,9 @@ bool FileSelNative::Execute0(int mode, const char *title)
|
||||||
g_slist_free (list);
|
g_slist_free (list);
|
||||||
}
|
}
|
||||||
ret = true;
|
ret = true;
|
||||||
|
gchar *h = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(fc));
|
||||||
|
ipath = h;
|
||||||
|
g_free(h);
|
||||||
}
|
}
|
||||||
gtk_widget_destroy(fc);
|
gtk_widget_destroy(fc);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "CtrlLib.h"
|
#include "CtrlLib.h"
|
||||||
|
#include "CtrlLib.h"
|
||||||
|
|
||||||
#ifdef GUI_WIN
|
#ifdef GUI_WIN
|
||||||
#ifndef PLATFORM_WINCE
|
#ifndef PLATFORM_WINCE
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ GUI_APP_MAIN
|
||||||
FileSelNative sel;
|
FileSelNative sel;
|
||||||
sel.ActiveDir(GetHomeDirectory());
|
sel.ActiveDir(GetHomeDirectory());
|
||||||
while(sel.ExecuteSelectDir("Just a test"))
|
while(sel.ExecuteSelectDir("Just a test"))
|
||||||
PromptOK(sel.Get());
|
PromptOK(sel.Get() + "&" + "active dir: " + sel.GetActiveDir());
|
||||||
|
|
||||||
sel.AllFilesType();
|
sel.AllFilesType();
|
||||||
sel.Type("Test2", "*.tst");
|
sel.Type("Test2", "*.tst");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue