Skip to content

Commit

Permalink
Remove needless code; fix KWin compositor disabling; enable GTK dialo…
Browse files Browse the repository at this point in the history
…gs on XFCE
  • Loading branch information
KockaAdmiralac committed Aug 4, 2018
1 parent 474bb2c commit c8b0b92
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 34 deletions.
13 changes: 3 additions & 10 deletions src/i18n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Really hacked-together naiive implementation of gettext
*/
#include "i18n.h"
#include "debugwriter.h"

#include <stdlib.h>
#include <stdio.h>
Expand All @@ -16,16 +15,13 @@ int family = LOCALE_FAMILY_LATIN;
size_t readSize;

int getLocaleFamily() {
Debug() << "Get family:" << family;
return family;
}

const char* findtext(unsigned int msgid, const char* fallback) {
Debug() << "Looking for msg" << msgid << fallback;
if (msgid >= nStr) {
return fallback;
} else {
Debug() << "found" << strdict[msgid];
return strdict[msgid];
}
}
Expand All @@ -52,12 +48,10 @@ void _setLocaleFamily(const char* locale) {
void _read(void * ptr, size_t size, size_t count, FILE * stream) {
readSize = fread(ptr, size, count, stream);
if (readSize != count) {
Debug() << "Short read in i18n!";
}
}

void loadLocale(const char* locale) {
Debug() << "Load locale:" << locale;
char pathbuf[100];
FILE* locfile;
char header[8];
Expand All @@ -73,18 +67,17 @@ void loadLocale(const char* locale) {
if (locfile) {
_read(header, 1, 8, locfile);
if (!strcmp(header, LOC_HEADER)) {
//read number of strs in this file
// Read number of strs in this file
_read(&nStr, 4, 1, locfile);
strdict = (char**)malloc(sizeof(char*) * nStr);
for (i = 0; i < nStr; i++) {
//read the size of the next string
// Read the size of the next string
_read(&strSize, 4, 1, locfile);
strdict[i] = (char*)malloc(strSize+1);
if (strSize > 0) {
//read the contents of the next string
// Read the contents of the next string
_read(strdict[i], 1, strSize, locfile);
strdict[i][strSize] = 0;
Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize;
}
strdict[i][strSize] = 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ int main(int argc, char *argv[])
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1");
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");

/* initialize SDL first */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0)
Expand Down
35 changes: 13 additions & 22 deletions src/oneshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>

//OS-Specific code
// OS-Specific code
#if defined _WIN32
#define OS_W32
#define WIN32_LEAN_AND_MEAN
Expand Down Expand Up @@ -296,6 +296,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
gtk_init(0, 0);
} else if (desktop.find("xfce") != std::string::npos) {
desktopEnv = "xfce";
gtk_init(0, 0);
} else if (desktop.find("kde") != std::string::npos) {
desktopEnv = "kde";
} else if (desktop.find("lxde") != std::string::npos) {
Expand Down Expand Up @@ -477,24 +478,28 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
if (!title)
title = "";
#if defined OS_LINUX
if (desktopEnv == "gnome" || desktopEnv == "mate" || desktopEnv == "cinnamon") {
if (
desktopEnv == "gnome" ||
desktopEnv == "mate" ||
desktopEnv == "cinnamon" ||
desktopEnv == "xfce"
) {
linux_DialogData data = {type, body, title, 0};
gdk_threads_add_idle(linux_dialog, &data);
gtk_main();
return data.result;
}
#endif

//SDL message box

//Button data
// SDL message box
// Button data
static const SDL_MessageBoxButtonData buttonOk = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK"};
static const SDL_MessageBoxButtonData buttonsOk[] = {buttonOk};
SDL_MessageBoxButtonData buttonYes = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, p->txtYes.c_str()};
SDL_MessageBoxButtonData buttonNo = {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, p->txtNo.c_str()};
SDL_MessageBoxButtonData buttonsYesNo[] = {buttonNo, buttonYes};

//Messagebox data
// Messagebox data
SDL_MessageBoxData data;
data.window = NULL;//p->window;
data.colorScheme = 0;
Expand Down Expand Up @@ -529,7 +534,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
break;
}

//Set buttons
// Set buttons
switch (type)
{
case MSG_INFO:
Expand All @@ -545,7 +550,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
break;
}

//Show messagebox
// Show messagebox
#ifdef OS_W32
PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC);
#endif
Expand Down Expand Up @@ -586,20 +591,6 @@ std::string Oneshot::textinput(const char* prompt, int char_limit, const char* f
// Disable text input
SDL_StopTextInput();

// //Free loaded images
// gPromptTextTexture.free();
// gInputTextTexture.free();

// //Free global font
// TTF_CloseFont(gFont);
// gFont = NULL;

// //Destroy renderer
// SDL_DestroyRenderer(gRenderer);
// gRenderer = NULL;
// delete promptBmp;
// delete inputBmp;

return threadData.inputText;
}

Expand Down
2 changes: 0 additions & 2 deletions src/settingsmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "util.h"
#include "sharedstate.h"
#include "i18n.h"
#include "debugwriter.h"


#include <algorithm>
Expand Down Expand Up @@ -539,7 +538,6 @@ struct SettingsMenuPrivate
int x, int y, int alignW,
Justification just, SDL_Color c, bool bold = false)
{
Debug() << "draw text:" << str;
SDL_Surface *txt = createTextSurface(str, c, bold);
if (txt) {
blitTextSurf(surf, x, y, alignW, txt, just);
Expand Down

0 comments on commit c8b0b92

Please sign in to comment.