Пример #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
bool
Application::InstallWithError (MoonError *error, bool user_initiated, bool unattended)
{
	MoonInstallerService *installer = Runtime::GetInstallerService ();
	Deployment *deployment = Deployment::GetCurrent ();

	// application manifest must allow out-of-browser support
	OutOfBrowserSettings *settings = deployment->GetOutOfBrowserSettings ();
	if (!settings) {
		// FIXME - this fix a crasher but is not complete wrt MSDN
		return false;
	}

	if (!IsInstallable ()) {
		MoonError::FillIn (error, MoonError::INVALID_OPERATION, "Applications may only be installed from http, https or file URLs");
		return false;
	}
	
	if (GetInstallState () == InstallStateInstalled || IsRunningOutOfBrowser ()) {
		MoonError::FillIn (error, MoonError::INVALID_OPERATION, "Application is already installed");
		return false;
	}

	// the dialog is displayed only if the action leading to this call was initiated directly from the user
	if (!unattended && !user_initiated && !deployment->GetSurface ()->IsUserInitiatedEvent ())
		return false;
	
	SetInstallState (InstallStateInstalling);
	
	if (installer->Install (deployment, unattended)) {
		SetInstallState (InstallStateInstalled);
		return true;
	}
	
	SetInstallState (InstallStateInstallFailed);
	
	return false;
}