Commit 601da92c authored by Mohammed Sadiq's avatar Mohammed Sadiq Committed by Guido Gunther

application: Move some functions from main.c

These are supposed to be run only once in the main application instance.
Let this be run in application class so that non-registered instances
wont run them.
parent d15bfa92
Pipeline #55931 passed with stages
in 10 minutes and 5 seconds
......@@ -32,6 +32,10 @@
#include "chatty-manager.h"
#include "chatty-application.h"
#include "chatty-settings.h"
#include "chatty-history.h"
#define LIBFEEDBACK_USE_UNSTABLE_API
#include <libfeedback.h>
/**
* SECTION: chatty-application
......@@ -263,6 +267,9 @@ chatty_application_startup (GApplication *application)
g_set_application_name (_("Chats"));
lfb_init (CHATTY_APP_ID, NULL);
chatty_history_open ();
self->settings = chatty_settings_get_default ();
self->css_provider = gtk_css_provider_new ();
......@@ -326,6 +333,15 @@ chatty_application_activate (GApplication *application)
self);
}
static void
chatty_application_shutdown (GApplication *application)
{
g_object_unref (chatty_settings_get_default ());
chatty_history_close ();
lfb_uninit ();
G_APPLICATION_CLASS (chatty_application_parent_class)->shutdown (application);
}
static void
chatty_application_class_init (ChattyApplicationClass *klass)
......@@ -339,6 +355,7 @@ chatty_application_class_init (ChattyApplicationClass *klass)
application_class->command_line = chatty_application_command_line;
application_class->startup = chatty_application_startup;
application_class->activate = chatty_application_activate;
application_class->shutdown = chatty_application_shutdown;
}
......
......@@ -10,36 +10,20 @@
#include "chatty-config.h"
#include "chatty-application.h"
#include "chatty-manager.h"
#include "chatty-history.h"
#include "chatty-settings.h"
#define LIBFEEDBACK_USE_UNSTABLE_API
#include <libfeedback.h>
int
main (int argc,
char *argv[])
{
int status;
g_autoptr(ChattyApplication) application = NULL;
textdomain (GETTEXT_PACKAGE);
textdomain (GETTEXT_PACKAGE);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
g_set_prgname (CHATTY_APP_ID);
lfb_init (CHATTY_APP_ID, NULL);
application = chatty_application_new ();
chatty_history_open();
status = g_application_run (G_APPLICATION (application), argc, argv);
g_object_unref (chatty_settings_get_default ());
chatty_history_close();
lfb_uninit();
return status;
return g_application_run (G_APPLICATION (application), argc, argv);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment