Пример #1
0
static void
gui_add_to_app_menu (GimpUIManager     *ui_manager,
                     GtkosxApplication *osx_app,
                     const gchar       *action_path,
                     gint               index)
{
  GtkWidget *item;

  item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui_manager), action_path);

  if (GTK_IS_MENU_ITEM (item))
    gtkosx_application_insert_app_menu_item (osx_app, GTK_WIDGET (item), index);
}
Пример #2
0
static void
_create_mac_integration (GtkWidget *menubar)
{
  GtkosxApplication *theOsxApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);

  /* from control-x to command-x in one call? Does _not_ work as advertized */
  gtkosx_application_set_use_quartz_accelerators (theOsxApp, TRUE);

  if (menubar) {
    /* hijack the menubar */
    gtkosx_application_set_menu_bar(theOsxApp, GTK_MENU_SHELL(menubar));
    /* move some items to the dia menu - apparently must be _after_ hijack */
    {
      GtkWidget *item;

      item = menus_get_widget (INTEGRATED_MENU "/Help/HelpAbout");
      if (GTK_IS_MENU_ITEM (item))
        gtkosx_application_insert_app_menu_item (theOsxApp, item, 0);
      gtkosx_application_insert_app_menu_item (theOsxApp, gtk_separator_menu_item_new (), 1);
      item = menus_get_widget (INTEGRATED_MENU "/File/FilePrefs");
      if (GTK_IS_MENU_ITEM (item))
        gtkosx_application_insert_app_menu_item (theOsxApp, item, 2);
      item = menus_get_widget (INTEGRATED_MENU "/File/FilePlugins");
      if (GTK_IS_MENU_ITEM (item))
        gtkosx_application_insert_app_menu_item (theOsxApp, item, 3);
#if 0 /* not sure if we should move these, too */
      item = menus_get_widget (INTEGRATED_MENU "/File/FileTree");
      if (GTK_IS_MENU_ITEM (item))
        gtkosx_application_insert_app_menu_item (theOsxApp, item, 4);
      item = menus_get_widget (INTEGRATED_MENU "/File/FileSheets");
      if (GTK_IS_MENU_ITEM (item))
        gtkosx_application_insert_app_menu_item (theOsxApp, item, 5);
#endif
      /* remove Quit from File menu */
      item = menus_get_widget (INTEGRATED_MENU "/File/FileQuit");
      if (GTK_IS_MENU_ITEM (item))
        gtk_widget_hide (item);
    }
    gtk_widget_hide (menubar); /* not working, it's shown elsewhere */
    /* setup the dock icon */
    gtkosx_application_set_dock_icon_pixbuf (theOsxApp,
	gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL));
  }
  /* Don't quit without asking to save files first */
  g_signal_connect (theOsxApp, "NSApplicationBlockTermination",
		    G_CALLBACK (_osx_app_exit), NULL);
  /* without this all the above wont have any effect */
  gtkosx_application_ready(theOsxApp);
}
Пример #3
0
static void
_create_mac_integration (void)
{
  GtkosxApplication *theOsxApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
  GtkWidget *menubar = NULL;

  /* from control-x to command-x in one call? Does _not_ work as advertized */
  gtkosx_application_set_use_quartz_accelerators (theOsxApp, TRUE);
  /* might be too early ... */
  menus_get_integrated_ui_menubar (&menubar, NULL, NULL);
  if (menubar) {
    gtk_widget_hide (menubar); /* not working, it's shown elsewhere */
    /* move some items to the dia menu */
    {
      GSList *proxies, *proxy;
      GtkAction *action;

      action = menus_get_action ("HelpAbout");
      proxies = gtk_action_get_proxies (action);

      for (proxy = proxies; proxy != NULL; proxy = g_slist_next (proxy)) {
        g_print ("XXX ");
        if (1 || GTK_IS_MENU_ITEM (proxy->data)) {
          gtkosx_application_insert_app_menu_item (theOsxApp, GTK_WIDGET (proxy->data), 0);
          break;
        }
      }     
    }
    /* hijack the menubar */
    gtkosx_application_set_menu_bar(theOsxApp, GTK_MENU_SHELL(menubar));
    /* setup the dock icon */
    gtkosx_application_set_dock_icon_pixbuf (theOsxApp,
	gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL));
  }
  /* without this all the above wont have any effect */
  gtkosx_application_ready(theOsxApp);
}
Пример #4
0
static void
gui_restore_after_callback (Gimp               *gimp,
                            GimpInitStatusFunc  status_callback)
{
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config);
  GimpDisplay   *display;

  if (gimp->be_verbose)
    g_print ("INIT: %s\n", G_STRFUNC);

  gimp->message_handler = GIMP_MESSAGE_BOX;

  /*  load the recent documents after gimp_real_restore() because we
   *  need the mime-types implemented by plug-ins
   */
  status_callback (NULL, _("Documents"), 0.9);
  gimp_recent_list_load (gimp);

  /*  enable this to always have icons everywhere  */
  if (g_getenv ("GIMP_ICONS_LIKE_A_BOSS"))
    {
      GdkScreen *screen = gdk_screen_get_default ();

      g_object_set (G_OBJECT (gtk_settings_get_for_screen (screen)),
                    "gtk-button-images", TRUE,
                    "gtk-menu-images",   TRUE,
                    NULL);
    }

  if (gui_config->restore_accels)
    menus_restore (gimp);

  ui_configurer = g_object_new (GIMP_TYPE_UI_CONFIGURER,
                                "gimp", gimp,
                                NULL);

  image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory,
                                                    "<Image>",
                                                    gimp,
                                                    gui_config->tearoff_menus);
  gimp_ui_manager_update (image_ui_manager, gimp);

  gimp_action_history_init (gimp);

#ifdef GDK_WINDOWING_QUARTZ
  {
    GtkosxApplication *osx_app;
    GtkWidget         *menu;
    GtkWidget         *item;

    osx_app = gtkosx_application_get ();

    menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager),
                                      "/image-menubar");
    if (GTK_IS_MENU_ITEM (menu))
      menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));

    gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu));
    gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE);

    gui_add_to_app_menu (image_ui_manager, osx_app,
                         "/image-menubar/Help/dialogs-about", 0);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         "/image-menubar/Help/dialogs-search-action", 1);

#define PREFERENCES "/image-menubar/Edit/Preferences/"

    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-preferences", 3);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-input-devices", 4);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-keyboard-shortcuts", 5);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-module-dialog", 6);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "plug-in-unit-editor", 7);

#undef PREFERENCES

    item = gtk_separator_menu_item_new ();
    gtkosx_application_insert_app_menu_item (osx_app, item, 8);

    item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager),
                                      "/image-menubar/File/file-quit");
    gtk_widget_hide (item);

    g_signal_connect (osx_app, "NSApplicationBlockTermination",
                      G_CALLBACK (gui_quartz_quit_callback),
                      image_ui_manager);

    gtkosx_application_ready (osx_app);
  }
#endif /* GDK_WINDOWING_QUARTZ */

  g_signal_connect_object (gui_config, "notify::single-window-mode",
                           G_CALLBACK (gui_single_window_mode_notify),
                           ui_configurer, 0);
  g_signal_connect_object (gui_config, "notify::tearoff-menus",
                           G_CALLBACK (gui_tearoff_menus_notify),
                           image_ui_manager, 0);
  g_signal_connect (image_ui_manager, "show-tooltip",
                    G_CALLBACK (gui_menu_show_tooltip),
                    gimp);
  g_signal_connect (image_ui_manager, "hide-tooltip",
                    G_CALLBACK (gui_menu_hide_tooltip),
                    gimp);

  gimp_devices_restore (gimp);
  gimp_controllers_restore (gimp, image_ui_manager);

  if (status_callback == splash_update)
    splash_destroy ();

  color_history_restore (gimp);

  if (gimp_get_show_gui (gimp))
    {
      GimpDisplayShell *shell;
      GtkWidget        *toplevel;

      /*  create the empty display  */
      display = GIMP_DISPLAY (gimp_create_display (gimp, NULL,
                                                   GIMP_UNIT_PIXEL, 1.0,
                                                   G_OBJECT (initial_screen),
                                                   initial_monitor));

      shell = gimp_display_get_shell (display);

      if (gui_config->restore_session)
        session_restore (gimp,
                         initial_screen,
                         initial_monitor);

      /*  move keyboard focus to the display  */
      toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
      gtk_window_present (GTK_WINDOW (toplevel));
    }

  /*  indicate that the application has finished loading  */
  gdk_notify_startup_complete ();

  /*  clear startup monitor variables  */
  initial_screen  = NULL;
  initial_monitor = -1;
}
Пример #5
0
static void
gui_restore_after_callback (Gimp               *gimp,
                            GimpInitStatusFunc  status_callback)
{
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config);
  GimpDisplay   *display;

  if (gimp->be_verbose)
    g_print ("INIT: %s\n", G_STRFUNC);

  gimp->message_handler = GIMP_MESSAGE_BOX;

  if (gui_config->restore_accels)
    menus_restore (gimp);

  ui_configurer = g_object_new (GIMP_TYPE_UI_CONFIGURER,
                                "gimp", gimp,
                                NULL);

  image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory,
                                                    "<Image>",
                                                    gimp,
                                                    gui_config->tearoff_menus);
  gimp_ui_manager_update (image_ui_manager, gimp);

#ifdef GDK_WINDOWING_QUARTZ
  {
    GtkosxApplication *osx_app;
    GtkWidget         *menu;
    GtkWidget         *item;

    osx_app = gtkosx_application_get ();

    menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager),
                                      "/image-menubar");
    if (GTK_IS_MENU_ITEM (menu))
      menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));

    gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu));
    gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE);

    gui_add_to_app_menu (image_ui_manager, osx_app,
                         "/image-menubar/Help/dialogs-about", 0);

#define PREFERENCES "/image-menubar/Edit/Preferences/"

    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-preferences", 2);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-input-devices", 3);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-keyboard-shortcuts", 4);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-module-dialog", 5);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "plug-in-unit-editor", 6);

#undef PREFERENCES

    item = gtk_separator_menu_item_new ();
    gtkosx_application_insert_app_menu_item (osx_app, item, 7);

    item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager),
                                      "/image-menubar/File/file-quit");
    gtk_widget_hide (item);

    g_signal_connect (osx_app, "NSApplicationBlockTermination",
                      G_CALLBACK (gui_quartz_quit_callback),
                      image_ui_manager);

    gtkosx_application_ready (osx_app);
  }
#endif /* GDK_WINDOWING_QUARTZ */

  g_signal_connect_object (gui_config, "notify::single-window-mode",
                           G_CALLBACK (gui_single_window_mode_notify),
                           ui_configurer, 0);
  g_signal_connect_object (gui_config, "notify::tearoff-menus",
                           G_CALLBACK (gui_tearoff_menus_notify),
                           image_ui_manager, 0);
  g_signal_connect (image_ui_manager, "show-tooltip",
                    G_CALLBACK (gui_menu_show_tooltip),
                    gimp);
  g_signal_connect (image_ui_manager, "hide-tooltip",
                    G_CALLBACK (gui_menu_hide_tooltip),
                    gimp);

  gimp_devices_restore (gimp);
  gimp_controllers_restore (gimp, image_ui_manager);

  if (status_callback == splash_update)
    splash_destroy ();

  color_history_restore (gimp);

  if (gimp_get_show_gui (gimp))
    {
      GimpDisplayShell *shell;

      /*  create the empty display  */
      display = GIMP_DISPLAY (gimp_create_display (gimp,
                                                   NULL,
                                                   GIMP_UNIT_PIXEL,
                                                   1.0));

      shell = gimp_display_get_shell (display);

      if (gui_config->restore_session)
        session_restore (gimp);

      /*  move keyboard focus to the display  */
      gtk_window_present (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shell))));
    }

  /*  indicate that the application has finished loading  */
  gdk_notify_startup_complete ();
}