tv_rename/gtk/gui.cpp
2020-04-01 16:13:39 +02:00

40 lines
1.2 KiB
C++

#include <errno.h>
#include <error.h>
#include <gtkmm/application.h>
#include <libintl.h>
#include <locale.h>
#include "../filesystem.hpp"
#include "../functions.hpp"
#include "../resources_linux.h"
#include "../tv_rename.hpp"
#include "mainwindow.hpp"
#define API_KEY "42B66F5E-C6BF-423F-ADF9-CC97163472F6"
#define DOMAIN "tv_rename"
int main( int argc, char **argv ) {
auto app = Gtk::Application::create(
argc, argv, "org.idonthaveanorganization.tvrename" );
if ( setlocale( LC_ALL, "" ) == NULL )
error( 1, errno, _( INVALID_LOCALE ).c_str() );
if ( FSLib::exists( "/usr/share/locale/en_US/LC_MESSAGES/tv_rename.mo" ) ) {
if ( bindtextdomain( DOMAIN, "/usr/share/locale" ) == NULL )
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
if ( textdomain( DOMAIN ) == NULL )
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
} else {
if ( bindtextdomain( DOMAIN, "./locale" ) == NULL )
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
if ( textdomain( DOMAIN ) == NULL )
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
}
authenticate( API_KEY );
MainWindow mw( app );
return app->run( mw );
}