GtkScrolledWindow *scroll;
GtkWidget *view_widget;
Component *component;
- gdouble zoom;
};
struct _Component {
static void container_open_cmd (GtkWidget *widget, Container *container);
static void container_close_cmd (GtkWidget *widget, Container *container);
static void container_exit_cmd (void);
+ static void container_about_cmd (GtkWidget *widget, Container *container);
static Component *container_activate_component (Container *container, char *component_goad_id);
- static void zoom_in_cmd (GtkWidget *widget, Container *container);
- static void zoom_out_cmd (GtkWidget *widget, Container *container);
- static void zoom_set (Container *container);
}
/*
GNOMEUIINFO_END
};
-static GnomeUIInfo container_menu_zoom [] = {
- { GNOME_APP_UI_ITEM, N_("_Zoom in"),
- N_("Increase the size of objects in the PDF"),
- zoom_in_cmd },
- { GNOME_APP_UI_ITEM, N_("_Zoom out"),
- N_("Decrease the size of objects in the PDF"),
- zoom_out_cmd },
+static GnomeUIInfo container_help_menu [] = {
+ GNOMEUIINFO_MENU_ABOUT_ITEM(container_about_cmd, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo container_main_menu [] = {
GNOMEUIINFO_MENU_FILE_TREE (container_file_menu),
- { GNOME_APP_UI_SUBTREE, N_("_Zoom"), NULL, container_menu_zoom },
+ GNOMEUIINFO_MENU_HELP_TREE (container_help_menu),
GNOMEUIINFO_END
};
g_return_val_if_fail (container != NULL, FALSE);
g_return_val_if_fail (container->view_widget == NULL, FALSE);
- comp = container_activate_component (container, "bonobo-object:image-x-pdf");
+ comp = container_activate_component (container, "bonobo-object:application-x-pdf");
if (!comp || !(object = comp->server)) {
gnome_error_dialog (_("Could not launch bonobo object."));
return FALSE;
GNOME_PersistStream_load (persist,
(GNOME_Stream) gnome_object_corba_objref (GNOME_OBJECT (stream)), &ev);
- zoom_set (container);
-
GNOME_Unknown_unref (persist, &ev);
CORBA_Object_release (persist, &ev);
CORBA_exception_free (&ev);
+
+/* gnome_view_frame_view_do_verb (comp->view_frame, "ZoomFit"); */
return TRUE;
}
char *fname = g_strdup (name);
if (container->view_widget) /* any sort of MDI sucks :-] */
container = container_new (fname);
- else
- open_pdf (container, fname);
+ else {
+ if (!open_pdf (container, fname))
+ container_destroy (container);
+ }
g_free (fname);
} else {
GtkWidget *dialog;
gtk_widget_destroy (GTK_WIDGET (fsel));
}
+ static void
+ component_destroy (Component *component)
+ {
+ CORBA_Environment ev;
+ g_return_if_fail (component != NULL);
+
+ CORBA_exception_init (&ev);
+
+ if (component->server)
+ GNOME_Unknown_unref (
+ gnome_object_corba_objref (GNOME_OBJECT (component->server)), &ev);
+ component->server = NULL;
+
+ CORBA_exception_free (&ev);
+ }
+
static void
container_destroy (Container *cont)
{
containers = g_list_remove (containers, cont);
- gtk_widget_destroy (cont->app);
+ if (cont->app)
+ gtk_widget_destroy (cont->app);
+
+ if (cont->component)
+ component_destroy (cont->component);
+ cont->component = NULL;
+
+ cont->app = NULL;
+
g_free (cont);
if (!containers)
gtk_main_quit ();
container_destroy ((Container *)containers->data);
}
- /*
- * Enforces the containers zoom factor.
- */
- static void
- zoom_set (Container *container)
- {
- g_return_if_fail (container != NULL);
- g_return_if_fail (container->component != NULL);
-
- gnome_view_frame_set_zoom_factor (container->component->view_frame,
- container->zoom);
- }
-
- static void
- zoom_in_cmd (GtkWidget *widget, Container *container)
- {
- g_return_if_fail (container != NULL);
- if (container->zoom < 180.0) {
- container->zoom *= 1.4;
- zoom_set (container);
- }
- }
- static void
- zoom_out_cmd (GtkWidget *widget, Container *container)
- {
- g_return_if_fail (container != NULL);
- if (container->zoom > 10.0) {
- container->zoom /= 1.4;
- zoom_set (container);
- }
- }
+static void
+container_about_cmd (GtkWidget *widget, Container *container)
+{
+ GtkWidget *about;
+ int i;
+
+ const gchar *authors[] = {
+ N_("Derek B. Noonburg, main author"),
+ N_("Michael Meeks, GNOME port maintainer."),
+ N_("Miguel de Icaza."),
+ N_("Nat Friedman."),
+ NULL
+ };
+
+#ifdef ENABLE_NLS
+ for (i = 0; authors[i] != NULL; i++)
+ authors [i] = _(authors [i]);
+#endif
+
+ about = gnome_about_new (_("GPDF"), VERSION,
+ _("(C) 1996-1999 Derek B. Noonburg."),
+ authors, NULL, NULL);
+
+ gnome_dialog_set_parent (GNOME_DIALOG (about), GTK_WINDOW (container->app));
+ gnome_dialog_set_close (GNOME_DIALOG (about), TRUE);
+ gtk_widget_show (about);
+}
}
static void
return object_server;
}
-/*
- * Use query_interface to see if `obj' has `interface'.
- */
-static gboolean
-gnome_object_has_interface (GnomeObject *obj, char *interface)
-{
- CORBA_Environment ev;
- CORBA_Object requested_interface;
-
- CORBA_exception_init (&ev);
-
- requested_interface = GNOME_Unknown_query_interface (
- gnome_object_corba_objref (obj), interface, &ev);
-
- CORBA_exception_free (&ev);
-
- if (!CORBA_Object_is_nil(requested_interface, &ev) &&
- ev._major == CORBA_NO_EXCEPTION)
- {
- /* Get rid of the interface we've been passed */
- CORBA_Object_release (requested_interface, &ev);
- return TRUE;
- }
-
- return FALSE;
-}
-
extern "C" {
static Component *
container_activate_component (Container *container, char *component_goad_id)
container->app = gnome_app_new ("pdf-viewer",
"GNOME PDF viewer");
- container->zoom = 86.0;
gtk_drag_dest_set (container->app,
GTK_DEST_DEFAULT_ALL,
main (int argc, char **argv)
{
CORBA_Environment ev;
- CORBA_ORB orb;
- char **view_files = NULL;
- int i;
+ CORBA_ORB orb;
+ char **view_files = NULL;
+ gboolean loaded;
+ int i;
CORBA_exception_init (&ev);
/* Load files */
i = 0;
+ loaded = FALSE;
if (view_files) {
for (i = 0; view_files[i]; i++)
- container_new (view_files[i]);
+ if (container_new (view_files[i]))
+ loaded = TRUE;
}
- if (i == 0)
+ if ((i == 0) || !loaded)
container_new (NULL);
poptFreeContext (ctx);