Hi,

I'm a new in Nokia770/N800 development. So, please, don't be surprised if my
question looks stupid. I created a simple Maemo application (see attached
file) which  is needed to specify server IP and Orbiter ID and run Plutohome
SDL Orbiter (application which allows to use Nokia as remote control for
home automation system Plutohome - plutohome.com).

The application works as I expect if I run it from xtem - it allows to
specify  the parameters, runs the Orbiter and stays  alive during the
Orbiter running. After close the Orbiter  (it's run in fullscreen mode) the
application is still running.

But if I run the application via Nokia's menu, it's closed by some reason
right after the Orbiter is started. I used as example bomberman game.

Any help will be very appreciated!

Thanks in advance.

--
Cheers,
Michael
/* Includes */
#include <hildon-widgets/hildon-program.h>
#include <gtk/gtk.h> 

#include <gconf/gconf.h>
#include <gconf/gconf-client.h>

#include <string.h>
#include <stdlib.h>
#include <stdio.h>


#define PACKAGE_VERSION "0.01"
#define VERSION "2.0.0.44-3"


GtkWidget *coreIP, *orbiterID, *lCheckBox;
HildonWindow *window;
GConfClient *gc_client;

gint* gloggin_prefs;
gchar* gorbiter_id;
gchar* gcore_ip;

static void start_po (GtkButton * button, gpointer data)
{
    char buffer[250];
    char snd[4];
    char swp[4];

    snd[0] = 0;
    swp[0] = 0;

    /* Button "Connect to another Server" is selected */
    if (strcmp ("", (char *) gtk_entry_get_text (GTK_ENTRY (coreIP))) == 0)	/* Test if there's a server name present */
	{
	    GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (window),
							GTK_DIALOG_DESTROY_WITH_PARENT,
							GTK_MESSAGE_ERROR,
							GTK_BUTTONS_CLOSE,
							"Please specify a valid address for Plutohome core!");
	    gtk_dialog_run (GTK_DIALOG (dialog));
	    gtk_widget_destroy (dialog);
	    return;
	}

	if (strcmp ("", (char *) gtk_entry_get_text (GTK_ENTRY (orbiterID))) == 0)	/* Test if there's a nickname present */
	{
	    GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (window),
							GTK_DIALOG_DESTROY_WITH_PARENT,
							GTK_MESSAGE_ERROR,
							GTK_BUTTONS_CLOSE,
							"Please specify an Orbiter ID!");
	    gtk_dialog_run (GTK_DIALOG (dialog));
	    gtk_widget_destroy (dialog);
	    return;
	}

	gconf_client_set_string(gc_client, "/apps/maemo/plutohomeorbiter/core_ip", gtk_entry_get_text (GTK_ENTRY (coreIP)), NULL);
	gconf_client_set_string(gc_client, "/apps/maemo/plutohomeorbiter/orbiter_id", gtk_entry_get_text (GTK_ENTRY (orbiterID)), NULL);
	
	sprintf (buffer, "Orbiter -r %s -d %s > /dev/null 2>&1",
		     gtk_entry_get_text (GTK_ENTRY (coreIP)),
		     gtk_entry_get_text (GTK_ENTRY (orbiterID)));
	puts (buffer);
	system (buffer);	
}


static void quit_po (GtkButton * button, gpointer data)
{
    gtk_widget_destroy (GTK_WIDGET (data));
}


static void display_help (GtkButton * button, gpointer data)
{
    GtkWidget *dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (window),
							    GTK_DIALOG_DESTROY_WITH_PARENT,
							    GTK_MESSAGE_INFO,
							    GTK_BUTTONS_OK,
							    "<small><b>Plutohome Obiter for Nokia N800.\n</b>"
							    "To start the Orbiter just specify core IP and Orbiter's ID.\n"
							    "Note: you have to connect to the WLAN network before run the Orbiter!\n\n"
								""
								"For more informationm please, visit plutohome.com and https://garage.maemo.org/projects/pluto-nokia/</small>");
    gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (dialog);
}

HildonWindow *create_form (void) 
{
	GtkWidget *label, *btnStart, *btnHelp, *btnQuit, *imgLogo, *fix, *frmPrefs;
	
	/* Create HildonWindow and set it to HildonProgram */
    window = HILDON_WINDOW(hildon_window_new());

    /* Add example label to window */
	fix = gtk_fixed_new();
    gtk_container_add(GTK_CONTAINER(window), fix);

	imgLogo = gtk_image_new_from_file ("plutologo.png");
    gtk_fixed_put (GTK_FIXED (fix), imgLogo, 20, 0);
    
	/* Info Label */
    label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (label),
			  "<small><b>Plutohome Orbiter v." VERSION ", compiled " __DATE__ "</b></small>\n");
	gtk_fixed_put(GTK_FIXED (fix), label, 150, 10);

    /* Frame Preferences */
    frmPrefs = gtk_frame_new ("");
    gtk_fixed_put (GTK_FIXED (fix), frmPrefs, 10, 100);
    gtk_widget_set_size_request (frmPrefs, 650, 300);

    /* Enter Core IP/host name */
    gtk_fixed_put (GTK_FIXED (fix), gtk_label_new ("Pluto Core IP:"), 80, 150);
    coreIP = gtk_entry_new_with_max_length (200);
	gtk_widget_set_size_request(coreIP, 200, 30);
    gtk_fixed_put (GTK_FIXED (fix), coreIP, 240, 150);
    gtk_entry_set_text(GTK_ENTRY(coreIP),gcore_ip ? gcore_ip : "");

    /* Enter Orbiter ID */
    gtk_fixed_put (GTK_FIXED (fix), gtk_label_new ("Orbiter ID:"), 80, 200);
    orbiterID = gtk_entry_new_with_max_length (10);	
	gtk_widget_set_size_request(orbiterID, 60, 30);
    gtk_fixed_put (GTK_FIXED (fix), orbiterID, 240, 200);
    gtk_entry_set_text(GTK_ENTRY(orbiterID),gorbiter_id ? gorbiter_id : "");

    /* Checkbuttons for logger	
	lCheckBox = gtk_check_button_new_with_label ("Logging");
    gtk_fixed_put (GTK_FIXED (fix), lCheckBox, 240, 240);	
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lCheckBox), gloggin_prefs ? gloggin_prefs : 0); */
    
    /* Three Buttons: Start, Info and Quit */
    btnStart = gtk_button_new_with_label ("Start Orbiter");
    gtk_widget_set_size_request (btnStart, 240, 60);
    gtk_fixed_put (GTK_FIXED (fix), btnStart, 20, 330);
    g_signal_connect (G_OBJECT (btnStart), "clicked", G_CALLBACK (start_po), window);

    btnHelp = gtk_button_new_with_label ("Info");
    gtk_widget_set_size_request (btnHelp, 100, 60);
    gtk_fixed_put (GTK_FIXED (fix), btnHelp, 290, 330);
    g_signal_connect (G_OBJECT (btnHelp), "clicked", G_CALLBACK (display_help), window);

    btnQuit = gtk_button_new_with_label ("Quit");
    gtk_widget_set_size_request (btnQuit, 240, 60);
    gtk_fixed_put (GTK_FIXED (fix), btnQuit, 410, 330);
    g_signal_connect (G_OBJECT (btnQuit), "clicked", G_CALLBACK (quit_po), window);
	
	/* Connect signal to X in the upper corner */
    g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL);


    /* Begin the main application */
    gtk_widget_show_all(GTK_WIDGET(window));
	
    return window;
}

void init_properties (void) 
{
	gorbiter_id 	= gconf_client_get_string(gc_client, "/apps/maemo/plutohomeorbiter/orbiter_id", NULL);
	gcore_ip 		= gconf_client_get_string(gc_client, "/apps/maemo/plutohomeorbiter/core_ip", NULL);
}

int main(int argc, char *argv[])
{
    /* Create needed variables */
    HildonProgram *program;
    HildonWindow *window;
	
	/* Initialize the GTK. */
    gtk_init(&argc, &argv);
	
	/* Init type system */
	g_type_init();

	/* Load default GConf path */
	gc_client = gconf_client_get_default();

	if (gc_client == NULL) {
		    return FALSE;
	}
	init_properties();

    /* Create the hildon program and setup the title */
    program = HILDON_PROGRAM(hildon_program_get_instance());
    g_set_application_name("Plutohome Orbiter");
    
	window = create_form();
    hildon_program_add_window(program, window);

    
    gtk_main();

    /* Exit */
    return 0;
}
_______________________________________________
maemo-developers mailing list
[email protected]
https://lists.maemo.org/mailman/listinfo/maemo-developers

Reply via email to