Permalink
Browse files

* Use portable code generation (for EV4) on Linux/Alpha

 * Catch the case when gnome-config isn't available or executable
 * Added an extras directory containing the "makedesktop.sh" script
 * Only offer the desktop menu option if there is a "binary" option
  • Loading branch information...
Sam Lantinga
Sam Lantinga committed Apr 10, 2000
1 parent 1c9a396 commit 8988a7a359cc36834bb18ab07931157a0d5bbfbc
Showing with 177 additions and 39 deletions.
  1. +8 −0 CHANGES
  2. +3 −1 Makefile
  3. +23 −21 console_ui.c
  4. +15 −0 copy.c
  5. +3 −0 copy.h
  6. +106 −0 extras/makedesktop.sh
  7. +8 −4 gtk_ui.c
  8. +11 −13 install.c
View
@@ -1,5 +1,13 @@
1.2.2:
+Sam Lantinga - Mon Apr 10 14:50:41 PDT 2000
+ * Use portable code generation (for EV4) on Linux/Alpha
+Sam Lantinga - Mon Apr 10 14:32:17 PDT 2000
+ * Catch the case when gnome-config isn't available or executable
+Sam Lantinga - Mon Apr 10 13:58:56 PDT 2000
+ * Added an extras directory containing the "makedesktop.sh" script
+Sam Lantinga - Mon Apr 10 13:54:04 PDT 2000
+ * Only offer the desktop menu option if there is a "binary" option
Sam Lantinga - Mon Apr 10 13:27:28 PDT 2000
* Limited the number of characters in the "current file" label
Sam Lantinga - Mon Apr 10 10:44:14 PDT 2000
View
@@ -9,7 +9,9 @@ libc := $(shell ./print_libc)
CC = gcc
OPTIMIZE = -Wall -g -O2 -funroll-loops
-#OPTIMIZE = -Wall -g
+ifeq ($(arch), alpha)
+ OPTIMIZE += -mcpu=ev4 -Wa,-mall
+endif
HEADERS = -I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/local/include
OPTIONS = -DSTUB_UI
View
@@ -217,18 +217,18 @@ static install_state console_license(install_info *info)
static install_state console_readme(install_info *info)
{
- const char *readme;
-
- readme = GetProductREADME(info);
- if ( readme && ! access(readme, R_OK) ) {
- char prompt[256];
-
- sprintf(prompt, "Would you like to read the %s file ?", readme);
- if ( console_prompt(prompt, RESPONSE_YES) == RESPONSE_YES ) {
- sprintf(prompt, PAGER_COMMAND " \"%s\"", readme);
- system(prompt);
- }
- }
+ const char *readme;
+
+ readme = GetProductREADME(info);
+ if ( readme && ! access(readme, R_OK) ) {
+ char prompt[256];
+
+ sprintf(prompt, "Would you like to read the %s file ?", readme);
+ if ( console_prompt(prompt, RESPONSE_YES) == RESPONSE_YES ) {
+ sprintf(prompt, PAGER_COMMAND " \"%s\"", readme);
+ system(prompt);
+ }
+ }
return SETUP_OPTIONS;
}
@@ -282,8 +282,10 @@ static install_state console_setup(install_info *info)
node = node->next;
}
- /* Ask for desktop menu items */
- if ( console_prompt("Do you want to install desktop items?", RESPONSE_YES) == RESPONSE_YES ) {
+ /* Ask for desktop menu items */
+ if ( has_binaries(info, info->config->root->childs) &&
+ console_prompt("Do you want to install desktop items?",
+ RESPONSE_YES) == RESPONSE_YES ) {
info->options.install_menuitems = 1;
}
@@ -304,12 +306,12 @@ static void console_update(install_info *info, const char *path, size_t progress
static char previous[200] = "";
if(strcmp(previous, current)){
- strncpy(previous,current, sizeof(previous));
- printf("Installing %s ...\n", current);
+ strncpy(previous,current, sizeof(previous));
+ printf("Installing %s ...\n", current);
}
printf(" %3d%% - %s\r", (int) (((float)progress/(float)size)*100.0), path);
if(progress==size)
- putchar('\n');
+ putchar('\n');
fflush(stdout);
}
@@ -329,7 +331,7 @@ static install_state console_complete(install_info *info)
new_state = SETUP_EXIT;
if ( info->installed_symlink &&
console_prompt("Would you like launch the game now?", RESPONSE_YES)
- == RESPONSE_YES ) {
+ == RESPONSE_YES ) {
new_state = SETUP_PLAY;
if ( getuid() == 0 ) {
const char *warning_text =
@@ -386,8 +388,8 @@ static install_state console_website(install_info *info)
int console_okay(Install_UI *UI)
{
if(!isatty(1)){
- fprintf(stderr,"Standard input is not a terminal!\n");
- return(0);
+ fprintf(stderr,"Standard input is not a terminal!\n");
+ return(0);
}
/* Set up the driver */
UI->init = console_init;
@@ -396,7 +398,7 @@ int console_okay(Install_UI *UI)
UI->setup = console_setup;
UI->update = console_update;
UI->abort = console_abort;
- UI->prompt = console_prompt;
+ UI->prompt = console_prompt;
UI->website = console_website;
UI->complete = console_complete;
View
15 copy.c
@@ -932,3 +932,18 @@ size_t size_tree(install_info *info, xmlNodePtr node)
}
return size;
}
+
+int has_binaries(install_info *info, xmlNodePtr node)
+{
+ int num_binaries;
+
+ num_binaries = 0;
+ while ( node ) {
+ if ( strcmp(node->name, "binary") == 0 ) {
+ ++num_binaries;
+ }
+ num_binaries += has_binaries(info, node->childs);
+ node = node->next;
+ }
+ return num_binaries;
+}
View
3 copy.h
@@ -20,5 +20,8 @@ extern size_t size_node(install_info *info, xmlNodePtr node);
/* Get the install size of an option tree, in bytes */
extern size_t size_tree(install_info *info, xmlNodePtr node);
+/* See whether or not an XML file contains binary entries */
+extern int has_binaries(install_info *info, xmlNodePtr node);
+
/* Utility function to parse a line in the XML file */
extern int parse_line(const char **srcpp, char *buf, int maxlen);
View
@@ -0,0 +1,106 @@
+#!/bin/sh
+#
+# A script to add a desktop menu item and symbolic link for an application
+#
+# Freely redistributable with the Loki Setup program
+# Written by Sam Lantinga, Loki Entertainment Software
+
+if [ $# != 5 ]; then
+ echo "Usage: $0 menu name comment icon path" >&2
+ exit 1
+fi
+menu=$1
+name=$2
+comment=$3
+icon=$4
+path=$5
+
+# Function to create directories as necessary (starting from /)
+function mkdirs
+{
+ oIFS="$IFS"
+ IFS="/"
+ set -- $1
+ IFS="$oIFS"
+ dir=""
+ for segment in $*; do
+ dir="$dir/$segment"
+ if [ ! -d "$dir" ]; then
+ mkdir "$dir"
+ fi
+ done
+}
+
+# The list of KDE desktop paths
+if [ "$KDEDIR" = "" ]; then
+ kde_paths="/usr/X11R6/share/applnk"
+ kde_paths="$kde_paths /usr/share/applnk"
+ kde_paths="$kde_paths /opt/kde/share/applnk"
+else
+ kde_paths="$KDEDIR/share/applnk"
+fi
+kde_paths="$kde_paths $HOME/.kde/share/applnk"
+
+
+# The list of RedHat unified desktop paths
+redhat_paths="/etc/X11/applnk"
+
+# The list of GNOME desktop paths
+gnome_base="`gnome-config --prefix 2>/dev/null`"
+if [ "$gnome_base" = "" ]; then
+ gnome_paths="/usr/share/gnome/app"
+ gnome_paths="$gnome_paths /usr/local/share/gnome/apps"
+ gnome_paths="$gnome_paths /opt/gnome/share/gnome/apps"
+else
+ gnome_paths="$gnome_base/share/gnome/apps"
+fi
+gnome_paths="$gnome_paths $HOME/.gnome/apps"
+
+for desktop in kde redhat gnome; do
+#echo "Desktop is $desktop"
+ if [ "$desktop" = "kde" ]; then
+ desktop_type="KDE "
+ desktop_suffix=".kdelnk"
+ else
+ desktop_type=""
+ desktop_suffix=".desktop"
+ fi
+ case $desktop in
+ kde) desktop_paths=$kde_paths;;
+ redhat) desktop_paths=$redhat_paths;;
+ gnome) desktop_paths=$gnome_paths;;
+ esac
+#echo "Desktop paths = $desktop_paths"
+ for desktop_path in $desktop_paths; do
+ if [ -w "$desktop_path" ]; then
+ mkdirs "$desktop_path/$menu"
+ menu_item="$desktop_path/$menu/$name$desktop_suffix"
+ if [ "$desktop" = "kde" ]; then
+ cat >"$menu_item" <<__EOF__
+# KDE Config File
+__EOF__
+ else
+ : >"$menu_item"
+ fi
+ cat >>"$menu_item" <<__EOF__
+[${desktop_type}Desktop Entry]
+Name=$name
+Comment=$comment
+Exec=$path
+Icon=$icon
+Terminal=0
+Type=Application
+__EOF__
+ fi
+ done
+ if [ "$menu_item" != "" ]; then
+ #echo "Wrote file $menu_item"
+ if [ "$desktop" = "redhat" ]; then
+ break
+ fi
+ menu_item=""
+ fi
+done
+
+# Create the symbolic link for the application
+ln -s "$path" "$SETUP_SYMLINKSPATH/$(basename $path)"
View
@@ -1,5 +1,5 @@
/* GTK-based UI
- $Id: gtk_ui.c,v 1.29 2000-04-10 20:28:49 hercules Exp $
+ $Id: gtk_ui.c,v 1.30 2000-04-10 21:51:36 hercules Exp $
*/
#include <limits.h>
@@ -595,13 +595,17 @@ static void init_binary_path(void)
return;
}
-static void init_menuitems_option(void)
+static void init_menuitems_option(install_info *info, xmlNodePtr node)
{
GtkWidget* widget;
widget = glade_xml_get_widget(setup_glade, "setup_menuitems_checkbox");
if ( widget ) {
- setup_checkbox_menuitems_slot(widget, NULL);
+ if ( has_binaries(info, node) ) {
+ setup_checkbox_menuitems_slot(widget, NULL);
+ } else {
+ gtk_widget_hide(widget);
+ }
} else {
log_warning(cur_info, "Unable to locate 'setup_menuitems_checkbox'");
}
@@ -844,7 +848,7 @@ static install_state gtkui_setup(install_info *info)
init_binary_path();
update_size();
update_space();
- init_menuitems_option();
+ init_menuitems_option(info, info->config->root->childs);
/* Center and show the installer */
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
View
@@ -1,4 +1,4 @@
-/* $Id: install.c,v 1.37 2000-04-10 20:28:49 hercules Exp $ */
+/* $Id: install.c,v 1.38 2000-04-10 21:51:36 hercules Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -704,21 +704,19 @@ char install_menuitems(install_info *info, desktop_type desktop)
}
break;
case DESKTOP_GNOME:
-#warning What happens when gnome-config is not available?
- fp = popen("gnome-config --prefix", "r");
+ app_links = gnome_app_links;
+ fp = popen("gnome-config --prefix 2>/dev/null", "r");
if (fp) {
- fgets(icon_base, PATH_MAX, fp);
- icon_base[sizeof(icon_base)-1]=0;
- strcat(icon_base, "/share/gnome/apps/");
- found_links[0] = icon_base;
- found_links[1] = "~/.gnome/apps/";
- found_links[2] = 0;
- app_links = found_links;
+ if ( fgets(icon_base, PATH_MAX-1, fp) ) {
+ icon_base[sizeof(icon_base)-1]=0;
+ strcat(icon_base, "/share/gnome/apps/");
+ found_links[0] = icon_base;
+ found_links[1] = "~/.gnome/apps/";
+ found_links[2] = 0;
+ app_links = found_links;
+ }
pclose(fp);
}
- else {
- app_links = gnome_app_links;
- }
break;
default:
return ret_val;

0 comments on commit 8988a7a

Please sign in to comment.