示例#1
0
//void setup_checkbox_option_slot( GtkWidget* widget, gpointer func_data)
int OnOptionClickEvent(OptionsButton *ButtonWithEventClick)
{
	//GtkWidget *window;
	xmlNodePtr node;
    //xmlNodePtr data_node = (xmlNodePtr) func_data; //gtk_object_get_data(GTK_OBJECT(widget),"data");
    xmlNodePtr data_node = (xmlNodePtr)ButtonWithEventClick->Data;

    carbon_debug("OnOptionClickEvent()\n");

	if(!data_node)
		return true;
	
	//window = glade_xml_get_widget(setup_glade, "setup_window");

	//if(GTK_TOGGLE_BUTTON(widget)->active)
    if(carbon_OptionsGetValue(ButtonWithEventClick))
    {
        carbon_debug("OnOptionClickEvent() - Button toggle to true\n");
		const char *warn = get_option_warn(cur_info, data_node);

		// does this option require a seperate EULA?
		xmlNodePtr child;
		child = data_node->childs;
		while(child)
		{
			if (!strcmp(child->name, "eula"))
			{
				const char* name = GetProductEULANode(cur_info, data_node, NULL);
				if(name)
				{
                    char buffer[MAX_README_SIZE];
                    load_file(name, buffer, MAX_README_SIZE);
                    if(!carbon_ReadmeOrLicense(MyRes, false, buffer))
                    {
                        carbon_OptionsSetValue(ButtonWithEventClick, false);
					    return true;
					}
                    // Else, license was accepted...get out of loop
                    break;
				}
				else
				{
					log_warning("option-specific EULA not found, can't set option on\n");
					// EULA not found 	or not accepted
					carbon_OptionsSetValue(ButtonWithEventClick, false);
					return true;
				}
			}
			child = child->next;
		}
		
		if ( warn && !in_setup ) { // Display a warning message to the user
			carbonui_prompt(warn, RESPONSE_OK);
		}

		/* Mark this option for installation */
		mark_option(cur_info, data_node, "true", 0);
		
		/* Recurse down any other options to re-enable grayed out options */
		node = data_node->childs;
		while ( node ) {
			//enable_tree(node, window);
            EnableTree(node, (OptionsBox *)ButtonWithEventClick->Box);
			node = node->next;
		}
	}
    else
    {
        carbon_debug("OnOptionClickEvent() - Button toggle to false\n");
		/* Unmark this option for installation */
		mark_option(cur_info, data_node, "false", 1);
		
		/* Recurse down any other options */
		node = data_node->childs;
		while ( node ) {
			if ( !strcmp(node->name, "option") ) {
				//GtkWidget *button;
				//button = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(window),
				//										 get_option_name(cur_info, node, NULL, 0));
                OptionsButton *button;
				button = carbon_GetButtonByName((OptionsBox *)ButtonWithEventClick->Box, get_option_name(cur_info, node, NULL, 0));

                if(button){ /* This recursively calls this function */
					//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
					//gtk_widget_set_sensitive(button, FALSE);
                    carbon_OptionsSetValue(button, false);
                    DisableControl(button->Control);
				}
			} else if ( !strcmp(node->name, "exclusive") ) {
				xmlNodePtr child;
				for ( child = node->childs; child; child = child->next) {
					//GtkWidget *button;
					
					//button = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(window),
					//										 get_option_name(cur_info, child, NULL, 0));
                    OptionsButton *button;
                    button = carbon_GetButtonByName((OptionsBox *)ButtonWithEventClick->Box, get_option_name(cur_info, node, NULL, 0));
					if(button){ /* This recursively calls this function */
						//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
						//gtk_widget_set_sensitive(button, FALSE);
                        carbon_OptionsSetValue(button, false);
                        DisableControl(button->Control);
					}
				}
			}
			node = node->next;
		}
	}
    cur_info->install_size = size_tree(cur_info, cur_info->config->root->childs);
	update_size();

    return true;
}
示例#2
0
static install_state carbonui_init(install_info *info, int argc, char **argv, int noninteractive)
{
    char title[1024];

    carbon_debug("***carbonui_init()\n");

    // Load the resources related to our carbon interface
    MyRes = carbon_LoadCarbonRes(OnCommandEvent, OnKeyboardEvent);
    // Couldn't allocate resources...exit setup.
    if(MyRes == NULL)
    {
        carbon_debug("carbonui_init() - Couldn't allocate carbon resources\n");
        return SETUP_ABORT;
    }

    // Save our state flag and install info structure
    cur_state = SETUP_INIT;
    cur_info = info;

    // Set window title based on info structure
    if(info->component)
        snprintf(title, sizeof(title), _("%s / %s Setup"), info->desc, GetProductComponent(info));
    else
        snprintf(title, sizeof(title), _("%s Setup"), info->desc);
    carbon_SetWindowTitle(MyRes, title);

    // Set the initial state
    if(noninteractive)
        carbon_ShowInstallScreen(MyRes, COPY_PAGE);
    else if(GetProductAllowsExpress(info))
        carbon_ShowInstallScreen(MyRes, CLASS_PAGE);
    else
        carbon_ShowInstallScreen(MyRes, OPTION_PAGE);

    // Disable the "View Readme" button if no README available
    if(!GetProductREADME(cur_info, NULL))
    {
        carbon_HideControl(MyRes, CLASS_README_BUTTON_ID);
        carbon_HideControl(MyRes, COPY_README_BUTTON_ID);
        carbon_HideControl(MyRes, DONE_README_BUTTON_ID);
        carbon_HideControl(MyRes, OPTION_README_BUTTON_ID);
    }

    // Set copy progress labels to blank by default
    carbon_SetLabelText(MyRes, COPY_TITLE_LABEL_ID, "");
    carbon_SetLabelText(MyRes, COPY_CURRENT_FILE_LABEL_ID, "");

    // Disable useless controls for meta-installer
    if(GetProductIsMeta(info))
    {
        carbon_HideControl(MyRes, OPTION_GLOBAL_OPTIONS_GROUP_ID);
        carbon_HideControl(MyRes, OPTION_FREESPACE_LABEL_ID);
        carbon_HideControl(MyRes, OPTION_FREESPACE_VALUE_LABEL_ID);
        carbon_HideControl(MyRes, OPTION_ESTSIZE_LABEL_ID);
        carbon_HideControl(MyRes, OPTION_ESTSIZE_VALUE_LABEL_ID);
        //carbon_HideControl(MyRes, OPTION_OPTIONS_SEPARATOR_ID);
    }

    // Disable path fields if they were provided on command line
    if(disable_install_path)
    {
        carbon_DisableControl(MyRes, OPTION_INSTALL_PATH_BUTTON_ID);
        carbon_DisableControl(MyRes, OPTION_INSTALL_PATH_ENTRY_ID);
    }
    if(disable_binary_path)
    {
        carbon_debug("carbonui_init() - disable_binary_path != 0\n");
        carbon_DisableControl(MyRes, OPTION_LINK_PATH_BUTTON_ID);
        carbon_DisableControl(MyRes, OPTION_LINK_PATH_ENTRY_ID);
    }
    // Path entry is always disabled when appbundle is set
    if(GetProductIsAppBundle(cur_info))
    {
        carbon_DisableControl(MyRes, OPTION_INSTALL_PATH_ENTRY_ID);
    }

    // Disable dock option if not requested in dockoption attribute
    /*const char *DesktopOptionString = xmlGetProp(cur_info->config->root, "desktopicon");
    if(DesktopOptionString != NULL)
    {
        printf("carbonui_init() - desktopicon = %s\n", DesktopOptionString);
        if(strcasecmp(DesktopOptionString, "yes") != 0)
            carbon_HideControl(MyRes, OPTION_CREATE_DESKTOP_ALIAS_BUTTON_ID);
    }
    // Else, option doesn't appear...disable it
    else
    {
        printf("carbonui_init() - desktopicon = NULL\n");
        carbon_HideControl(MyRes, OPTION_CREATE_DESKTOP_ALIAS_BUTTON_ID);
    }*/

    // If product has no binary, don't provide them with option to set
    // link location.
    if(GetProductHasNoBinaries(info))
    {
        carbon_HideControl(MyRes, OPTION_LINK_PATH_LABEL_ID);
        carbon_HideControl(MyRes, OPTION_LINK_PATH_ENTRY_ID);
        carbon_HideControl(MyRes, OPTION_LINK_PATH_BUTTON_ID);
    }

    // Hide symlink checkbox if no binary or feature not used
    if(GetProductHasNoBinaries(info) || (!GetProductHasPromptBinaries(info)))
        carbon_HideControl(MyRes, OPTION_SYMBOLIC_LINK_CHECK_ID);

    // Set initial install size
    info->install_size = size_tree(info, info->config->root->childs);

    // Needed so that Expert is detected properly at this point
    //license_okay = 1;

    // Check if we should check "Expert" installation by default
	if(check_for_installation(info))
        carbon_SetInstallClass(MyRes, false);

    // If product has an end user license, show it
    if(GetProductEULA(info, NULL))
    {
        //license_okay = 0;
        cur_state = SETUP_LICENSE;
    }
    // Otherwise, show the readme
    else
    {
        //license_okay = 1;
        cur_state = SETUP_README;
    }

    // Update the install image
    carbon_UpdateImage(MyRes, GetProductSplash(info), SETUP_BASE, GetProductSplashPosition(info));

    return cur_state;
}
示例#3
0
文件: tree.c 项目: smohanhc/dalgos
int size_tree(struct node* head)
{ if(head == NULL)
    return(0);
  else
    return(size_tree(head->left)+1+size_tree(head->right));
}