|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Copyright (C) 2013 Red Hat
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
8ea169 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
8ea169 |
* the Free Software Foundation; either version 2 of the License, or
|
|
Packit |
8ea169 |
* (at your option) any later version.
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
8ea169 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8ea169 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
8ea169 |
* GNU General Public License for more details.
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
8ea169 |
* along with this program; if not, write to the Free Software
|
|
Packit |
8ea169 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
#include "system-config-abrt.h"
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#include <stdlib.h>
|
|
Packit |
8ea169 |
#include "libabrt.h"
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#define APP_NAME "System Config ABRT"
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static void
|
|
Packit |
8ea169 |
system_config_abrt_window_close_cb(gpointer user_data)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
gtk_widget_destroy(GTK_WIDGET(user_data));
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static GtkWidget *
|
|
Packit |
8ea169 |
system_config_abrt_window_new(GApplication *app)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
GtkWidget *wnd = gtk_application_window_new(GTK_APPLICATION(app));
|
|
Packit |
8ea169 |
gtk_window_set_default_size(GTK_WINDOW(wnd), 500, 300);
|
|
Packit |
8ea169 |
gtk_window_set_title(GTK_WINDOW(wnd), _("Problem Reporting Configuration"));
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
GtkWidget *sca = system_config_abrt_widget_new_with_close_button(
|
|
Packit |
8ea169 |
system_config_abrt_window_close_cb, wnd);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
gtk_container_add(GTK_CONTAINER(wnd), sca);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
return wnd;
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/* SystemConfigAbrt : GtkApplication */
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
typedef struct
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
GtkApplication parent_instance;
|
|
Packit |
8ea169 |
} SystemConfigAbrt;
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
typedef GtkApplicationClass SystemConfigAbrtClass;
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
G_DEFINE_TYPE (SystemConfigAbrt, system_config_abrt, GTK_TYPE_APPLICATION)
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static void
|
|
Packit |
8ea169 |
system_config_abrt_finalize (GObject *object)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
G_OBJECT_CLASS(system_config_abrt_parent_class)->finalize(object);
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static void
|
|
Packit |
8ea169 |
about_activated (GSimpleAction *action,
|
|
Packit |
8ea169 |
GVariant *parameter,
|
|
Packit |
8ea169 |
gpointer user_data)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
const gchar *authors[] = {
|
|
Packit |
8ea169 |
"ABRT Team <crash-catcher@lists.fedorahosted.org>",
|
|
Packit |
8ea169 |
NULL
|
|
Packit |
8ea169 |
};
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
gtk_show_about_dialog (NULL,
|
|
Packit |
8ea169 |
"program-name", APP_NAME,
|
|
Packit |
8ea169 |
"title", _("About System Config ABRT"),
|
|
Packit |
8ea169 |
"version", VERSION,
|
|
Packit |
8ea169 |
"website", "https://github.com/abrt/abrt/wiki/overview",
|
|
Packit |
8ea169 |
"authors", authors,
|
|
Packit |
8ea169 |
NULL);
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static void
|
|
Packit |
8ea169 |
quit_activated (GSimpleAction *action,
|
|
Packit |
8ea169 |
GVariant *parameter,
|
|
Packit |
8ea169 |
gpointer user_data)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
GApplication *app = user_data;
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
g_application_quit(app);
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static GActionEntry app_entries[] = {
|
|
Packit |
8ea169 |
{ "about", about_activated, NULL, NULL, NULL },
|
|
Packit |
8ea169 |
{ "quit", quit_activated, NULL, NULL, NULL },
|
|
Packit |
8ea169 |
};
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static void
|
|
Packit |
8ea169 |
system_config_abrt_startup(GApplication *application)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
G_APPLICATION_CLASS(system_config_abrt_parent_class)->startup(application);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
g_action_map_add_action_entries(G_ACTION_MAP(application), app_entries, G_N_ELEMENTS(app_entries), application);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
GMenu *app_menu = g_menu_new();
|
|
Packit |
8ea169 |
g_menu_append(app_menu, _("About"), "app.about");
|
|
Packit |
8ea169 |
g_menu_append(app_menu, _("Quit"), "app.quit");
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
gtk_application_set_app_menu(GTK_APPLICATION(application), G_MENU_MODEL(app_menu));
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static void
|
|
Packit |
8ea169 |
system_config_abrt_shutdown(GApplication *application)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
G_APPLICATION_CLASS(system_config_abrt_parent_class)->shutdown (application);
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static void
|
|
Packit |
8ea169 |
system_config_abrt_activate(GApplication *application)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
GtkWidget *wnd = system_config_abrt_window_new(application);
|
|
Packit |
8ea169 |
gtk_widget_show_all(wnd);
|
|
Packit |
8ea169 |
gtk_application_add_window(GTK_APPLICATION(application), GTK_WINDOW(wnd));
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static void
|
|
Packit |
8ea169 |
system_config_abrt_init (SystemConfigAbrt *app)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static void
|
|
Packit |
8ea169 |
system_config_abrt_class_init (SystemConfigAbrtClass *class)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
GApplicationClass *application_class = G_APPLICATION_CLASS(class);
|
|
Packit |
8ea169 |
GObjectClass *object_class = G_OBJECT_CLASS(class);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
application_class->startup = system_config_abrt_startup;
|
|
Packit |
8ea169 |
application_class->shutdown = system_config_abrt_shutdown;
|
|
Packit |
8ea169 |
application_class->activate = system_config_abrt_activate;
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
object_class->finalize = system_config_abrt_finalize;
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
SystemConfigAbrt *
|
|
Packit |
8ea169 |
system_config_abrt_new (void)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
SystemConfigAbrt *system_config_abrt;
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
g_set_application_name(APP_NAME);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
system_config_abrt = g_object_new(system_config_abrt_get_type(),
|
|
Packit |
8ea169 |
"application-id", "org.freedesktop.SystemConfigAbrt",
|
|
Packit |
8ea169 |
"flags", G_APPLICATION_HANDLES_OPEN,
|
|
Packit |
8ea169 |
NULL);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
return system_config_abrt;
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/* End class */
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
int main(int argc, char *argv[])
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
glib_init();
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
SystemConfigAbrt *system_config_abrt = system_config_abrt_new();
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
const int status = g_application_run(G_APPLICATION(system_config_abrt), argc, argv);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
g_object_unref(system_config_abrt);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
return status;
|
|
Packit |
8ea169 |
}
|