Skip to content

Commit

Permalink
Succinct handling of mstrings in themes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed Apr 22, 2024
1 parent 68ff0f4 commit af5650d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
25 changes: 13 additions & 12 deletions src/themes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
const unsigned utf32ellipsis = 0x2026;
extern YFont menuFont;

DTheme::DTheme(IApp *app, YSMListener *smActionListener, const mstring &label, const mstring &theme):
DObject(app, label, null), fTheme(theme)
DTheme::DTheme(IApp* app, YSMListener* listener, mstring label, mstring theme)
: DObject(app, label, null)
, smActionListener(listener)
, fTheme(theme)
{
this->smActionListener = smActionListener;
}

DTheme::~DTheme() {
Expand All @@ -48,10 +49,10 @@ void DTheme::open() {
smActionListener->handleSMAction(ICEWM_ACTION_RESTARTWM);
}

ThemesMenu::ThemesMenu(IApp *app, YSMListener *smActionListener, YActionListener *wmActionListener, YWindow *parent)
: ObjectMenu(wmActionListener, parent)
ThemesMenu::ThemesMenu(IApp* app, YSMListener* smListener, YActionListener* wmListener)
: ObjectMenu(wmListener)
, themeCount(0)
, smActionListener(smActionListener)
, smActionListener(smListener)
, app(app)
{
}
Expand Down Expand Up @@ -86,7 +87,7 @@ void ThemesMenu::refresh() {
}
}

int ThemesMenu::countThemes(const upath& path) {
int ThemesMenu::countThemes(upath path) {
int ret = 0;
for (udir dir(path); dir.next(); ) {
ret += (path + dir.entry() + "default.theme").isReadable();
Expand All @@ -100,8 +101,8 @@ ThemesMenu::~ThemesMenu() {
YMenuItem* ThemesMenu::newThemeItem(
IApp* app,
YSMListener* smActionListener,
const mstring& label,
const mstring& relThemeName,
mstring label,
mstring relThemeName,
ObjectMenu* container)
{
YMenuItem* item = nullptr;
Expand All @@ -117,7 +118,7 @@ YMenuItem* ThemesMenu::newThemeItem(
return item;
}

void ThemesMenu::findThemes(const upath& path, ObjectMenu* container) {
void ThemesMenu::findThemes(upath path, ObjectMenu* container) {
mstring defTheme("/default.theme");

bool bNesting = inrange(nestedThemeMenuMinNumber, 1, themeCount - 1);
Expand Down Expand Up @@ -198,8 +199,8 @@ void ThemesMenu::findThemes(const upath& path, ObjectMenu* container) {
void ThemesMenu::findThemeAlternatives(
IApp *app,
YSMListener *smActionListener,
const upath& path,
const mstring& relName,
upath path,
mstring relName,
YMenuItem *item,
ObjectMenu* container)
{
Expand Down
20 changes: 10 additions & 10 deletions src/themes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __THEMES_H
#define __THEMES_H
#ifndef THEMES_H
#define THEMES_H

#include "objmenu.h"
#include "obj.h"
Expand All @@ -10,7 +10,7 @@ class YActionListener;

class DTheme: public DObject {
public:
DTheme(IApp *app, YSMListener *smActionListener, const mstring &label, const mstring &theme);
DTheme(IApp* app, YSMListener* listener, mstring label, mstring theme);
virtual ~DTheme();

virtual void open();
Expand All @@ -21,35 +21,35 @@ class DTheme: public DObject {

class ThemesMenu: public ObjectMenu {
public:
ThemesMenu(IApp *app, YSMListener *smActionListener, YActionListener *wmActionListener, YWindow *parent = nullptr);
ThemesMenu(IApp *app, YSMListener *smListener, YActionListener *wmListener);
virtual ~ThemesMenu();

virtual void updatePopup();
virtual void refresh();

private:
void findThemes(const upath& path, ObjectMenu* container);
void findThemes(upath path, ObjectMenu* container);

YMenuItem *newThemeItem(
IApp *app,
YSMListener *smActionListener,
const mstring& label,
const mstring& relThemeName,
mstring label,
mstring relThemeName,
ObjectMenu* container);

void findThemeAlternatives(
IApp *app,
YSMListener *smActionListener,
const upath& path,
const mstring& relName,
upath path,
mstring relName,
YMenuItem *item,
ObjectMenu* container);

// this solution isn't nice. Saving it globaly somewhere would be
// much better, we would have a themeCound from the last refresh
// cycle and update it after menu construction, counting themes that
// are actually added to menues
int countThemes(const upath& path);
int countThemes(upath path);
int themeCount;

YSMListener *smActionListener;
Expand Down

0 comments on commit af5650d

Please sign in to comment.