tv_rename/gtk/gui.cpp

39 lines
1.3 KiB
C++
Raw Normal View History

2020-03-12 19:52:23 +00:00
#include <errno.h>
#include <error.h>
2019-01-23 19:46:03 +00:00
#include <gtkmm/application.h>
2020-03-12 19:52:23 +00:00
#include <libintl.h>
#include <locale.h>
2019-01-23 19:46:03 +00:00
2020-04-01 14:07:37 +00:00
#include "../filesystem.hpp"
#include "../functions.hpp"
#include "../resources_linux.h"
#include "../tv_rename.hpp"
2020-04-01 14:13:39 +00:00
#include "mainwindow.hpp"
2020-01-16 10:12:22 +00:00
#define API_KEY "42B66F5E-C6BF-423F-ADF9-CC97163472F6"
2020-03-12 19:52:23 +00:00
#define DOMAIN "tv_rename"
2019-01-23 19:46:03 +00:00
2019-02-04 16:39:48 +00:00
int main( int argc, char **argv ) {
auto app = Gtk::Application::create(
argc, argv, "org.idonthaveanorganization.tvrename" );
2019-01-23 19:46:03 +00:00
2020-03-12 19:52:23 +00:00
if ( setlocale( LC_ALL, "" ) == NULL )
2020-04-12 19:12:44 +00:00
error( 1, errno, "%s", _( INVALID_LOCALE ).c_str() );
if ( FSLib::exists( "/usr/share/locale/en_US/LC_MESSAGES/tv_rename.mo" ) ) {
if ( bindtextdomain( DOMAIN, "/usr/share/locale" ) == NULL )
2020-04-12 19:12:44 +00:00
error( 1, errno, "%s", _( MEM_ALLOC_FAILED ).c_str() );
if ( textdomain( DOMAIN ) == NULL )
2020-04-12 19:12:44 +00:00
error( 1, errno, "%s", _( MEM_ALLOC_FAILED ).c_str() );
} else {
if ( bindtextdomain( DOMAIN, "./locale" ) == NULL )
2020-04-12 19:12:44 +00:00
error( 1, errno, "%s", _( MEM_ALLOC_FAILED ).c_str() );
if ( textdomain( DOMAIN ) == NULL )
2020-04-12 19:12:44 +00:00
error( 1, errno, "%s", _( MEM_ALLOC_FAILED ).c_str() );
}
2020-03-12 19:52:23 +00:00
2020-04-01 18:09:15 +00:00
// TODO let user know that program is authenticating and will start shortly
2020-01-16 10:12:22 +00:00
authenticate( API_KEY );
2019-02-04 16:39:48 +00:00
MainWindow mw( app );
return app->run( mw );
2019-01-23 19:46:03 +00:00
}