[planner] Use gtk_init_with_args() instead GnomeProgram
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [planner] Use gtk_init_with_args() instead GnomeProgram
- Date: Sun, 21 Mar 2010 22:26:08 +0000 (UTC)
commit 8b9104f145b722dc427ea6f1216e305ad16a64e3
Author: Javier Jardón <jjardon gnome org>
Date: Sun Mar 21 22:42:39 2010 +0100
Use gtk_init_with_args() instead GnomeProgram
src/planner-main.c | 66 +++++++++++++++++++---------------------------------
1 files changed, 24 insertions(+), 42 deletions(-)
---
diff --git a/src/planner-main.c b/src/planner-main.c
index 99887cb..4bf07f2 100644
--- a/src/planner-main.c
+++ b/src/planner-main.c
@@ -25,63 +25,50 @@
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#ifdef WITH_GNOME
-#include <libgnome/gnome-program.h>
-#include <libgnomeui/gnome-ui-init.h>
-#endif
#include "libplanner/mrp-paths.h"
#include "planner-application.h"
#include "planner-window.h"
static PlannerApplication *application;
+/* Command line options */
+static gchar *geometry = NULL;
+static gchar **args_remaining = NULL;
+static GOptionEntry options[] = {
+ { "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry, N_("Create the initial window with the given geometry."), N_("GEOMETRY")},
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args_remaining, NULL, N_("FILES") },
+ { NULL }
+ };
int
main (int argc, char **argv)
{
GtkWidget *main_window;
-#ifdef WITH_GNOME
- GnomeProgram *program;
-#endif
- gchar *geometry;
- GOptionContext *context;
- gint i;
- const GOptionEntry entries[] = {
- { "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry,
- N_("Create the initial window with the given geometry."), N_("GEOMETRY")
- },
- { NULL }
- };
+ GError *error = NULL;
gchar *filename;
gchar *locale_dir;
+ gint i;
locale_dir = mrp_paths_get_locale_dir ();
bindtextdomain (GETTEXT_PACKAGE, locale_dir);
g_free(locale_dir);
-
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- geometry = NULL;
-
g_set_application_name ("Planner");
- context = g_option_context_new (_("[FILE...]"));
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_add_group (context, gtk_get_option_group (TRUE));
- g_option_context_parse (context, &argc, &argv, NULL);
- g_option_context_free (context);
-
-#ifdef WITH_GNOME
- program = gnome_program_init (PACKAGE, VERSION,
- LIBGNOMEUI_MODULE,
- argc, argv,
- GNOME_PROGRAM_STANDARD_PROPERTIES,
- GNOME_PARAM_HUMAN_READABLE_NAME, "Planner",
- NULL);
-#endif
-
+ /* Initialize GTK+ program */
+ if (!gtk_init_with_args (&argc, &argv,
+ _("- Planner project management"),
+ options,
+ GETTEXT_PACKAGE,
+ &error)) {
+ g_printerr (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
+ error->message, argv[0]);
+ g_error_free (error);
+ return 1;
+ }
filename = mrp_paths_get_image_dir ("gnome-planner.png");
gtk_window_set_default_icon_from_file (filename, NULL);
@@ -95,11 +82,10 @@ main (int argc, char **argv)
#endif
application = planner_application_new ();
-
main_window = planner_application_new_window (application);
- if (geometry != NULL) {
- gtk_window_parse_geometry (GTK_WINDOW (main_window), geometry);
- }
+
+ if ((geometry) && !gtk_window_parse_geometry (GTK_WINDOW (main_window), geometry))
+ g_warning(_("Invalid geometry string \"%s\"\n"), geometry);
gtk_widget_show_all (main_window);
@@ -140,9 +126,5 @@ main (int argc, char **argv)
g_object_unref (application);
-#ifdef WITH_GNOME
- g_object_unref (program);
-#endif
-
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]