Beispiel #1
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);
}
Beispiel #2
0
int main(int argc, char *argv[]){
#if GLIB_MAJOR_VERSION<3 && GLIB_MINOR_VERSION<32
    if(!g_thread_supported()){
	g_thread_init(NULL);
	gdk_threads_init();
    }
#endif
    gtk_init(&argc, &argv);
#ifdef MAC_INTEGRATION
    GtkosxApplication *theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
#endif
    icon_main=gdk_pixbuf_new_from_inline(-1,icon_draw,FALSE,NULL);
    if(argc<2){
	error("Must call drawdaemon with at least one argument\n");
    }
    sock=strtol(argv[1], NULL, 10);
    if(sock<0){
	error("sock=%d\n", sock);
    }
    //info("sock=%d\n", sock);
    socket_block(sock, 0);
    {
	char fnlog[PATH_MAX];
	snprintf(fnlog, PATH_MAX,"%s/drawdaemon.log", TEMP);
	if(!freopen(fnlog, "w", stdout)) {
	    perror("freopen");
	    warning("Error redirect stdout\n");
	}
	if(!freopen(fnlog, "w", stderr)) {
	    perror("freopen");
	    warning("Error redirect stderr\n");
	}
	setbuf(stdout,NULL);
	setbuf(stderr,NULL);
    }
#ifdef MAC_INTEGRATION
    gtkosx_application_set_dock_icon_pixbuf(theApp, icon_main);
    gtkosx_application_ready(theApp);
#endif
    g_thread_new("listen_draw", (GThreadFunc)listen_draw, NULL);
    create_window();
    gtk_main();
}/*main */
Beispiel #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);
}