示例#1
0
void
MoonWindowGtk::RightClickMenu ()
{
	Deployment *deployment = Deployment::GetCurrent ();
	OutOfBrowserSettings *settings;
	GtkWidget *menu_item;
	GtkWidget *menu;
	char *name;

	menu = gtk_menu_new();

	menu_item = gtk_menu_item_new_with_label ("Moonlight Settings");

	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
	g_signal_connect_swapped (G_OBJECT(menu_item), "activate", G_CALLBACK (show_moonlight_dialog), this);

	if (deployment && (settings = deployment->GetOutOfBrowserSettings ())) {
		Application *application = deployment->GetCurrentApplication ();
		
		switch (application->GetInstallState ()) {
		case InstallStateNotInstalled:
			if (application->IsInstallable () && settings->GetShowInstallMenuItem ()) {
				name = g_strdup_printf ("Install %s onto this computer...", settings->GetShortName ());
				menu_item = gtk_menu_item_new_with_label (name);
				gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
				g_signal_connect_swapped (G_OBJECT(menu_item), "activate", G_CALLBACK (install_application), this);
				g_free (name);
			}
			break;
		case InstallStateInstalled:
			menu_item = gtk_menu_item_new_with_label ("Remove this application...");
			gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
			g_signal_connect_swapped (G_OBJECT(menu_item), "activate", G_CALLBACK (uninstall_application), this);
			break;
		default:
			break;
		}
	}

	gtk_widget_show_all (menu);
	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
}
示例#2
0
static MoonWindow*
create_window (Deployment *deployment, const char *app_id)
{
	MoonAppRecord *app;
	OutOfBrowserSettings *oob;
	MoonWindow *moon_window;
	Surface *surface;

	/* fetch the app record */
	if (!(app = installer->GetAppRecord (app_id))) {
		g_warning ("Could not find application: %s", app_id);
		return NULL;
	}

	/* create the moonlight widget */
	moon_window = winsys->CreateWindow (MoonWindowType_Desktop, 0, 0);
	surface = new Surface (moon_window);
	surface->EnsureManagedPeer ();
	deployment->SetSurface (surface);
	moon_window->SetSurface (surface);

	setup_app (deployment, installer->GetBaseInstallDir (), app);

	surface->AddXamlHandler (Surface::ErrorEvent, error_handler, NULL);
	surface->unref ();

	/* load the xap */
	if (!deployment->InitializeManagedDeployment (NULL, NULL, NULL)) {
		surface->unref ();
		return NULL;
	}
	
	if ((oob = deployment->GetOutOfBrowserSettings ()))
		load_window_icons (moon_window, deployment, oob->GetIcons ());
	
	delete app;

	return moon_window;
}
示例#3
0
static MoonWindow*
create_window (Deployment *deployment, const char *app_id)
{
	MoonAppRecord *app;
	OutOfBrowserSettings *oob;
	WindowSettings *settings;
	MoonWindow *moon_window;
	Surface *surface;

	/* fetch the app record */
	if (!(app = installer->GetAppRecord (app_id))) {
		g_warning ("Could not find application: %s", app_id);
		return NULL;
	}

	/* create the moonlight widget */
	moon_window = winsys->CreateWindow (MoonWindowType_Desktop, 0, 0);
	surface = new Surface (moon_window);
	deployment->SetSurface (surface);
	moon_window->SetSurface (surface);

	if (!load_app (deployment, installer->GetBaseInstallDir (), app))
		return NULL;
	
	surface->AddXamlHandler (Surface::ErrorEvent, error_handler, NULL);
	
	if ((oob = deployment->GetOutOfBrowserSettings ())) {
		load_window_icons (moon_window, deployment, oob->GetIcons ());
		settings = oob->GetWindowSettings ();
	} else
		settings = NULL;
	
	if (settings != NULL) {
		Uri *uri;
		const char *hostname = NULL;

		uri = Uri::Create (app->origin);
		if (uri != NULL)
			hostname = uri->GetHost ();

		if (!hostname || !*hostname)
			hostname = "localhost";

		char *window_title = g_strdup_printf ("%s - %s",
						      settings->GetTitle(),
						      hostname);

		delete uri;

		moon_window->SetTitle (window_title);

		g_free (window_title);

		moon_window->Resize (settings->GetWidth (), settings->GetHeight());
			
		if (settings->GetWindowStartupLocation () == WindowStartupLocationManual) {
			// FIXME: this should really use a MoonWindow::Move
			moon_window->SetLeft (settings->GetLeft ());
			moon_window->SetTop (settings->GetTop ());
		}

		moon_window->SetStyle (settings->GetWindowStyle ());

	} else if (oob != NULL) {
		moon_window->SetTitle (oob->GetShortName ());
	} else {
		moon_window->SetTitle ("Moonlight");
	}
	
	delete app;

	return moon_window;
}