| 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ |
|---|
| 2 | /* |
|---|
| 3 | * main.c |
|---|
| 4 | * Copyright (C) Yasumichi Akahoshi 2010 <yasumichi@vinelinux.org> |
|---|
| 5 | * |
|---|
| 6 | * rpm-config-update is free software: you can redistribute it and/or modify it |
|---|
| 7 | * under the terms of the GNU General Public License as published by the |
|---|
| 8 | * Free Software Foundation, either version 3 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * rpm-config-update is distributed in the hope that it will be useful, but |
|---|
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 14 | * See the GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License along |
|---|
| 17 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #include <sys/types.h> |
|---|
| 21 | #include <sys/stat.h> |
|---|
| 22 | #include <unistd.h> |
|---|
| 23 | #include <string.h> |
|---|
| 24 | #include <stdio.h> |
|---|
| 25 | |
|---|
| 26 | #include <config.h> |
|---|
| 27 | |
|---|
| 28 | #include <gtk/gtk.h> |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | /* |
|---|
| 33 | * Standard gettext macros. |
|---|
| 34 | */ |
|---|
| 35 | #ifdef ENABLE_NLS |
|---|
| 36 | # include <libintl.h> |
|---|
| 37 | # undef _ |
|---|
| 38 | # define _(String) dgettext (PACKAGE, String) |
|---|
| 39 | # ifdef gettext_noop |
|---|
| 40 | # define N_(String) gettext_noop (String) |
|---|
| 41 | # else |
|---|
| 42 | # define N_(String) (String) |
|---|
| 43 | # endif |
|---|
| 44 | #else |
|---|
| 45 | # define textdomain(String) (String) |
|---|
| 46 | # define gettext(String) (String) |
|---|
| 47 | # define dgettext(Domain,Message) (Message) |
|---|
| 48 | # define dcgettext(Domain,Message,Type) (Message) |
|---|
| 49 | # define bindtextdomain(Domain,Directory) (Domain) |
|---|
| 50 | # define _(String) (String) |
|---|
| 51 | # define N_(String) (String) |
|---|
| 52 | #endif |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | #include "callbacks.h" |
|---|
| 57 | |
|---|
| 58 | /* For testing propose use the local (not installed) ui file */ |
|---|
| 59 | /* #define UI_FILE PACKAGE_DATA_DIR"/rpm_config_update/ui/rpm_config_update.ui" */ |
|---|
| 60 | #define UI_FILE "src/rpm_config_update.ui" |
|---|
| 61 | |
|---|
| 62 | GtkWidget* |
|---|
| 63 | create_window (void) |
|---|
| 64 | { |
|---|
| 65 | GtkWidget *window; |
|---|
| 66 | GtkBuilder *builder; |
|---|
| 67 | GError* error = NULL; |
|---|
| 68 | |
|---|
| 69 | builder = gtk_builder_new (); |
|---|
| 70 | if (!gtk_builder_add_from_file (builder, UI_FILE, &error)) |
|---|
| 71 | { |
|---|
| 72 | g_warning ("Couldn't load builder file: %s", error->message); |
|---|
| 73 | g_error_free (error); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | /* This is important */ |
|---|
| 77 | gtk_builder_connect_signals (builder, NULL); |
|---|
| 78 | window = GTK_WIDGET (gtk_builder_get_object (builder, "window")); |
|---|
| 79 | |
|---|
| 80 | g_object_unref (builder); |
|---|
| 81 | |
|---|
| 82 | return window; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | int |
|---|
| 87 | main (int argc, char *argv[]) |
|---|
| 88 | { |
|---|
| 89 | GtkWidget *window; |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | #ifdef ENABLE_NLS |
|---|
| 93 | bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); |
|---|
| 94 | bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); |
|---|
| 95 | textdomain (GETTEXT_PACKAGE); |
|---|
| 96 | #endif |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | gtk_set_locale (); |
|---|
| 100 | gtk_init (&argc, &argv); |
|---|
| 101 | |
|---|
| 102 | window = create_window (); |
|---|
| 103 | gtk_widget_show (window); |
|---|
| 104 | |
|---|
| 105 | gtk_main (); |
|---|
| 106 | return 0; |
|---|
| 107 | } |
|---|