Unified
Split
Showing
with
44 additions
and 74 deletions.
- +5 −10 src/MainWindow.cpp
- +25 −42 src/Options.cpp
- +2 −3 src/Options.h
- +0 −1 src/SettingsWindow.cpp
- +1 −2 src/SettingsWindow.h
- +5 −5 src/TeamItem.cpp
- +6 −11 src/ThreadItem.cpp
| @@ -53,25 +53,24 @@ MainWindow::MainWindow(void) | ||
|
|
||
| menuBar->AddItem(menu); | ||
|
|
||
|
|
||
| fToolBar = new BToolBar(B_HORIZONTAL); | ||
|
|
||
|
|
||
| BGroupLayout *topBox = BLayoutBuilder::Group<>(this,B_VERTICAL, 0) | ||
| .Add(menuBar) | ||
| .Add(fToolBar) | ||
| .AddGroup(B_VERTICAL) | ||
| .SetInsets(B_USE_WINDOW_INSETS, 0, B_USE_WINDOW_INSETS, B_USE_WINDOW_INSETS) | ||
| .Add(teamView); | ||
|
|
||
| teamView->LoadState(&(slayer->options.columnsState)); | ||
|
|
||
| team_items_list = 0; | ||
| team_amount = 0; | ||
| iteration = 0; | ||
|
|
||
| refreshThread = new RefreshThread(); | ||
| UpdateTeams(); | ||
|
|
||
|
|
||
| if (slayer->options.wind_rect.IsValid()) { | ||
| MoveTo(slayer->options.wind_rect.left, | ||
| slayer->options.wind_rect.top); | ||
| @@ -250,13 +249,9 @@ void MainWindow::MessageReceived(BMessage *message) | ||
|
|
||
| void MainWindow::Quit() | ||
| { | ||
|
|
||
| if (slayer->options.save_wind_pos) { | ||
| slayer->options.wind_rect = Frame(); | ||
| slayer->options.wind_minimized = minimized; | ||
| } | ||
| /* if (slayer->options.save_workspace) | ||
| slayer->options.workspaces = Workspaces();*/ | ||
| slayer->options.wind_rect = Frame(); | ||
| teamView->SaveState(&slayer->options.columnsState); | ||
| // slayer->options.wind_minimized = minimized; | ||
|
|
||
| // What follows is a really ugly hack to detect if the user closed | ||
| // the window with close button, or if Application wants to close | ||
| @@ -24,13 +24,11 @@ | ||
| Options::Options() | ||
| { | ||
| refresh = 250; | ||
| save_wind_pos = true; | ||
| save_workspace = true; | ||
| workspace_activation = current_workspace; | ||
| workspaces = 1; | ||
| wind_minimized = false; | ||
| wind_rect.Set(1.0, 1.0, 0.0, 0.0); | ||
| shown_columns = id_col|priority_col|state_col|cpu_col|name_col; | ||
| // shown_columns = id_col|priority_col|state_col|cpu_col|name_col; | ||
| } | ||
|
|
||
| void Options::Save() | ||
| @@ -41,31 +39,21 @@ void Options::Save() | ||
| printf("Couldn't save options\n"); | ||
| return; | ||
| } | ||
|
|
||
| path.SetTo(path.Path(), SETTINGS_FILE); | ||
|
|
||
| BFile node(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); | ||
| if (node.InitCheck() != B_NO_ERROR) { | ||
| BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); | ||
| if (file.InitCheck() != B_NO_ERROR) { | ||
| printf("Couldn't open file for saving\n"); | ||
| return; | ||
| } | ||
| BMessage message; | ||
|
|
||
| message.AddInt32("refresh", refresh); | ||
| message.AddRect("wind_rect", wind_rect); | ||
| message.AddMessage("columnsState", &columnsState); | ||
| message.AddInt8("workspace_activation", workspace_activation); | ||
| message.AddInt32("workspaces", workspaces); | ||
|
|
||
| char tmp; | ||
| node.WriteAttr("refresh", B_INT32_TYPE, 0, &refresh, sizeof(int32)); | ||
| node.WriteAttr("save_wind_pos", B_CHAR_TYPE, 0, &(tmp = save_wind_pos), | ||
| sizeof(tmp)); | ||
| node.WriteAttr("save_workspace", B_CHAR_TYPE, 0, &(tmp = save_workspace), | ||
| sizeof(tmp)); | ||
| node.WriteAttr("workspace_activation", B_INT32_TYPE, 0, &workspace_activation, | ||
| sizeof(workspace_activation)); | ||
| node.WriteAttr("workspaces", B_INT32_TYPE, 0, &workspaces, | ||
| sizeof(workspaces)); | ||
| node.WriteAttr("wind_minimized", B_CHAR_TYPE, 0, &(tmp = wind_minimized), | ||
| sizeof(wind_minimized)); | ||
| node.WriteAttr("wind_rect", B_RECT_TYPE, 0, &wind_rect, | ||
| sizeof(wind_rect)); | ||
| node.WriteAttr("shown_columns", B_INT32_TYPE, 0, &shown_columns, | ||
| sizeof(shown_columns)); | ||
| message.Flatten(&file); | ||
| } | ||
|
|
||
| void Options::Load() | ||
| @@ -78,27 +66,22 @@ void Options::Load() | ||
| } | ||
| path.SetTo(path.Path(), SETTINGS_FILE); | ||
|
|
||
| BNode node(path.Path()); | ||
| if (node.InitCheck() != B_NO_ERROR) | ||
| BFile file(path.Path(), B_READ_ONLY); | ||
| if (file.InitCheck() != B_NO_ERROR) | ||
| return; | ||
|
|
||
| char tmp; | ||
|
|
||
| node.ReadAttr("refresh", B_INT32_TYPE, 0, &refresh, sizeof(int32)); | ||
| node.ReadAttr("save_wind_pos", B_CHAR_TYPE, 0, &tmp, | ||
| sizeof(tmp)); save_wind_pos = tmp; | ||
| node.ReadAttr("save_workspace", B_CHAR_TYPE, 0, &tmp, | ||
| sizeof(tmp)); save_workspace = tmp; | ||
| node.ReadAttr("workspace_activation", B_INT32_TYPE, 0, &workspace_activation, | ||
| sizeof(workspace_activation)); | ||
| node.ReadAttr("workspaces", B_INT32_TYPE, 0, &workspaces, | ||
| sizeof(workspaces)); | ||
| node.ReadAttr("wind_minimized", B_CHAR_TYPE, 0, &tmp, | ||
| sizeof(wind_minimized)); wind_minimized = tmp; | ||
| node.ReadAttr("wind_rect", B_RECT_TYPE, 0, &wind_rect, | ||
| sizeof(wind_rect)); | ||
|
|
||
| node.ReadAttr("shown_columns", B_INT32_TYPE, 0, &shown_columns, sizeof(shown_columns)); | ||
| BMessage message; | ||
| message.Unflatten(&file); | ||
|
|
||
| if (message.FindInt32("refresh", &refresh) != B_OK) | ||
| refresh = 250; | ||
| message.FindRect("wind_rect", &wind_rect); | ||
| message.FindMessage("columnsState", &columnsState); | ||
| int8 tmp; | ||
| if (message.FindInt8("workspace_activation", &((int8)workspace_activation)) != B_OK) | ||
| workspace_activation = current_workspace; | ||
| if (message.FindInt32("workspaces", &workspaces) != B_OK) | ||
| workspaces = 1; | ||
| } | ||
|
|
||
| /* | ||
| @@ -24,8 +24,6 @@ | ||
|
|
||
| struct Options { | ||
| int32 refresh; | ||
| bool save_wind_pos; | ||
| bool save_workspace; | ||
| enum { | ||
| current_workspace, | ||
| all_workspaces, | ||
| @@ -42,7 +40,8 @@ struct Options { | ||
| cpu_col = 0x10, | ||
| name_col = 0x20 | ||
| }; | ||
| int32 shown_columns; | ||
| // int32 shown_columns; | ||
| BMessage columnsState; | ||
|
|
||
| /* | ||
| public: | ||
| @@ -107,7 +107,6 @@ void SettingsWindow::MessageReceived(BMessage *message) | ||
| slayer->options.workspace_activation = Options::all_workspaces; workspaces_field->SetEnabled(false); break; | ||
| case IE_SETTINGSWINDOW_SETTINGSSAVEWORKSPACE: // 'SettingsSaveWorkspace' is pressed... | ||
| message->FindInt32("workspace_number", &slayer->options.workspaces); | ||
| slayer->options.save_workspace = true; | ||
| break; | ||
| case IE_SETTINGSWINDOW_SETTINGSREFRESH: // Enter is pressed in 'SettingsRefresh'... | ||
| SetRefreshDelay(); | ||
| @@ -13,8 +13,7 @@ | ||
| class SettingsWindow : public BWindow | ||
| { | ||
| BDecimalSpinner *refresh; | ||
| BCheckBox *save_window; | ||
| BCheckBox *save_workspace; | ||
|
|
||
| BRadioButton *current_workspace, | ||
| *all_workspaces, | ||
| *saved_workspace; | ||
| @@ -33,10 +33,10 @@ TeamItem::TeamItem(team_info *info) : BRow() | ||
| team = info->team; | ||
| area_count = info->area_count; | ||
| // memory_usage = 0; | ||
| if (slayer->options.shown_columns & Options::memory_col) | ||
| // if (slayer->options.shown_columns & Options::memory_col) | ||
| memory_usage = CountMemory(); | ||
| else | ||
| memory_usage = 0; | ||
| // else | ||
| // memory_usage = 0; | ||
|
|
||
| get_app_info(team, &team_icon, &name, &fullName); | ||
| if (name == NULL) { | ||
| @@ -77,7 +77,7 @@ int32 TeamItem::update(team_info *info) | ||
| } */ | ||
|
|
||
| // no updating unless necessary | ||
| if (slayer->options.shown_columns & Options::memory_col) { | ||
| // if (slayer->options.shown_columns & Options::memory_col) { | ||
| size_t mem = CountMemory(); | ||
| if (mem != memory_usage) { | ||
|
|
||
| @@ -96,7 +96,7 @@ int32 TeamItem::update(team_info *info) | ||
| changed |= areas_chg; | ||
| } | ||
| } | ||
| } | ||
| // } | ||
|
|
||
| return changed; | ||
| } | ||
| @@ -63,30 +63,25 @@ void ThreadItem::update(thread_info *info) | ||
| user_time = info->user_time; | ||
| kernel_time = info->kernel_time; | ||
|
|
||
| if (strcmp(info->name, name) && | ||
| (slayer->options.shown_columns & Options::name_col)) { | ||
| if (strcmp(info->name, name) /* && | ||
| (slayer->options.shown_columns & Options::name_col) */) { | ||
|
|
||
| strcpy(name, info->name); | ||
| // SetField(new BStringField(name), 1); | ||
| ((BStringField*)GetField(1))->SetString(name); | ||
| changed |= name_chg; | ||
| } | ||
| if ((priority != info->priority) && | ||
| (slayer->options.shown_columns & Options::priority_col)) { | ||
| if ((priority != info->priority) /* && | ||
| (slayer->options.shown_columns & Options::priority_col) */) { | ||
|
|
||
| priority = info->priority; | ||
| sprintf(str, "%ld", priority); | ||
| //SetColumnContent(TeamListView::priority_ndx, str, false); | ||
| ////SetField(new BStringField(str), 3); | ||
| ((BStringField*)GetField(3))->SetString(str); | ||
| changed |= priority_chg; | ||
| } | ||
| if ((state != info->state) && | ||
| (slayer->options.shown_columns & Options::state_col)) { | ||
| if ((state != info->state) /*&& | ||
| (slayer->options.shown_columns & Options::state_col)*/) { | ||
|
|
||
| state = info->state; | ||
| //SetColumnContent(TeamListView::state_ndx, strp, false); | ||
| //SetField(new BStringField(strp), 4); | ||
| ((BStringField*)GetField(4))->SetString(RetrieveStateString(state)); | ||
| changed |= state_chg; | ||
| } | ||