~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/widgets/gimpsessioninfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * gimpsessioninfo.c
25
25
 
26
26
#include <gtk/gtk.h>
27
27
 
 
28
#include "libgimpconfig/gimpconfig.h"
 
29
 
28
30
#include "widgets-types.h"
29
31
 
30
 
#include "config/gimpconfig-serialize.h"
31
 
#include "config/gimpconfigwriter.h"
32
 
#include "config/gimpscanner.h"
33
 
 
34
32
#include "gimpcontainerview.h"
35
33
#include "gimpcontainerview-utils.h"
36
34
#include "gimpdialogfactory.h"
56
54
  SESSION_INFO_DOCKABLE,
57
55
 
58
56
  SESSION_INFO_DOCKABLE_TAB_STYLE,
59
 
  SESSION_INFO_DOCKABLE_PREVIEW_SIZE,
 
57
  SESSION_INFO_DOCKABLE_VIEW_SIZE,
60
58
  SESSION_INFO_DOCKABLE_AUX
61
59
};
62
60
 
424
422
                {
425
423
                  GimpContainerView *view;
426
424
                  GEnumValue        *enum_value;
427
 
                  gchar             *tab_style    = "icon";
428
 
                  gint               preview_size = -1;
 
425
                  const gchar       *tab_style = "icon";
 
426
                  gint               view_size = -1;
429
427
                  GList             *aux_info;
430
428
 
431
429
                  gimp_config_writer_open (writer, "dockable");
444
442
                  view = gimp_container_view_get_by_dockable (dockable);
445
443
 
446
444
                  if (view)
447
 
                    preview_size = gimp_container_view_get_preview_size (view,
448
 
                                                                         NULL);
 
445
                    view_size = gimp_container_view_get_view_size (view, NULL);
449
446
 
450
 
                  if (preview_size > 0 &&
451
 
                      preview_size != entry->preview_size)
 
447
                  if (view_size > 0 &&
 
448
                      view_size != entry->view_size)
452
449
                    {
453
450
                      gimp_config_writer_open (writer, "preview-size");
454
 
                      gimp_config_writer_printf (writer, "%d", preview_size);
 
451
                      gimp_config_writer_printf (writer, "%d", view_size);
455
452
                      gimp_config_writer_close (writer);
456
453
                    }
457
454
 
534
531
  g_scanner_scope_add_symbol (scanner, SESSION_INFO_DOCKABLE, "tab-style",
535
532
                              GINT_TO_POINTER (SESSION_INFO_DOCKABLE_TAB_STYLE));
536
533
  g_scanner_scope_add_symbol (scanner, SESSION_INFO_DOCKABLE, "preview-size",
537
 
                              GINT_TO_POINTER (SESSION_INFO_DOCKABLE_PREVIEW_SIZE));
 
534
                              GINT_TO_POINTER (SESSION_INFO_DOCKABLE_VIEW_SIZE));
538
535
  g_scanner_scope_add_symbol (scanner, SESSION_INFO_DOCKABLE, "aux-info",
539
536
                              GINT_TO_POINTER (SESSION_INFO_DOCKABLE_AUX));
540
537
 
731
728
      dialog =
732
729
        gimp_dialog_factory_dialog_new (factory, screen,
733
730
                                        info->toplevel_entry->identifier,
734
 
                                        info->toplevel_entry->preview_size,
 
731
                                        info->toplevel_entry->view_size,
735
732
                                        TRUE);
736
733
 
737
734
      if (dialog && info->aux_info)
764
761
              GimpSessionInfoDockable *dockable_info = pages->data;
765
762
              GtkWidget               *dockable;
766
763
 
767
 
              if (dockable_info->preview_size < GIMP_VIEW_SIZE_TINY ||
768
 
                  dockable_info->preview_size > GIMP_VIEW_SIZE_GIGANTIC)
769
 
                dockable_info->preview_size = -1;
 
764
              if (dockable_info->view_size < GIMP_VIEW_SIZE_TINY ||
 
765
                  dockable_info->view_size > GIMP_VIEW_SIZE_GIGANTIC)
 
766
                dockable_info->view_size = -1;
770
767
 
771
768
              /*  use the new dock's dialog factory to create dockables
772
769
               *  because it may be different from the dialog factory
776
773
                gimp_dialog_factory_dockable_new (dock->dialog_factory,
777
774
                                                  dock,
778
775
                                                  dockable_info->identifier,
779
 
                                                  dockable_info->preview_size);
 
776
                                                  dockable_info->view_size);
780
777
 
781
778
              if (! dockable)
782
779
                continue;
791
788
                                 GIMP_DOCKABLE (dockable), -1);
792
789
            }
793
790
 
794
 
          if ((book_info->current_page > 0) &&
795
 
              (book_info->current_page <
796
 
               gtk_notebook_get_n_pages (GTK_NOTEBOOK (dockbook))))
 
791
          if (book_info->current_page <
 
792
              gtk_notebook_get_n_pages (GTK_NOTEBOOK (dockbook)))
797
793
            {
798
794
              gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
799
795
                                             book_info->current_page);
800
796
            }
 
797
          else
 
798
            {
 
799
              gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook), 0);
 
800
            }
801
801
        }
802
802
 
803
803
      for (books = info->books; books; books = g_list_next (books))
831
831
/* This function mostly lifted from
832
832
 * gtk+/gdk/gdkscreen.c:gdk_screen_get_monitor_at_window()
833
833
 */
834
 
static gint 
835
 
get_appropriate_monitor (GdkScreen      *screen,
836
 
                         gint            x,
837
 
                         gint            y,
838
 
                         gint            w,
839
 
                         gint            h)
 
834
static gint
 
835
get_appropriate_monitor (GdkScreen *screen,
 
836
                         gint       x,
 
837
                         gint       y,
 
838
                         gint       w,
 
839
                         gint       h)
840
840
{
841
 
  gint num_monitors, i, area = 0, monitor = -1;
842
841
  GdkRectangle rect;
843
 
  
844
 
  rect.x = x;
845
 
  rect.y = y;
846
 
  rect.width = w;
 
842
  gint         area    = 0;
 
843
  gint         monitor = -1;
 
844
  gint         num_monitors;
 
845
  gint         i;
 
846
 
 
847
  rect.x      = x;
 
848
  rect.y      = y;
 
849
  rect.width  = w;
847
850
  rect.height = h;
848
851
 
849
852
  num_monitors = gdk_screen_get_n_monitors (screen);
850
 
  
 
853
 
851
854
  for (i = 0; i < num_monitors; i++)
852
855
    {
853
 
      GdkRectangle tmp_monitor, intersect;
854
 
      
855
 
      gdk_screen_get_monitor_geometry (screen, i, &tmp_monitor);
856
 
      gdk_rectangle_intersect (&rect, &tmp_monitor, &intersect);
857
 
      
858
 
      if (intersect.width * intersect.height > area)
859
 
        { 
860
 
          area = intersect.width * intersect.height;
 
856
      GdkRectangle geometry;
 
857
 
 
858
      gdk_screen_get_monitor_geometry (screen, i, &geometry);
 
859
 
 
860
      if (gdk_rectangle_intersect (&rect, &geometry, &geometry) &&
 
861
          geometry.width * geometry.height > area)
 
862
        {
 
863
          area = geometry.width * geometry.height;
861
864
          monitor = i;
862
865
        }
863
866
    }
 
867
 
864
868
  if (monitor >= 0)
865
869
    return monitor;
866
870
  else
881
885
 
882
886
  screen = gtk_widget_get_screen (info->widget);
883
887
 
884
 
  if ((!info->toplevel_entry || info->toplevel_entry->remember_size) &&
885
 
      info->width > 0 && info->height > 0)
 
888
  if ((! info->toplevel_entry || info->toplevel_entry->remember_size) &&
 
889
      (info->width > 0 && info->height > 0))
886
890
    {
887
891
      gdk_screen_get_monitor_geometry (screen,
888
892
                                       get_appropriate_monitor (screen,
889
 
                                                                info->x, info->y,
890
 
                                                                info->width, info->height),
 
893
                                                                info->x,
 
894
                                                                info->y,
 
895
                                                                info->width,
 
896
                                                                info->height),
891
897
                                       &monitor);
892
 
      info->x = CLAMP (info->x, monitor.x, monitor.x + monitor.width  - info->width);
893
 
      info->y = CLAMP (info->y, monitor.y, monitor.y + monitor.height - info->height);
 
898
 
 
899
      info->x = CLAMP (info->x,
 
900
                       monitor.x, monitor.x + monitor.width  - info->width);
 
901
      info->y = CLAMP (info->y,
 
902
                       monitor.y, monitor.y + monitor.height - info->height);
894
903
    }
895
904
  else
896
905
    {
897
906
      gdk_screen_get_monitor_geometry (screen,
898
 
                                     gdk_screen_get_monitor_at_point (screen, info->x, info->y),
899
 
                                     &monitor);
 
907
                                       gdk_screen_get_monitor_at_point (screen,
 
908
                                                                        info->x,
 
909
                                                                        info->y),
 
910
                                       &monitor);
900
911
 
901
912
      info->x = CLAMP (info->x, monitor.x, monitor.x + monitor.width  - 128);
902
913
      info->y = CLAMP (info->y, monitor.y, monitor.y + monitor.height - 128);
925
936
      gdk_window_get_root_origin (info->widget->window, &info->x, &info->y);
926
937
 
927
938
      if (! info->toplevel_entry || info->toplevel_entry->remember_size)
928
 
        {
929
 
          info->width  = info->widget->allocation.width;
930
 
          info->height = info->widget->allocation.height;
931
 
        }
 
939
        {
 
940
          info->width  = info->widget->allocation.width;
 
941
          info->height = info->widget->allocation.height;
 
942
        }
932
943
      else
933
 
        {
934
 
          info->width  = 0;
935
 
          info->height = 0;
936
 
        }
 
944
        {
 
945
          info->width  = 0;
 
946
          info->height = 0;
 
947
        }
937
948
    }
938
949
 
939
950
  info->open = FALSE;
1147
1158
                dockable->tab_style = enum_value->value;
1148
1159
              break;
1149
1160
 
1150
 
            case SESSION_INFO_DOCKABLE_PREVIEW_SIZE:
 
1161
            case SESSION_INFO_DOCKABLE_VIEW_SIZE:
1151
1162
              token = G_TOKEN_INT;
1152
 
              if (! gimp_scanner_parse_int (scanner, &dockable->preview_size))
 
1163
              if (! gimp_scanner_parse_int (scanner, &dockable->view_size))
1153
1164
                goto error;
1154
1165
              break;
1155
1166