Lauris Kaplinski <lauris@helixcode.com>
-I borrowed quite a bit of code from gedit2 to create the bonobo-mdi shell for
-gLabels. The authors of gedit2:
-
- Paolo Maggi <maggi@athena.polito.it>
- Chema Celorio <chema@ximian.com>
- James Willcox <jwillcox@cs.indiana.edu>
- Federico Mena Quintero <federico@ximian.com>
-
-
Translations:
Olivier Berger <oberger@april.org> -- French
Marcus Bauer <m@7n7.de> -- German (original)
- Christian Neumair <christian-neumair@web.de> -- German
+ Christian Neumair <christian-neumair@web.de> -- German (1.89.1)
Takeshi AIHANA <aihana@gnome.gr.jp> -- Japanese
Paulo Rogério Ormenese <pormenese@uol.com.br> -- Brazilian Portuguese
Víctor Moral <victor@pasmao.net> -- Spanish translations
Basically the goal of version 1.90 is to port all current
features/capabilities to the GNOME 2.0 platform, clean up the architecture,
-and create a bonobo-mdi shell.
+and create a bonobo shell.
The goal for version 1.92 is to improve several user interface capabilities
and add drawing capabilities.
set, add tools for creating and downloading new templates, and add inline
images to glabels files.
-The goals for version 2.2 and beyond is to add sophisticated text effects
-and support vector images.
+The goals for version 2.2 and beyond is to add rich text objects,
+add sophisticated text effects and support vector images.
Detailed Outline:
- Port to Gnome 2.0 Platform
- - Create a new MDI shell based on bonoboMDI (see gedit2).
+ - Create a new SDI shell based on bonobo (no more MDI!).
- Migrate to a more faithful MVC architecture:
- Migrate models (labels, label objects, and templates)
Other:
- Add preferences options:
- - MDI style [*]
- object defaults (colors, line widths, fonts)
- [*] These only need to be supported through gconf.
-
-
- Support all paper sizes that gnome-print knows about
- Recent documents
- support for the import of vector graphics formats such as EPS or SVG.
+ - Make text items rich. I.e. allow multiple characteristics to
+ exist within a single object.
+
- Text effects. (follow contour, shadows, ...)
part of the underlying print system but is currently difficult to
accomplish, so I may want to add the hack.
- - Make text items rich. I.e. allow multiple characteristics to
- exist within a single object.
-
- Add a mini style preview for barcode properties (possibly text too?).
- Eye candy: Create a custom widget to replace spin buttons for
src/glabels-batch.c
src/splash.c
src/splash.h
-src/mdi.c
-src/mdi.h
-src/mdi-child.c
-src/mdi-child.h
+src/window.c
+src/window.h
src/stock.c
src/stock.h
src/ui.h
src/color.h
src/canvas-hacktext.c
src/canvas-hacktext.h
-src/bonobo-mdi-child.c
-src/bonobo-mdi-child.h
-src/bonobo-mdi.c
-src/bonobo-mdi.h
src/gnome-recent-model.c
src/gnome-recent-model.h
src/gnome-recent-util.c
glabels_SOURCES = \
glabels.c \
- glabels.h \
splash.c \
splash.h \
- mdi.c \
- mdi.h \
- mdi-child.c \
- mdi-child.h \
+ window.c \
+ window.h \
stock.c \
stock.h \
ui.h \
color.h \
canvas-hacktext.c \
canvas-hacktext.h \
- bonobo-mdi-child.c \
- bonobo-mdi-child.h \
- bonobo-mdi.c \
- bonobo-mdi.h \
gnome-recent-model.c \
gnome-recent-model.h \
gnome-recent-util.c \
+++ /dev/null
-/*
- * bonobo-mdi-child.c - implementation of a BonoboMDI object
- *
- * Copyright (C) 2001-2002 Free Software Foundation
- *
- * 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.
- *
- * Author: Paolo Maggi
- */
-
-#include "bonobo-mdi-child.h"
-
-struct _BonoboMDIChildPrivate
-{
- GObject *parent;
-
- gchar *name;
- GList *views;
-};
-
-enum {
- NAME_CHANGED,
- LAST_SIGNAL
-};
-
-static void bonobo_mdi_child_class_init (BonoboMDIChildClass *klass);
-static void bonobo_mdi_child_instance_init (BonoboMDIChild *);
-static void bonobo_mdi_child_finalize (GObject *);
-
-static GtkWidget *bonobo_mdi_child_set_label (BonoboMDIChild *, GtkWidget *, gpointer);
-static GtkWidget *bonobo_mdi_child_create_view (BonoboMDIChild *);
-
-static void bonobo_mdi_child_real_name_changed (BonoboMDIChild *child, gchar* old_name);
-
-static GObjectClass *parent_class = NULL;
-static guint mdi_child_signals [LAST_SIGNAL] = { 0 };
-
-GType
-bonobo_mdi_child_get_type (void)
-{
- static GType bonobo_mdi_child_type = 0;
-
- if (bonobo_mdi_child_type == 0)
- {
- static const GTypeInfo our_info =
- {
- sizeof (BonoboMDIChildClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) bonobo_mdi_child_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (BonoboMDIChild),
- 0, /* n_preallocs */
- (GInstanceInitFunc) bonobo_mdi_child_instance_init
- };
-
- bonobo_mdi_child_type = g_type_register_static (G_TYPE_OBJECT,
- "BonoboMDIChild",
- &our_info,
- 0);
- }
-
- return bonobo_mdi_child_type;
-}
-
-static void
-bonobo_mdi_child_class_init (BonoboMDIChildClass *klass)
-{
- GObjectClass *gobject_class;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class = (GObjectClass*)klass;
-
- gobject_class->finalize = bonobo_mdi_child_finalize;
-
- klass->create_view = NULL;
- klass->get_config_string = NULL;
- klass->set_label = bonobo_mdi_child_set_label;
-
- klass->name_changed = bonobo_mdi_child_real_name_changed;
-
- mdi_child_signals[NAME_CHANGED] =
- g_signal_new ("name_changed",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (BonoboMDIChildClass, name_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
-}
-
-static void
-bonobo_mdi_child_instance_init (BonoboMDIChild *mdi_child)
-{
- g_return_if_fail (BONOBO_IS_MDI_CHILD (mdi_child));
-
- mdi_child->priv = g_new0 (BonoboMDIChildPrivate, 1);
-
- mdi_child->priv->name = NULL;
- mdi_child->priv->parent = NULL;
- mdi_child->priv->views = NULL;
-}
-
-
-/* the default set_label function: returns a GtkLabel with child->priv->name
- * if you provide your own, it should return a new widget if its old_label
- * parameter is NULL and modify and return the old widget otherwise. it
- * should (obviously) NOT call the parent class handler!
- */
-static GtkWidget *
-bonobo_mdi_child_set_label (BonoboMDIChild *child, GtkWidget *old_label, gpointer data)
-{
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), NULL);
- g_return_val_if_fail (child->priv != NULL, NULL);
-
- if (old_label != NULL)
- {
- gtk_label_set_text (GTK_LABEL (old_label), child->priv->name);
- return old_label;
- }
- else
- {
- GtkWidget *label;
-
- label = gtk_label_new (child->priv->name);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-
- return label;
- }
-}
-
-static void
-bonobo_mdi_child_finalize (GObject *obj)
-{
- BonoboMDIChild *mdi_child;
-
- g_return_if_fail (BONOBO_IS_MDI_CHILD (obj));
-
- mdi_child = BONOBO_MDI_CHILD (obj);
- g_return_if_fail (mdi_child->priv != NULL);
-
- while (mdi_child->priv->views)
- bonobo_mdi_child_remove_view (mdi_child,
- GTK_WIDGET (mdi_child->priv->views->data));
-
- if (mdi_child->priv->name != NULL)
- g_free (mdi_child->priv->name);
-
- if (mdi_child->priv != NULL)
- g_free (mdi_child->priv);
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize)(obj);
-}
-
-/**
- * bonobo_mdi_child_add_view:
- * @mdi_child: A pointer to a BonoboMDIChild object.
- *
- * Description:
- * Creates a new view of a child (a GtkWidget) adds it to the list
- * of the views and returns a pointer to it. Virtual function
- * that has to be specified for classes derived from BonoboMDIChild
- * is used to create the new view.
- *
- * Return value:
- * A pointer to the new view.
- **/
-GtkWidget *
-bonobo_mdi_child_add_view (BonoboMDIChild *mdi_child)
-{
- GtkWidget *view = NULL;
-
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (mdi_child), NULL);
- g_return_val_if_fail (mdi_child->priv != NULL, NULL);
-
- view = bonobo_mdi_child_create_view (mdi_child);
-
- if (view) {
- mdi_child->priv->views = g_list_append (mdi_child->priv->views, view);
-
- g_object_set_data (G_OBJECT (view), "BonoboMDIChild", mdi_child);
- }
-
- return view;
-}
-
-/**
- * bonobo_mdi_child_remove_view:
- * @mdi_child: A pointer to a BonoboMDIChild object.
- * @view: View to be removed.
- *
- * Description:
- * Removes view @view from the list of @mdi_child's views and
- * unrefs it.
- **/
-void
-bonobo_mdi_child_remove_view (BonoboMDIChild *mdi_child, GtkWidget *view)
-{
- g_return_if_fail (BONOBO_IS_MDI_CHILD (mdi_child));
- g_return_if_fail (mdi_child->priv != NULL);
- g_return_if_fail (GTK_IS_WIDGET (view));
-
- mdi_child->priv->views = g_list_remove (mdi_child->priv->views, view);
-
- g_object_unref (G_OBJECT (view));
-}
-
-/**
- * bonobo_mdi_child_set_name:
- * @mdi_child: A pointer to a BonoboMDIChild object.
- * @name: String containing the new name for the child.
- *
- * Description:
- * Changes name of @mdi_child to @name. @name is duplicated and stored
- * in @mdi_child. If @mdi_child has already been added to BonoboMDI,
- * it also takes care of updating it.
- **/
-void
-bonobo_mdi_child_set_name (BonoboMDIChild *mdi_child, const gchar *name)
-{
- gchar *old_name;
-
- g_return_if_fail (BONOBO_IS_MDI_CHILD (mdi_child));
- g_return_if_fail (mdi_child->priv != NULL);
-
- old_name = mdi_child->priv->name;
-
- if (old_name == name)
- return;
-
- mdi_child->priv->name = (gchar *)g_strdup (name);
-
- g_signal_emit (G_OBJECT (mdi_child),
- mdi_child_signals [NAME_CHANGED], 0,
- old_name);
-
- if (old_name)
- g_free (old_name);
-}
-
-static GtkWidget *
-bonobo_mdi_child_create_view (BonoboMDIChild *child)
-{
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), NULL);
-
- if (BONOBO_MDI_CHILD_GET_CLASS (child)->create_view)
- return BONOBO_MDI_CHILD_GET_CLASS (child)->create_view (child, NULL);
-
- return NULL;
-}
-
-static void
-bonobo_mdi_child_real_name_changed (BonoboMDIChild *child, gchar* old_name)
-{
- g_return_if_fail (BONOBO_IS_MDI_CHILD (child));
-
- return;
-}
-
-gchar *
-bonobo_mdi_child_get_name (const BonoboMDIChild *mdi_child)
-{
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (mdi_child), NULL);
- g_return_val_if_fail (mdi_child->priv != NULL, NULL);
-
- if (mdi_child->priv->name)
- return g_strdup (mdi_child->priv->name);
- else
- return NULL;
-}
-
-GList *
-bonobo_mdi_child_get_views (const BonoboMDIChild *mdi_child)
-{
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (mdi_child), NULL);
- g_return_val_if_fail (mdi_child->priv != NULL, NULL);
-
- return mdi_child->priv->views;
-}
-
-GObject *
-bonobo_mdi_child_get_parent (const BonoboMDIChild *mdi_child)
-{
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (mdi_child), NULL);
- g_return_val_if_fail (mdi_child->priv != NULL, NULL);
-
- return G_OBJECT (mdi_child->priv->parent);
-
-}
-
-void
-bonobo_mdi_child_set_parent (BonoboMDIChild *mdi_child, GObject *parent)
-{
- g_return_if_fail (BONOBO_IS_MDI_CHILD (mdi_child));
- g_return_if_fail (mdi_child->priv != NULL);
-
- mdi_child->priv->parent = parent;
-}
+++ /dev/null
-/*
- * bonobo-mdi-child.h - definition of a BonoboMDI object
- *
- * Copyright (C) 2001-2002 Free Software Foundation
- *
- * 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.
- *
- * Author: Paolo Maggi
- */
-
-#ifndef _BONOBO_MDI_CHILD_H_
-#define _BONOBO_MDI_CHILD_H_
-
-#include <gtk/gtk.h>
-#include <bonobo/bonobo-window.h>
-
-#define BONOBO_TYPE_MDI_CHILD (bonobo_mdi_child_get_type ())
-#define BONOBO_MDI_CHILD(obj) (GTK_CHECK_CAST ((obj), BONOBO_TYPE_MDI_CHILD, BonoboMDIChild))
-#define BONOBO_MDI_CHILD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), BONOBO_TYPE_MDI_CHILD, BonoboMDIChildClass))
-#define BONOBO_IS_MDI_CHILD(obj) (GTK_CHECK_TYPE ((obj), BONOBO_TYPE_MDI_CHILD))
-#define BONOBO_IS_MDI_CHILD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BONOBO_TYPE_MDI_CHILD))
-#define BONOBO_MDI_CHILD_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BONOBO_TYPE_MDI_CHILD, BonoboMDIChildClass))
-
-/* BonoboMDIChild
- * is an abstract class. In order to use it, you have to either derive a
- * new class from it and set the proper virtual functions in its parent
- * BonoboMDIChildClass structure or use the BonoboMDIGenericChild class
- * that allows to specify the relevant functions on a per-instance basis
- * and can directly be used with BonoboMDI.
- */
-
-typedef struct _BonoboMDIChildPrivate BonoboMDIChildPrivate;
-
-typedef struct
-{
- GObject object;
-
- BonoboMDIChildPrivate *priv;
-} BonoboMDIChild;
-
-
-typedef GtkWidget *(*BonoboMDIChildViewCreator) (BonoboMDIChild *, gpointer);
-typedef GList *(*BonoboMDIChildMenuCreator) (BonoboMDIChild *, GtkWidget *, gpointer);
-typedef gchar *(*BonoboMDIChildConfigFunc) (BonoboMDIChild *, gpointer);
-typedef GtkWidget *(*BonoboMDIChildLabelFunc) (BonoboMDIChild *, GtkWidget *, gpointer);
-
-/*
- * Note that if you override the set_label virtual function, it should return
- * a new widget if its GtkWidget* parameter is NULL and modify and return the
- * old widget otherwise.
- * (see bonobo-mdi-child.c/bonobo_mdi_child_set_book_label() for an example).
- */
-
-typedef struct
-{
- GObjectClass parent_class;
-
- /* Virtual functions */
- BonoboMDIChildViewCreator create_view;
- BonoboMDIChildConfigFunc get_config_string;
- BonoboMDIChildLabelFunc set_label;
-
- void (* name_changed) (BonoboMDIChild *mdi_child, gchar* old_name);
-
-} BonoboMDIChildClass;
-
-GType bonobo_mdi_child_get_type (void) G_GNUC_CONST;
-
-GtkWidget *bonobo_mdi_child_add_view (BonoboMDIChild *mdi_child);
-void bonobo_mdi_child_remove_view (BonoboMDIChild *mdi_child,
- GtkWidget *view);
-
-GList *bonobo_mdi_child_get_views (const BonoboMDIChild *mdi_child);
-
-void bonobo_mdi_child_set_name (BonoboMDIChild *mdi_child,
- const gchar *name);
-gchar *bonobo_mdi_child_get_name (const BonoboMDIChild *mdi_child);
-
-void bonobo_mdi_child_set_parent (BonoboMDIChild *mdi_child,
- GObject *parent);
-GObject *bonobo_mdi_child_get_parent (const BonoboMDIChild *mdi_child);
-
-G_END_DECLS
-
-#endif /* _BONOBO_MDI_CHILD_H_ */
-
-
-
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * bonobo-mdi.c - implementation of a BonoboMDI object
- *
- * Copyright (C) 2001-2002 Free Software Foundation
- *
- * 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.
- *
- * Author: Paolo Maggi
- */
-
-/*
- * Modified by the gedit Team, 2001-2002. See the AUTHORS file for a
- * list of people on the gedit Team.
- * See the ChangeLog files for a list of changes.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "bonobo-mdi.h"
-
-#include <bonobo/bonobo-i18n.h>
-#include <marshal.h>
-#include <bonobo/bonobo-dock-layout.h>
-#include <bonobo/bonobo-ui-util.h>
-
-#include "debug.h"
-
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#define BONOBO_MDI_KEY "BonoboMDI"
-#define BONOBO_MDI_CHILD_KEY "BonoboMDIChild"
-#define UI_COMPONENT_KEY "UIComponent"
-#define BOOK_KEY "Book"
-#define WINDOW_INFO_KEY "BonoboMDIWindowInfo"
-
-static void bonobo_mdi_class_init (BonoboMDIClass *);
-static void bonobo_mdi_instance_init (BonoboMDI *);
-static void bonobo_mdi_finalize (GObject *);
-static void child_list_menu_create (BonoboMDI *, BonoboWindow *);
-
-static void child_list_activated_cb (BonoboUIComponent *uic, gpointer user_data,
- const gchar* verbname);
-
-void child_list_menu_remove_item(BonoboMDI *, BonoboMDIChild *);
-void child_list_menu_add_item (BonoboMDI *, BonoboMDIChild *);
-
-static void app_create (BonoboMDI *, gchar *, const char *);
-static void app_clone (BonoboMDI *, BonoboWindow *, const char *);
-static void app_destroy (BonoboWindow *, BonoboMDI *);
-static void app_set_view (BonoboMDI *, BonoboWindow *, GtkWidget *);
-
-static gboolean app_close_book (BonoboWindow *, GdkEventAny *, BonoboMDI *);
-
-static GtkWidget *book_create (BonoboMDI *);
-static void book_switch_page (GtkNotebook *, GtkNotebookPage *,
- gint, BonoboMDI *);
-static gboolean book_motion (GtkWidget *widget, GdkEventMotion *e,
- gpointer data);
-static gboolean book_button_press (GtkWidget *widget, GdkEventButton *e,
- gpointer data);
-static gboolean book_button_release (GtkWidget *widget, GdkEventButton *e,
- gpointer data);
-static void book_add_view (GtkNotebook *, GtkWidget *);
-static void set_page_by_widget (GtkNotebook *, GtkWidget *);
-
-static gboolean toplevel_focus (BonoboWindow *, GdkEventFocus *, BonoboMDI *);
-
-static void set_active_view (BonoboMDI *, GtkWidget *);
-
-/* convenience functions that call child's "virtual" functions */
-static GtkWidget *child_set_label (BonoboMDIChild *, GtkWidget *);
-
-static void child_name_changed (BonoboMDIChild *mdi_child,
- gchar* old_name,
- BonoboMDI *mdi);
-static void bonobo_mdi_update_child (BonoboMDI *mdi, BonoboMDIChild *child);
-
-static gchar* escape_underscores (const gchar* text);
-
-static GtkWidget* get_book_from_window (BonoboWindow *window);
-
-static GdkCursor *drag_cursor = NULL;
-
-enum {
- ADD_CHILD,
- REMOVE_CHILD,
- ADD_VIEW,
- REMOVE_VIEW,
- CHILD_CHANGED,
- VIEW_CHANGED,
- TOP_WINDOW_CREATED,
- TOP_WINDOW_DESTROY,
- ALL_WINDOWS_DESTROYED,
- LAST_SIGNAL
-};
-
-
-struct _BonoboMDIPrivate
-{
- GtkPositionType tab_pos;
-
- guint signal_id;
- gint in_drag : 1;
-
- gchar *mdi_name;
- gchar *title;
-
- gchar *ui_xml;
- gchar *ui_file_name;
- BonoboUIVerb *verbs;
-
- /* Probably only one of these would do, but... redundancy rules ;) */
- BonoboMDIChild *active_child;
- GtkWidget *active_view;
- BonoboWindow *active_window;
-
- GList *windows; /* toplevel windows - BonoboWindow widgets */
- GList *children; /* children - BonoboMDIChild objects*/
-
- GSList *registered; /* see comment for bonobo_mdi_(un)register() functions
- * below for an explanation. */
-
- /* Paths for insertion of mdi-child list menu via */
- gchar *child_list_path;
-
- gint default_window_height;
- gint default_window_width;
-};
-
-typedef gboolean (*BonoboMDISignal1) (GObject *, gpointer, gpointer);
-typedef void (*BonoboMDISignal2) (GObject *, gpointer, gpointer);
-
-static GObjectClass *parent_class = NULL;
-static guint mdi_signals [LAST_SIGNAL] = { 0 };
-
-GType
-bonobo_mdi_get_type (void)
-{
- static GType bonobo_mdi_type = 0;
-
- if (bonobo_mdi_type == 0)
- {
- static const GTypeInfo our_info =
- {
- sizeof (BonoboMDIClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) bonobo_mdi_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (BonoboMDI),
- 0, /* n_preallocs */
- (GInstanceInitFunc) bonobo_mdi_instance_init
- };
-
- bonobo_mdi_type = g_type_register_static (G_TYPE_OBJECT,
- "BonoboMDI",
- &our_info,
- 0);
- }
-
- return bonobo_mdi_type;
-}
-
-static void
-bonobo_mdi_class_init (BonoboMDIClass *class)
-{
- GObjectClass *object_class;
-
- object_class = (GObjectClass*) class;
-
- object_class->finalize = bonobo_mdi_finalize;
-
- mdi_signals[ADD_CHILD] =
- g_signal_new ("add_child",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BonoboMDIClass, add_child),
- NULL, NULL,
- gl_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN,
- 1,
- BONOBO_TYPE_MDI_CHILD);
-
- mdi_signals[REMOVE_CHILD] =
- g_signal_new ("remove_child",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BonoboMDIClass, remove_child),
- NULL, NULL,
- gl_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN,
- 1,
- BONOBO_TYPE_MDI_CHILD);
-
- mdi_signals[ADD_VIEW] =
- g_signal_new ("add_view",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BonoboMDIClass, add_view),
- NULL, NULL,
- gl_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN,
- 1,
- GTK_TYPE_WIDGET);
-
- mdi_signals[REMOVE_VIEW] =
- g_signal_new ("remove_view",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BonoboMDIClass, remove_view),
- NULL, NULL,
- gl_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN,
- 1,
- GTK_TYPE_WIDGET);
-
- mdi_signals[CHILD_CHANGED] =
- g_signal_new ("child_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BonoboMDIClass, child_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- BONOBO_TYPE_MDI_CHILD);
-
- mdi_signals[VIEW_CHANGED] =
- g_signal_new ("view_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(BonoboMDIClass, view_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- GTK_TYPE_WIDGET);
-
- mdi_signals[TOP_WINDOW_CREATED] =
- g_signal_new ("top_window_created",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BonoboMDIClass, top_window_created),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- BONOBO_TYPE_WINDOW);
-
- mdi_signals[TOP_WINDOW_DESTROY] =
- g_signal_new ("top_window_destroy",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BonoboMDIClass, top_window_destroy),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- BONOBO_TYPE_WINDOW);
-
- mdi_signals[ALL_WINDOWS_DESTROYED] =
- g_signal_new ("all_windows_destroyed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BonoboMDIClass, all_windows_destroyed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
-
- class->add_child = NULL;
- class->remove_child = NULL;
- class->add_view = NULL;
- class->remove_view = NULL;
- class->child_changed = NULL;
- class->view_changed = NULL;
- class->top_window_created = NULL;
-
- parent_class = gtk_type_class (G_TYPE_OBJECT);
-}
-
-static void
-bonobo_mdi_finalize (GObject *object)
-{
- BonoboMDI *mdi;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_if_fail (BONOBO_IS_MDI (object));
-
- mdi = BONOBO_MDI (object);
- g_return_if_fail (mdi->priv != NULL);
-
- bonobo_mdi_remove_all (mdi, TRUE);
-
- if (mdi->priv->child_list_path != NULL)
- g_free (mdi->priv->child_list_path);
-
- if (mdi->priv->mdi_name != NULL)
- g_free (mdi->priv->mdi_name);
-
- if (mdi->priv->title != NULL)
- g_free (mdi->priv->title);
-
- if (mdi->priv->ui_xml != NULL)
- g_free (mdi->priv->ui_xml);
-
- if (mdi->priv->ui_file_name != NULL)
- g_free (mdi->priv->ui_file_name);
-
- g_free (mdi->priv);
- mdi->priv = NULL;
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize)(object);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-
-static void
-bonobo_mdi_instance_init (BonoboMDI *mdi)
-{
- gl_debug (DEBUG_MDI, "");
-
- g_return_if_fail (BONOBO_IS_MDI (mdi));
-
- mdi->priv = g_new0 (BonoboMDIPrivate, 1);
- g_return_if_fail (mdi->priv != NULL);
-
- mdi->priv->tab_pos = GTK_POS_TOP;
-
- mdi->priv->signal_id = 0;
- mdi->priv->in_drag = FALSE;
-
- mdi->priv->children = NULL;
- mdi->priv->windows = NULL;
- mdi->priv->registered = NULL;
-
- mdi->priv->active_child = NULL;
- mdi->priv->active_window = NULL;
- mdi->priv->active_view = NULL;
-
- mdi->priv->ui_xml = NULL;
- mdi->priv->ui_file_name = NULL;
- mdi->priv->verbs = NULL;
-
- mdi->priv->child_list_path = NULL;
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-
-/**
- * bonobo_mdi_new:
- * @mdi_name: Application name as used in filenames and paths.
- * @title: Title of the application windows.
- *
- * Description:
- * Creates a new MDI object. @mdi_name and @title are used for
- * MDI's calling bonobo_window_new ().
- *
- * Return value:
- * A pointer to a new BonoboMDI object.
- **/
-GObject*
-bonobo_mdi_new (const gchar *mdi_name, const gchar *title,
- gint default_window_width, gint default_window_height)
-{
- BonoboMDI *mdi;
-
- gl_debug (DEBUG_MDI, "");
-
- mdi = g_object_new (BONOBO_TYPE_MDI, NULL);
-
- mdi->priv->mdi_name = g_strdup (mdi_name);
- mdi->priv->title = g_strdup (title);
-
- mdi->priv->default_window_width = default_window_width;
- mdi->priv->default_window_height = default_window_height;
-
- gl_debug (DEBUG_MDI, "END");
-
- return G_OBJECT (mdi);
-}
-
-static GtkWidget *
-child_set_label (BonoboMDIChild *child, GtkWidget *label)
-{
- GtkWidget *w;
- w = BONOBO_MDI_CHILD_GET_CLASS (child)->set_label (child, label, NULL);
-
- return w;
-}
-
-static void
-set_page_by_widget (GtkNotebook *book, GtkWidget *view)
-{
- gint i;
-
- i = gtk_notebook_page_num (book, view);
-
- if (gtk_notebook_get_current_page (book) != i)
- gtk_notebook_set_current_page (book, i);
-}
-
-static void
-child_list_activated_cb (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname)
-{
- BonoboMDI* mdi;
- BonoboMDIChild *child = BONOBO_MDI_CHILD (user_data);
- g_return_if_fail (child != NULL);
-
- gl_debug (DEBUG_MDI, "");
-
- mdi = BONOBO_MDI (g_object_get_data (G_OBJECT (child), BONOBO_MDI_KEY));
- g_return_if_fail (mdi != NULL);
-
- if (child && (child != mdi->priv->active_child))
- {
- GList *views = bonobo_mdi_child_get_views (child);
-
- if (views)
- bonobo_mdi_set_active_view (mdi, views->data);
- else
- bonobo_mdi_add_view (mdi, child);
- }
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static gchar*
-escape_underscores (const gchar* text)
-{
- GString *str;
- gint length;
- const gchar *p;
- const gchar *end;
-
- g_return_val_if_fail (text != NULL, NULL);
-
- length = strlen (text);
-
- str = g_string_new ("");
-
- p = text;
- end = text + length;
-
- while (p != end)
- {
- const gchar *next;
- next = g_utf8_next_char (p);
-
- switch (*p)
- {
- case '_':
- g_string_append (str, "__");
- break;
- default:
- g_string_append_len (str, p, next - p);
- break;
- }
-
- p = next;
- }
-
- return g_string_free (str, FALSE);
-}
-
-static void
-child_list_menu_create (BonoboMDI *mdi, BonoboWindow *win)
-{
- GList *child;
- BonoboUIComponent *ui_component;
-
- if (mdi->priv->child_list_path == NULL)
- return;
-
- ui_component = BONOBO_UI_COMPONENT (
- g_object_get_data (G_OBJECT (win), UI_COMPONENT_KEY));
-
- child = mdi->priv->children;
-
- bonobo_ui_component_freeze (ui_component, NULL);
-
- while (child)
- {
- gchar *xml = NULL;
- gchar *cmd = NULL;
- gchar *verb_name = NULL;
- gchar *tip;
- gchar *escaped_name;
- gchar *safe_name;
- gchar *child_name = bonobo_mdi_child_get_name (BONOBO_MDI_CHILD (child->data));
-
- safe_name = g_markup_escape_text (child_name, strlen (child_name));
- g_return_if_fail (safe_name != NULL);
-
- escaped_name = escape_underscores (safe_name);
- g_return_if_fail (escaped_name != NULL);
-
- tip = g_strdup_printf (_("Activate %s"), safe_name);
- verb_name = g_strdup_printf ("Child_%p", child->data);
- xml = g_strdup_printf ("<menuitem name=\"%s\" verb=\"%s\""
- " _label=\"%s\"/>", verb_name, verb_name, escaped_name);
- cmd = g_strdup_printf ("<cmd name = \"%s\" _label=\"%s\""
- " _tip=\"%s\"/>", verb_name, escaped_name, tip);
-
- g_free (tip);
- g_free (child_name);
- g_free (safe_name);
- g_free (escaped_name);
-
- bonobo_ui_component_set_translate (ui_component, mdi->priv->child_list_path, xml, NULL);
- bonobo_ui_component_set_translate (ui_component, "/commands/", cmd, NULL);
- bonobo_ui_component_add_verb (ui_component, verb_name, child_list_activated_cb, child->data);
-
- g_free (xml);
- g_free (cmd);
- g_free (verb_name);
-
- child = g_list_next (child);
- }
-
- bonobo_ui_component_thaw (ui_component, NULL);
-}
-
-
-void
-child_list_menu_remove_item (BonoboMDI *mdi, BonoboMDIChild *child)
-{
- GList *win_node;
- gchar *path, *cmd, *verb_name;
-
- gl_debug (DEBUG_MDI, "");
-
- if(mdi->priv->child_list_path == NULL)
- return;
-
- win_node = mdi->priv->windows;
-
- verb_name = g_strdup_printf ("Child_%p", child);
- path = g_strdup_printf ("%s%s", mdi->priv->child_list_path, verb_name);
- cmd = g_strdup_printf ("/commands/%s", verb_name);
-
- while (win_node)
- {
- BonoboUIComponent *ui_component;
-
- ui_component = BONOBO_UI_COMPONENT (
- g_object_get_data (G_OBJECT (win_node->data), UI_COMPONENT_KEY));
-
- bonobo_ui_component_remove_verb (ui_component, verb_name);
- bonobo_ui_component_rm (ui_component, path, NULL);
- bonobo_ui_component_rm (ui_component, cmd, NULL);
- win_node = g_list_next (win_node);
- }
-
- g_free (path);
- g_free (cmd);
- g_free (verb_name);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-
-void
-child_list_menu_add_item (BonoboMDI *mdi, BonoboMDIChild *child)
-{
- GList *win_node;
- gchar *child_name, *escaped_name, *safe_name;
- gchar* xml, *cmd, *verb_name, *tip;
- int accel_num;
-
- if(mdi->priv->child_list_path == NULL)
- return;
-
- accel_num = g_list_length (mdi->priv->children);
-
- win_node = mdi->priv->windows;
-
- child_name = bonobo_mdi_child_get_name (child);
-
- safe_name = g_markup_escape_text (child_name, strlen (child_name));
- g_return_if_fail (safe_name != NULL);
-
- escaped_name = escape_underscores (safe_name);
- g_return_if_fail (escaped_name != NULL);
-
- verb_name = g_strdup_printf ("Child_%p", child);
-
- tip = g_strdup_printf (_("Activate %s"), safe_name);
- xml = g_strdup_printf ("<menuitem name=\"%s\" verb=\"%s\""
- " _label=\"%s\"/>", verb_name, verb_name, escaped_name);
-
- if (accel_num > 9)
- cmd = g_strdup_printf ("<cmd name = \"%s\" _label=\"%s\""
- " _tip=\"%s\"/>", verb_name, escaped_name, tip);
- else
- cmd = g_strdup_printf ("<cmd name = \"%s\" _label=\"%s\""
- " _tip=\"%s\" accel=\"*Alt*%d\"/>", verb_name,
- escaped_name, tip, accel_num);
-
-
- while (win_node)
- {
- BonoboUIComponent *ui_component;
-
- ui_component = BONOBO_UI_COMPONENT (
- g_object_get_data (G_OBJECT (win_node->data), UI_COMPONENT_KEY));
-
-
- bonobo_ui_component_set_translate (ui_component, mdi->priv->child_list_path, xml, NULL);
- bonobo_ui_component_set_translate (ui_component, "/commands/", cmd, NULL);
- bonobo_ui_component_add_verb (ui_component, verb_name, child_list_activated_cb, child);
-
- win_node = g_list_next (win_node);
- }
-
- g_free (tip);
- g_free (escaped_name);
- g_free (child_name);
- g_free (xml);
- g_free (cmd);
- g_free (verb_name);
- g_free (safe_name);
-}
-
-static gboolean
-book_motion (GtkWidget *widget, GdkEventMotion *e, gpointer data)
-{
- BonoboMDI *mdi;
-
- mdi = BONOBO_MDI (data);
-
- if (!drag_cursor)
- drag_cursor = gdk_cursor_new (GDK_HAND2);
-
- if (e->window == GTK_NOTEBOOK (widget)->event_window)
- {
- mdi->priv->in_drag = TRUE;
- gtk_grab_add (widget);
- gdk_pointer_grab (widget->window, FALSE,
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON_RELEASE_MASK, NULL,
- drag_cursor, GDK_CURRENT_TIME);
- if (mdi->priv->signal_id)
- {
- g_signal_handler_disconnect (G_OBJECT (widget),
- mdi->priv->signal_id);
- mdi->priv->signal_id = 0;
- }
- }
-
- return FALSE;
-}
-
-static gboolean
-book_button_press (GtkWidget *widget, GdkEventButton *e, gpointer data)
-{
- BonoboMDI *mdi;
-
- mdi = BONOBO_MDI (data);
-
- if ((e->button == 1) && (e->window == GTK_NOTEBOOK (widget)->event_window))
- mdi->priv->signal_id = g_signal_connect (
- G_OBJECT (widget),
- "motion_notify_event",
- G_CALLBACK (book_motion),
- mdi);
-
- return FALSE;
-}
-
-static gboolean
-book_button_release (GtkWidget *widget, GdkEventButton *e, gpointer data)
-{
- gint x = e->x_root, y = e->y_root;
- BonoboMDI *mdi;
-
- mdi = BONOBO_MDI(data);
-
- if (mdi->priv->signal_id)
- {
- g_signal_handler_disconnect (G_OBJECT (widget), mdi->priv->signal_id);
- mdi->priv->signal_id = 0;
- }
-
- if ((e->button == 1) && mdi->priv->in_drag)
- {
- GdkWindow *window;
- GList *child;
- BonoboWindow *win;
- GtkWidget *view, *new_book;
- GtkNotebook *old_book = GTK_NOTEBOOK (widget);
-
- mdi->priv->in_drag = FALSE;
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gtk_grab_remove (widget);
-
- window = gdk_window_at_pointer (&x, &y);
- if (window)
- window = gdk_window_get_toplevel (window);
-
- child = mdi->priv->windows;
-
- while (child)
- {
- if (window == GTK_WIDGET (child->data)->window)
- {
- int cur_page;
-
- /* page was dragged to another notebook */
-
- old_book = GTK_NOTEBOOK(widget);
- new_book = get_book_from_window (BONOBO_WINDOW (child->data));
-
- if (old_book == (GtkNotebook *) new_book)
- /* page has been dropped on the source notebook */
- return FALSE;
-
- cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (old_book));
-
- if (cur_page >= 0)
- {
- view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (old_book), cur_page);
- gtk_container_remove (GTK_CONTAINER(old_book), view);
-
- book_add_view (GTK_NOTEBOOK (new_book), view);
-
- win = bonobo_mdi_get_window_from_view (view);
- gdk_window_raise (GTK_WIDGET(win)->window);
-
- mdi->priv->active_window = win;
-
- cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (old_book));
-
- if (cur_page < 0)
- {
- mdi->priv->active_window = win;
- win = BONOBO_WINDOW (gtk_widget_get_toplevel (
- GTK_WIDGET (old_book)));
- mdi->priv->windows = g_list_remove(mdi->priv->windows, win);
- gtk_widget_destroy (GTK_WIDGET (win));
- }
-
- g_signal_emit (G_OBJECT (mdi),
- mdi_signals [CHILD_CHANGED],
- 0,
- NULL);
-
- g_signal_emit (G_OBJECT (mdi),
- mdi_signals [VIEW_CHANGED],
- 0,
- view);
- }
-
- return FALSE;
- }
-
- child = child->next;
- }
-
- if (g_list_length (old_book->children) == 1)
- return FALSE;
-
- /* create a new toplevel */
- if (old_book->cur_page)
- {
- gint width, height;
- int cur_page = gtk_notebook_get_current_page (old_book);
-
- view = gtk_notebook_get_nth_page (old_book, cur_page);
-
- win = bonobo_mdi_get_window_from_view (view);
-
- gtk_window_get_size (GTK_WINDOW (win), &width, &height);
-
- gtk_container_remove (GTK_CONTAINER (old_book), view);
-
- app_clone (mdi, win, NULL);
-
- new_book = book_create (mdi);
-
- book_add_view (GTK_NOTEBOOK (new_book), view);
-
- gtk_window_set_position (GTK_WINDOW (mdi->priv->active_window), GTK_WIN_POS_MOUSE);
-
- gtk_window_set_default_size (GTK_WINDOW (mdi->priv->active_window), width, height);
-
- if (!GTK_WIDGET_VISIBLE (mdi->priv->active_window))
- gtk_widget_show (GTK_WIDGET (mdi->priv->active_window));
- }
- }
-
- return FALSE;
-}
-
-static GtkWidget *
-book_create (BonoboMDI *mdi)
-{
- GtkWidget *us;
- GtkWidget *vbox;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (mdi->priv->active_window != NULL, NULL);
-
- vbox = gtk_vbox_new (FALSE, 0);
- us = gtk_notebook_new ();
-
- gtk_notebook_set_tab_pos (GTK_NOTEBOOK (us), mdi->priv->tab_pos);
-
- gtk_box_pack_start (GTK_BOX (vbox), us, TRUE, TRUE, 0);
-
- gtk_widget_show_all (vbox);
-
- bonobo_window_set_contents (mdi->priv->active_window, vbox);
- g_object_set_data (G_OBJECT (mdi->priv->active_window), BOOK_KEY, us);
-
- gtk_widget_add_events (us, GDK_BUTTON1_MOTION_MASK);
-
- g_signal_connect (G_OBJECT (us), "switch_page",
- G_CALLBACK (book_switch_page), mdi);
-
- g_signal_connect (G_OBJECT (us), "button_press_event",
- G_CALLBACK (book_button_press), mdi);
- g_signal_connect (G_OBJECT (us), "button_release_event",
- G_CALLBACK (book_button_release), mdi);
-
- gtk_notebook_set_scrollable (GTK_NOTEBOOK (us), TRUE);
-
- gl_debug (DEBUG_MDI, "END");
-
- return us;
-}
-
-static void
-book_add_view (GtkNotebook *book, GtkWidget *view)
-{
- BonoboMDIChild *child;
- GtkWidget *title;
-
- gl_debug (DEBUG_MDI, "");
-
- child = bonobo_mdi_get_child_from_view (view);
-
- title = child_set_label (child, NULL);
-
- gtk_notebook_append_page (book, view, title);
-
- if (g_list_length (book->children) > 1)
- set_page_by_widget (book, view);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static void
-book_switch_page (GtkNotebook *book, GtkNotebookPage *pg, gint page_num, BonoboMDI *mdi)
-{
- BonoboWindow *win;
- GtkWidget *page;
-
- gl_debug (DEBUG_MDI, "");
-
- win = BONOBO_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (book)));
-
- page = gtk_notebook_get_nth_page (book, page_num);
-
- if (page != NULL)
- {
- if (page != mdi->priv->active_view)
- app_set_view (mdi, win, page);
- }
- else
- app_set_view (mdi, win, NULL);
-
- gl_debug (DEBUG_MDI, "END");
-
-}
-
-static GtkWidget*
-get_book_from_window (BonoboWindow *window)
-{
- gpointer *book;
-
- g_return_val_if_fail (window != NULL, NULL);
-
- book = g_object_get_data (G_OBJECT (window), BOOK_KEY);
-
- return (book != NULL) ? GTK_WIDGET (book) : NULL;
-}
-
-static gboolean
-toplevel_focus (BonoboWindow *win, GdkEventFocus *event, BonoboMDI *mdi)
-{
- GtkWidget *contents;
-
- gl_debug (DEBUG_MDI, "");
-
- /* updates active_view and active_child when a new toplevel receives focus */
- g_return_val_if_fail (BONOBO_IS_WINDOW (win), FALSE);
-
- mdi->priv->active_window = win;
-
- contents = get_book_from_window (win);
-
- if (GTK_NOTEBOOK (contents)->cur_page)
- {
- int cur_page;
- GtkWidget *child;
-
- cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (contents));
- child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (contents), cur_page);
- set_active_view (mdi, child);
- }
- else
- set_active_view (mdi, NULL);
-
- gl_debug (DEBUG_MDI, "END");
-
- return FALSE;
-}
-
-static gboolean
-app_configure_event_handler (GtkWidget *widget, GdkEventConfigure *event)
-{
- BonoboMDIWindowInfo *window_info;
-
- g_return_val_if_fail (BONOBO_IS_WINDOW (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- window_info = (BonoboMDIWindowInfo*)
- g_object_get_data (G_OBJECT (widget), WINDOW_INFO_KEY);
- g_return_val_if_fail (window_info != NULL, FALSE);
-
- window_info->width = event->width;
- window_info->height = event->height;
-
- return FALSE;
-}
-
-static gboolean
-app_window_state_event_handler (GtkWidget *widget, GdkEventWindowState *event)
-{
- BonoboMDIWindowInfo *window_info;
-
- g_return_val_if_fail (BONOBO_IS_WINDOW (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- window_info = (BonoboMDIWindowInfo*)
- g_object_get_data (G_OBJECT (widget), WINDOW_INFO_KEY);
- g_return_val_if_fail (window_info != NULL, FALSE);
-
- window_info->state = event->new_window_state;
-
- return FALSE;
-}
-
-
-static void
-app_clone (BonoboMDI *mdi, BonoboWindow *win, const char *window_role)
-{
- gl_debug (DEBUG_MDI, "");
-
- app_create (mdi, NULL, window_role);
-
- if (win != NULL)
- {
- const BonoboMDIWindowInfo *window_info = bonobo_mdi_get_window_info (win);
- g_return_if_fail (window_info != NULL);
-
- if ((window_info->state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
- gtk_window_maximize (GTK_WINDOW (mdi->priv->active_window));
- else
- {
- gtk_window_set_default_size (GTK_WINDOW (mdi->priv->active_window),
- window_info->width,
- window_info->height);
-
- gtk_window_unmaximize (GTK_WINDOW (mdi->priv->active_window));
- }
-
- if ((window_info->state & GDK_WINDOW_STATE_STICKY ) != 0)
- gtk_window_stick (GTK_WINDOW (mdi->priv->active_window));
- else
- gtk_window_unstick (GTK_WINDOW (mdi->priv->active_window));
- }
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-
-static gboolean
-app_close_book (BonoboWindow *win, GdkEventAny *event, BonoboMDI *mdi)
-{
- BonoboMDIChild *child;
- GtkWidget *view;
- gint handler_ret = TRUE;
-
- gl_debug (DEBUG_MDI, "");
-
- if (g_list_length (mdi->priv->windows) == 1)
- {
- if (!bonobo_mdi_remove_all (mdi, FALSE))
- {
- gl_debug (DEBUG_MDI, "END1");
-
- return TRUE;
- }
-
- mdi->priv->windows = g_list_remove (mdi->priv->windows, win);
- gtk_widget_destroy (GTK_WIDGET (win));
-
- /* only emit al_windows_destroyed signal if there are no non-MDI windows registered
- with it. */
- if (mdi->priv->registered == NULL)
- g_signal_emit (G_OBJECT (mdi), mdi_signals [ALL_WINDOWS_DESTROYED], 0);
- }
- else
- {
- GList *children = gtk_container_get_children (
- GTK_CONTAINER (get_book_from_window (win)));
- GList *li;
-
- if (children == NULL)
- {
- mdi->priv->windows = g_list_remove (mdi->priv->windows, win);
- gtk_widget_destroy (GTK_WIDGET (win));
-
- gl_debug (DEBUG_MDI, "END2");
-
- return FALSE;
- }
-
- /* first check if all the children in this notebook can be removed */
- for (li = children; li != NULL; li = li->next)
- {
- GList *node;
- view = li->data;
-
- child = bonobo_mdi_get_child_from_view (view);
-
- node = bonobo_mdi_child_get_views (child);
-
- while (node)
- {
- if (bonobo_mdi_get_window_from_view (node->data) != win)
- break;
-
- node = node->next;
- }
-
- if (node == NULL)
- {
- /* all the views reside in this BonoboWindow */
- g_signal_emit (G_OBJECT(mdi),
- mdi_signals [REMOVE_CHILD],
- 0,
- child,
- &handler_ret);
-
- if (handler_ret == FALSE)
- {
- g_list_free (children);
-
- gl_debug (DEBUG_MDI, "END3");
-
- return TRUE;
- }
- }
- }
-
- /* now actually remove all children/views! */
- for (li = children; li != NULL; li = li->next)
- {
- view = li->data;
-
- child = bonobo_mdi_get_child_from_view (view);
-
- /* if this is the last view, remove the child */
- if (g_list_length (bonobo_mdi_child_get_views (child)) == 1)
- bonobo_mdi_remove_child (mdi, child, TRUE);
- else
- bonobo_mdi_remove_view (mdi, view, TRUE);
- }
-
- g_list_free (children);
- }
-
- gl_debug (DEBUG_MDI, "END");
-
- return FALSE;
-}
-
-static void
-app_set_view (BonoboMDI *mdi, BonoboWindow *win, GtkWidget *view)
-{
- gl_debug (DEBUG_MDI, "");
-
- gtk_window_set_title (GTK_WINDOW (win), mdi->priv->title);
-
- set_active_view (mdi, view);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static void
-app_destroy (BonoboWindow *win, BonoboMDI *mdi)
-{
- gl_debug (DEBUG_MDI, "");
-
- if (mdi->priv->active_window == win)
- mdi->priv->active_window =
- (mdi->priv->windows != NULL) ? BONOBO_WINDOW (mdi->priv->windows->data) : NULL;
-
- g_signal_emit (G_OBJECT (mdi), mdi_signals [TOP_WINDOW_DESTROY], 0, win);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-/* Generates a unique string for a window role.
- *
- * Taken from EOG.
- */
-static char *
-gen_role (void)
-{
- char *ret;
- static char *hostname;
- time_t t;
- static int serial;
-
- t = time (NULL);
-
- if (!hostname) {
- static char buffer [512];
-
- if ((gethostname (buffer, sizeof (buffer) - 1) == 0) &&
- (buffer [0] != 0))
- hostname = buffer;
- else
- hostname = "localhost";
- }
-
- ret = g_strdup_printf ("bonobo-mdi-window-%d-%d-%d-%ld-%d@%s",
- getpid (),
- getgid (),
- getppid (),
- (long) t,
- serial++,
- hostname);
-
- return ret;
-}
-
-static void
-app_create (BonoboMDI *mdi, gchar *layout_string, const char *window_role)
-{
- GtkWidget *window;
- BonoboWindow *bw;
- gchar* config_path;
- BonoboUIContainer *ui_container = NULL;
- BonoboUIComponent *ui_component = NULL;
- BonoboMDIWindowInfo *window_info = NULL;
-
- gl_debug (DEBUG_MDI, "");
-
- window = bonobo_window_new (mdi->priv->mdi_name, mdi->priv->title);
- g_return_if_fail (window != NULL);
-
- gtk_window_set_default_size (GTK_WINDOW (window),
- mdi->priv->default_window_width,
- mdi->priv->default_window_height);
-
- if (window_role)
- gtk_window_set_role (GTK_WINDOW (window), window_role);
- else {
- char *role;
-
- role = gen_role ();
- gtk_window_set_role (GTK_WINDOW (window), role);
- g_free (role);
- }
-
- bw = BONOBO_WINDOW (window);
-
- mdi->priv->windows = g_list_append (mdi->priv->windows, window);
-
- g_signal_connect (G_OBJECT (window), "delete_event",
- G_CALLBACK (app_close_book), mdi);
- g_signal_connect (G_OBJECT (window), "focus_in_event",
- G_CALLBACK (toplevel_focus), mdi);
- g_signal_connect (G_OBJECT (window), "destroy",
- G_CALLBACK (app_destroy), mdi);
- g_signal_connect (G_OBJECT (window), "configure_event",
- G_CALLBACK (app_configure_event_handler), NULL);
- g_signal_connect (G_OBJECT (window), "window_state_event",
- G_CALLBACK (app_window_state_event_handler), NULL);
-
- /* Create Container: */
- ui_container = bonobo_window_get_ui_container (bw);
-
- config_path = g_strdup_printf ("/%s/UIConfig/kvps", mdi->priv->mdi_name);
-
- bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (bw),
- config_path);
- g_free (config_path);
-
- /* Create a UI component with which to communicate with the window */
- ui_component = bonobo_ui_component_new_default ();
-
- /* Associate the BonoboUIComponent with the container */
- bonobo_ui_component_set_container (
- ui_component, BONOBO_OBJREF (ui_container), NULL);
-
- /* set up UI */
- if (mdi->priv->ui_xml != NULL)
- {
- bonobo_ui_component_set_translate (ui_component,
- "/", mdi->priv->ui_xml, NULL);
- }
- else
- if (mdi->priv->ui_file_name)
- {
- bonobo_ui_util_set_ui (ui_component, "", mdi->priv->ui_file_name,
- mdi->priv->mdi_name, NULL);
- }
-
- if (mdi->priv->verbs)
- bonobo_ui_component_add_verb_list_with_data (ui_component,
- mdi->priv->verbs, mdi);
-
- mdi->priv->active_window = bw;
- mdi->priv->active_child = NULL;
- mdi->priv->active_view = NULL;
-
- window_info = g_new0 (BonoboMDIWindowInfo, 1);
-
- g_object_set_data (G_OBJECT (bw), UI_COMPONENT_KEY, ui_component);
- g_object_set_data_full (G_OBJECT (bw), WINDOW_INFO_KEY, window_info, g_free);
-
- g_signal_emit (G_OBJECT (mdi), mdi_signals [TOP_WINDOW_CREATED], 0, window);
-
- child_list_menu_create (mdi, bw);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static void
-set_active_view (BonoboMDI *mdi, GtkWidget *view)
-{
- BonoboMDIChild *old_child;
- GtkWidget *old_view;
-
- gl_debug (DEBUG_MDI, "");
-
- old_child = mdi->priv->active_child;
- old_view = mdi->priv->active_view;
-
- mdi->priv->active_view = view;
-
- if (!view)
- mdi->priv->active_child = NULL;
- else
- {
-
- mdi->priv->active_child = bonobo_mdi_get_child_from_view (view);
- mdi->priv->active_window = bonobo_mdi_get_window_from_view (view);
-
- gtk_widget_grab_focus (GTK_WIDGET (view));
- }
-
- if (view == old_view)
- {
- gl_debug (DEBUG_MDI, "END1");
-
- return;
- }
-
- if (mdi->priv->active_child != old_child)
- {
- gl_debug (DEBUG_MDI, "Emit child_changed");
-
- g_signal_emit (G_OBJECT (mdi), mdi_signals [CHILD_CHANGED], 0, old_child);
- }
-
- gl_debug (DEBUG_MDI, "Emit view_changed");
-
- g_signal_emit (G_OBJECT (mdi), mdi_signals [VIEW_CHANGED], 0, old_view);
-
- gl_debug (DEBUG_MDI, "END2");
-}
-
-/**
- * bonobo_mdi_set_active_view:
- * @mdi: A pointer to an MDI object.
- * @view: A pointer to the view that is to become the active one.
- *
- * Description:
- * Sets the active view to @view. It also raises the window containing it
- * and gives it focus.
- **/
-void
-bonobo_mdi_set_active_view (BonoboMDI *mdi, GtkWidget *view)
-{
- GtkWindow *window;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_if_fail (mdi != NULL);
- g_return_if_fail (BONOBO_IS_MDI (mdi));
- g_return_if_fail (view != NULL);
- g_return_if_fail (GTK_IS_WIDGET (view));
-
- set_page_by_widget (GTK_NOTEBOOK (view->parent), view);
-
- window = GTK_WINDOW (bonobo_mdi_get_window_from_view (view));
-
- gtk_window_present (window);
-
- set_active_view (mdi, view);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-/**
- * bonobo_mdi_add_view:
- * @mdi: A pointer to a BonoboMDI object.
- * @child: A pointer to a child.
- *
- * Description:
- * Creates a new view of the child and adds it to the MDI. BonoboMDIChild
- * @child has to be added to the MDI with a call to bonobo_mdi_add_child
- * before its views are added to the MDI.
- * An "add_view" signal is emitted to the MDI after the view has been
- * created, but before it is shown and added to the MDI, with a pointer to
- * the created view as its parameter. The view is added to the MDI only if
- * the signal handler (if it exists) returns %TRUE. If the handler returns
- * %FALSE, the created view is destroyed and not added to the MDI.
- *
- * Return value:
- * %TRUE if adding the view succeeded and %FALSE otherwise.
- **/
-gboolean
-bonobo_mdi_add_view (BonoboMDI *mdi, BonoboMDIChild *child)
-{
- GtkWidget *view;
- GtkWidget *book;
- gint ret = TRUE;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (mdi != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE);
- g_return_val_if_fail (child != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), FALSE);
-
- view = bonobo_mdi_child_add_view (child);
-
- g_return_val_if_fail (view != NULL, FALSE);
-
- g_signal_emit (G_OBJECT (mdi), mdi_signals [ADD_VIEW], 0, view, &ret);
-
- if (!ret)
- {
- bonobo_mdi_child_remove_view (child, view);
-
- gl_debug (DEBUG_MDI, "END1");
-
- return FALSE;
- }
-
- if (mdi->priv->active_window == NULL)
- {
- app_create (mdi, NULL, NULL);
- gtk_widget_show (GTK_WIDGET (mdi->priv->active_window));
- }
-
-
- if (!GTK_WIDGET_VISIBLE (view))
- gtk_widget_show (view);
-
- book = get_book_from_window (mdi->priv->active_window);
-
- if (book == NULL)
- book = book_create (mdi);
-
- book_add_view (GTK_NOTEBOOK (book), view);
-
- /* this reference will compensate the view's unrefing
- when removed from its parent later, as we want it to
- stay valid until removed from the child with a call
- to bonobo_mdi_child_remove_view() */
- g_object_ref (G_OBJECT (view));
- gtk_object_sink (GTK_OBJECT (view));
-
- g_object_set_data (G_OBJECT (view), BONOBO_MDI_CHILD_KEY, child);
-
- gl_debug (DEBUG_MDI, "END2");
-
- return TRUE;
-}
-
-/**
- * bonobo_mdi_add_toplevel_view:
- * @mdi: A pointer to a BonoboMDI object.
- * @child: A pointer to a BonoboMDIChild object to be added to the MDI.
- * @window_role: X window role to use for the window, for session-management
- * purposes. If this is %NULL, a unique role string will be automatically
- * generated.
- *
- * Description:
- * Creates a new view of the child and adds it to the MDI; it behaves the
- * same way as bonobo_mdi_add_view in %BONOBO_MDI_MODAL and %BONOBO_MDI_TOPLEVEL
- * modes, but in %BONOBO_MDI_NOTEBOOK mode, the view is added in a new
- * toplevel window unless the active one has no views in it.
- *
- * Return value:
- * %TRUE if adding the view succeeded and %FALSE otherwise.
- **/
-gboolean
-bonobo_mdi_add_toplevel_view (BonoboMDI *mdi, BonoboMDIChild *child, const char *window_role)
-{
- GtkWidget *view;
- gint ret = TRUE;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (mdi != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE);
- g_return_val_if_fail (child != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), FALSE);
-
- view = bonobo_mdi_child_add_view (child);
-
- g_return_val_if_fail (view != NULL, FALSE);
-
- g_signal_emit (G_OBJECT (mdi), mdi_signals [ADD_VIEW], 0, view, &ret);
-
- if (ret == FALSE)
- {
- bonobo_mdi_child_remove_view (child, view);
-
- gl_debug (DEBUG_MDI, "END1");
-
- return FALSE;
- }
-
- bonobo_mdi_open_toplevel (mdi, window_role);
-
- if (!GTK_WIDGET_VISIBLE (view))
- gtk_widget_show (view);
-
- book_add_view (GTK_NOTEBOOK (get_book_from_window (mdi->priv->active_window)), view);
-
- /* this reference will compensate the view's unrefing
- when removed from its parent later, as we want it to
- stay valid until removed from the child with a call
- to bonobo_mdi_child_remove_view() */
- g_object_ref (G_OBJECT (view));
- gtk_object_sink (GTK_OBJECT (view));
-
- g_object_set_data (G_OBJECT (view), BONOBO_MDI_CHILD_KEY, child);
-
- gl_debug (DEBUG_MDI, "END2");
-
- return TRUE;
-}
-
-/**
- * bonobo_mdi_remove_view:
- * @mdi: A pointer to a BonoboMDI object.
- * @view: View to remove.
- * @force: If TRUE, the "remove_view" signal is not emitted.
- *
- * Description:
- * Removes a view from an MDI.
- * A "remove_view" signal is emitted to the MDI before actually removing
- * view. The view is removed only if the signal handler (if it exists and
- * the @force is set to %FALSE) returns %TRUE.
- *
- * Return value:
- * %TRUE if the view was removed and %FALSE otherwise.
- **/
-gboolean
-bonobo_mdi_remove_view (BonoboMDI *mdi, GtkWidget *view, gint force)
-{
- GtkWidget *book;
- BonoboWindow *window;
- BonoboMDIChild *child;
- gint ret = TRUE;
- gint pn;
- gboolean was_active_window = FALSE;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (mdi != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE);
- g_return_val_if_fail (view != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_WIDGET (view), FALSE);
-
- if (!force)
- g_signal_emit (G_OBJECT (mdi), mdi_signals [REMOVE_VIEW], 0, view, &ret);
-
- if (ret == FALSE)
- {
- gl_debug (DEBUG_MDI, "END1");
-
- return FALSE;
- }
-
- was_active_window = (view == mdi->priv->active_view);
-
- child = bonobo_mdi_get_child_from_view (view);
- window = bonobo_mdi_get_window_from_view (view);
-
- book = get_book_from_window (window);
- g_return_val_if_fail (book != NULL, TRUE);
-
- if (g_list_length (GTK_NOTEBOOK (book)->children) == 1)
- app_set_view (mdi, window, NULL);
-
- bonobo_mdi_child_remove_view (child, view);
-
- pn = gtk_notebook_page_num (GTK_NOTEBOOK (book), view);
- gtk_notebook_remove_page (GTK_NOTEBOOK (book), pn);
-
- if (GTK_NOTEBOOK (book)->cur_page == NULL)
- {
- if ((g_list_length (mdi->priv->windows) > 1) ||
- (mdi->priv->registered != NULL))
- {
- gl_debug (DEBUG_VIEW, "Destroy window");
-
- /* if this is NOT the last toplevel or a registered object
- exists, destroy the toplevel */
- mdi->priv->windows = g_list_remove (mdi->priv->windows, window);
- gtk_widget_destroy (GTK_WIDGET (window));
-
- if (mdi->priv->active_window && was_active_window)
- mdi->priv->active_view = bonobo_mdi_get_view_from_window (
- mdi,
- mdi->priv->active_window);
- }
- }
- else
- {
- pn = gtk_notebook_get_current_page (GTK_NOTEBOOK (book));
- app_set_view (mdi, window, gtk_notebook_get_nth_page (GTK_NOTEBOOK (book), pn));
- }
-
-
- gl_debug (DEBUG_MDI, "END2");
-
- return TRUE;
-}
-
-static void
-child_name_changed (BonoboMDIChild *mdi_child, gchar* old_name, BonoboMDI *mdi)
-{
- bonobo_mdi_update_child (mdi, mdi_child);
-}
-
-/**
- * bonobo_mdi_add_child:
- * @mdi: A pointer to a BonoboMDI object.
- * @child: A pointer to a BonoboMDIChild to add to the MDI.
- *
- * Description:
- * Adds a new child to the MDI. No views are added: this has to be done with
- * a call to bonobo_mdi_add_view.
- * First an "add_child" signal is emitted to the MDI with a pointer to the
- * child as its parameter. The child is added to the MDI only if the signal
- * handler (if it exists) returns %TRUE. If the handler returns %FALSE, the
- * child is not added to the MDI.
- *
- * Return value:
- * %TRUE if the child was added successfully and %FALSE otherwise.
- **/
-gint
-bonobo_mdi_add_child (BonoboMDI *mdi, BonoboMDIChild *child)
-{
- gint ret = TRUE;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (mdi != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE);
- g_return_val_if_fail (child != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), FALSE);
-
- g_signal_emit (G_OBJECT (mdi), mdi_signals [ADD_CHILD], 0, child, &ret);
-
- if (ret == FALSE)
- {
- gl_debug (DEBUG_MDI, "END1");
-
- return FALSE;
- }
-
- bonobo_mdi_child_set_parent (child, G_OBJECT (mdi));
-
- mdi->priv->children = g_list_append (mdi->priv->children, child);
-
- g_signal_connect (G_OBJECT (child), "name_changed",
- G_CALLBACK (child_name_changed), mdi);
-
- child_list_menu_add_item (mdi, child);
-
- g_object_set_data (G_OBJECT (child), BONOBO_MDI_KEY, mdi);
-
- gl_debug (DEBUG_MDI, "END2");
-
- return TRUE;
-}
-
-/**
- * bonobo_mdi_remove_child:
- * @mdi: A pointer to a BonoboMDI object.
- * @child: Child to remove.
- * @force: If TRUE, the "remove_child" signal is not emitted
- *
- * Description:
- * Removes a child and all of its views from the MDI.
- * A "remove_child" signal is emitted to the MDI with @child as its parameter
- * before actually removing the child. The child is removed only if the signal
- * handler (if it exists and the @force is set to %FALSE) returns %TRUE.
- *
- * Return value:
- * %TRUE if the removal was successful and %FALSE otherwise.
- **/
-gint
-bonobo_mdi_remove_child (BonoboMDI *mdi, BonoboMDIChild *child, gint force)
-{
- gint ret = TRUE;
- GList *view_node;
- GtkWidget *view;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (mdi != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE);
- g_return_val_if_fail (child != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), FALSE);
-
- /* if force is set to TRUE, don't call the remove_child handler (ie there is no way for the
- user to stop removal of the child) */
-
- if (!force)
- g_signal_emit (G_OBJECT (mdi), mdi_signals [REMOVE_CHILD], 0, child, &ret);
-
- if (ret == FALSE)
- {
- gl_debug (DEBUG_MDI, "END1");
-
- return FALSE;
- }
-
- view_node = bonobo_mdi_child_get_views (child);
-
- while (view_node)
- {
- view = GTK_WIDGET (view_node->data);
- view_node = view_node->next;
- bonobo_mdi_remove_view (mdi, GTK_WIDGET (view), TRUE);
- }
-
- mdi->priv->children = g_list_remove (mdi->priv->children, child);
-
- child_list_menu_remove_item (mdi, child);
-
- if (child == mdi->priv->active_child)
- mdi->priv->active_child = NULL;
-
- bonobo_mdi_child_set_parent (child, NULL);
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (child), G_CALLBACK (child_name_changed), mdi);
-
- g_object_unref (G_OBJECT (child));
-
- gl_debug (DEBUG_MDI, "END2");
-
- return TRUE;
-}
-
-/**
- * bonobo_mdi_remove_all:
- * @mdi: A pointer to a BonoboMDI object.
- * @force: If TRUE, the "remove_child" signal is not emitted
- *
- * Description:
- * Removes all children and all views from the MDI.
- * A "remove_child" signal is emitted to the MDI for each child before
- * actually trying to remove any. If signal handlers for all children (if
- * they exist and the @force is set to %FALSE) return %TRUE, all children
- * and their views are removed and none otherwise.
- *
- * Return value:
- * %TRUE if the removal was successful and %FALSE otherwise.
- **/
-gint
-bonobo_mdi_remove_all (BonoboMDI *mdi, gint force)
-{
- GList *child_node;
- gint handler_ret = TRUE;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (mdi != NULL, FALSE);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE);
-
- /* first check if removal of any child will be prevented by the
- remove_child signal handler */
- if (!force)
- {
- child_node = mdi->priv->children;
- while (child_node)
- {
- g_signal_emit (G_OBJECT (mdi),
- mdi_signals [REMOVE_CHILD],
- 0,
- child_node->data,
- &handler_ret);
-
- /* if any of the children may not be removed, none will be */
- if (handler_ret == FALSE)
- {
- gl_debug (DEBUG_MDI, "END1");
-
- return FALSE;
- }
-
- child_node = child_node->next;
- }
- }
-
- /* remove all the children with force arg set to true so that remove_child
- handlers are not called again */
- while (mdi->priv->children)
- bonobo_mdi_remove_child (mdi, BONOBO_MDI_CHILD (mdi->priv->children->data), TRUE);
-
- gl_debug (DEBUG_MDI, "END2");
-
- return TRUE;
-}
-
-/**
- * bonobo_mdi_open_toplevel:
- * @mdi: A pointer to a BonoboMDI object.
- * @window_role: X window role to use for the window, for session-management
- * purposes. If this is %NULL, a unique role string will be automatically
- * generated.
- *
- * Description:
- * Opens a new toplevel window. This is usually used only for opening
- * the initial window on startup (just before calling gtkmain()) if no
- * windows were open because a session was restored or children were added
- * because of command line args).
- **/
-void
-bonobo_mdi_open_toplevel (BonoboMDI *mdi, const char *window_role)
-{
- gl_debug (DEBUG_MDI, "");
-
- g_return_if_fail (mdi != NULL);
- g_return_if_fail (BONOBO_IS_MDI (mdi));
-
- app_clone (mdi, mdi->priv->active_window, window_role);
-
- book_create (mdi);
-
- gtk_widget_show (GTK_WIDGET (mdi->priv->active_window));
-
- gl_debug (DEBUG_MDI, "END1");
-}
-
-/**
- * bonobo_mdi_update_child:
- * @mdi: A pointer to a BonoboMDI object.
- * @child: Child to update.
- *
- * Description:
- * Updates all notebook labels of @child's views and their window titles
- * after its name changes. It is not required if bonobo_mdi_child_set_name()
- * is used for setting the child's name.
- **/
-static void
-bonobo_mdi_update_child (BonoboMDI *mdi, BonoboMDIChild *child)
-{
- GtkWidget *view, *title;
- GList *view_node;
- GList *win_node;
- gchar* child_name, *path, *path_cmd, *tip, *escaped_name;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_if_fail (mdi != NULL);
- g_return_if_fail (BONOBO_IS_MDI (mdi));
- g_return_if_fail (child != NULL);
- g_return_if_fail (BONOBO_IS_MDI_CHILD (child));
-
- view_node = bonobo_mdi_child_get_views (child);
-
- while (view_node)
- {
- view = GTK_WIDGET (view_node->data);
-
- title = child_set_label (child, NULL);
-
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (view->parent), view, title);
-
- view_node = g_list_next (view_node);
- }
-
- /* Update child list menus */
- if(mdi->priv->child_list_path == NULL)
- {
- gl_debug (DEBUG_MDI, "END1");
-
- return;
- }
-
- win_node = mdi->priv->windows;
-
- child_name = bonobo_mdi_child_get_name (child);
- escaped_name = escape_underscores (child_name);
- path = g_strdup_printf ("%sChild_%p", mdi->priv->child_list_path, child);
- path_cmd = g_strdup_printf ("/commands/Child_%p", child);
- tip = g_strdup_printf (_("Activate %s"), child_name);
-
- while (win_node)
- {
- BonoboUIComponent *ui_component;
-
- ui_component = BONOBO_UI_COMPONENT (
- g_object_get_data (G_OBJECT (win_node->data), UI_COMPONENT_KEY));
-
- bonobo_ui_component_set_prop (ui_component, path, "label", escaped_name, NULL);
- bonobo_ui_component_set_prop (ui_component, path, "tip", tip, NULL);
-
- win_node = g_list_next (win_node);
- }
-
- g_free (escaped_name);
- g_free (path);
- g_free (path_cmd);
- g_free (tip);
- g_free (child_name);
-
- gl_debug (DEBUG_MDI, "END2");
-}
-
-/**
- * bonobo_mdi_find_child:
- * @mdi: A pointer to a BonoboMDI object.
- * @name: A string with a name of the child to find.
- *
- * Description:
- * Finds a child named @name.
- *
- * Return value:
- * A pointer to the BonoboMDIChild object if the child was found and NULL
- * otherwise.
- **/
-BonoboMDIChild *
-bonobo_mdi_find_child (BonoboMDI *mdi, const gchar *name)
-{
- GList *child_node;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (mdi != NULL, NULL);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL);
-
- child_node = mdi->priv->children;
- while (child_node)
- {
- gchar* child_name = bonobo_mdi_child_get_name (BONOBO_MDI_CHILD (child_node->data));
-
- if (strcmp (child_name, name) == 0)
- {
- g_free (child_name);
-
- gl_debug (DEBUG_MDI, "END1");
-
- return BONOBO_MDI_CHILD (child_node->data);
- }
-
- g_free (child_name);
-
- child_node = g_list_next (child_node);
- }
-
- gl_debug (DEBUG_MDI, "END2");
-
- return NULL;
-}
-
-/**
- * bonobo_mdi_get_active_child:
- * @mdi: A pointer to a BonoboMDI object.
- *
- * Description:
- * Returns a pointer to the active BonoboMDIChild object.
- *
- * Return value:
- * A pointer to the active BonoboMDIChild object. %NULL, if there is none.
- **/
-BonoboMDIChild *
-bonobo_mdi_get_active_child (BonoboMDI *mdi)
-{
- g_return_val_if_fail (mdi != NULL, NULL);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL);
-
- if (mdi->priv->active_view)
- return (bonobo_mdi_get_child_from_view (mdi->priv->active_view));
-
- return NULL;
-}
-
-/**
- * bonobo_mdi_get_active_view:
- * @mdi: A pointer to a BonoboMDI object.
- *
- * Description:
- * Returns a pointer to the active view (the one with the focus).
- *
- * Return value:
- * A pointer to a GtkWidget *.
- **/
-GtkWidget *
-bonobo_mdi_get_active_view (BonoboMDI *mdi)
-{
- g_return_val_if_fail (mdi != NULL, NULL);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL);
-
- return mdi->priv->active_view;
-}
-
-/**
- * bonobo_mdi_get_active_window:
- * @mdi: A pointer to a BonoboMDI object.
- *
- * Description:
- * Returns a pointer to the toplevel window containing the active view.
- *
- * Return value:
- * A pointer to a BonoboWindow that has the focus.
- **/
-BonoboWindow *
-bonobo_mdi_get_active_window (BonoboMDI *mdi)
-{
- g_return_val_if_fail (mdi != NULL, NULL);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL);
-
- return mdi->priv->active_window;
-}
-
-void
-bonobo_mdi_set_ui_template (BonoboMDI *mdi, const gchar *xml, BonoboUIVerb verbs[])
-{
- g_return_if_fail (mdi != NULL);
- g_return_if_fail (BONOBO_IS_MDI (mdi));
- g_return_if_fail (xml != NULL);
-
- if (mdi->priv->ui_xml != NULL)
- g_free (mdi->priv->ui_xml);
-
- mdi->priv->ui_xml = g_strdup (xml);
-
- /* FIXME */
- mdi->priv->verbs = verbs;
-}
-
-void
-bonobo_mdi_set_ui_template_file (BonoboMDI *mdi, const gchar *file_name, BonoboUIVerb verbs[])
-{
- g_return_if_fail (mdi != NULL);
- g_return_if_fail (BONOBO_IS_MDI (mdi));
- g_return_if_fail (file_name != NULL);
-
- if (mdi->priv->ui_file_name != NULL)
- g_free (mdi->priv->ui_file_name);
-
- mdi->priv->ui_file_name = g_strdup (file_name);
-
- /* FIXME */
- mdi->priv->verbs = verbs;
-}
-
-/**
- * bonobo_mdi_set_child_list_path:
- * @mdi: A pointer to a BonoboMDI object.
- * @path: A menu path where the child list menu should be inserted
- *
- * Description:
- * Sets the position for insertion of menu items used to activate the MDI
- * children that were added to the MDI. See gnome_app_find_menu_pos for
- * details on menu paths. If the path is not set or set to %NULL, these menu
- * items aren't going to be inserted in the MDI menu structure. Note that if
- * you want all menu items to be inserted in their own submenu, you have to
- * create that submenu (and leave it empty, of course).
- **/
-void
-bonobo_mdi_set_child_list_path (BonoboMDI *mdi, const gchar *path)
-{
- g_return_if_fail (mdi != NULL);
- g_return_if_fail (BONOBO_IS_MDI (mdi));
-
- if (mdi->priv->child_list_path)
- g_free (mdi->priv->child_list_path);
-
- mdi->priv->child_list_path = g_strdup (path);
-}
-
-/**
- * bonobo_mdi_register:
- * @mdi: A pointer to a BonoboMDI object.
- * @object: Object to register.
- *
- * Description:
- * Registers GObject @object with MDI.
- * This is mostly intended for applications that open other windows besides
- * those opened by the MDI and want to continue to run even when no MDI
- * windows exist (an example of this would be GIMP's window with tools, if
- * the pictures were MDI children). As long as there is an object registered
- * with the MDI, the MDI will not destroy itself when the last of its windows
- * is closed. If no objects are registered, closing the last MDI window
- * results in MDI being destroyed.
- **/
-void
-bonobo_mdi_register (BonoboMDI *mdi, GObject *object)
-{
- if (!g_slist_find (mdi->priv->registered, object))
- mdi->priv->registered = g_slist_append (mdi->priv->registered, object);
-}
-
-/**
- * bonobo_mdi_unregister:
- * @mdi: A pointer to a BonoboMDI object.
- * @object: Object to unregister.
- *
- * Description:
- * Removes GObject @object from the list of registered objects.
- **/
-void
-bonobo_mdi_unregister (BonoboMDI *mdi, GObject *object)
-{
- mdi->priv->registered = g_slist_remove (mdi->priv->registered, object);
-}
-
-/**
- * bonobo_mdi_get_child_from_view:
- * @view: A pointer to a GtkWidget.
- *
- * Description:
- * Returns a child that @view is a view of.
- *
- * Return value:
- * A pointer to the BonoboMDIChild the view belongs to.
- **/
-BonoboMDIChild *
-bonobo_mdi_get_child_from_view (GtkWidget *view)
-{
- return BONOBO_MDI_CHILD (g_object_get_data (G_OBJECT(view), BONOBO_MDI_CHILD_KEY));
-}
-
-/**
- * bonobo_mdi_get_window_from_view:
- * @view: A pointer to a GtkWidget.
- *
- * Description:
- * Returns the toplevel window for this view.
- *
- * Return value:
- * A pointer to the BonoboWindow containg the specified view.
- **/
-BonoboWindow *
-bonobo_mdi_get_window_from_view (GtkWidget *view)
-{
- return BONOBO_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)));
-}
-
-/**
- * bonobo_mdi_get_view_from_window:
- * @mdi: A pointer to a BonoboMDI object.
- * @win: A pointer to a BonoboWindow widget.
- *
- * Description:
- * Returns the pointer to the view in the MDI toplevel window @win.
- * If the mode is set to %GNOME_MDI_NOTEBOOK, the view in the current
- * page is returned.
- *
- * Return value:
- * A pointer to a view.
- **/
-GtkWidget *
-bonobo_mdi_get_view_from_window (BonoboMDI *mdi, BonoboWindow *win)
-{
- GtkWidget *book;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (mdi != NULL, NULL);
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL);
- g_return_val_if_fail (win != NULL, NULL);
- g_return_val_if_fail (BONOBO_IS_WINDOW (win), NULL);
-
- book = get_book_from_window (win);
- g_return_val_if_fail (book != NULL, NULL);
-
- if (GTK_NOTEBOOK (book)->cur_page)
- {
- int cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (book));
-
- gl_debug (DEBUG_MDI, "END1");
-
- return gtk_notebook_get_nth_page (GTK_NOTEBOOK (book), cur_page);
- }
- else
- {
- gl_debug (DEBUG_MDI, "END2");
-
- return NULL;
- }
-}
-
-void
-bonobo_mdi_construct (BonoboMDI *mdi, const gchar* name, const gchar* title,
- gint default_window_width, gint default_window_height)
-{
- g_return_if_fail (mdi->priv->mdi_name == NULL);
- g_return_if_fail (mdi->priv->title == NULL);
-
- g_return_if_fail (name != NULL);
- g_return_if_fail (title != NULL);
-
- mdi->priv->mdi_name = g_strdup (name);
- mdi->priv->title = g_strdup (title);
-
- mdi->priv->default_window_width = default_window_width;
- mdi->priv->default_window_height = default_window_height;
-
-}
-
-GList *
-bonobo_mdi_get_children (BonoboMDI *mdi)
-{
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE);
-
- return mdi->priv->children;
-}
-
-GList *
-bonobo_mdi_get_windows (BonoboMDI *mdi)
-{
- g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE);
-
- return mdi->priv->windows;
-}
-
-
-
-BonoboUIComponent*
-bonobo_mdi_get_ui_component_from_window (BonoboWindow* win)
-{
- return BONOBO_UI_COMPONENT (
- g_object_get_data (G_OBJECT (win), UI_COMPONENT_KEY));
-}
-
-const BonoboMDIWindowInfo *
-bonobo_mdi_get_window_info (BonoboWindow *win)
-{
- return (const BonoboMDIWindowInfo *)
- g_object_get_data (G_OBJECT (win), WINDOW_INFO_KEY);
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * bonobo-mdi.h - definition of a BonoboMDI object
- *
- * Copyright (C) 2001-2002 Free Software Foundation
- *
- * 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.
- *
- * Author: Paolo Maggi
- */
-
-/*
- * Modified by the gedit Team, 2001-2002. See the AUTHORS file for a
- * list of people on the gedit Team.
- * See the ChangeLog files for a list of changes.
- */
-
-#ifndef _BONOBO_MDI_H_
-#define _BONOBO_MDI_H_
-
-#include <gtk/gtk.h>
-#include <bonobo/bonobo-window.h>
-#include <bonobo/bonobo-ui-component.h>
-
-
-#include "bonobo-mdi-child.h"
-
-#define BONOBO_TYPE_MDI (bonobo_mdi_get_type ())
-#define BONOBO_MDI(obj) (GTK_CHECK_CAST ((obj), BONOBO_TYPE_MDI, BonoboMDI))
-#define BONOBO_MDI_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), BONOBO_TYPE_MDI, BonoboMDIClass))
-#define BONOBO_IS_MDI(obj) (GTK_CHECK_TYPE ((obj), BONOBO_TYPE_MDI))
-#define BONOBO_IS_MDI_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BONOBO_TYPE_MDI))
-#define BONOBO_MDI_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BONOBO_TYPE_MDI, BonoboMDIClass))
-
-typedef struct _BonoboMDIPrivate BonoboMDIPrivate;
-
-typedef struct {
- GObject object;
-
- BonoboMDIPrivate *priv;
-} BonoboMDI;
-
-typedef struct {
- GObjectClass parent_class;
-
- /* Signals */
- gboolean (*add_child) (BonoboMDI *mdi, BonoboMDIChild *child);
- gboolean (*remove_child) (BonoboMDI *mdi, BonoboMDIChild *child);
- gboolean (*add_view) (BonoboMDI *mdi, GtkWidget *view);
- gboolean (*remove_view) (BonoboMDI *mdi, GtkWidget *view);
- void (*child_changed) (BonoboMDI *mdi, BonoboMDIChild *child);
- void (*view_changed) (BonoboMDI *mdi, GtkWidget *view);
- void (*top_window_created) (BonoboMDI *mdi, BonoboWindow *window);
- void (*top_window_destroy) (BonoboMDI *mdi, BonoboWindow *window);
- void (*all_windows_destroyed)(BonoboMDI *mdi);
-} BonoboMDIClass;
-
-typedef struct _BonoboMDIWindowInfo BonoboMDIWindowInfo;
-
-struct _BonoboMDIWindowInfo {
- gint width;
- gint height;
-
- GdkWindowState state;
-};
-
-/*
- * description of BonoboMDI signals:
- *
- * gboolean add_child(BonoboMDI *, BonoboMDIChild *)
- * gboolean add_view(BonoboMDI *, GtkWidget *)
- * are called before actually adding a mdi_child or a view to the MDI. if the handler returns
- * TRUE, the action proceeds otherwise the mdi_child or view are not added.
- *
- * gboolean remove_child(BonoboMDI *, BonoboMDIChild *)
- * gboolean remove_view(BonoboMDI *, GtkWidget *)
- * are called before removing mdi_child or view. the handler should return true if the object
- * is to be removed from MDI
- *
- * void child_changed(BonoboMDI *, BonoboMDIChild *)
- * gets called each time when active child is changed with the second argument
- * pointing to the old child. mdi->active_view and mdi->active_child still already
- * hold the new values
- *
- * void view_changed(BonoboMDI *, GtkWidget *)
- * is emitted whenever a view is changed, regardless of it being the view of the same child as
- * the old view or not. the second argument points to the old view, mdi->active_view and
- * mdi->active_child hold the new values. if the child has also been changed, this signal is
- * emitted after the child_changed signal.
- *
- * void top_window_created(BonoboMDI *, BonoboWindow *)
- * is called with each newly created BonoboWindow to allow the MDI user to customize it (add a
- * statusbar, toolbars or menubar if the method with ui templates is not sufficient,
- * etc.).
- * no contents may be set since BonoboMDI uses them for storing either a view of a child
- * or a notebook
- */
-
-GType bonobo_mdi_get_type (void);
-
-GObject *bonobo_mdi_new (const gchar *mdi_name,
- const gchar *title,
- gint default_window_width,
- gint default_window_height);
-
-void bonobo_mdi_construct (BonoboMDI *mdi,
- const gchar *name,
- const gchar *title,
- gint default_window_width,
- gint default_window_height);
-
-/* setting the ui template*/
-void bonobo_mdi_set_ui_template (BonoboMDI *mdi,
- const gchar *xml,
- BonoboUIVerb verbs[]);
-void bonobo_mdi_set_ui_template_file (BonoboMDI *mdi,
- const gchar *file_name,
- BonoboUIVerb verbs[]);
-
-void bonobo_mdi_set_child_list_path (BonoboMDI *mdi,
- const gchar *path);
-
-/* manipulating views */
-gboolean bonobo_mdi_add_view (BonoboMDI *mdi,
- BonoboMDIChild *child);
-gboolean bonobo_mdi_add_toplevel_view (BonoboMDI *mdi,
- BonoboMDIChild *child,
- const char *window_role);
-gboolean bonobo_mdi_remove_view (BonoboMDI *mdi,
- GtkWidget *view,
- gboolean force);
-
-GtkWidget *bonobo_mdi_get_active_view (BonoboMDI *mdi);
-void bonobo_mdi_set_active_view (BonoboMDI *mdi,
- GtkWidget *view);
-
-/* manipulating children */
-gint bonobo_mdi_add_child (BonoboMDI *mdi,
- BonoboMDIChild *child);
-gint bonobo_mdi_remove_child (BonoboMDI *mdi,
- BonoboMDIChild *child,
- gboolean force);
-gint bonobo_mdi_remove_all (BonoboMDI *mdi,
- gboolean force);
-
-void bonobo_mdi_open_toplevel (BonoboMDI *mdi,
- const char *window_role);
-
-BonoboMDIChild *bonobo_mdi_get_active_child (BonoboMDI *mdi);
-BonoboMDIChild *bonobo_mdi_find_child (BonoboMDI *mdi,
- const gchar *name);
-
-BonoboWindow *bonobo_mdi_get_active_window (BonoboMDI *mdi);
-
-/*
- * the following two functions are here to make life easier if an application
- * creates objects (like opening a window) that should "keep the application
- * alive" even if there are no MDI windows open. any such windows should be
- * registered with the MDI: as long as there is a window registered, the MDI
- * will not destroy itself (even if the last of its windows is closed). on the
- * other hand, closing the last MDI window when no objects are registered
- * with the MDI will result in MDI being gtk_object_destroy()ed.
- */
-void bonobo_mdi_register (BonoboMDI *mdi,
- GObject *object);
-void bonobo_mdi_unregister (BonoboMDI *mdi,
- GObject *object);
-
-/*
- * convenience functions for retrieveing BonoboMDIChild and BonoboApp
- * objects associated with a particular view and for retrieveing the
- * visible view of a certain BonoboWindow.
- */
-BonoboWindow *bonobo_mdi_get_window_from_view (GtkWidget *view);
-BonoboMDIChild *bonobo_mdi_get_child_from_view (GtkWidget *view);
-GtkWidget *bonobo_mdi_get_view_from_window (BonoboMDI *mdi,
- BonoboWindow *window);
-
-GList *bonobo_mdi_get_children (BonoboMDI *mdi);
-GList *bonobo_mdi_get_windows (BonoboMDI *mdi);
-
-BonoboUIComponent *bonobo_mdi_get_ui_component_from_window (BonoboWindow *win);
-
-/* Utility function to generate unique window roles */
-char *bonobo_mdi_generate_window_role (void);
-
-const BonoboMDIWindowInfo *bonobo_mdi_get_window_info (BonoboWindow *win);
-
-#endif /* _BONOBO_MDI_H_ */
-
-
#include <libgnomeui/libgnomeui.h>
#include "commands.h"
-#include "glabels.h"
-#include "mdi-child.h"
#include "view.h"
#include "file.h"
#include "print.h"
gpointer user_data,
const gchar *verbname)
{
- gl_debug (DEBUG_COMMANDS, "verbname: %s", verbname);
+ glWindow *window = GL_WINDOW (user_data);
+
+ gl_debug (DEBUG_COMMANDS, "");
- gl_file_new ();
+ gl_file_new (GTK_WINDOW(window));
}
/****************************************************************************/
gpointer user_data,
const gchar *verbname)
{
- BonoboMDIChild *active_child;
-
+ glWindow *window = GL_WINDOW (user_data);
+
gl_debug (DEBUG_COMMANDS, "");
- active_child = bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi));
-
- gl_file_open ((glMDIChild*) active_child);
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
+ gl_file_open (GTK_WINDOW(window));
}
/****************************************************************************/
gpointer user_data,
const gchar *verbname)
{
- glMDIChild *active_child;
-
+ glWindow *window = GL_WINDOW (user_data);
+
gl_debug (DEBUG_COMMANDS, "");
- active_child = GL_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)));
- if (active_child == NULL)
- return;
-
- gl_file_save (active_child);
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
+ gl_file_save (GL_VIEW(window->view)->label, GTK_WINDOW(window));
}
/****************************************************************************/
gpointer user_data,
const gchar *verbname)
{
- glMDIChild *active_child;
-
+ glWindow *window = GL_WINDOW (user_data);
+
gl_debug (DEBUG_COMMANDS, "");
- active_child = GL_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)));
- if (active_child == NULL)
- return;
-
- gl_file_save_as (active_child);
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
+ gl_file_save_as (GL_VIEW(window->view)->label, GTK_WINDOW(window));
}
/****************************************************************************/
gpointer user_data,
const gchar *verbname)
{
- glLabel *label = glabels_get_active_label ();
- BonoboWindow *win = glabels_get_active_window ();
-
+ glWindow *window = GL_WINDOW (user_data);
+
gl_debug (DEBUG_COMMANDS, "");
- g_return_if_fail (label != NULL);
- g_return_if_fail (win != NULL);
+ g_return_if_fail (window && GL_IS_WINDOW(window));
- gl_print_dialog (label, win);
+ gl_print_dialog (GL_VIEW(window->view)->label, GTK_WINDOW(window));
}
gpointer user_data,
const gchar *verbname)
{
- GtkWidget *active_view;
-
- gl_debug (DEBUG_COMMANDS, "");
+ glWindow *window = GL_WINDOW (user_data);
- active_view = GTK_WIDGET (glabels_get_active_view ());
-
- if (active_view == NULL)
- return;
-
- glabels_close_x_button_pressed = TRUE;
-
- gl_file_close (active_view);
-
- glabels_close_x_button_pressed = FALSE;
-}
-
-/****************************************************************************/
-/* File->Close_all command. */
-/****************************************************************************/
-void
-gl_cmd_file_close_all (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar *verbname)
-{
gl_debug (DEBUG_COMMANDS, "");
- glabels_close_x_button_pressed = TRUE;
-
- gl_file_close_all ();
+ g_return_if_fail (window && GL_IS_WINDOW(window));
- glabels_close_x_button_pressed = FALSE;
+ gl_file_close (window);
}
/****************************************************************************/
gpointer user_data,
const gchar *verbname)
{
+ glWindow *window = GL_WINDOW (user_data);
+
gl_debug (DEBUG_COMMANDS, "");
- glabels_exit_button_pressed = TRUE;
-
- gl_file_exit ();
+ g_return_if_fail (window && GL_IS_WINDOW(window));
- glabels_exit_button_pressed = FALSE;
+ gl_file_exit ();
}
gpointer user_data,
const gchar *verbname)
{
- glView* active_view;
+ glWindow *window = GL_WINDOW (user_data);
- active_view = glabels_get_active_view ();
- g_return_if_fail (active_view);
-
- gl_view_cut (active_view);
+ gl_debug (DEBUG_COMMANDS, "");
+
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
+ gl_view_cut (GL_VIEW(window->view));
}
/****************************************************************************/
gpointer user_data,
const gchar *verbname)
{
- glView* active_view;
+ glWindow *window = GL_WINDOW (user_data);
- active_view = glabels_get_active_view ();
- g_return_if_fail (active_view);
-
- gl_view_copy (active_view);
+ gl_debug (DEBUG_COMMANDS, "");
+
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
+ gl_view_copy (GL_VIEW(window->view));
}
/****************************************************************************/
gpointer user_data,
const gchar *verbname)
{
- glView* active_view;
+ glWindow *window = GL_WINDOW (user_data);
- active_view = glabels_get_active_view ();
- g_return_if_fail (active_view);
-
- gl_view_paste (active_view);
+ gl_debug (DEBUG_COMMANDS, "");
+
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
+ gl_view_paste (GL_VIEW(window->view));
}
gpointer user_data,
const gchar *verbname)
{
- glView* active_view;
+ glWindow *window = GL_WINDOW (user_data);
- active_view = glabels_get_active_view ();
- g_return_if_fail (active_view);
-
- gl_view_delete_selection (active_view);
+ gl_debug (DEBUG_COMMANDS, "");
+
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
+ gl_view_delete_selection (GL_VIEW(window->view));
}
gpointer user_data,
const gchar *verbname)
{
- glView* active_view;
+ glWindow *window = GL_WINDOW (user_data);
- active_view = glabels_get_active_view ();
+ gl_debug (DEBUG_COMMANDS, "");
- g_return_if_fail (active_view);
-
- gl_view_select_all (active_view);
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
+ gl_view_select_all (GL_VIEW(window->view));
}
/****************************************************************************/
gpointer user_data,
const gchar *verbname)
{
- glView* active_view;
+ glWindow *window = GL_WINDOW (user_data);
+
+ gl_debug (DEBUG_COMMANDS, "");
- active_view = glabels_get_active_view ();
+ g_return_if_fail (window && GL_IS_WINDOW(window));
- g_return_if_fail (active_view);
-
- gl_view_unselect_all (active_view);
+ gl_view_unselect_all (GL_VIEW(window->view));
}
/****************************************************************************/
gpointer user_data,
const gchar *verbname)
{
+ glWindow *window = GL_WINDOW (user_data);
static GtkWidget *dlg = NULL;
gl_debug (DEBUG_COMMANDS, "");
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
if (dlg != NULL)
{
gtk_window_present (GTK_WINDOW (dlg));
gtk_window_set_transient_for (GTK_WINDOW (dlg),
- GTK_WINDOW (glabels_get_active_window ()));
+ GTK_WINDOW(window));
return;
}
- dlg = gl_prefs_dialog_new (GTK_WINDOW (glabels_get_active_window ()));
+ dlg = gl_prefs_dialog_new (GTK_WINDOW(window));
g_signal_connect (G_OBJECT (dlg), "destroy",
G_CALLBACK (gtk_widget_destroyed), &dlg);
gpointer user_data,
const gchar *verbname)
{
+ glWindow *window = GL_WINDOW (user_data);
GError *error = NULL;
gl_debug (DEBUG_COMMANDS, "");
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
gnome_help_display_with_doc_id (NULL, NULL, "glabels.xml", NULL, &error);
if (error != NULL)
gpointer user_data,
const gchar *verbname)
{
+ glWindow *window = GL_WINDOW (user_data);
static GtkWidget *about = NULL;
GdkPixbuf *pixbuf = NULL;
gl_debug (DEBUG_COMMANDS, "");
+ g_return_if_fail (window && GL_IS_WINDOW(window));
+
if (about != NULL)
{
gdk_window_show (about->window);
pixbuf);
gtk_window_set_transient_for (GTK_WINDOW (about),
- GTK_WINDOW (glabels_get_active_window ()));
+ GTK_WINDOW (window));
gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE);
gpointer user_data,
const gchar *verbname);
-void gl_cmd_file_close_all (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar *verbname);
-
void gl_cmd_file_exit (BonoboUIComponent *uic,
gpointer user_data,
const gchar *verbname);
gint gl_debug_commands = 0;
gint gl_debug_undo = 0;
gint gl_debug_recent = 0;
-gint gl_debug_mdi = 0;
+gint gl_debug_window = 0;
+gint gl_debug_ui = 0;
gint gl_debug_media_select = 0;
gint gl_debug_mini_preview = 0;
gint gl_debug_wdgt = 0;
(gl_debug_commands && section == GL_DEBUG_COMMANDS) ||
(gl_debug_undo && section == GL_DEBUG_UNDO) ||
(gl_debug_recent && section == GL_DEBUG_RECENT) ||
- (gl_debug_mdi && section == GL_DEBUG_MDI) ||
+ (gl_debug_window && section == GL_DEBUG_WINDOW) ||
+ (gl_debug_ui && section == GL_DEBUG_UI) ||
(gl_debug_media_select && section == GL_DEBUG_MEDIA_SELECT) ||
(gl_debug_mini_preview && section == GL_DEBUG_MINI_PREVIEW) ||
(gl_debug_wdgt && section == GL_DEBUG_WDGT) )
GL_DEBUG_UNDO,
GL_DEBUG_RECENT,
GL_DEBUG_COMMANDS,
- GL_DEBUG_MDI,
+ GL_DEBUG_WINDOW,
+ GL_DEBUG_UI,
GL_DEBUG_MEDIA_SELECT,
GL_DEBUG_MINI_PREVIEW,
GL_DEBUG_WDGT,
extern gint gl_debug_commands;
extern gint gl_debug_undo;
extern gint gl_debug_recent;
-extern gint gl_debug_mdi;
+extern gint gl_debug_window;
+extern gint gl_debug_ui;
extern gint gl_debug_media_select;
extern gint gl_debug_mini_preview;
extern gint gl_debug_wdgt;
#define DEBUG_UNDO GL_DEBUG_UNDO, __FILE__, __LINE__, __FUNCTION__
#define DEBUG_RECENT GL_DEBUG_RECENT, __FILE__, __LINE__, __FUNCTION__
#define DEBUG_COMMANDS GL_DEBUG_COMMANDS,__FILE__, __LINE__, __FUNCTION__
-#define DEBUG_MDI GL_DEBUG_MDI, __FILE__, __LINE__, __FUNCTION__
+#define DEBUG_WINDOW GL_DEBUG_WINDOW, __FILE__, __LINE__, __FUNCTION__
+#define DEBUG_UI GL_DEBUG_UI, __FILE__, __LINE__, __FUNCTION__
#define DEBUG_MEDIA_SELECT GL_DEBUG_MEDIA_SELECT, __FILE__, __LINE__, __FUNCTION__
#define DEBUG_MINI_PREVIEW GL_DEBUG_MINI_PREVIEW, __FILE__, __LINE__, __FUNCTION__
#define DEBUG_WDGT GL_DEBUG_WDGT, __FILE__, __LINE__, __FUNCTION__
#include <gnome.h>
#include <string.h>
-#include "glabels.h"
#include "xml-label.h"
#include "file.h"
-#include "mdi.h"
#include "recent.h"
#include "hig.h"
#include "alert.h"
/* "New" menu callback. */
/*****************************************************************************/
void
-gl_file_new (void)
+gl_file_new (GtkWindow *window)
{
GtkWidget *dlg;
- BonoboWindow *win = glabels_get_active_window ();
gl_debug (DEBUG_FILE, "START");
- g_return_if_fail (glabels_mdi != NULL);
- g_return_if_fail (win != NULL);
+ g_return_if_fail (window != NULL);
dlg = gl_hig_dialog_new_with_buttons (_("New Label or Card"),
- GTK_WINDOW (win),
+ window,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
create_new_dialog_widgets (GL_HIG_DIALOG (dlg));
+ g_object_set_data (G_OBJECT (dlg), "parent_window", window);
+
g_signal_connect (G_OBJECT(dlg), "response",
G_CALLBACK (new_response), dlg);
rotate_sel = gl_wdgt_rotate_label_new ();
gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), rotate_sel);
- g_object_set_data (G_OBJECT (dlg), "template_entry",
- template_entry);
+ g_object_set_data (G_OBJECT (dlg), "template_entry", template_entry);
g_object_set_data (G_OBJECT (dlg), "rotate_sel", rotate_sel);
g_signal_connect (G_OBJECT (template_entry), "changed",
gint response,
gpointer user_data)
{
- GtkWidget *template_entry, *rotate_sel;
- glMDIChild *new_child = NULL;
+ GtkWidget *template_entry, *rotate_sel, *new_window;
+ glTemplate *template;
+ glLabel *label;
gint ret;
+ glWindow *window;
gl_debug (DEBUG_FILE, "START");
case GTK_RESPONSE_OK:
template_entry =
GTK_WIDGET (g_object_get_data (G_OBJECT (dlg),
- "template_entry"));
+ "template_entry"));
rotate_sel = GTK_WIDGET (g_object_get_data (G_OBJECT (dlg),
- "rotate_sel"));
+ "rotate_sel"));
if (page_size != NULL)
g_free (page_size);
rotate_flag =
gl_wdgt_rotate_label_get_state (GL_WDGT_ROTATE_LABEL (rotate_sel));
- new_child = gl_mdi_child_new (sheet_name, rotate_flag);
- gl_debug (DEBUG_FILE, "template set.");
+ template = gl_template_from_name (sheet_name);
- ret = bonobo_mdi_add_child (BONOBO_MDI (glabels_mdi),
- BONOBO_MDI_CHILD (new_child));
- g_return_if_fail (ret != FALSE);
- gl_debug (DEBUG_FILE, "Child added.");
+ label = GL_LABEL(gl_label_new ());
+ gl_label_set_template (label, template);
+ gl_label_set_rotate_flag (label, rotate_flag);
- ret = bonobo_mdi_add_view (BONOBO_MDI (glabels_mdi),
- BONOBO_MDI_CHILD (new_child));
- g_return_if_fail (ret != FALSE);
- gl_debug (DEBUG_FILE, "View added.");
+ window =
+ GL_WINDOW (g_object_get_data (G_OBJECT (dlg),
+ "parent_window"));
+ if ( gl_window_is_empty (window) ) {
+ gl_window_set_label (window, label);
+ } else {
+ new_window = gl_window_new_from_label (label);
+ gtk_widget_show_all (new_window);
+ }
+
- gtk_widget_grab_focus (GTK_WIDGET (glabels_get_active_view ()));
break;
}
/* "Open" menu callback. */
/*****************************************************************************/
void
-gl_file_open (glMDIChild *active_child)
+gl_file_open (GtkWindow *window)
{
GtkFileSelection *fsel;
- BonoboWindow *app = glabels_get_active_window ();
gl_debug (DEBUG_FILE, "START");
- g_return_if_fail (app != NULL);
+ g_return_if_fail (window != NULL);
fsel = GTK_FILE_SELECTION (gtk_file_selection_new (_("Open")));
- gtk_window_set_transient_for (GTK_WINDOW (fsel), GTK_WINDOW (app));
+ gtk_window_set_transient_for (GTK_WINDOW (fsel), window);
gtk_window_set_title (GTK_WINDOW (fsel), _("Open label"));
g_signal_connect (G_OBJECT (fsel->ok_button), "clicked",
{
gchar *filename;
GtkWidget *dlg;
- glMDIChild *new_child = NULL;
gint ret;
GnomeRecentModel *recent;
gboolean
gl_file_open_recent (GnomeRecentView *view,
const gchar *filename,
- BonoboWindow *win)
+ GtkWindow *window)
{
gl_debug (DEBUG_FILE, "");
- return gl_file_open_real (filename, GTK_WINDOW(win));
+ return gl_file_open_real (filename, window);
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
gboolean
gl_file_open_real (const gchar *filename,
- GtkWindow *win)
+ GtkWindow *window)
{
gchar *abs_filename;
- glMDIChild *new_child = NULL;
+ glLabel *label;
+ glXMLLabelStatus status;
GnomeRecentModel *recent;
gint ret;
+ GtkWidget *new_window;
gl_debug (DEBUG_FILE, "START");
abs_filename = gl_util_make_absolute (filename);
- new_child = gl_mdi_child_new_with_uri (filename, NULL);
- if (!new_child) {
+ label = gl_xml_label_open (abs_filename, &status);
+ if (!label) {
GtkWidget *dlg;
gchar *primary_msg;
primary_msg = g_strdup_printf (_("Could not open file \"%s\""),
filename);
- dlg = gl_alert_dialog_new (GTK_WINDOW(win),
+ dlg = gl_alert_dialog_new (window,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
} else {
- ret = bonobo_mdi_add_child (BONOBO_MDI (glabels_mdi),
- BONOBO_MDI_CHILD (new_child));
- g_return_if_fail (ret != FALSE);
- gl_debug (DEBUG_FILE, "Child added.");
-
- ret = bonobo_mdi_add_view (BONOBO_MDI (glabels_mdi),
- BONOBO_MDI_CHILD (new_child));
- g_return_if_fail (ret != FALSE);
- gl_debug (DEBUG_FILE, "View added.");
-
- gtk_widget_grab_focus (GTK_WIDGET (glabels_get_active_view ()));
+ if ( gl_window_is_empty (GL_WINDOW(window)) ) {
+ gl_window_set_label (GL_WINDOW(window), label);
+ } else {
+ new_window = gl_window_new_from_label (label);
+ gtk_widget_show_all (new_window);
+ }
recent = gl_recent_get_model ();
gnome_recent_model_add (recent, abs_filename);
/* "Save" menu callback. */
/*****************************************************************************/
gboolean
-gl_file_save (glMDIChild *child)
+gl_file_save (glLabel *label,
+ GtkWindow *window)
{
glXMLLabelStatus status;
- glLabel *label = NULL;
GError *error = NULL;
gchar *filename = NULL;
GnomeRecentModel *recent;
gl_debug (DEBUG_FILE, "");
- g_return_val_if_fail (child != NULL, FALSE);
-
- label = child->label;
g_return_val_if_fail (label != NULL, FALSE);
if (gl_label_is_untitled (label))
{
gl_debug (DEBUG_FILE, "Untitled");
- return gl_file_save_as (child);
+ return gl_file_save_as (label, window);
}
if (!gl_label_is_modified (label))
primary_msg = g_strdup_printf (_("Could not save file \"%s\""),
filename);
- dialog = gl_alert_dialog_new (GTK_WINDOW(glabels_get_active_window()),
+ dialog = gl_alert_dialog_new (window,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
/* "Save As" menu callback. */
/*****************************************************************************/
gboolean
-gl_file_save_as (glMDIChild *child)
+gl_file_save_as (glLabel *label,
+ GtkWindow *window)
{
GtkFileSelection *fsel;
- BonoboWindow *app = glabels_get_active_window ();
gboolean saved_flag = FALSE;
gboolean destroy_flag = FALSE;
gl_debug (DEBUG_FILE, "START");
- g_return_val_if_fail (child != NULL, FALSE);
- g_return_val_if_fail (app != NULL, FALSE);
+ g_return_val_if_fail (label != NULL, FALSE);
+ g_return_val_if_fail (window != NULL, FALSE);
fsel = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save label as")));
gtk_window_set_modal (GTK_WINDOW (fsel), TRUE);
- gtk_window_set_transient_for (GTK_WINDOW (fsel), GTK_WINDOW (app));
+ gtk_window_set_transient_for (GTK_WINDOW (fsel), window);
- g_object_set_data (G_OBJECT (fsel), "child", child);
+ g_object_set_data (G_OBJECT (fsel), "label", label);
g_object_set_data (G_OBJECT (fsel), "saved_flag", &saved_flag);
g_signal_connect (G_OBJECT (fsel->ok_button), "clicked",
{
gchar *raw_filename, *filename;
GtkWidget *dlg;
- glMDIChild *child;
glLabel *label;
glXMLLabelStatus status;
GnomeRecentModel *recent;
g_return_if_fail (GTK_IS_FILE_SELECTION (fsel));
- child = g_object_get_data (G_OBJECT(fsel), "child");
+ label = g_object_get_data (G_OBJECT(fsel), "label");
saved_flag = g_object_get_data (G_OBJECT(fsel), "saved_flag");
- g_return_if_fail (child != NULL);
- g_return_if_fail (GL_IS_MDI_CHILD (child));
- gl_debug (DEBUG_FILE, "Got child");
-
- label = child->label;
-
/* get the filename */
raw_filename = g_strdup (gtk_file_selection_get_filename (fsel));
/*****************************************************************************/
/* "Close" menu callback. */
/*****************************************************************************/
-void
-gl_file_close (GtkWidget *view)
+gboolean
+gl_file_close (glWindow *window)
{
- gint ret;
- BonoboMDIChild *child;
+ glView *view;
+ glLabel *label;
+ gboolean close = TRUE;
gl_debug (DEBUG_FILE, "START");
- g_return_if_fail (view != NULL);
+ g_return_val_if_fail (window && GL_IS_WINDOW(window), TRUE);
- child = bonobo_mdi_get_child_from_view (view);
- g_return_if_fail (child != NULL);
+ if ( !gl_window_is_empty (window) ) {
- if (g_list_length (bonobo_mdi_child_get_views (child)) > 1)
- {
- ret = bonobo_mdi_remove_view (BONOBO_MDI (glabels_mdi), view, FALSE);
- gl_debug (DEBUG_FILE, "View removed.");
- }
- else
- {
- ret = bonobo_mdi_remove_child (BONOBO_MDI (glabels_mdi), child, FALSE);
- gl_debug (DEBUG_FILE, "Child removed.");
- }
+ view = GL_VIEW(window->view);
+ label = view->label;
- if (ret)
- gl_mdi_set_active_window_title (BONOBO_MDI (glabels_mdi));
+ if (gl_label_is_modified (label)) {
+ GtkWidget *msgbox, *w;
+ gchar *fname = NULL, *msg = NULL;
+ gint ret;
+ gboolean exiting;
- if (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)) == NULL)
- {
- gl_mdi_set_active_window_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
- }
+ fname = gl_label_get_short_name (label);
+
+ msg = g_strdup_printf (_("Save changes to document \"%s\" before closing?"),
+ fname);
+
+ msgbox = gl_alert_dialog_new (GTK_WINDOW(window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ msg,
+ _("Your changes will be lost if you don't save them."));
- gl_debug (DEBUG_FILE, "END");
-}
+ gtk_dialog_add_button (GTK_DIALOG (msgbox),
+ _("Close without saving"),
+ GTK_RESPONSE_NO);
-/*****************************************************************************/
-/* "Close all" */
-/*****************************************************************************/
-gboolean
-gl_file_close_all (void)
-{
- gboolean ret;
+ gtk_dialog_add_button (GTK_DIALOG (msgbox),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gl_debug (DEBUG_FILE, "START");
+ gtk_dialog_add_button (GTK_DIALOG (msgbox),
+ GTK_STOCK_SAVE, GTK_RESPONSE_YES);
- ret = bonobo_mdi_remove_all (BONOBO_MDI (glabels_mdi), FALSE);
+ gtk_dialog_set_default_response (GTK_DIALOG (msgbox), GTK_RESPONSE_YES);
+
+ gtk_window_set_resizable (GTK_WINDOW (msgbox), FALSE);
+
+ ret = gtk_dialog_run (GTK_DIALOG (msgbox));
+
+ gtk_widget_destroy (msgbox);
+
+ g_free (fname);
+ g_free (msg);
+
+ switch (ret)
+ {
+ case GTK_RESPONSE_YES:
+ close = gl_file_save (label,
+ GTK_WINDOW(window));
+ break;
+ case GTK_RESPONSE_NO:
+ close = TRUE;
+ break;
+ default:
+ close = FALSE;
+ }
+
+ gl_debug (DEBUG_FILE, "CLOSE: %s", close ? "TRUE" : "FALSE");
+ }
+
+ }
+
+ if (close) {
+ gtk_widget_destroy (GTK_WIDGET(window));
+
+ if ( gl_window_get_window_list () == NULL ) {
+
+ gl_debug (DEBUG_FILE, "All windows closed.");
+
+ bonobo_main_quit ();
+ }
- if (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)) == NULL)
- {
- gl_mdi_set_active_window_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
}
gl_debug (DEBUG_FILE, "END");
- return ret;
+ return close;
}
/*****************************************************************************/
void
gl_file_exit (void)
{
- gl_debug (DEBUG_FILE, "START");
-
- if (!gl_file_close_all ())
- return;
-
- gl_debug (DEBUG_FILE, "All files closed.");
-
- /* We need to disconnect the signal because mdi "destroy" event
- is connected to gl_file_exit ( i.e. this function ). */
- g_signal_handlers_disconnect_by_func (G_OBJECT (glabels_mdi),
- G_CALLBACK (gl_file_exit), NULL);
-
- gl_prefs_save_settings ();
+ const GList *window_list;
+ GList *p, *p_next;
- gl_debug (DEBUG_FILE, "Unref glabels_mdi.");
+ gl_debug (DEBUG_FILE, "START");
- g_object_unref (G_OBJECT (glabels_mdi));
+ window_list = gl_window_get_window_list ();
- gl_debug (DEBUG_FILE, "Unref glabels_mdi: DONE");
+ for (p=(GList *)window_list; p != NULL; p=p_next) {
+ p_next = p->next;
- gtk_main_quit ();
+ gl_file_close (GL_WINDOW(p->data));
+ }
gl_debug (DEBUG_FILE, "END");
}
#ifndef __FILE_H__
#define __FILE_H__
-#include "mdi-child.h"
#include "gnome-recent-view.h"
+#include <gtk/gtk.h>
+
+#include "label.h"
+#include "window.h"
G_BEGIN_DECLS
-void gl_file_new (void);
+void gl_file_new (GtkWindow *window);
+
+void gl_file_open (GtkWindow *window);
-void gl_file_open (glMDIChild *active_child);
gboolean gl_file_open_recent (GnomeRecentView *view,
const gchar *filename,
- BonoboWindow *win);
+ GtkWindow *window);;
gboolean gl_file_open_real (const gchar *filename,
- GtkWindow *win);
-
+ GtkWindow *window);
-gboolean gl_file_save (glMDIChild *child);
-gboolean gl_file_save_as (glMDIChild *child);
+gboolean gl_file_save (glLabel *label,
+ GtkWindow *window);
+gboolean gl_file_save_as (glLabel *label,
+ GtkWindow *window);
-void gl_file_close (GtkWidget *view);
-gboolean gl_file_close_all (void);
+gboolean gl_file_close (glWindow *window);
void gl_file_exit (void);
_tip="Close the current file" pixtype="stock" pixname="gtk-close"
accel="*Alt*F4"/>
- <cmd name="FileCloseAll" _label="Close All"
- _tip="Close all open files" pixtype="stock" pixname="gtk-close"
- accel="*Shift**Alt*F4"/>
-
<cmd name="FileExit" _label="Quit" _tip="Quit the program"
pixtype="stock" pixname="gtk-quit" accel="*Control*Q"/>
<menuitem name="FileClose" verb="" _label="_Close"/>
- <menuitem name="FileCloseAll" verb="" _label="Clos_e All"/>
-
<menuitem name="FileExit" verb="" _label="_Quit"/>
</submenu>
</submenu>
-<submenu name="Documents" _label="_Documents">
-
- <placeholder name="DocumentsOps_1" delimit="bottom"/>
-
- <placeholder name="OpenDocuments" />
-
- <placeholder name="DocumentsOps_2" delimit="top"/>
-
-</submenu>
-
<submenu name="Help" _label="_Help">
<menuitem name="HelpContents" verb="" _label="_Contents"/>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/*
- * This file is based on gedit2.c from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
- *
- */
#include <config.h>
#include <libgnome/libgnome.h>
#include <libgnomeui/libgnomeui.h>
#include <libgnomeui/gnome-window-icon.h>
-#include "glabels.h"
#include "splash.h"
#include "stock.h"
#include "merge.h"
#include "template.h"
-#include "mdi.h"
#include "prefs.h"
-#include "file.h"
#include "debug.h"
+#include "window.h"
#define ICON_PIXMAP gnome_program_locate_file (NULL,\
GNOME_FILE_DOMAIN_APP_PIXMAP,\
"glabels/glabels-icon.png",\
FALSE, NULL)
-glMDI *glabels_mdi = NULL;
-gboolean glabels_close_x_button_pressed = FALSE;
-gboolean glabels_exit_button_pressed = FALSE;
-
static const struct poptOption options [] =
{
{ "debug-view", '\0', POPT_ARG_NONE, &gl_debug_view, 0,
{ "debug-recent", '\0', POPT_ARG_NONE, &gl_debug_recent, 0,
N_("Show recent debugging messages."), NULL },
- { "debug-mdi", '\0', POPT_ARG_NONE, &gl_debug_mdi, 0,
- N_("Show mdi debugging messages."), NULL },
+ { "debug-window", '\0', POPT_ARG_NONE, &gl_debug_window, 0,
+ N_("Show window debugging messages."), NULL },
+
+ { "debug-ui", '\0', POPT_ARG_NONE, &gl_debug_ui, 0,
+ N_("Show ui debugging messages."), NULL },
{ "debug-media-select", '\0', POPT_ARG_NONE, &gl_debug_media_select, 0,
N_("Show media select widget debugging messages."), NULL },
char **args;
GList *file_list = NULL, *p;
gint i;
+ GtkWidget *win;
bindtextdomain (GETTEXT_PACKAGE, GLABELS_LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
gl_merge_ui_init();
gl_recent_init();
+ if (bonobo_ui_init ("glabels", VERSION, &argc, argv) == FALSE) {
+ g_error (_("Could not initialize Bonobo!\n"));
+ }
+
/* 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),
file_list = g_list_append (file_list, args[i]);
}
- /* Create glabels_mdi and open the first top level window */
- glabels_mdi = gl_mdi_new ();
- bonobo_mdi_open_toplevel (BONOBO_MDI (glabels_mdi), NULL);
-
+ /* Open files or create empty top-level window. */
for (p = file_list; p; p = p->next) {
- gl_file_open_real (p->data,
- GTK_WINDOW(glabels_get_active_window()));
+ win = gl_window_new_from_file (p->data);
+ gtk_widget_show_all (win);
+ }
+ if ( gl_window_get_window_list() == NULL ) {
+ win = gl_window_new ();
+ gtk_widget_show_all (win);
}
g_list_free (file_list);
- gtk_main();
+
+ /* Begin main loop */
+ bonobo_main();
return 0;
}
-BonoboWindow*
-glabels_get_active_window (void)
-{
- g_return_val_if_fail (glabels_mdi != NULL, NULL);
-
- return bonobo_mdi_get_active_window (BONOBO_MDI (glabels_mdi));
-}
-
-glLabel*
-glabels_get_active_label (void)
-{
- BonoboMDIChild *active_child;
-
- g_return_val_if_fail (glabels_mdi != NULL, NULL);
-
- active_child = bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi));
-
- if (active_child == NULL)
- return NULL;
-
- return GL_MDI_CHILD (active_child)->label;
-}
-
-glView*
-glabels_get_active_view (void)
-{
- GtkWidget *active_view;
-
- g_return_val_if_fail (glabels_mdi != NULL, NULL);
-
- active_view = bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi));
-
- if (active_view == NULL)
- return NULL;
-
- return GL_VIEW (active_view);
-}
-
-GList*
-glabels_get_top_windows (void)
-{
- g_return_val_if_fail (glabels_mdi != NULL, NULL);
-
- return bonobo_mdi_get_windows (BONOBO_MDI (glabels_mdi));
-}
-
+++ /dev/null
-/*
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * glabels.h: GLabels main module header file
- *
- * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
- *
- * 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
- */
-
-/*
- * This file is based on gedit.h from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
- *
- */
-#ifndef __GLABELS_H__
-#define __GLABELS_H__
-
-#include <gmodule.h>
-#include <glib/glist.h>
-#include <bonobo/bonobo-window.h>
-
-#include "mdi.h"
-#include "label.h"
-#include "view.h"
-
-G_BEGIN_DECLS
-
-extern glMDI* glabels_mdi;
-extern gboolean glabels_close_x_button_pressed;
-extern gboolean glabels_exit_button_pressed;
-
-BonoboWindow* glabels_get_active_window (void);
-glLabel* glabels_get_active_label (void);
-glView* glabels_get_active_view (void);
-GList* glabels_get_top_windows (void);
-
-G_END_DECLS
-
-#endif /* __GLABELS_H__ */
-
-
-
+++ /dev/null
-/*
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * mdi-child.c: gLabels MDI child module
- *
- * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
- *
- * 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
- */
-
-/*
- * This file is based on gedit-mdi-child.c from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
- * Copyright (C) 2002 Paolo Maggi
- *
- */
-#include <config.h>
-
-#include "mdi-child.h"
-#include "xml-label.h"
-#include "label.h"
-#include "view.h"
-#include "marshal.h"
-#include "debug.h"
-
-struct _glMDIChildPrivate
-{
- GtkWidget *tab_label;
-};
-
-enum {
- STATE_CHANGED,
- UNDO_REDO_STATE_CHANGED,
- LAST_SIGNAL
-};
-
-static void gl_mdi_child_class_init (glMDIChildClass *klass);
-static void gl_mdi_child_init (glMDIChild *mdi);
-static void gl_mdi_child_finalize (GObject *obj);
-static void gl_mdi_child_destroy (GtkObject *obj);
-
-static void gl_mdi_child_real_state_changed (glMDIChild* child);
-
-static GtkWidget *gl_mdi_child_create_view (BonoboMDIChild *child);
-
-static void gl_mdi_child_document_state_changed_handler (glLabel *label,
- glMDIChild* child);
-
-static void gl_mdi_child_document_can_undo_redo_handler (glLabel *label,
- gboolean can,
- glMDIChild* child);
-
-static gchar* gl_mdi_child_get_config_string (BonoboMDIChild *child,
- gpointer data);
-
-static BonoboMDIChildClass *parent_class = NULL;
-static guint mdi_child_signals[LAST_SIGNAL] = { 0 };
-
-
-GType
-gl_mdi_child_get_type (void)
-{
- static GType mdi_child_type = 0;
-
- gl_debug (DEBUG_MDI, "START");
-
- if (mdi_child_type == 0)
- {
- static const GTypeInfo our_info =
- {
- sizeof (glMDIChildClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gl_mdi_child_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (glMDIChild),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gl_mdi_child_init
- };
-
- mdi_child_type = g_type_register_static (BONOBO_TYPE_MDI_CHILD,
- "glMDIChild",
- &our_info,
- 0);
- }
-
- gl_debug (DEBUG_MDI, "END");
-
- return mdi_child_type;
-}
-
-static void
-gl_mdi_child_class_init (glMDIChildClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gl_debug (DEBUG_MDI, "START");
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = gl_mdi_child_finalize;
-
- klass->state_changed = gl_mdi_child_real_state_changed;
- klass->undo_redo_state_changed = NULL;
-
- mdi_child_signals [STATE_CHANGED] =
- g_signal_new ("state_changed",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (glMDIChildClass, state_changed),
- NULL, NULL,
- gl_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- mdi_child_signals [UNDO_REDO_STATE_CHANGED] =
- g_signal_new ("undo_redo_state_changed",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (glMDIChildClass, undo_redo_state_changed),
- NULL, NULL,
- gl_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- BONOBO_MDI_CHILD_CLASS (klass)->create_view =
- (BonoboMDIChildViewCreator)(gl_mdi_child_create_view);
-
- BONOBO_MDI_CHILD_CLASS (klass)->get_config_string =
- (BonoboMDIChildConfigFunc)(gl_mdi_child_get_config_string);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static void
-gl_mdi_child_init (glMDIChild *child)
-{
- gl_debug (DEBUG_MDI, "START");
-
- child->priv = g_new0 (glMDIChildPrivate, 1);
-
- child->priv->tab_label = NULL;
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static void
-gl_mdi_child_finalize (GObject *obj)
-{
- glMDIChild *child;
-
- gl_debug (DEBUG_MDI, "START");
-
- g_return_if_fail (obj != NULL);
-
- child = GL_MDI_CHILD (obj);
-
- g_return_if_fail (GL_IS_MDI_CHILD (child));
- g_return_if_fail (child->priv != NULL);
-
- if (child->label != NULL)
- g_object_unref (G_OBJECT (child->label));
-
- g_free (child->priv);
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static void gl_mdi_child_real_state_changed (glMDIChild* child)
-{
- gchar* docname = NULL;
- gchar* tab_name = NULL;
-
- gl_debug (DEBUG_MDI, "START");
-
- g_return_if_fail (child != NULL);
- g_return_if_fail (child->label != NULL);
-
- docname = gl_label_get_short_name (child->label);
- g_return_if_fail (docname != NULL);
-
- if (gl_label_is_modified (child->label))
- {
- tab_name = g_strdup_printf ("%s*", docname);
- }
- else
- {
- tab_name = g_strdup_printf ("%s", docname);
- }
-
- g_free (docname);
-
- g_return_if_fail (tab_name != NULL);
-
- bonobo_mdi_child_set_name (BONOBO_MDI_CHILD (child), tab_name);
-
- g_free (tab_name);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static void
-gl_mdi_child_document_state_changed_handler (glLabel *label, glMDIChild* child)
-{
- gl_debug (DEBUG_MDI, "");
- g_return_if_fail (child->label == label);
-
- g_signal_emit (G_OBJECT (child), mdi_child_signals [STATE_CHANGED], 0);
-}
-
-static void
-gl_mdi_child_document_can_undo_redo_handler (glLabel *label, gboolean can,
- glMDIChild* child)
-{
- gl_debug (DEBUG_MDI, "");
- g_return_if_fail (child->label == label);
-
- g_signal_emit (G_OBJECT (child), mdi_child_signals [UNDO_REDO_STATE_CHANGED], 0);
-}
-
-
-static void
-gl_mdi_child_connect_signals (glMDIChild *child)
-{
- gl_debug (DEBUG_MDI, "START");
-
- g_signal_connect (G_OBJECT (child->label), "name_changed",
- G_CALLBACK (gl_mdi_child_document_state_changed_handler),
- child);
- g_signal_connect (G_OBJECT (child->label), "modified_changed",
- G_CALLBACK (gl_mdi_child_document_state_changed_handler),
- child);
-#if 0
- g_signal_connect (G_OBJECT (child->label), "can_undo",
- G_CALLBACK (gl_mdi_child_document_can_undo_redo_handler),
- child);
- g_signal_connect (G_OBJECT (child->label), "can_redo",
- G_CALLBACK (gl_mdi_child_document_can_undo_redo_handler),
- child);
-#endif
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-/**
- * gl_mdi_child_new:
- *
- * Creates a new #glMDIChild object.
- *
- * Return value: a new #glMDIChild
- **/
-glMDIChild*
-gl_mdi_child_new (const gchar *tmplt_name,
- gboolean rotate_flag)
-{
- glMDIChild *child;
- gchar *doc_name;
- glTemplate *template;
-
- gl_debug (DEBUG_MDI, "START");
-
- child = GL_MDI_CHILD (g_object_new (GL_TYPE_MDI_CHILD, NULL));
- g_return_val_if_fail (child != NULL, NULL);
-
- child->label = GL_LABEL (gl_label_new ());
- g_return_val_if_fail (child->label != NULL, NULL);
-
- template = gl_template_from_name (tmplt_name);
- gl_label_set_template (child->label, template);
- gl_template_free (&template);
- gl_label_set_rotate_flag (child->label, rotate_flag);
- gl_label_clear_modified (child->label);
-
- doc_name = gl_label_get_short_name (child->label);
- bonobo_mdi_child_set_name (BONOBO_MDI_CHILD (child), doc_name);
- g_free(doc_name);
-
- gl_mdi_child_connect_signals (child);
-
- gl_debug (DEBUG_MDI, "END");
-
- return child;
-}
-
-glMDIChild*
-gl_mdi_child_new_with_uri (const gchar *uri, GError **error)
-{
- glMDIChild *child;
- glLabel *doc;
- glXMLLabelStatus status;
-
- gl_debug (DEBUG_MDI, "START");
-
- doc = gl_xml_label_open (uri, &status);
-
- if (doc == NULL)
- {
- return NULL;
- }
-
- child = GL_MDI_CHILD (g_object_new (GL_TYPE_MDI_CHILD, NULL));
- g_return_val_if_fail (child != NULL, NULL);
-
- child->label = doc;
- g_return_val_if_fail (child->label != NULL, NULL);
-
- gl_mdi_child_real_state_changed (child);
-
- gl_mdi_child_connect_signals (child);
-
- gl_debug (DEBUG_MDI, "END");
-
- return child;
-}
-
-static GtkWidget *
-gl_mdi_child_create_view (BonoboMDIChild *child)
-{
- glView *new_view;
-
- gl_debug (DEBUG_MDI, "START");
-
- g_return_val_if_fail (child != NULL, NULL);
- g_return_val_if_fail (GL_IS_MDI_CHILD (child), NULL);
-
- new_view = GL_VIEW(gl_view_new (GL_MDI_CHILD (child)->label));
-
- gtk_widget_show_all (GTK_WIDGET (new_view));
-
- gl_debug (DEBUG_MDI, "END");
-
- return GTK_WIDGET (new_view);
-}
-
-static gchar*
-gl_mdi_child_get_config_string (BonoboMDIChild *child, gpointer data)
-{
- glMDIChild *c;
-
- gl_debug (DEBUG_MDI, "");
-
- g_return_val_if_fail (child != NULL, NULL);
- g_return_val_if_fail (GL_IS_MDI_CHILD (child), NULL);
-
- c = GL_MDI_CHILD (child);
-
- return gl_label_get_filename (c->label);
-}
+++ /dev/null
-/*
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * mdi-child.h: gLabels MDI child module header file
- *
- * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
- *
- * 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
- */
-
-/*
- * This file is based on gedit-mdi-child.h from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
- * Copyright (C) 2002 Paolo Maggi
- *
- */
-#ifndef __MDI_CHILD_H__
-#define __MDI_CHILD_H__
-
-#include <bonobo-mdi.h>
-
-#include "label.h"
-
-G_BEGIN_DECLS
-
-#define GL_TYPE_MDI_CHILD (gl_mdi_child_get_type ())
-#define GL_MDI_CHILD(o) (GTK_CHECK_CAST ((o), GL_TYPE_MDI_CHILD, glMDIChild))
-#define GL_MDI_CHILD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MDI_CHILD, \
- glMDIChildClass))
-#define GL_IS_MDI_CHILD(o) (GTK_CHECK_TYPE ((o), GL_TYPE_MDI_CHILD))
-#define GL_IS_MDI_CHILD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MDI_CHILD))
-#define GL_MDI_CHILD_GET_CLASS(o) (GTK_CHECK_GET_CLASS ((o), GL_TYPE_MDI_CHILD, glMdiChildClass))
-
-
-typedef struct _glMDIChild glMDIChild;
-typedef struct _glMDIChildClass glMDIChildClass;
-
-typedef struct _glMDIChildPrivate glMDIChildPrivate;
-
-struct _glMDIChild
-{
- BonoboMDIChild child;
-
- glLabel *label;
- glMDIChildPrivate *priv;
-};
-
-struct _glMDIChildClass
-{
- BonoboMDIChildClass parent_class;
-
- /* MDI child state changed */
- void (*state_changed) (glMDIChild *child);
-
- void (*undo_redo_state_changed) (glMDIChild *child);
-};
-
-
-GtkType gl_mdi_child_get_type (void) G_GNUC_CONST;
-
-glMDIChild* gl_mdi_child_new (const gchar *tmplt_name,
- gboolean rotate_flag);
-
-glMDIChild* gl_mdi_child_new_with_uri (const gchar *uri,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __MDI_CHILD_H__ */
-
+++ /dev/null
-/*
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * mdi.c: gLabels MDI module
- *
- * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
- *
- * 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
- */
-
-/*
- * This file is based on gedit-mdi.c from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
- * Copyright (C) 2002 Paolo Maggi
- *
- */
-#include <config.h>
-
-#include <libgnome/libgnome.h>
-#include <libgnomeui/libgnomeui.h>
-#include <libgnomevfs/gnome-vfs.h>
-
-#include <string.h>
-
-#include "mdi.h"
-#include "mdi-child.h"
-#include "glabels.h"
-#include "ui.h"
-#include "prefs.h"
-#include "file.h"
-#include "view.h"
-#include "debug.h"
-#include "alert.h"
-
-#include <bonobo/bonobo-ui-util.h>
-#include <bonobo/bonobo-control.h>
-
-/*========================================================*/
-/* Private macros and constants. */
-/*========================================================*/
-
-#define DEFAULT_WINDOW_WIDTH 500
-#define DEFAULT_WINDOW_HEIGHT 375
-
-/*========================================================*/
-/* Private types. */
-/*========================================================*/
-
-struct _glMDIPrivate
-{
- gint untitled_number;
-};
-
-
-/*========================================================*/
-/* Private globals. */
-/*========================================================*/
-
-static BonoboMDIClass *parent_class = NULL;
-
-
-/*========================================================*/
-/* Private function prototypes. */
-/*========================================================*/
-
-static void gl_mdi_class_init (glMDIClass *klass);
-static void gl_mdi_init (glMDI *mdi);
-static void gl_mdi_finalize (GObject *object);
-
-static void gl_mdi_app_created_cb (BonoboMDI *mdi, BonoboWindow *win);
-
-static gint gl_mdi_add_child_cb (BonoboMDI *mdi, BonoboMDIChild *child);
-static gint gl_mdi_add_view_cb (BonoboMDI *mdi, GtkWidget *view);
-static gint gl_mdi_remove_child_cb (BonoboMDI *mdi, BonoboMDIChild *child);
-static gint gl_mdi_remove_view_cb (BonoboMDI *mdi, GtkWidget *view);
-
-static void gl_mdi_view_changed_cb (BonoboMDI *mdi, GtkWidget *old_view);
-static void gl_mdi_child_changed_cb (BonoboMDI *mdi, BonoboMDIChild *old_child);
-static void gl_mdi_child_state_changed_cb (glMDIChild *child);
-
-static void gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi);
-static void gl_mdi_set_active_window_selection_verbs_sensitivity (BonoboMDI *mdi);
-
-
-\f
-/*****************************************************************************/
-/* Boilerplate object stuff. */
-/*****************************************************************************/
-GType
-gl_mdi_get_type (void)
-{
- static GType mdi_type = 0;
-
- if (mdi_type == 0)
- {
- static const GTypeInfo our_info =
- {
- sizeof (glMDIClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gl_mdi_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (glMDI),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gl_mdi_init
- };
-
- mdi_type = g_type_register_static (BONOBO_TYPE_MDI,
- "glMDI",
- &our_info,
- 0);
- }
-
- return mdi_type;
-}
-
-static void
-gl_mdi_class_init (glMDIClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- gl_debug (DEBUG_MDI, "START");
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = gl_mdi_finalize;
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static void
-gl_mdi_init (glMDI *mdi)
-{
- gl_debug (DEBUG_MDI, "START");
-
- bonobo_mdi_construct (BONOBO_MDI (mdi), "glabels", "gLabels",
- DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
-
- mdi->priv = g_new0 (glMDIPrivate, 1);
-
- mdi->priv->untitled_number = 0;
-
- bonobo_mdi_set_ui_template_file (BONOBO_MDI (mdi),
- GLABELS_UI_DIR "glabels-ui.xml",
- gl_ui_verbs);
-
- bonobo_mdi_set_child_list_path (BONOBO_MDI (mdi), "/menu/Documents/");
-
- /* Connect signals */
- g_signal_connect (G_OBJECT (mdi), "top_window_created",
- G_CALLBACK (gl_mdi_app_created_cb), NULL);
-
- g_signal_connect (G_OBJECT (mdi), "add_child",
- G_CALLBACK (gl_mdi_add_child_cb), NULL);
- g_signal_connect (G_OBJECT (mdi), "add_view",
- G_CALLBACK (gl_mdi_add_view_cb), NULL);
-
- g_signal_connect (G_OBJECT (mdi), "remove_child",
- G_CALLBACK (gl_mdi_remove_child_cb), NULL);
- g_signal_connect (G_OBJECT (mdi), "remove_view",
- G_CALLBACK (gl_mdi_remove_view_cb), NULL);
-
- g_signal_connect (G_OBJECT (mdi), "child_changed",
- G_CALLBACK (gl_mdi_child_changed_cb), NULL);
- g_signal_connect (G_OBJECT (mdi), "view_changed",
- G_CALLBACK (gl_mdi_view_changed_cb), NULL);
-
- g_signal_connect (G_OBJECT (mdi), "all_windows_destroyed",
- G_CALLBACK (gl_file_exit), NULL);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-static void
-gl_mdi_finalize (GObject *object)
-{
- glMDI *mdi;
-
- gl_debug (DEBUG_MDI, "START");
-
- g_return_if_fail (object != NULL);
-
- mdi = GL_MDI (object);
-
- g_return_if_fail (GL_IS_MDI (mdi));
- g_return_if_fail (mdi->priv != NULL);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-
- g_free (mdi->priv);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-
-/*****************************************************************************/
-/* NEW mdi object. */
-/*****************************************************************************/
-glMDI*
-gl_mdi_new (void)
-{
- glMDI *mdi;
-
- gl_debug (DEBUG_MDI, "START");
-
- mdi = GL_MDI (g_object_new (GL_TYPE_MDI, NULL));
- g_return_val_if_fail (mdi != NULL, NULL);
-
- gl_debug (DEBUG_MDI, "END");
- return mdi;
-}
-
-/*---------------------------------------------------------------------------*/
-/* App created callback. */
-/*---------------------------------------------------------------------------*/
-static void
-gl_mdi_app_created_cb (BonoboMDI *mdi,
- BonoboWindow *win)
-{
- GtkWidget *widget;
- BonoboControl *control;
- BonoboUIComponent *ui_component;
-
- gl_debug (DEBUG_MDI, "START");
-
- ui_component = bonobo_mdi_get_ui_component_from_window (win);
- g_return_if_fail (ui_component != NULL);
-
- gl_ui_init (ui_component, win);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* Child state changed callback. */
-/*---------------------------------------------------------------------------*/
-static void
-gl_mdi_child_state_changed_cb (glMDIChild *child)
-{
- gl_debug (DEBUG_MDI, "START");
-
- if (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)) != BONOBO_MDI_CHILD (child))
- return;
-
- gl_mdi_set_active_window_title (BONOBO_MDI (glabels_mdi));
- gl_mdi_set_active_window_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* Child undo/redo state changed callback. */
-/*---------------------------------------------------------------------------*/
-static void
-gl_mdi_child_undo_redo_state_changed_cb (glMDIChild *child)
-{
- gl_debug (DEBUG_MDI, "START");
-
- if (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)) != BONOBO_MDI_CHILD (child))
- return;
-
- gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
- gl_debug (DEBUG_MDI, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* Add child callback. */
-/*---------------------------------------------------------------------------*/
-static gint
-gl_mdi_add_child_cb (BonoboMDI *mdi,
- BonoboMDIChild *child)
-{
- gl_debug (DEBUG_MDI, "START");
-
- g_signal_connect (G_OBJECT (child), "state_changed",
- G_CALLBACK (gl_mdi_child_state_changed_cb),
- NULL);
- g_signal_connect (G_OBJECT (child), "undo_redo_state_changed",
- G_CALLBACK (gl_mdi_child_undo_redo_state_changed_cb),
- NULL);
-
- gl_debug (DEBUG_MDI, "END");
- return TRUE;
-}
-
-/*---------------------------------------------------------------------------*/
-/* View selection state changed callback. */
-/*---------------------------------------------------------------------------*/
-static void
-gl_mdi_view_selection_state_changed_cb (glView *view)
-{
- gl_debug (DEBUG_MDI, "START");
-
- if (bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi)) != GTK_WIDGET (view))
- return;
-
- gl_mdi_set_active_window_selection_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
- gl_debug (DEBUG_MDI, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* Add view callback. */
-/*---------------------------------------------------------------------------*/
-static gint
-gl_mdi_add_view_cb (BonoboMDI *mdi,
- GtkWidget *view)
-{
- gl_debug (DEBUG_MDI, "START");
-
- g_signal_connect (G_OBJECT (view), "selection_changed",
- G_CALLBACK (gl_mdi_view_selection_state_changed_cb),
- NULL);
-
- gl_debug (DEBUG_MDI, "END");
- return TRUE;
-}
-
-/*---------------------------------------------------------------------------*/
-/* Remove child callback. */
-/*---------------------------------------------------------------------------*/
-static gint
-gl_mdi_remove_child_cb (BonoboMDI *mdi,
- BonoboMDIChild *child)
-{
- glLabel *doc;
- gboolean close = TRUE;
-
- gl_debug (DEBUG_MDI, "START");
-
- g_return_val_if_fail (child != NULL, FALSE);
- g_return_val_if_fail (GL_MDI_CHILD (child)->label != NULL, FALSE);
-
- doc = GL_MDI_CHILD (child)->label;
-
- if (gl_label_is_modified (doc))
- {
- GtkWidget *msgbox, *w;
- gchar *fname = NULL, *msg = NULL;
- gint ret;
- gboolean exiting;
-
- w = GTK_WIDGET (g_list_nth_data (bonobo_mdi_child_get_views (child), 0));
-
- if(w != NULL)
- bonobo_mdi_set_active_view (mdi, w);
-
- fname = gl_label_get_short_name (doc);
-
- msg = g_strdup_printf (_("Save changes to document \"%s\" before closing?"),
- fname);
-
- msgbox = gl_alert_dialog_new (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- msg,
- _("Your changes will be lost if you don't save them."));
-
- gtk_dialog_add_button (GTK_DIALOG (msgbox),
- _("Close without saving"),
- GTK_RESPONSE_NO);
-
- if (glabels_close_x_button_pressed)
- exiting = FALSE;
- else if (glabels_exit_button_pressed)
- exiting = TRUE;
- else
- {
- /* Delete event generated */
- if (g_list_length (bonobo_mdi_get_windows (BONOBO_MDI (glabels_mdi))) == 1)
- exiting = TRUE;
- else
- exiting = FALSE;
- }
-
-
- gtk_dialog_add_button (GTK_DIALOG (msgbox),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-
- gtk_dialog_add_button (GTK_DIALOG (msgbox),
- GTK_STOCK_SAVE, GTK_RESPONSE_YES);
-
- gtk_dialog_set_default_response (GTK_DIALOG (msgbox), GTK_RESPONSE_YES);
-
- gtk_window_set_resizable (GTK_WINDOW (msgbox), FALSE);
-
- ret = gtk_dialog_run (GTK_DIALOG (msgbox));
-
- gtk_widget_destroy (msgbox);
-
- g_free (fname);
- g_free (msg);
-
- switch (ret)
- {
- case GTK_RESPONSE_YES:
- close = gl_file_save (GL_MDI_CHILD (child));
- break;
- case GTK_RESPONSE_NO:
- close = TRUE;
- break;
- default:
- close = FALSE;
- }
-
- gl_debug (DEBUG_MDI, "CLOSE: %s", close ? "TRUE" : "FALSE");
- }
-
- gl_debug (DEBUG_MDI, "END");
- return close;
-}
-
-/*---------------------------------------------------------------------------*/
-/* Remove view callback. */
-/*---------------------------------------------------------------------------*/
-static gint
-gl_mdi_remove_view_cb (BonoboMDI *mdi,
- GtkWidget *view)
-{
- gl_debug (DEBUG_MDI, "");
- gl_debug (DEBUG_MDI, "END");
-
- return TRUE;
-}
-
-/*****************************************************************************/
-/* Set title of active window. */
-/*****************************************************************************/
-void
-gl_mdi_set_active_window_title (BonoboMDI *mdi)
-{
- BonoboMDIChild *active_child = NULL;
- glLabel *doc = NULL;
- gchar *docname = NULL;
- gchar *title = NULL;
-
- gl_debug (DEBUG_MDI, "START");
-
-
- active_child = bonobo_mdi_get_active_child (mdi);
- if (active_child == NULL)
- return;
-
- doc = GL_MDI_CHILD (active_child)->label;
- g_return_if_fail (doc != NULL);
-
- /* Set active window title */
- docname = gl_label_get_short_name (doc);
- g_return_if_fail (docname != NULL);
-
- if (gl_label_is_modified (doc))
- {
- title = g_strdup_printf ("%s %s - glabels",
- docname, _("(modified)"));
- }
- else
- {
- title = g_strdup_printf ("%s - glabels", docname);
-
- }
-
- gtk_window_set_title (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)), title);
-
- g_free (docname);
- g_free (title);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* Child changed callback. */
-/*---------------------------------------------------------------------------*/
-static
-void gl_mdi_child_changed_cb (BonoboMDI *mdi,
- BonoboMDIChild *old_child)
-{
- gl_debug (DEBUG_MDI, "START");
-
- gl_mdi_set_active_window_title (mdi);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* View changed callback. */
-/*---------------------------------------------------------------------------*/
-static
-void gl_mdi_view_changed_cb (BonoboMDI *mdi,
- GtkWidget *old_view)
-{
- BonoboWindow *win;
- GtkWidget *status;
- GtkWidget *active_view;
-
- gl_debug (DEBUG_MDI, "START");
-
- gl_mdi_set_active_window_verbs_sensitivity (mdi);
-
- active_view = bonobo_mdi_get_active_view (mdi);
-
- win = bonobo_mdi_get_active_window (mdi);
- g_return_if_fail (win != NULL);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-/*****************************************************************************/
-/* Set sensitivity of verbs in active window. */
-/*****************************************************************************/
-void
-gl_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi)
-{
- BonoboWindow *active_window = NULL;
- BonoboMDIChild *active_child = NULL;
- glView *view = NULL;
- BonoboUIComponent *ui_component;
-
- gl_debug (DEBUG_MDI, "START");
-
- active_window = bonobo_mdi_get_active_window (mdi);
-
- if (active_window == NULL)
- return;
-
- ui_component = bonobo_mdi_get_ui_component_from_window (active_window);
- g_return_if_fail (ui_component != NULL);
-
- active_child = bonobo_mdi_get_active_child (mdi);
-
- if (active_child == NULL)
- {
- gl_ui_update_nodoc (ui_component);
- return;
- }
-
- view = GL_VIEW (bonobo_mdi_get_active_view (mdi));
-
- gl_ui_update_all (ui_component, view);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-
-/*****************************************************************************/
-/* Set sensitivity of undo/redo verbs in active window. */
-/*****************************************************************************/
-static void
-gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi)
-{
- BonoboWindow *active_window = NULL;
- BonoboMDIChild *active_child = NULL;
- glLabel *doc = NULL;
- BonoboUIComponent *ui_component;
-
- gl_debug (DEBUG_MDI, "START");
-
- active_window = bonobo_mdi_get_active_window (mdi);
- g_return_if_fail (active_window != NULL);
-
- ui_component = bonobo_mdi_get_ui_component_from_window (active_window);
- g_return_if_fail (ui_component != NULL);
-
- active_child = bonobo_mdi_get_active_child (mdi);
- doc = GL_MDI_CHILD (active_child)->label;
- g_return_if_fail (doc != NULL);
-
- gl_ui_update_undo_redo_verbs (ui_component, doc);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
-/*****************************************************************************/
-/* Set sensitivity of selection verbs in active window. */
-/*****************************************************************************/
-static void
-gl_mdi_set_active_window_selection_verbs_sensitivity (BonoboMDI *mdi)
-{
- BonoboWindow *active_window = NULL;
- glView *view = NULL;
- BonoboUIComponent *ui_component;
-
- gl_debug (DEBUG_MDI, "START");
-
- active_window = bonobo_mdi_get_active_window (mdi);
- g_return_if_fail (active_window != NULL);
-
- ui_component = bonobo_mdi_get_ui_component_from_window (active_window);
- g_return_if_fail (ui_component != NULL);
-
- view = GL_VIEW (bonobo_mdi_get_active_view (mdi));
- g_return_if_fail (view != NULL);
-
- gl_ui_update_selection_verbs (ui_component, view);
-
- gl_debug (DEBUG_MDI, "END");
-}
-
+++ /dev/null
-/*
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * mdi.h: gLabels MDI module header file
- *
- * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
- *
- * 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
- */
-
-/*
- * This file is based on gedit-mdi.h from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
- * Copyright (C) 2002 Paolo Maggi
- *
- */
-#ifndef __MDI_H__
-#define __MDI_H__
-
-#include <bonobo-mdi.h>
-
-G_BEGIN_DECLS
-
-#define GL_TYPE_MDI (gl_mdi_get_type ())
-#define GL_MDI(obj) (GTK_CHECK_CAST ((obj), GL_TYPE_MDI, glMDI))
-#define GL_MDI_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MDI, glMDIClass))
-#define GL_IS_MDI(obj) (GTK_CHECK_TYPE ((obj), GL_TYPE_MDI))
-#define GL_IS_MDI_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MDI))
-#define GL_MDI_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GL_TYPE_MDI, glMdiClass))
-
-
-typedef struct _glMDI glMDI;
-typedef struct _glMDIClass glMDIClass;
-
-typedef struct _glMDIPrivate glMDIPrivate;
-
-struct _glMDI
-{
- BonoboMDI mdi;
-
- glMDIPrivate *priv;
-};
-
-struct _glMDIClass
-{
- BonoboMDIClass parent_class;
-};
-
-
-GtkType gl_mdi_get_type (void) G_GNUC_CONST;
-
-glMDI* gl_mdi_new (void);
-
-void gl_mdi_set_active_window_title (BonoboMDI *mdi);
-
-void gl_mdi_update_ui_according_to_preferences (glMDI *mdi);
-
-void gl_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi);
-
-G_END_DECLS
-
-#endif /* __MDI_H__ */
-
*/
#include <config.h>
-#include "glabels.h"
-#include "mdi.h"
#include "view.h"
#include "merge.h"
#include "merge-ui.h"
{
static PropertyDialogPassback *data = NULL;
GtkWidget *dialog;
- BonoboWindow *win = glabels_get_active_window ();
if (data == NULL) {
data = g_new0 (PropertyDialogPassback, 1);
dialog = gl_hig_dialog_new_with_buttons (
_("Edit document-merge properties"),
- GTK_WINDOW (win),
+ NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
#include <libgnome/libgnome.h>
#include <libgnomeui/libgnomeui.h>
-#include "bonobo-mdi.h"
#include "prefs-dialog.h"
#include "prefs.h"
-#include "glabels.h"
#include "wdgt-line.h"
#include "wdgt-fill.h"
#include "wdgt-text-props.h"
#include <libgnome/libgnome.h>
#include <libgnomeui/libgnomeui.h>
-#include <bonobo-mdi.h>
#include <gconf/gconf-client.h>
#include "prefs.h"
-#include "glabels.h"
#include "util.h"
#include "debug.h"
#define PREF_DRAWING_TOOLBAR_BUTTONS_STYLE "/drawing-toolbar-buttons-style"
#define PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS "/drawing-toolbar-view-tooltips"
-#define PREF_MDI_MODE "/mdi-mode"
-#define PREF_TABS_POSITION "/mdi-tabs-position"
-
#define PREF_MAX_RECENTS "/max-recents"
/* Default values */
void
gl_prefs_save_settings (void)
{
- BonoboWindow* active_window = NULL;
-
gl_debug (DEBUG_PREFS, "START");
g_return_if_fail (gconf_client != NULL);
NULL);
- /* MDI */
- gconf_client_set_int (gconf_client,
- BASE_KEY PREF_MDI_MODE,
- gl_prefs->mdi_mode,
- NULL);
-
- gconf_client_set_int (gconf_client,
- BASE_KEY PREF_TABS_POSITION,
- gl_prefs->mdi_tabs_position,
- NULL);
-
-
/* Recent files */
gconf_client_set_int (gconf_client,
BASE_KEY PREF_MAX_RECENTS,
TRUE);
- /* User Inferface/MDI */
- gl_prefs->mdi_mode =
- get_int (gconf_client,
- BASE_KEY PREF_MDI_MODE,
- 0);
-
- gl_prefs->mdi_tabs_position =
- get_int (gconf_client,
- BASE_KEY PREF_TABS_POSITION,
- 0);
-
-
/* Recent files */
gl_prefs->max_recents =
get_int (gconf_client,
#include "label.h"
#include "bc.h"
#include "template.h"
-#include "mdi.h"
-#include "glabels.h"
#include "wdgt-print-copies.h"
#include "wdgt-print-merge.h"
#ifndef __PRINT_DIALOG_H__
#define __PRINT_DIALOG_H__
-#include <gnome.h>
-#include <bonobo-mdi.h>
+#include <bonobo/bonobo-window.h>
#include "label.h"
extern void gl_print_dialog (glLabel *label, BonoboWindow *win);
/*
* (GLABELS) Label and Business Card Creation program for GNOME
*
- * tools.c: toolbar module
+ * tools.c: implementation of drawing toolbar verbs
*
* Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
*
#include <config.h>
#include "tools.h"
-#include "glabels.h"
+#include "window.h"
#include "merge-properties.h"
/*===========================================*/
/*****************************************************************************/
void
gl_tools_arrow (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_arrow_mode (view);
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_arrow_mode (GL_VIEW(window->view));
}
}
/*****************************************************************************/
void
gl_tools_text (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_object_create_mode (view, GL_LABEL_OBJECT_TEXT);
+ if (window->view != NULL) {
+ gl_view_object_create_mode (GL_VIEW(window->view),
+ GL_LABEL_OBJECT_TEXT);
}
}
/*****************************************************************************/
void
gl_tools_box (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_object_create_mode (view, GL_LABEL_OBJECT_BOX);
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_object_create_mode (GL_VIEW(window->view),
+ GL_LABEL_OBJECT_BOX);
}
}
/*****************************************************************************/
void
gl_tools_line (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_object_create_mode (view, GL_LABEL_OBJECT_LINE);
+ if (window->view != NULL) {
+ gl_view_object_create_mode (GL_VIEW(window->view),
+ GL_LABEL_OBJECT_LINE);
}
}
/*****************************************************************************/
void
gl_tools_ellipse (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_object_create_mode (view,
- GL_LABEL_OBJECT_ELLIPSE);
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_object_create_mode (GL_VIEW(window->view),
+ GL_LABEL_OBJECT_ELLIPSE);
}
}
/*****************************************************************************/
void
gl_tools_image (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_object_create_mode (view, GL_LABEL_OBJECT_IMAGE);
+ if (window->view != NULL) {
+ gl_view_object_create_mode (GL_VIEW(window->view),
+ GL_LABEL_OBJECT_IMAGE);
}
}
/*****************************************************************************/
void
gl_tools_barcode (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_object_create_mode (view,
- GL_LABEL_OBJECT_BARCODE);
+ if (window->view != NULL) {
+ gl_view_object_create_mode (GL_VIEW(window->view),
+ GL_LABEL_OBJECT_BARCODE);
}
}
/*****************************************************************************/
void
gl_tools_zoomin (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_zoom_in (view);
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_zoom_in (GL_VIEW(window->view));
}
}
/*****************************************************************************/
void
gl_tools_zoomout (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_zoom_out (view);
+ if (window->view != NULL) {
+ gl_view_zoom_out (GL_VIEW(window->view));
}
}
/*****************************************************************************/
void
gl_tools_zoom1to1 (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_set_zoom (view, 1.0);
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_set_zoom (GL_VIEW(window->view), 1.0);
}
}
/*****************************************************************************/
void
gl_tools_merge_properties (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_merge_properties_dialog (view);
+ if (window->view != NULL) {
+ gl_merge_properties_dialog (GL_VIEW(window->view));
}
}
/*****************************************************************************/
void
gl_tools_object_properties (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_edit_object_props (view);
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_edit_object_props (GL_VIEW(window->view));
}
}
/*****************************************************************************/
void
gl_tools_raise_objects (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_raise_selection (view);
+ if (window->view != NULL) {
+ gl_view_raise_selection (GL_VIEW(window->view));
}
}
/*****************************************************************************/
void
gl_tools_lower_objects (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname)
+ gpointer user_data,
+ const gchar *verbname)
{
- glView *view;
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
- view = glabels_get_active_view ();
- if (view != NULL) {
- gl_view_lower_selection (view);
+ if (window->view != NULL) {
+ gl_view_lower_selection (GL_VIEW(window->view));
}
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
-/*
- * This file is based on gedit-menus.c from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
- *
- */
#include <config.h>
#include "gnome-recent-view.h"
#include "ui.h"
#include "commands.h"
#include "tools.h"
-#include "glabels.h"
#include "recent.h"
#include "file.h"
#include "prefs.h"
+#include "debug.h"
+
+/*========================================================*/
+/* Private macros and constants. */
+/*========================================================*/
+#define GLABELS_UI_XML GLABELS_UI_DIR "glabels-ui.xml"
+
+/*========================================================*/
+/* Private types. */
+/*========================================================*/
+
+
/*===========================================*/
-/* Public globals */
+/* Private globals */
/*===========================================*/
-BonoboUIVerb gl_ui_verbs [] = {
+
+static BonoboUIVerb gl_ui_verbs [] = {
BONOBO_UI_VERB ("FileNew", gl_cmd_file_new),
BONOBO_UI_VERB ("FileOpen", gl_cmd_file_open),
BONOBO_UI_VERB ("FileSave", gl_cmd_file_save),
BONOBO_UI_VERB ("FileSaveAs", gl_cmd_file_save_as),
BONOBO_UI_VERB ("FilePrint", gl_cmd_file_print),
BONOBO_UI_VERB ("FileClose", gl_cmd_file_close),
- BONOBO_UI_VERB ("FileCloseAll", gl_cmd_file_close_all),
BONOBO_UI_VERB ("FileExit", gl_cmd_file_exit),
BONOBO_UI_VERB ("EditCut", gl_cmd_edit_cut),
BONOBO_UI_VERB ("EditCopy", gl_cmd_edit_copy),
BONOBO_UI_VERB_END
};
-/*========================================================*/
-/* Private macros and constants. */
-/*========================================================*/
-
-
-/*========================================================*/
-/* Private types. */
-/*========================================================*/
-
-
-/*===========================================*/
-/* Private globals */
-/*===========================================*/
-
static gchar* doc_verbs [] = {
"/commands/FileSave",
"/commands/FileSaveAs",
const char *state,
BonoboWindow *win);
-static void set_app_main_toolbar_style (BonoboWindow *win);
-static void set_app_drawing_toolbar_style (BonoboWindow *win);
+static void set_app_main_toolbar_style (BonoboUIComponent *ui_component);
+static void set_app_drawing_toolbar_style (BonoboUIComponent *ui_component);
static void
set_verb_sensitive (BonoboUIComponent *ui_component,
/*****************************************************************************/
/* Initialize UI component for given window. */
/*****************************************************************************/
-void gl_ui_init (BonoboUIComponent *ui_component,
- BonoboWindow *win)
+void
+gl_ui_init (BonoboUIComponent *ui_component,
+ BonoboWindow *win)
{
GnomeRecentView *recent_view;
GnomeRecentModel *recent_model;
+ gl_debug (DEBUG_UI, "START");
+
+ gl_debug (DEBUG_UI, "window = %p", win);
+
g_return_if_fail (ui_component != NULL);
+ bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (win),
+ "/glabels/UIConfig/kvps");
+ gl_debug (DEBUG_UI, "Path set");
+
+ bonobo_ui_util_set_ui (ui_component,
+ "", GLABELS_UI_XML, "gLabels", NULL);
+ gl_debug (DEBUG_UI, "UI set");
+
+ bonobo_ui_component_add_verb_list_with_data(ui_component,
+ gl_ui_verbs, win);
+ gl_debug (DEBUG_UI, "verb list added");
+
/* Set the toolbar style according to prefs */
- set_app_main_toolbar_style (win);
+ set_app_main_toolbar_style (ui_component);
- /* Add listener fo the view menu */
+ /* Add listener for the view menu */
bonobo_ui_component_add_listener (ui_component, "ViewMainToolbar",
(BonoboUIListenerFn)view_menu_item_toggled_cb,
(gpointer)win);
(gpointer)win);
/* Set the toolbar style according to prefs */
- set_app_drawing_toolbar_style (win);
+ set_app_drawing_toolbar_style (ui_component);
- /* Add listener fo the view menu */
+ /* Add listener for the view menu */
bonobo_ui_component_add_listener (ui_component, "ViewDrawingToolbar",
(BonoboUIListenerFn)view_menu_item_toggled_cb,
(gpointer)win);
g_signal_connect (G_OBJECT (recent_view), "activate",
G_CALLBACK (gl_file_open_recent), win);
+ gl_debug (DEBUG_UI, "END");
}
/*****************************************************************************/
/* Update all verbs of given UI component. */
/*****************************************************************************/
-void gl_ui_update_all (BonoboUIComponent *ui_component,
- glView *view)
+void
+gl_ui_update_all (BonoboUIComponent *ui_component,
+ glView *view)
{
glLabel *label;
+ gl_debug (DEBUG_UI, "START");
+
bonobo_ui_component_freeze (ui_component, NULL);
set_verb_list_sensitive (ui_component, doc_verbs, TRUE);
gl_view_is_selection_atomic (view));
bonobo_ui_component_thaw (ui_component, NULL);
+
+ gl_debug (DEBUG_UI, "END");
}
/*****************************************************************************/
/* Update all verbs of given UI component to "no document" state. */
/*****************************************************************************/
-void gl_ui_update_nodoc (BonoboUIComponent *ui_component)
+void
+gl_ui_update_nodoc (BonoboUIComponent *ui_component)
{
+ gl_debug (DEBUG_UI, "START");
+
bonobo_ui_component_freeze (ui_component, NULL);
set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
bonobo_ui_component_thaw (ui_component, NULL);
+
+ gl_debug (DEBUG_UI, "END");
}
/*****************************************************************************/
-/* Update undo/redo verbs of given UI component. */
+/* Update label modified verbs of given UI component. */
/*****************************************************************************/
-void gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component,
- glLabel *label)
+void
+gl_ui_update_modified_verbs (BonoboUIComponent *ui_component,
+ glLabel *label)
{
- bonobo_ui_component_freeze (ui_component, NULL);
+ gl_debug (DEBUG_UI, "START");
- set_verb_sensitive (ui_component,
- "/commands/EditUndo", gl_label_can_undo (label));
+ bonobo_ui_component_freeze (ui_component, NULL);
- set_verb_sensitive (ui_component,
- "/commands/EditRedo", gl_label_can_redo (label));
+ set_verb_list_sensitive (ui_component,
+ doc_modified_verbs,
+ gl_label_is_modified (label));
bonobo_ui_component_thaw (ui_component, NULL);
+
+ gl_debug (DEBUG_UI, "END");
}
/*****************************************************************************/
/* Update verbs associated with selection state of given UI component. */
/*****************************************************************************/
-void gl_ui_update_selection_verbs (BonoboUIComponent *ui_component,
- glView *view)
+void
+gl_ui_update_selection_verbs (BonoboUIComponent *ui_component,
+ glView *view)
{
+ gl_debug (DEBUG_UI, "START");
+
bonobo_ui_component_freeze (ui_component, NULL);
set_verb_list_sensitive (ui_component,
gl_view_is_selection_atomic (view));
bonobo_ui_component_thaw (ui_component, NULL);
+
+ gl_debug (DEBUG_UI, "END");
+}
+
+/*****************************************************************************/
+/* Update undo/redo verbs of given UI component. */
+/*****************************************************************************/
+void
+gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component,
+ glLabel *label)
+{
+ gl_debug (DEBUG_UI, "START");
+
+ bonobo_ui_component_freeze (ui_component, NULL);
+
+ set_verb_sensitive (ui_component,
+ "/commands/EditUndo", gl_label_can_undo (label));
+
+ set_verb_sensitive (ui_component,
+ "/commands/EditRedo", gl_label_can_redo (label));
+
+ bonobo_ui_component_thaw (ui_component, NULL);
+
+ gl_debug (DEBUG_UI, "END");
}
/*---------------------------------------------------------------------------*/
{
gboolean s;
+ gl_debug (DEBUG_UI, "");
+
s = (strcmp (state, "1") == 0);
if ((strcmp (path, "ViewMainToolbar") == 0) &&
(s != gl_prefs->main_toolbar_visible))
{
gl_prefs->main_toolbar_visible = s;
- set_app_main_toolbar_style (win);
+ set_app_main_toolbar_style (ui_component);
return;
}
(gl_prefs->main_toolbar_buttons_style != GL_TOOLBAR_SYSTEM))
{
gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
- set_app_main_toolbar_style (win);
+ set_app_main_toolbar_style (ui_component);
return;
}
(gl_prefs->main_toolbar_buttons_style != GL_TOOLBAR_ICONS))
{
gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS;
- set_app_main_toolbar_style (win);
+ set_app_main_toolbar_style (ui_component);
return;
}
(gl_prefs->main_toolbar_buttons_style != GL_TOOLBAR_ICONS_AND_TEXT))
{
gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
- set_app_main_toolbar_style (win);
+ set_app_main_toolbar_style (ui_component);
return;
}
(s != gl_prefs->main_toolbar_view_tooltips))
{
gl_prefs->main_toolbar_view_tooltips = s;
- set_app_main_toolbar_style (win);
+ set_app_main_toolbar_style (ui_component);
return;
}
(s != gl_prefs->drawing_toolbar_visible))
{
gl_prefs->drawing_toolbar_visible = s;
- set_app_drawing_toolbar_style (win);
+ set_app_drawing_toolbar_style (ui_component);
return;
}
(gl_prefs->drawing_toolbar_buttons_style != GL_TOOLBAR_SYSTEM))
{
gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
- set_app_drawing_toolbar_style (win);
+ set_app_drawing_toolbar_style (ui_component);
return;
}
(gl_prefs->drawing_toolbar_buttons_style != GL_TOOLBAR_ICONS))
{
gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_ICONS;
- set_app_drawing_toolbar_style (win);
+ set_app_drawing_toolbar_style (ui_component);
return;
}
(gl_prefs->drawing_toolbar_buttons_style != GL_TOOLBAR_ICONS_AND_TEXT))
{
gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
- set_app_drawing_toolbar_style (win);
+ set_app_drawing_toolbar_style (ui_component);
return;
}
(s != gl_prefs->drawing_toolbar_view_tooltips))
{
gl_prefs->drawing_toolbar_view_tooltips = s;
- set_app_drawing_toolbar_style (win);
+ set_app_drawing_toolbar_style (ui_component);
return;
}
/* PRIVATE. Set main toolbar style. */
/*---------------------------------------------------------------------------*/
static void
-set_app_main_toolbar_style (BonoboWindow *win)
+set_app_main_toolbar_style (BonoboUIComponent *ui_component)
{
- BonoboUIComponent *ui_component;
GConfClient *client;
gboolean labels;
- g_return_if_fail (BONOBO_IS_WINDOW (win));
-
- ui_component = bonobo_mdi_get_ui_component_from_window (win);
- g_return_if_fail (ui_component != NULL);
+ gl_debug (DEBUG_UI, "START");
+
+ g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
bonobo_ui_component_freeze (ui_component, NULL);
error:
bonobo_ui_component_thaw (ui_component, NULL);
+ gl_debug (DEBUG_UI, "END");
}
/* PRIVATE. Set drawing toolbar style. */
/*---------------------------------------------------------------------------*/
static void
-set_app_drawing_toolbar_style (BonoboWindow *win)
+set_app_drawing_toolbar_style (BonoboUIComponent *ui_component)
{
- BonoboUIComponent *ui_component;
GConfClient *client;
gboolean labels;
-
- g_return_if_fail (BONOBO_IS_WINDOW (win));
-
- ui_component = bonobo_mdi_get_ui_component_from_window (win);
- g_return_if_fail (ui_component != NULL);
+ gl_debug (DEBUG_UI, "START");
+
+ g_return_if_fail (BONOBO_IS_UI_COMPONENT(ui_component));
bonobo_ui_component_freeze (ui_component, NULL);
error:
bonobo_ui_component_thaw (ui_component, NULL);
+ gl_debug (DEBUG_UI, "END");
}
gchar *cname,
gboolean sensitive)
{
+ gl_debug (DEBUG_UI, "START");
+
g_return_if_fail (cname != NULL);
g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
"sensitive",
sensitive ? "1" : "0",
NULL);
+
+ gl_debug (DEBUG_UI, "END");
}
/*---------------------------------------------------------------------------*/
gchar **vlist,
gboolean sensitive)
{
+ gl_debug (DEBUG_UI, "START");
+
g_return_if_fail (vlist != NULL);
g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
sensitive ? "1" : "0",
NULL);
}
+
+ gl_debug (DEBUG_UI, "END");
}
/*---------------------------------------------------------------------------*/
gchar *cname,
gboolean state)
{
+ gl_debug (DEBUG_UI, "START");
+
g_return_if_fail (cname != NULL);
g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
"state",
state ? "1" : "0",
NULL);
+
+ gl_debug (DEBUG_UI, "END");
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
-/*
- * This file is based on gedit-menus.h from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
- *
- */
#ifndef __GL_UI_H__
#define __GL_UI_H__
#include "view.h"
-extern BonoboUIVerb gl_ui_verbs [];
-
-
extern void gl_ui_init (BonoboUIComponent *ui_component,
BonoboWindow *win);
+
extern void gl_ui_update_all (BonoboUIComponent *ui_component,
glView *view);
+
extern void gl_ui_update_nodoc (BonoboUIComponent *ui_component);
-extern void gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component,
+
+extern void gl_ui_update_modified_verbs (BonoboUIComponent *ui_component,
glLabel *label);
+
extern void gl_ui_update_selection_verbs (BonoboUIComponent *ui_component,
glView *view);
+extern void gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component,
+ glLabel *label);
+
#endif /* __GL_UI_H__ */
#include "view-highlight.h"
-#include "glabels.h"
#include "wdgt-bc-data.h"
#include "wdgt-bc-props.h"
#include "wdgt-bc-style.h"
construct_properties_dialog (glViewBarcode *view_barcode)
{
GtkWidget *dialog, *wsection;
- BonoboWindow *win = glabels_get_active_window ();
glLabelObject *object;
gdouble x, y, w, h, label_width, label_height;
glTextNode *text_node;
/* Build dialog. */
/*-----------------------------------------------------------------*/
dialog = gl_hig_dialog_new_with_buttons ( _("Edit barcode object properties"),
- GTK_WINDOW (win),
+ NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
#include "view-highlight.h"
-#include "glabels.h"
#include "wdgt-line.h"
#include "wdgt-fill.h"
#include "wdgt-size.h"
construct_properties_dialog (glViewBox *view_box)
{
GtkWidget *dialog, *wsection;
- BonoboWindow *win = glabels_get_active_window ();
glLabelObject *object;
gdouble line_width;
guint line_color, fill_color;
/* Build dialog with notebook. */
/*-----------------------------------------------------------------*/
dialog = gl_hig_dialog_new_with_buttons ( _("Edit box object properties"),
- GTK_WINDOW (win),
+ NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
#include "view-highlight.h"
-#include "glabels.h"
#include "wdgt-line.h"
#include "wdgt-fill.h"
#include "wdgt-size.h"
construct_properties_dialog (glViewEllipse *view_ellipse)
{
GtkWidget *dialog, *wsection;
- BonoboWindow *win = glabels_get_active_window ();
glLabelObject *object;
gdouble line_width;
guint line_color, fill_color;
/* Build dialog with notebook. */
/*-----------------------------------------------------------------*/
dialog = gl_hig_dialog_new_with_buttons ( _("Edit ellipse object properties"),
- GTK_WINDOW (win),
+ NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
#include "view-highlight.h"
-#include "glabels.h"
#include "wdgt-line.h"
#include "wdgt-fill.h"
#include "wdgt-size.h"
construct_properties_dialog (glViewImage *view_image)
{
GtkWidget *dialog, *wsection, *wbutton;
- BonoboWindow *win = glabels_get_active_window ();
glLabelObject *object;
gdouble x, y, w, h, label_width, label_height;
gchar *filename;
/* Build dialog. */
/*-----------------------------------------------------------------*/
dialog = gl_hig_dialog_new_with_buttons ( _("Edit image object properties"),
- GTK_WINDOW (win),
+ NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
#include "view-highlight.h"
-#include "glabels.h"
#include "wdgt-line.h"
#include "wdgt-vector.h"
#include "wdgt-position.h"
construct_properties_dialog (glViewLine *view_line)
{
GtkWidget *dialog, *wsection;
- BonoboWindow *win = glabels_get_active_window ();
glLabelObject *object;
gdouble line_width;
guint line_color;
/* Build dialog with notebook. */
/*-----------------------------------------------------------------*/
dialog = gl_hig_dialog_new_with_buttons ( _("Edit line object properties"),
- GTK_WINDOW (win),
+ NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
#include "view-text.h"
#include "canvas-hacktext.h"
#include "view-highlight.h"
-#include "glabels.h"
#include "wdgt-text-entry.h"
#include "wdgt-text-props.h"
#include "wdgt-position.h"
construct_properties_dialog (glViewText *view_text)
{
GtkWidget *dialog, *wsection, *wbutton;
- BonoboWindow *win = glabels_get_active_window ();
glLabelObject *object;
gdouble x, y, w, h, label_width, label_height;
GList *lines;
/* Build dialog. */
/*-----------------------------------------------------------------*/
dialog = gl_hig_dialog_new_with_buttons ( _("Edit text object properties"),
- GTK_WINDOW (win),
+ NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,