mirror of
https://github.com/wizbright/waybox.git
synced 2025-11-02 09:01:42 -05:00
Merge pull request #19 from keithbowes/gettext
* Added gettext catalogs * Adapted from Openbox to hopefully give us a lot of mostly complete translations immediately. * Added building the .pot and .gmo files * Prepared strings for translation * Using wlr_log() instead of printf() for logging messages * A hopefully acceptable solution * Openbox-esque help * Cut down the blank lines in the debug logs * It seems that wlr_log already outputs an end-of-line character * Removed the messages which make no sense in Wayland * Cleaned up the .po files * Proper translation notes and where to report bugs * More debugging messages
This commit is contained in:
commit
ab16a76696
51 changed files with 16878 additions and 17 deletions
|
|
@ -1,38 +1,77 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-server.h>
|
||||
|
||||
#include "waybox/server.h"
|
||||
|
||||
bool show_help(char *name)
|
||||
{
|
||||
printf(_("Syntax: %s [options]\n"), name);
|
||||
printf(_("\nOptions:\n"));
|
||||
printf(_(" --help Display this help and exit\n"));
|
||||
printf(_(" --version Display the version and exit\n"));
|
||||
/* TRANSLATORS: If you translate FILE, be sure the text remains aligned. */
|
||||
printf(_(" --config-file FILE Specify the path to the config file to use\n"));
|
||||
printf(_(" --sm-disable Disable connection to the session manager\n"));
|
||||
printf(_(" --startup CMD Run CMD after starting\n"));
|
||||
printf(_(" --debug Display debugging output\n"));
|
||||
printf(_("\nOther Openbox options aren't accepted, "
|
||||
"mostly due to them being nonsensical on Wayland.\n"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
|
||||
char *startup_cmd = NULL;
|
||||
if (argc > 0) {
|
||||
enum wlr_log_importance debuglevel = WLR_ERROR;
|
||||
if (argc > 1) {
|
||||
int i;
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (!strcmp("--debug", argv[i]) || !strcmp("-v", argv[i]) || !strcmp("--exit", argv[i])) {
|
||||
printf("Warning: option %s is currently unimplemented\n", argv[i]);
|
||||
} else if ((!strcmp("--startup", argv[i]) || !strcmp("-s", argv[i])) && i < argc) {
|
||||
startup_cmd = argv[i + 1];
|
||||
if (!strcmp("--debug", argv[i]) || !strcmp("-v", argv[i])) {
|
||||
debuglevel = WLR_INFO;
|
||||
} else if ((!strcmp("--startup", argv[i]) || !strcmp("-s", argv[i]))) {
|
||||
if (i < argc - 1) {
|
||||
startup_cmd = argv[i + 1];
|
||||
} else {
|
||||
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
|
||||
}
|
||||
} else if (!strcmp("--version", argv[i]) || !strcmp("-V", argv[i])) {
|
||||
printf(PACKAGE_NAME " " PACKAGE_VERSION "\n");
|
||||
return 0;
|
||||
} else if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) {
|
||||
show_help(argv[0]);
|
||||
return 0;
|
||||
} else if (!strcmp("--config-file", argv[i]) ||
|
||||
!strcmp("--sm-disable", argv[i])) {
|
||||
fprintf(stderr, _("%s hasn't been implemented yet.\n"), argv[i]);
|
||||
if (i == argc - 1) {
|
||||
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
|
||||
}
|
||||
} else if (argv[i][0] == '-') {
|
||||
printf("Usage: %s [--debug] [--exit] [--help] [--startup CMD] [--version]\n", argv[0]);
|
||||
return strcmp("--help", argv[i]) != 0 && strcmp("-h", argv[i]) != 0;
|
||||
show_help(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wlr_log_init(debuglevel, NULL);
|
||||
struct wb_server server = {0};
|
||||
|
||||
if (!wb_create_backend(&server)) {
|
||||
printf("Failed to create backend\n");
|
||||
if (wb_create_backend(&server)) {
|
||||
wlr_log(WLR_INFO, "%s", _("Successfully created backend"));
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "%s", _("Failed to create backend"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!wb_start_server(&server)) {
|
||||
printf("Failed to start server\n");
|
||||
if (wb_start_server(&server)) {
|
||||
wlr_log(WLR_INFO, "%s", _("Successfully started server"));
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "%s", _("Failed to start server"));
|
||||
wb_terminate(&server);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ static void render_surface(struct wlr_surface *surface, int sx, int sy, void *da
|
|||
* means. You don't have to worry about this, wlroots takes care of it. */
|
||||
struct wlr_texture *texture = wlr_surface_get_texture(surface);
|
||||
if (texture == NULL) {
|
||||
wlr_log(WLR_ERROR, "%s: %s", _("Couldn't get a surface texture"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -75,6 +76,7 @@ void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
||||
if (!wlr_output_attach_render(output->wlr_output, NULL)) {
|
||||
wlr_log_errno(WLR_ERROR, "%s", _("Couldn't attach renderer to output"));
|
||||
return;
|
||||
}
|
||||
int width, height;
|
||||
|
|
@ -119,6 +121,7 @@ void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
listener, server, new_output
|
||||
);
|
||||
struct wlr_output *wlr_output = data;
|
||||
wlr_log(WLR_INFO, "%s: %s", _("New output device detected"), wlr_output->name);
|
||||
|
||||
if (!wl_list_empty(&wlr_output->modes)) {
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
|
||||
|
|
@ -126,6 +129,7 @@ void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
wlr_output_enable(wlr_output, true);
|
||||
|
||||
if (!wlr_output_commit(wlr_output)) {
|
||||
wlr_log_errno(WLR_ERROR, "%s", _("Couldn't commit pending frame to output"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,12 +128,15 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
|
|||
struct wb_server *server = wl_container_of(listener, server, new_input);
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
wlr_log(WLR_INFO, "%s: %s", _("New keyboard detected"), device->name);
|
||||
handle_new_keyboard(server, device);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
wlr_log(WLR_INFO, "%s: %s", _("New pointer detected"), device->name);
|
||||
wlr_cursor_attach_input_device(server->cursor->cursor, device);
|
||||
break;
|
||||
default:
|
||||
wlr_log(WLR_INFO, "%s: %s", _("Unsupported input device detected"), device->name);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ bool wb_create_backend(struct wb_server* server) {
|
|||
// create display
|
||||
server->wl_display = wl_display_create();
|
||||
if (server->wl_display == NULL) {
|
||||
fprintf(stderr, "Failed to connect to a Wayland display\n");
|
||||
wlr_log(WLR_ERROR, "%s", _("Failed to connect to a Wayland display"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -40,13 +40,13 @@ bool wb_start_server(struct wb_server* server) {
|
|||
}
|
||||
|
||||
if (!wlr_backend_start(server->backend)) {
|
||||
fprintf(stderr, "Failed to start backend\n");
|
||||
wlr_log(WLR_ERROR, "%s", _("Failed to start backend"));
|
||||
wlr_backend_destroy(server->backend);
|
||||
wl_display_destroy(server->wl_display);
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("Running Wayland compositor on Wayland display '%s'\n", socket);
|
||||
wlr_log(WLR_INFO, "%s: WAYLAND_DISPLAY=%s", _("Running Wayland compositor on Wayland display"), socket);
|
||||
setenv("WAYLAND_DISPLAY", socket, true);
|
||||
|
||||
wlr_gamma_control_manager_v1_create(server->wl_display);
|
||||
|
|
@ -68,7 +68,7 @@ bool wb_terminate(struct wb_server* server) {
|
|||
wlr_output_layout_destroy(server->layout);
|
||||
wl_display_destroy(server->wl_display);
|
||||
|
||||
printf("Display destroyed.\n");
|
||||
wlr_log(WLR_INFO, "%s", _("Display destroyed"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "waybox/xdg_shell.h"
|
||||
|
||||
void focus_view(struct wb_view *view, struct wlr_surface *surface) {
|
||||
wlr_log(WLR_INFO, "%s: %s", _("Keyboard focus is now on surface"),
|
||||
wlr_xdg_surface_from_wlr_surface(surface)->toplevel->app_id);
|
||||
/* Note: this function only deals with keyboard focus. */
|
||||
if (view == NULL) {
|
||||
return;
|
||||
|
|
@ -54,11 +56,15 @@ static void xdg_surface_unmap(struct wl_listener *listener, void *data) {
|
|||
|
||||
/* If the current view is mapped, focus it. */
|
||||
if (current_view->mapped) {
|
||||
wlr_log(WLR_INFO, "%s: %s", _("Focusing current view"),
|
||||
current_view->xdg_surface->toplevel->app_id);
|
||||
focus_view(current_view, current_view->xdg_surface->surface);
|
||||
}
|
||||
/* Otherwise, focus the next view, if any. */
|
||||
else if (next_view->xdg_surface->surface &&
|
||||
wlr_surface_is_xdg_surface(next_view->xdg_surface->surface)) {
|
||||
wlr_log(WLR_INFO, "%s: %s", _("Focusing next view"),
|
||||
next_view->xdg_surface->toplevel->app_id);
|
||||
focus_view(next_view, next_view->xdg_surface->surface);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue