コード例 #1
0
void GscPreferencesWindow::on_window_reset_all_button_clicked()
{
	Gtk::MessageDialog dialog(*this,
			"\nAre you sure you want to reset all program settings to their defaults?\n",
			true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true);

	if (dialog.run() == Gtk::RESPONSE_YES) {
		rconfig::clear_config_all();
		import_config();
		// close the window, because the user might get the impression that "Cancel" will revert.
		destroy(this);
	}
}
コード例 #2
0
GscPreferencesWindow::GscPreferencesWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
		: AppUIResWidget<GscPreferencesWindow, true>(gtkcobj, ref_ui), device_options_treeview(0)
{
	// Connect callbacks

	APP_GTKMM_CONNECT_VIRTUAL(delete_event);  // make sure the event handler is called

	Gtk::Button* window_cancel_button = 0;
	APP_UI_RES_AUTO_CONNECT(window_cancel_button, clicked);

	Gtk::Button* window_ok_button = 0;
	APP_UI_RES_AUTO_CONNECT(window_ok_button, clicked);

	Gtk::Button* window_reset_all_button = 0;
	APP_UI_RES_AUTO_CONNECT(window_reset_all_button, clicked);


	Gtk::Button* smartctl_binary_browse_button = 0;
	APP_UI_RES_AUTO_CONNECT(smartctl_binary_browse_button, clicked);


	Gtk::Button* device_options_add_device_button = 0;
	APP_UI_RES_AUTO_CONNECT(device_options_add_device_button, clicked);

	Gtk::Button* device_options_remove_device_button = 0;
	APP_UI_RES_AUTO_CONNECT(device_options_remove_device_button, clicked);

	Gtk::Entry* device_options_device_entry = 0;
	APP_UI_RES_AUTO_CONNECT(device_options_device_entry, changed);

	Gtk::Entry* device_options_parameter_entry = 0;
	APP_UI_RES_AUTO_CONNECT(device_options_parameter_entry, changed);


	// Accelerators

	Glib::RefPtr<Gtk::AccelGroup> accel_group = this->get_accel_group();
	if (window_cancel_button) {
		window_cancel_button->add_accelerator("clicked", accel_group, GDK_Escape,
				Gdk::ModifierType(0), Gtk::AccelFlags(0));
	}


	// create Device Options treeview
	get_ui()->get_widget_derived("device_options_treeview", device_options_treeview);
	device_options_treeview->set_preferences_window(this);

	// we can't do this in treeview's constructor, it doesn't know about this window yet.
	this->device_widget_set_remove_possible(false);  // initial state

	// hide win32-only options for non-win32.
#ifndef _WIN32
	Gtk::CheckButton* smartctl_search_check = this->lookup_widget<Gtk::CheckButton*>("search_in_smartmontools_first_check");
	if (smartctl_search_check)
		smartctl_search_check->hide();
#endif


	// ---------------

	import_config();

	// show();
}
コード例 #3
0
ファイル: upgrade.c プロジェクト: jhbsz/LC4
void
do_upgrade_post(char *url, webs_t stream, int len, char *boundary)
{
    char buf[POST_BUF_SIZE];

    upgrade_result = EINVAL;
    upgrade_type = 0;

    /* Turn on the flag to omit the follwoing HTTP request. */
    refuse_request = 1;

    /* Look for our part */
    while (len > 0) {
        if (!wfgets(buf, MIN(len + 1, sizeof(buf)), stream))
            return;
        len -= strlen(buf);
        if (!strncasecmp(buf, "Content-Disposition:", 20)) {
            if (strstr(buf, "name=\"binfile\"")) { 
                /* upgrade image */
                upgrade_type = FIRMWARE;
                break;
            } else if (strstr(buf, "name=\"cfgfile\"")) {   
                /* import configuration */
                upgrade_type = CONFIG;
                break;
            }
        }
    }

#ifdef DEBUG
    printf("%s upgrade\n", (upgrade_type == FIRMWARE) ? "firmware" : "config" );
#endif

    /* Skip boundary and headers */
    while (len > 0) {
        if (!wfgets(buf, MIN(len + 1, sizeof(buf)), stream))
            return;
#ifdef DEBUG
    printf("[%d]%s", strlen(buf), buf);
#endif
        len -= strlen(buf);
        if (!strcmp(buf, "\n") || !strcmp(buf, "\r\n"))
            break;
    }

#ifdef DEBUG
    printf("content length[%d]\n", len);
#endif

    if ( upgrade_type == FIRMWARE ) {
        upgrade_result = do_upgrade(NULL, stream, &len);
    } 

    if ( upgrade_type == CONFIG ) {
        upgrade_result = import_config(NULL, stream, &len);
    }
    
    /* Slurp anything remaining in the request */
    while (len--)
#if defined(HTTPS_SUPPORT)
        if (do_ssl)
            BIO_gets((BIO *) stream, buf, 1);
        else
#endif
            (void) fgetc(stream);
}