Skip to content

Commit

Permalink
window: Disconnect from Gypsum and use the locally-correct name
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Jun 30, 2023
1 parent d9bc8c5 commit 5cf413b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions window.pike
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
//GTK utility functions/classes lifted straight from Gypsum

//NOTE: In this file, persist is a valid alias for persist_config, for
//compatibility where the code exists also elsewhere (eg Gypsum).
#define persist persist_config

//Usage: gtksignal(some_object,"some_signal",handler,arg,arg,arg) --> save that object.
//Equivalent to some_object->signal_connect("some_signal",handler,arg,arg,arg)
//When this object expires, the signal is disconnected, which should gc the function.
Expand Down Expand Up @@ -177,22 +173,22 @@ class configdlg
inherit window;
//Provide me...
mapping(string:mixed) windowprops=(["title":"Configure"]);
mapping(string:mapping(string:mixed)) items; //Will never be rebound. Will generally want to be an alias for a better-named mapping, or something out of persist[] (and see persist_key)
mapping(string:mapping(string:mixed)) items; //Will never be rebound. Will generally want to be an alias for a better-named mapping, or something out of persist_config[] (and see persist_key)
void save_content(mapping(string:mixed) info) { } //Retrieve content from the window and put it in the mapping.
void load_content(mapping(string:mixed) info) { } //Store information from info into the window
void delete_content(string kwd,mapping(string:mixed) info) { } //Delete the thing with the given keyword.
constant allow_new=1; //Set to 0 to remove the -- New -- entry; if omitted, -- New -- will be present and entries can be created.
constant allow_delete=1; //Set to 0 to disable the Delete button (it'll always be visible though)
constant allow_rename=1; //Set to 0 to ignore changes to keywords
constant elements=({ });
constant persist_key=0; //(string) Set this to the persist[] key to load items[] from; if set, persist will be saved after edits.
constant persist_key=0; //(string) Set this to the persist_config[] key to load items[] from; if set, persist will be saved after edits.
constant descr_key=0; //(string) Set this to a key inside the info mapping to populate with descriptions.
//... end provide me.
string last_selected; //Set when something is loaded. Unless the user renames the thing, will be equal to win->kwd->get_text().

protected void create(string|void name)
{
if (persist_key && !items) items=persist->setdefault(persist_key,([]));
if (persist_key && !items) items=persist_config->setdefault(persist_key,([]));
::create(!is_subwindow && name); //Unless we're a main window, pass on no args to the window constructor - all configdlgs are independent
}

Expand All @@ -219,7 +215,7 @@ class configdlg
foreach (win->real_ints,string key) info[key]=(int)win[key]->get_text();
foreach (win->real_bools,string key) info[key]=(int)win[key]->get_active();
save_content(info);
if (persist_key) persist->save();
if (persist_key) persist_config->save();
[object iter,object store]=win->sel->get_selected();
if (newkwd!=oldkwd)
{
Expand All @@ -240,7 +236,7 @@ class configdlg
foreach (win->real_strings+win->real_ints,string key) win[key]->set_text("");
foreach (win->real_bools,string key) win[key]->set_active(0);
delete_content(kwd,m_delete(items,kwd));
if (persist_key) persist->save();
if (persist_key) persist_config->save();
}

int ischanged()
Expand Down Expand Up @@ -413,7 +409,7 @@ class menu_item
class ircsettings
{
inherit window;
mapping config = persist->path("ircsettings");
mapping config = persist_config->path("ircsettings");

void makewindow()
{
Expand Down Expand Up @@ -449,7 +445,7 @@ class ircsettings
config->http_address = "http://" + config->http_address;
if (has_suffix(config->http_address, "/")) config->http_address = config->http_address[..<1]; //Strip trailing slash
config->listen_address = win->listen_address->get_text();
persist->save();
persist_config->save();
closewindow();
if (!G->G->irc) G->bootstrap_all(); //Force an update to get us connected.
}
Expand Down

0 comments on commit 5cf413b

Please sign in to comment.