diff options
author | Jens Finke <jens@src.gnome.org> | 2003-02-14 15:41:42 +0000 |
---|---|---|
committer | Jens Finke <jens@src.gnome.org> | 2003-02-14 15:41:42 +0000 |
commit | 905a8b5d282cca0247ef0096186e30d08372d194 (patch) | |
tree | 4907e672295c95686b0f31dc562a7b0f92e22e7c /shell | |
parent | 82b27320d9b7e99b103e4a131c71b5d39eecaf9f (diff) | |
download | eog-905a8b5d282cca0247ef0096186e30d08372d194.tar.gz |
2003-02-14 Jens Finke
New eog architecture. Moved more stuff into libeog and basically merged
image-view.[ch] and ui-image.[ch]. The result is eog-scroll-view.[ch].
* libeog/ui-image.[ch],
* libeog/image-view.[ch]: Removed.
* libeog/eog-scroll-view.[ch]: New, basic widget for displaying an
EogImage.
* libeog/eog-image-helper.[ch],
* libeog/eog-image.[ch]: Image model, provides all operations on
an image.
* libeog/eog-full-screen.[ch]: Moved from viewer. Uses a
EogScrollView widget for displaying the image.
* libeog/libeog-marshal.list: New, list of callback marshallers.
* libeog/Makefile.am: SOURES file list updated, added
libeog-marshal.[ch] generation.
* libeog/accessible-image-view.[ch]: Use EogScrollView instead of
ImageView. Fixed indention.
* libeog/eog-pixbuf-util.c (eog_pixbuf_flip_vertical): Free
pixbuf.
* libeog/eog-pixbuf-util.h: Added include guards.
* libeog/zoom.[ch] (zoom_image_has_standard_size): Removed.
* viewer/Makefile.am (SOURCES): Removed everything except main.c
and eog-image-view.[ch]
* viewer/eog-image-view.[ch]: Rewritten. This bonobo object serves
as a simple wrapper for an EogScrollView and EogImage and provides
onyl gui and glue code. It implements the PersistFile, Control and
Zoomable interfaces.
* viewer/main.c (eog_image_viewer_factory): Removed EogImage
bonobo stuff.
* shell/eog-window.c (sb_policy_changed): Removed.
(eog_window_init): Don't register for policy changes.
(adapt_window_size): New function.
(property_changed_cb): New window/width, window/height properties.
(adapt_window_size_to_control): Simplified, call
adapt_window_size.
* configure.in: Bumped version to 2.3.0.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/eog-window.c | 154 |
1 files changed, 50 insertions, 104 deletions
diff --git a/shell/eog-window.c b/shell/eog-window.c index ecb954ac..dece86e7 100644 --- a/shell/eog-window.c +++ b/shell/eog-window.c @@ -71,12 +71,6 @@ struct _EogWindowPrivate { /* statusbar */ GtkWidget *statusbar; - /* Window scrolling policy type */ - GtkPolicyType sb_policy; - - /* GConf client notify id's */ - guint sb_policy_notify_id; - /* list of files recieved from a drag'n'drop action */ GList *dnd_files; }; @@ -358,7 +352,6 @@ eog_window_destroy (GtkObject *object) /* Clean up GConf-related stuff */ if (priv->client) { - gconf_client_notify_remove (priv->client, priv->sb_policy_notify_id); gconf_client_remove_dir (priv->client, "/apps/eog", NULL); g_object_unref (G_OBJECT (priv->client)); priv->client = NULL; @@ -405,23 +398,6 @@ eog_window_class_init (EogWindowClass *class) widget_class->drag_data_received = eog_window_drag_data_received; } -/* Handler for changes on the window sb policy */ -static void -sb_policy_changed_cb (GConfClient *client, guint notify_id, GConfEntry *entry, gpointer data) -{ -/* EogWindow *window; - EogWindowPrivate *priv; - - window = EOG_WINDOW (data); - priv = window->priv; - - priv->sb_policy = gconf_value_get_int (entry->value); - - gtk_scroll_frame_set_policy (GTK_SCROLL_FRAME (priv->ui), priv->sb_policy, priv->sb_policy);*/ -} - - - /* Object initialization function for windows */ static void eog_window_init (EogWindow *window) @@ -443,15 +419,6 @@ eog_window_init (EogWindow *window) gconf_client_add_dir (priv->client, "/apps/eog", GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); - priv->sb_policy_notify_id = gconf_client_notify_add ( - priv->client, "/apps/eog/window/sb_policy", - sb_policy_changed_cb, window, - NULL, NULL); - - priv->sb_policy = gconf_client_get_int ( - priv->client, "/apps/eog/window/sb_policy", - NULL); - window_list = g_list_prepend (window_list, window); priv->ctrl_widget = NULL; @@ -779,6 +746,40 @@ eog_window_open_dialog (EogWindow *window) } static void +adapt_window_size (EogWindow *window, int width, int height) +{ + int xthick, ythick; + int req_height, req_width; + EogWindowPrivate *priv; + + priv = window->priv; + + /* this is the size of the frame around the vbox */ + xthick = priv->box->style->xthickness; + ythick = priv->box->style->ythickness; + req_width = req_height = -1; + + g_print ("adapt window size cb\n"); + + if (height > 0) { + req_height = + height + + (GTK_WIDGET(window)->allocation.height - priv->box->allocation.height) + + priv->statusbar->allocation.height + + 2 * ythick; + } + + if (width > 0) { + req_width = + width + + (GTK_WIDGET(window)->allocation.width - priv->box->allocation.width) + + 2 * xthick; + } + + gtk_window_resize (GTK_WINDOW (window), req_width, req_height); +} + +static void property_changed_cb (BonoboListener *listener, char *event_name, CORBA_any *any, @@ -789,12 +790,20 @@ property_changed_cb (BonoboListener *listener, window = EOG_WINDOW (user_data); - if (!g_ascii_strcasecmp (event_name, "window/title")) + if (!g_ascii_strcasecmp (event_name, "window/title")) { gtk_window_set_title (GTK_WINDOW (window), BONOBO_ARG_GET_STRING (any)); - else if (!g_ascii_strcasecmp (event_name, "window/status")) + } + else if (!g_ascii_strcasecmp (event_name, "window/status")) { gnome_appbar_set_status (GNOME_APPBAR (window->priv->statusbar), - BONOBO_ARG_GET_STRING (any)); + BONOBO_ARG_GET_STRING (any)); + } + else if (!g_ascii_strcasecmp (event_name, "window/width")) { + adapt_window_size (window, BONOBO_ARG_GET_INT (any), -1); + } + else if (!g_ascii_strcasecmp (event_name, "window/height")) { + adapt_window_size (window, -1, BONOBO_ARG_GET_INT (any)); + } } static void @@ -1042,20 +1051,13 @@ get_collection_control_list (GList *text_uri_list) #endif /* HAVE_COLLECTION */ - void -adapt_shell_size_to_control (EogWindow *window, Bonobo_Control control) +adapt_window_size_to_control (EogWindow *window, Bonobo_Control control) { CORBA_Environment ev; EogWindowPrivate *priv; Bonobo_PropertyBag pb; - gint32 width, height; gint32 image_width, image_height; - int sw, sh; - Bonobo_Zoomable zi; - gboolean need_zoom; - int req_width, req_height; - int xthick, ythick; g_return_if_fail (EOG_IS_WINDOW (window)); @@ -1066,67 +1068,11 @@ adapt_shell_size_to_control (EogWindow *window, Bonobo_Control control) pb = bonobo_control_frame_get_control_property_bag (priv->ctrl_frame, &ev); if (pb == CORBA_OBJECT_NIL) return; - - /* FIXME: We try to obtain the desired size of the component - * here. The image/width image/height properties aren't - * generally available in controls and work only with the - * eog-image-viewer component! - */ - image_width = bonobo_pbclient_get_long (pb, "image/width", &ev); - image_height = bonobo_pbclient_get_long (pb, "image/height", &ev); + image_width = bonobo_pbclient_get_long (pb, "window/width", &ev); + image_height = bonobo_pbclient_get_long (pb, "window/height", &ev); - sw = gdk_screen_width (); - sh = gdk_screen_height (); - need_zoom = FALSE; + adapt_window_size (window, image_width, image_height); - if (image_width >= sw) { - width = 0.75 * sw; - need_zoom = TRUE; - } - else { - width = image_width; - } - if (image_height >= sh) { - height = 0.75 * sh; - need_zoom = TRUE; - } - else { - height = image_height; - } - - if (!width || !height) { - bonobo_object_release_unref (pb, &ev); - return; - } - - /* this is the size of the frame around the vbox */ - xthick = priv->box->style->xthickness; - ythick = priv->box->style->ythickness; - - req_height = - height + - (GTK_WIDGET(window)->allocation.height - priv->box->allocation.height) + - priv->statusbar->allocation.height + - 2 * ythick; - - req_width = - width + - (GTK_WIDGET(window)->allocation.width - priv->box->allocation.width) + - 2 * xthick; - - gtk_window_resize (GTK_WINDOW (window), req_width, req_height); - - if (need_zoom) { - zi = Bonobo_Unknown_queryInterface (control, "IDL:Bonobo/Zoomable:1.0", &ev); - if (zi != CORBA_OBJECT_NIL) { - double zoom_level; - zoom_level = zoom_fit_scale (width, height, - image_width, image_height, TRUE); - Bonobo_Zoomable_setLevel (zi, zoom_level, &ev); - bonobo_object_release_unref (zi, &ev); - } - } - bonobo_object_release_unref (pb, &ev); CORBA_exception_free (&ev); } @@ -1160,7 +1106,7 @@ add_control_to_ui (EogWindow *window, Bonobo_Control control) priv->ctrl_widget = NULL; } - adapt_shell_size_to_control (window, control); + adapt_window_size_to_control (window, control); CORBA_exception_free (&ev); |