diff options
Diffstat (limited to 'tikzit/src/gtk/PreviewWindow.m')
-rw-r--r-- | tikzit/src/gtk/PreviewWindow.m | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/tikzit/src/gtk/PreviewWindow.m b/tikzit/src/gtk/PreviewWindow.m index 418886e..5443e8d 100644 --- a/tikzit/src/gtk/PreviewWindow.m +++ b/tikzit/src/gtk/PreviewWindow.m @@ -26,9 +26,11 @@ @interface PreviewWindow (Private) - (BOOL) updateOrShowError; +- (void) updateDefaultSize; @end // {{{ API + @implementation PreviewWindow - (id) init { @@ -46,7 +48,8 @@ window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL)); gtk_window_set_title (window, "Preview"); - gtk_window_set_resizable (window, FALSE); + gtk_window_set_resizable (window, TRUE); + gtk_window_set_default_size (window, 150.0, 150.0); g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), @@ -54,7 +57,6 @@ GtkWidget *pdfArea = gtk_drawing_area_new (); gtk_container_add (GTK_CONTAINER (window), pdfArea); - gtk_widget_set_size_request (pdfArea, 150.0, 150.0); gtk_widget_show (pdfArea); surface = [[WidgetSurface alloc] initWithWidget:pdfArea]; [surface setRenderDelegate:previewer]; @@ -81,26 +83,9 @@ [previewer setDocument:doc]; } -- (void) updateSize { - double width = 150; - double height = 150; - if ([previewer isValid]) { - double pWidth = [previewer width]; - double pHeight = [previewer height]; - width = (width < pWidth + 4) ? pWidth + 4 : width; - height = (height < pHeight + 4) ? pHeight + 4 : height; - NSPoint offset; - offset.x = (width-pWidth)/2.0; - offset.y = (height-pHeight)/2.0; - [[surface transformer] setOrigin:offset]; - } - [surface setSizeRequestWidth:width height:height]; -} - - (BOOL) update { if ([self updateOrShowError]) { - [self updateSize]; - [surface invalidate]; + [self updateDefaultSize]; return YES; } @@ -109,7 +94,7 @@ - (void) show { if ([self updateOrShowError]) { - [self updateSize]; + [self updateDefaultSize]; gtk_widget_show (GTK_WIDGET (window)); [surface invalidate]; } @@ -186,6 +171,18 @@ } return YES; } + +- (void) updateDefaultSize { + double width = 150; + double height = 150; + if ([previewer isValid]) { + double pWidth = [previewer width]; + double pHeight = [previewer height]; + width = (width < pWidth + 4) ? pWidth + 4 : width; + height = (height < pHeight + 4) ? pHeight + 4 : height; + } + gtk_window_set_default_size (window, width, height); +} @end // vim:ft=objc:ts=8:et:sts=4:sw=4 |