From: Jim Evins Date: Wed, 7 Feb 2007 03:31:11 +0000 (+0000) Subject: 2007-02-06 Jim Evins X-Git-Tag: glabels-2_3_0~359 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=665381a70f6353b094d0b1a1c4307b70a6e2b1be;p=glabels 2007-02-06 Jim Evins Assorted cleanup and removal of deprecated items. * src/splash.c: * src/splash.h: * src/Makefile.am: Removed annoying splash screen. * src/glabels-batch.c: (main): * src/glabels.c: (main): Converted from popt to GOption. * src/object-editor-shadow-page.c: (gl_object_editor_set_shadow_state): Removed deprecated method on GtkToggleButton. * src/ui-commands.c: (gl_ui_cmd_help_about): Removed dependency on libgnomui/qnome-url.h. * src/template-designer.c: Removed dependency on libgnome/gnome-program.h. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@613 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 6125200b..4c438fed 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,23 @@ +2007-02-06 Jim Evins + +Assorted cleanup and removal of deprecated items. + + * src/splash.c: + * src/splash.h: + * src/Makefile.am: + Removed annoying splash screen. + * src/glabels-batch.c: (main): + * src/glabels.c: (main): + Converted from popt to GOption. + * src/object-editor-shadow-page.c: + (gl_object_editor_set_shadow_state): + Removed deprecated method on GtkToggleButton. + * src/ui-commands.c: (gl_ui_cmd_help_about): + Removed dependency on libgnomui/qnome-url.h. + * src/template-designer.c: + Removed dependency on libgnome/gnome-program.h. + + 2007-02-04 Jim Evins * src/color.c: diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index 6c84a274..3c06b0d6 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -8,17 +8,19 @@ bin_PROGRAMS = glabels glabels-batch INCLUDES = \ -I$(top_srcdir) \ -I$(top_builddir) \ - $(GLABELS_CFLAGS) \ -I$(LIB_BARCODE_DIR) \ -I$(LIB_IEC16022_DIR) \ + $(GLABELS_CFLAGS) \ + $(DISABLE_DEPRECATED_CFLAGS) \ -DPREFIX=\""$(prefix)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ -DDATADIR=\""$(datadir)"\" \ -DLIBDIR=\""$(libdir)"\" \ -DGLABELS_LOCALEDIR=\""$(datadir)/locale"\" \ -DGLABELS_GLADE_DIR=\""$(datadir)/glabels/glade/"\" \ - -DG_LOG_DOMAIN=\""glabels\"" \ - $(DISABLE_DEPRECATED_CFLAGS) + -DGLABELS_ICON_DIR=\""$(datadir)/pixmaps/"\" \ + -DGLABELS_PIXMAP_DIR=\""$(datadir)/pixmaps/glabels/"\" \ + -DG_LOG_DOMAIN=\""glabels\"" glabels_LDFLAGS = -export-dynamic @@ -43,8 +45,6 @@ BUILT_SOURCES = \ glabels_SOURCES = \ glabels.c \ - splash.c \ - splash.h \ warning-handler.c \ warning-handler.h \ critical-error-handler.c \ diff --git a/glabels2/src/glabels-batch.c b/glabels2/src/glabels-batch.c index 64588deb..0ffa7bd3 100644 --- a/glabels2/src/glabels-batch.c +++ b/glabels2/src/glabels-batch.c @@ -39,39 +39,38 @@ /*============================================*/ /* Private globals */ /*============================================*/ -static gboolean help_flag = FALSE; -static gboolean version_flag = FALSE; -static gchar *output = "output.pdf"; -static gint n_copies = 1; -static gint n_sheets = 1; -static gint first = 1; -static gboolean outline_flag = FALSE; -static gboolean reverse_flag = FALSE; -static gboolean crop_marks_flag = FALSE; -static gchar *input = NULL; - -static struct poptOption options[] = { - {"help", '?', POPT_ARG_NONE, &help_flag, 1, - N_("print this message"), NULL}, - {"version", 'v', POPT_ARG_NONE, &version_flag, 0, - N_("print the version of glabels-batch being used"), NULL}, - {"output", 'o', POPT_ARG_STRING, &output, 0, +static gboolean help_flag = FALSE; +static gboolean version_flag = FALSE; +static gchar *output = "output.pdf"; +static gint n_copies = 1; +static gint n_sheets = 1; +static gint first = 1; +static gboolean outline_flag = FALSE; +static gboolean reverse_flag = FALSE; +static gboolean crop_marks_flag = FALSE; +static gchar *input = NULL; +static gchar **remaining_args = NULL; + +static GOptionEntry option_entries[] = { + {"output", 'o', 0, G_OPTION_ARG_STRING, &output, N_("set output filename (default=\"output.pdf\")"), N_("filename")}, - {"sheets", 's', POPT_ARG_INT, &n_sheets, 0, + {"sheets", 's', 0, G_OPTION_ARG_INT, &n_sheets, N_("number of sheets (default=1)"), N_("sheets")}, - {"copies", 'c', POPT_ARG_INT, &n_copies, 0, + {"copies", 'c', 0, G_OPTION_ARG_INT, &n_copies, N_("number of copies (default=1)"), N_("copies")}, - {"first", 'f', POPT_ARG_INT, &first, 0, + {"first", 'f', 0, G_OPTION_ARG_INT, &first, N_("first label on first sheet (default=1)"), N_("first")}, - {"outline", 'l', POPT_ARG_NONE, &outline_flag, 0, + {"outline", 'l', 0, G_OPTION_ARG_NONE, &outline_flag, N_("print outlines (to test printer alignment)"), NULL}, - {"reverse", 'r', POPT_ARG_NONE, &reverse_flag, 0, + {"reverse", 'r', 0, G_OPTION_ARG_NONE, &reverse_flag, N_("print in reverse (i.e. a mirror image)"), NULL}, - {"cropmarks", 'C', POPT_ARG_NONE, &crop_marks_flag, 0, + {"cropmarks", 'C', 0, G_OPTION_ARG_NONE, &crop_marks_flag, N_("print crop marks"), NULL}, - {"input", 'i', POPT_ARG_STRING, &input, 0, + {"input", 'i', 0, G_OPTION_ARG_STRING, &input, N_("input file for merging"), N_("filename")}, - {NULL, '\0', 0, NULL, 0, NULL, NULL} + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, + &remaining_args, NULL, N_("[FILE...]") }, + { NULL } }; @@ -82,54 +81,45 @@ static struct poptOption options[] = { int main (int argc, char **argv) { + GOptionContext *option_context; GnomeProgram *program; - poptContext pctx; - gchar **args; gint rc; - GSList *p, *file_list = NULL; - gint n_files; + GList *p, *file_list = NULL; gchar *abs_fn; glLabel *label = NULL; glMerge *merge = NULL; glXMLLabelStatus status; glPrintOp *print_op; + gchar *utf8_filename; bindtextdomain (GETTEXT_PACKAGE, GLABELS_LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); + option_context = g_option_context_new (_("- batch process gLabels label files")); + g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE); + + /* Initialize minimal gnome program */ program = gnome_program_init ("glabels-batch", VERSION, - LIBGNOME_MODULE, 1, argv, + LIBGNOME_MODULE, argc, argv, + GNOME_PARAM_GOPTION_CONTEXT, option_context, GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); - /* argument parsing */ - pctx = poptGetContext (NULL, argc, (const char **)argv, options, 0); - poptSetOtherOptionHelp (pctx, _("[OPTION...] GLABELS_FILE...") ); - if ( (rc = poptGetNextOpt(pctx)) < -1 ) { - fprintf (stderr, "%s: %s\n", - poptBadOption (pctx,0), poptStrerror(rc)); - poptPrintUsage (pctx, stderr, 0); - return -1; - } - if ( version_flag ) { - fprintf ( stderr, "glabels-batch %s\n", VERSION ); - return -1; - } - if ( help_flag ) { - poptPrintHelp (pctx, stderr, 0); - return -1; - } - args = (char **) poptGetArgs (pctx); - for (n_files = 0; args && args[n_files]; n_files++) { - file_list = g_slist_append (file_list, args[n_files]); - } - if ( !n_files ) { - fprintf ( stderr, _("missing glabels file\n") ); - poptPrintHelp (pctx, stderr, 0); - return -1; - } - poptFreeContext (pctx); + /* create file list */ + if (remaining_args != NULL) { + gint i, num_args; + + num_args = g_strv_length (remaining_args); + for (i = 0; i < num_args; ++i) { + utf8_filename = g_filename_to_utf8 (remaining_args[i], -1, NULL, NULL, NULL); + if (utf8_filename) + file_list = g_list_append (file_list, utf8_filename); + } + g_strfreev (remaining_args); + remaining_args = NULL; + } /* initialize components */ gl_debug_init (); @@ -179,7 +169,7 @@ main (int argc, char **argv) } } - g_slist_free (file_list); + g_list_free (file_list); return 0; } diff --git a/glabels2/src/glabels.c b/glabels2/src/glabels.c index b8583f36..40a69739 100644 --- a/glabels2/src/glabels.c +++ b/glabels2/src/glabels.c @@ -44,7 +44,6 @@ /*========================================================*/ /* Private macros and constants. */ /*========================================================*/ -#define ICON_PIXMAP_FILE "glabels.png" /*========================================================*/ /* Private globals */ @@ -70,24 +69,33 @@ void client_die_cb (GnomeClient *client, int main (int argc, char **argv) { - GValue value = { 0, }; - GnomeProgram *program; - gchar *icon_file; - GnomeClient *client; - poptContext ctx; - char **args; - GList *file_list = NULL, *p; - gint i; - GtkWidget *win; - gchar *utf8_filename; + gchar **remaining_args = NULL; + GOptionEntry option_entries[] = { + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, + &remaining_args, NULL, N_("[FILE...]") }, + { NULL } + }; + + GOptionContext *option_context; + GnomeProgram *program; + gchar *icon_file; + GnomeClient *client; + GList *file_list = NULL, *p; + GtkWidget *win; + gchar *utf8_filename; bindtextdomain (GETTEXT_PACKAGE, GLABELS_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); + option_context = g_option_context_new (_("- gLabels label designer")); + g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE); + + /* Initialize gnome program */ program = gnome_program_init ("glabels", VERSION, LIBGNOMEUI_MODULE, argc, argv, + GNOME_PARAM_GOPTION_CONTEXT, option_context, GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); @@ -95,21 +103,17 @@ main (int argc, char **argv) gl_critical_error_handler_init(); gl_warning_handler_init(); - /* Splash screen */ - gl_splash (); - /* Set default icon */ - icon_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP, - ICON_PIXMAP_FILE, FALSE, NULL); + icon_file = GLABELS_ICON_DIR "glabels.png"; if (!g_file_test (icon_file, G_FILE_TEST_EXISTS)) { - g_message ("Could not find %s", ICON_PIXMAP_FILE); + g_message ("Could not find %s", icon_file); } else { gnome_window_icon_set_default_from_file (icon_file); } - g_free (icon_file); + /* Initialize subsystems */ gl_debug_init (); @@ -120,6 +124,7 @@ main (int argc, char **argv) gl_merge_init (); gl_recent_init (); + client = gnome_master_client(); g_signal_connect (G_OBJECT (client), "save_yourself", @@ -129,20 +134,22 @@ main (int argc, char **argv) g_signal_connect (G_OBJECT (client), "die", G_CALLBACK (client_die_cb), NULL); + /* Parse args and build the list of files to be loaded at startup */ - g_value_init (&value, G_TYPE_POINTER); - g_object_get_property (G_OBJECT (program), - GNOME_PARAM_POPT_CONTEXT, &value); - ctx = g_value_get_pointer (&value); - g_value_unset (&value); - args = (char**) poptGetArgs(ctx); - for (i = 0; args && args[i]; i++) - { - utf8_filename = g_filename_to_utf8 (args[i], -1, NULL, NULL, NULL); - if (utf8_filename) - file_list = g_list_append (file_list, utf8_filename); + if (remaining_args != NULL) { + gint i, num_args; + + num_args = g_strv_length (remaining_args); + for (i = 0; i < num_args; ++i) { + utf8_filename = g_filename_to_utf8 (remaining_args[i], -1, NULL, NULL, NULL); + if (utf8_filename) + file_list = g_list_append (file_list, utf8_filename); + } + g_strfreev (remaining_args); + remaining_args = NULL; } + /* Open files or create empty top-level window. */ for (p = file_list; p; p = p->next) { win = gl_window_new_from_file (p->data); diff --git a/glabels2/src/object-editor-shadow-page.c b/glabels2/src/object-editor-shadow-page.c index 338ca0be..a2fce7c3 100644 --- a/glabels2/src/object-editor-shadow-page.c +++ b/glabels2/src/object-editor-shadow-page.c @@ -169,8 +169,8 @@ gl_object_editor_set_shadow_state (glObjectEditor *editor, shadow_enable_check_toggled_cb, editor); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (editor->priv->shadow_enable_check), - state); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->shadow_enable_check), + state); gtk_widget_set_sensitive (editor->priv->shadow_controls_table, state); g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->shadow_enable_check), diff --git a/glabels2/src/splash.c b/glabels2/src/splash.c deleted file mode 100644 index a47fbfc5..00000000 --- a/glabels2/src/splash.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * splash.c: Splash screen module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "splash.h" - -#include -#include -#include -#include -#include -#include -#include - -#define SPLASH_PIXMAP_FILE "glabels/glabels-splash.png" - -#define SPLASH_TIMEOUT 2000 - -static GtkWidget *splash = NULL; - -static gint splash_timeout (gpointer not_used); - - -/***************************************************************************/ -/* Create splash screen. */ -/***************************************************************************/ -void -gl_splash (void) -{ - gchar *splash_pixmap_file; - GtkWidget *wimage, *wvbox, *wframe1, *wframe2; - gchar *label; - GdkPixbuf *pixbuf; - GError *gerror = NULL; - - if (splash) - return; - - splash = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_position (GTK_WINDOW (splash), GTK_WIN_POS_CENTER); - - wframe1 = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (wframe1), GTK_SHADOW_OUT); - wframe2 = gtk_frame_new (NULL); - - wvbox = gtk_vbox_new (FALSE, 5); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 2); - - splash_pixmap_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP, - SPLASH_PIXMAP_FILE, - FALSE, NULL); - - if (!g_file_test (splash_pixmap_file, G_FILE_TEST_EXISTS)) { - g_message ("Could not find %s", SPLASH_PIXMAP_FILE); - } - pixbuf = gdk_pixbuf_new_from_file (splash_pixmap_file, &gerror); - if (gerror != NULL) { - g_message ("cannot open splash pixbuf: %s", gerror->message ); - gtk_widget_destroy (splash); - return; - } - g_free (splash_pixmap_file); - wimage = gtk_image_new_from_pixbuf (pixbuf); - g_object_unref (G_OBJECT (pixbuf)); - - gtk_container_add (GTK_CONTAINER (splash), wframe1); - gtk_container_add (GTK_CONTAINER (wframe1), wframe2); - gtk_container_add (GTK_CONTAINER (wframe2), wvbox); - - gtk_box_pack_start (GTK_BOX (wvbox), wimage, TRUE, TRUE, 0); - - label = g_strdup_printf ("Version %s", VERSION); - gtk_box_pack_start (GTK_BOX (wvbox), - gtk_label_new (label), TRUE, TRUE, 0); - g_free (label); - - gtk_widget_show_all (splash); - - gtk_timeout_add (SPLASH_TIMEOUT, splash_timeout, NULL); - - while (gtk_events_pending ()) { - gtk_main_iteration (); - } -} - -/*-------------------------------------------------------------------------*/ -/* PRIVATE. Callback to tear-down splash screen once timer has expired. */ -/*-------------------------------------------------------------------------*/ -static gint -splash_timeout (gpointer not_used) -{ - if (splash) { - gtk_widget_destroy (splash); - splash = NULL; - } - - return FALSE; -} - diff --git a/glabels2/src/splash.h b/glabels2/src/splash.h deleted file mode 100644 index 70128aed..00000000 --- a/glabels2/src/splash.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * splash.c: Splash screen module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __SPLASH_H__ -#define __SPLASH_H__ - -#include - -G_BEGIN_DECLS - -void gl_splash (void); - -G_END_DECLS - -#endif diff --git a/glabels2/src/template-designer.c b/glabels2/src/template-designer.c index 399ac1ed..74f60f44 100644 --- a/glabels2/src/template-designer.c +++ b/glabels2/src/template-designer.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -46,35 +45,13 @@ /*========================================================*/ /* Private macros and constants. */ /*========================================================*/ -#define ICON_PIXMAP gnome_program_locate_file (NULL,\ - GNOME_FILE_DOMAIN_APP_PIXMAP,\ - "glabels.png",\ - FALSE, NULL) - -#define EX_RECT_IMAGE gnome_program_locate_file (NULL,\ - GNOME_FILE_DOMAIN_APP_PIXMAP,\ - "glabels/ex-rect-size.png",\ - FALSE, NULL) - -#define EX_ROUND_IMAGE gnome_program_locate_file (NULL,\ - GNOME_FILE_DOMAIN_APP_PIXMAP,\ - "glabels/ex-round-size.png",\ - FALSE, NULL) - -#define EX_CD_IMAGE gnome_program_locate_file (NULL,\ - GNOME_FILE_DOMAIN_APP_PIXMAP,\ - "glabels/ex-cd-size.png",\ - FALSE, NULL) - -#define EX_NLAYOUTS_IMAGE1 gnome_program_locate_file (NULL,\ - GNOME_FILE_DOMAIN_APP_PIXMAP,\ - "glabels/ex-1layout.png",\ - FALSE, NULL) - -#define EX_NLAYOUTS_IMAGE2 gnome_program_locate_file (NULL,\ - GNOME_FILE_DOMAIN_APP_PIXMAP,\ - "glabels/ex-2layouts.png",\ - FALSE, NULL) +#define ICON_PIXMAP (GLABELS_ICON_DIR "glabels.png") + +#define EX_RECT_IMAGE (GLABELS_PIXMAP_DIR "ex-rect-size.png") +#define EX_ROUND_IMAGE (GLABELS_PIXMAP_DIR "ex-round-size.png") +#define EX_CD_IMAGE (GLABELS_PIXMAP_DIR "ex-cd-size.png") +#define EX_NLAYOUTS_IMAGE1 (GLABELS_PIXMAP_DIR "ex-1layout.png") +#define EX_NLAYOUTS_IMAGE2 (GLABELS_PIXMAP_DIR "ex-2layouts.png") #define DEFAULT_MARGIN 9.0 diff --git a/glabels2/src/ui-commands.c b/glabels2/src/ui-commands.c index 72283735..d3884ec1 100644 --- a/glabels2/src/ui-commands.c +++ b/glabels2/src/ui-commands.c @@ -30,7 +30,6 @@ #include #include #include -#include #include "view.h" #include "file.h" @@ -41,10 +40,6 @@ #include "recent.h" #include "debug.h" -#define LOGO_PIXMAP gnome_program_locate_file (NULL,\ - GNOME_FILE_DOMAIN_APP_PIXMAP,\ - "glabels/glabels-about-logo.png",\ - FALSE, NULL) /****************************************************************************/ @@ -1061,21 +1056,6 @@ gl_ui_cmd_help_contents (GtkAction *action, gl_debug (DEBUG_COMMANDS, "END"); } -/*--------------------------------------------------------------------------*/ -/** Private: URL handler. */ -/*--------------------------------------------------------------------------*/ -static void -activate_url (GtkAboutDialog *about, - const gchar *url, - gpointer data) -{ - gl_debug (DEBUG_COMMANDS, "START"); - - gnome_url_show (url, NULL); - - gl_debug (DEBUG_COMMANDS, "END"); -} - /****************************************************************************/ /** Help/About command. */ @@ -1140,9 +1120,7 @@ gl_ui_cmd_help_about (GtkAction *action, } else { - pixbuf = gdk_pixbuf_new_from_file ( LOGO_PIXMAP, NULL); - - gtk_about_dialog_set_url_hook (activate_url, NULL, NULL); + pixbuf = gdk_pixbuf_new_from_file (GLABELS_PIXMAP_DIR "glabels-splash.png", NULL); about = gtk_about_dialog_new (); gtk_about_dialog_set_name (GTK_ABOUT_DIALOG(about), _("glabels"));