Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-dev] Gtk+ launcher


Oddly enough, it's the SWT team which is responsible for the launcher. I'll make sure this gets sent to the right person.

Thanks,
McQ.



Tom Tromey <tromey@xxxxxxxxxx>
Sent by: eclipse-dev-admin@xxxxxxxxxxx

07/03/2002 05:19 PM
Please respond to eclipse-dev

       
        To:        eclipse-dev@xxxxxxxxxxx
        cc:        
        Subject:        [eclipse-dev] Gtk+ launcher


A couple days ago I downloaded the Gtk+ version of Eclipse 2.0.  I was
surprised to find that there is still a Motif dependency in the
launcher.  We'd prefer not to have this, so I wrote a Gtk+ launcher.

It is appended, along with a simple Makefile.

To build it:

* cvs co platform-launcher
* mkdir platform-launcher/library/gtk
* cd platform-launcher/library/gtk
* make
* Copy the resulting eclipse-gtk to the Eclipse install tree

How do I go about getting this into CVS?

Apologies if this is the wrong mailing list.  I didn't see anything
more appropriate.

Tom

/*
* Copyright (C) 2002 Red Hat, Inc.
*
* Written by Tom Tromey <tromey@xxxxxxxxxx>
*
* Parts derived from eclipseMotif.c, copyright info:
* Copyright (c) 2001, 2002 IBM Corp and others.  All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*/

#include "eclipseOS.h"

#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>

#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

/* Global Variables */
char   dirSeparator  = '/';
char   pathSeparator = ':';
char*  consoleVM     = "java";
char*  defaultVM     = "java";
char*  shippedVMDir  = "jre/bin/";
char*  guiList[] = { "motif", "gtk1x", "gtk", NULL };

static void
die (int signum)
{
 /* FIXME: probably not correct.  */
 exit (0);
}

static gboolean
timeout_hit (gpointer data)
{
 GtkWidget *main = GTK_WIDGET (data);
 gtk_widget_hide (main);
 return FALSE;
}

int
showSplash (char *timeoutString, char *baseDir, char *featureImage)
{
 GtkWidget *image;
 GtkWindow *main;
 gchar *file;
 int timeout;

 if (featureImage == NULL)
   {
     char *splashFile, *locale, *c;

     locale = strdup (setlocale (LC_CTYPE, NULL));

     /* Remove the encoding portion if present.  */
     c = strchr (locale, '.');
     if (c != NULL)
                c[0] = '\0';

     file = g_strconcat (baseDir, "/splash/", locale,
                                                    "/splash_full.xpm", NULL);
     if (! g_file_test (file, G_FILE_TEST_EXISTS))
                {
                  /* Remove the country portion if present.  */
                  c = strchr (locale, '_');
                  if (c != NULL)
                    c[0] = '\0';

                  g_free (file);
                  file = g_strconcat (baseDir, "/splash/", locale,
                                                        "/splash_full.xpm", NULL);

                  if (! g_file_test (file, G_FILE_TEST_EXISTS))
                    {
                      g_free (file);
                      file = g_strconcat (baseDir, "/splash/splash_full.xpm", NULL);
                    }
                }
   }
 else
   file = g_strdup (featureImage);

 if (! g_file_test (file, G_FILE_TEST_EXISTS))
   {
     g_free (file);
     file = NULL;
   }

 if (! file)
   return 1;

 image = gtk_image_new_from_file (file);
 g_free (file);

 signal (SIGUSR2, die);

 main = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
 gtk_container_add (GTK_CONTAINER (main), GTK_WIDGET (image));
 gtk_window_set_decorated (main, FALSE);
 gtk_window_set_position (main, GTK_WIN_POS_CENTER);
 gtk_widget_show_all (GTK_WIDGET (main));

 /* Determine the splash timeout value (in seconds).  */
 timeout = 0;
 if (timeoutString != NULL && strlen (timeoutString) > 0)
   sscanf (timeoutString, "%d", &timeout);
 if (timeout != 0)
   gtk_timeout_add (timeout * 1000, timeout_hit, (gpointer) main);

 gtk_main ();

 return 0;
}

void
displayMessage (char *message)
{
 GtkWidget *dialog;

 dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
                                                                      GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
                                                                      "%s", message);
 gtk_dialog_run (GTK_DIALOG (dialog));
 gtk_widget_destroy (dialog);
}

void
initWindowSystem (int *argc, char *argv[], int showSplash)
{
 /* FIXME: do argument-saving hack like Motif?  */

 gtk_set_locale ();
 /* FIXME: this is subtly wrong.  */
 gtk_init (argc, &argv);
}

/* Get the window system specific VM arguments */
char **
getArgVM (char *vm)
{
 char **result;
 char *version;

 static char *argVM_JAVA[] = { NULL };

#if 0
 if (isJ9VM( vm ))
   return argVM_J9;
#endif

 /* Use the default arguments for a standard Java VM */
 result = argVM_JAVA;

 return result;
}

int
startJavaVM (char* args[])
{
 int exitCode;
 pid_t child;

 child = fork ();
 if (child == 0)
   {
     /* Child process ... start the JVM */
     execv (args[0], args);

     /* The JVM would not start ... return error code to parent process. */
     _exit (errno);
   }
 else if (child > 0)
   {
     /* Wait for child to terminate.  */
     wait (&exitCode);
     if (WIFEXITED (exitCode))
                exitCode = WEXITSTATUS (exitCode);
     else
                exitCode = 1;
   }
 else
   exitCode = errno;

 return exitCode;
}


#**********************************************************************
# Copyright (c) 2001, 2002 IBM Corp. and others.  All rights reserved.
# This file is made available under the terms of the Common Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/cpl-v10.html

#  
# Contributors:
#     Kevin Cornell (Rational Software Corporation)
#**********************************************************************


# No comment.

PROGRAM_OUTPUT = eclipse-gtk
PROGRAM_NAME = Eclipse
DEFAULT_OS = linux
DEFAULT_OS_ARCH = x86
DEFAULT_WS = gtk


# Makefile for creating the eclipse launcher program.

# This script expects the following environment variables set:
#
# PROGRAM_OUTPUT - the filename of the output executable
# PROGRAM_NAME - the title of the splash screen

# Define the object modules to be compiled and flags.
OBJS = eclipse.o eclipseUtil.o eclipseGtk.o
EXEC = $(PROGRAM_OUTPUT)
LIBS = `pkg-config --libs gtk+-2.0`
CFLAGS = -g \
                -DPROGRAM_NAME="\"$(PROGRAM_NAME)\"" \
                -DDEFAULT_OS="\"$(DEFAULT_OS)\"" \
                -DDEFAULT_OS_ARCH="\"$(DEFAULT_OS_ARCH)\"" \
                -DDEFAULT_WS="\"$(DEFAULT_WS)\"" \
                -I. \
                -I.. \
                `pkg-config --cflags gtk+-2.0`

all: $(EXEC)

.c.o:
                $(CC) $(CFLAGS) -c $< -o $@

eclipse.o: ../eclipse.c
                $(CC) $(CFLAGS) -c $< -o $@

eclipseUtil.o: ../eclipseUtil.c
                $(CC) $(CFLAGS) -c $< -o $@

$(EXEC): $(OBJS)
                $(CC) -o $(EXEC) $(OBJS) $(LIBS)

clean:
                rm -f $(EXEC) $(OBJS)
_______________________________________________
eclipse-dev mailing list
eclipse-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/eclipse-dev



Back to the top