示例#1
0
static void
configure_fields_dialog (ETableConfig *config, GladeXML *gui)
{
	GtkWidget *scrolled;

	scrolled = glade_xml_get_widget (gui, "custom-available");
	config->available = e_table_scrolled_get_table (E_TABLE_SCROLLED (scrolled));
	g_object_get (config->available,
		      "model", &config->available_model,
		      NULL);
	gtk_widget_show_all (scrolled);

	scrolled = glade_xml_get_widget (gui, "custom-shown");
	config->shown = e_table_scrolled_get_table (E_TABLE_SCROLLED (scrolled));
	g_object_get (config->shown,
		      "model", &config->shown_model,
		      NULL);
	gtk_widget_show_all (scrolled);

	connect_button (config, gui, "button-add",    G_CALLBACK (config_button_add));
	connect_button (config, gui, "button-remove", G_CALLBACK (config_button_remove));
	connect_button (config, gui, "button-up",     G_CALLBACK (config_button_up));
	connect_button (config, gui, "button-down",   G_CALLBACK (config_button_down));

	setup_fields (config);
}
示例#2
0
void
connection_toggle()
{
    if(tuner.thread)
    {
        connect_button(TRUE);
        if(!conf.disconnect_confirm || ui_dialog_confirm_disconnect())
        {
            /* The tuner is connected, shutdown it */
            tuner_write(tuner.thread, "X");
            /* Lock the connection button until the thread ends */
            gtk_widget_set_sensitive(ui.b_connect, FALSE);
            g_usleep(100000);
            tuner_thread_cancel(tuner.thread);
        }
        return;
    }

    /* Drop current rotator state */
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui.b_cw), FALSE);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui.b_ccw), FALSE);

    /* Display connection dialog */
    connection_dialog(FALSE);
}
示例#3
0
static void
connection_dialog_connected(gint mode,
                            gint fd)
{
    gtk_window_set_title(GTK_WINDOW(ui.window), ui.window_title);
    signal_clear();
    connection_dialog_status("Waiting for tuner...");
    gtk_widget_set_sensitive(ui.b_connect, FALSE);

    wait_for_tuner = TRUE;
    tuner.thread = tuner_thread_new(mode, fd);

    while(!tuner.ready && tuner.thread)
    {
        if(gtk_events_pending())
            gtk_main_iteration();
        if(!gtk_events_pending())
            g_usleep(10000);
    }

    if(!tuner.thread)
    {
        if(wait_for_tuner)
        {
            connection_dialog_unlock(TRUE);
            connection_dialog_status("Connection has been unexpectedly closed.");
            wait_for_tuner = FALSE;
        }
        successfully_connected = FALSE;
        return;
    }

    successfully_connected = TRUE;

    if(tuner.send_settings)
    {
        tuner_set_volume();
        tuner_set_squelch();
        tuner_set_mode(tuner.mode);
        tuner_set_frequency(conf.initial_freq);
        tuner_set_agc();
        tuner_set_bandwidth();
        tuner_set_deemphasis();
        tuner_set_gain();
        tuner_set_antenna();
    }

    connect_button(TRUE);
    gtk_widget_set_sensitive(ui.b_connect, TRUE);
    wait_for_tuner = FALSE;
    gtk_widget_destroy(dialog);
}
示例#4
0
View::View(BaseObjectType* cobject,
	   const Glib::RefPtr<Gtk::Builder>& builder)
  : Gtk::Window(cobject), m_builder(builder)
{
  // Menus
  connect_action ("OpenStl",         sigc::mem_fun(*this, &View::load_stl) );
  connect_action ("OpenGCode",       sigc::mem_fun(*this, &View::load_gcode) );
  connect_action ("Quit",            sigc::ptr_fun(&Gtk::Main::quit));
  connect_action ("About",           sigc::mem_fun(*this, &View::about_dialog) );

  connect_action ("PreferencesDialog", sigc::bind(sigc::mem_fun(*this, &View::show_dialog),
						  "preferences_dlg"));
  connect_action ("LoadSettings",    sigc::mem_fun(*this, &View::load_settings));
  connect_action ("SaveSettings",    sigc::mem_fun(*this, &View::save_settings));
  connect_action ("SaveSettingsAs",  sigc::mem_fun(*this, &View::save_settings_as));

#if 0
  // Simple tab
  connect_button ("s_load_stl",      sigc::mem_fun(*this, &View::load_stl) );
  connect_button ("s_convert_gcode", sigc::mem_fun(*this, &View::ConvertToGCode) );
  connect_button ("s_load_gcode",    sigc::mem_fun(*this, &View::load_gcode) );
  connect_button ("s_print",         sigc::mem_fun(*this, &View::SimplePrint) );
#endif

  // View tab
  connect_button ("m_load_stl",      sigc::mem_fun(*this, &View::load_stl) );
  connect_button ("m_save_stl",      sigc::mem_fun(*this, &View::save_stl) );
  connect_button ("m_delete",        sigc::mem_fun(*this, &View::delete_selected_stl) );
  connect_button ("m_duplicate",     sigc::mem_fun(*this, &View::duplicate_selected_stl) );
  connect_button ("m_auto_rotate",   sigc::mem_fun(*this, &View::auto_rotate) );
  connect_button ("m_rot_x",         sigc::bind(sigc::mem_fun(*this, &View::rotate_selection), Vector4f(1,0,0, M_PI/2)));
  connect_button ("m_rot_y",         sigc::bind(sigc::mem_fun(*this, &View::rotate_selection), Vector4f(0,1,0, M_PI/2)));
  connect_button ("m_rot_z",         sigc::bind(sigc::mem_fun(*this, &View::rotate_selection), Vector4f(0,0,1, M_PI/2)));
  m_builder->get_widget ("m_rfo_tree", m_rfo_tree);

  m_translation_row = new TranslationSpinRow (this, m_rfo_tree, "m_box_translate");

  Gtk::HScale *scale_slider;
  m_builder->get_widget("m_scale_slider", scale_slider);
  scale_slider->set_range(0.01, 5.0);
  scale_slider->set_value(1.0);
  m_rfo_tree->get_selection()->signal_changed().connect
      (sigc::mem_fun(*this, &View::update_scale_slider));
  scale_slider->signal_value_changed().connect
      (sigc::mem_fun(*this, &View::scale_object));

  add_statusbar_msg("m_scale_event_box", "Scale the selected object");

  // GCode tab
  m_builder->get_widget ("g_gcode", m_gcode_entry);
  m_gcode_entry->set_activates_default();
  m_gcode_entry->signal_activate().connect (sigc::mem_fun(*this, &View::send_gcode));;

  connect_button ("g_load_gcode",    sigc::mem_fun(*this, &View::load_gcode) );
  connect_button ("g_convert_gcode", sigc::mem_fun(*this, &View::convert_to_gcode) );
  connect_button ("g_save_gcode",    sigc::mem_fun(*this, &View::save_gcode) );
  connect_button ("g_send_gcode",    sigc::mem_fun(*this, &View::send_gcode) );

  // Print tab
  connect_button ("p_kick",          sigc::mem_fun(*this, &View::kick_clicked) );
  m_builder->get_widget ("p_power", m_power_button);
  m_power_button->signal_toggled().connect    (sigc::mem_fun(*this, &View::power_toggled));
  m_builder->get_widget ("p_print", m_print_button);
  m_print_button->signal_clicked().connect    (sigc::mem_fun(*this, &View::print_clicked) );
  m_builder->get_widget ("p_pause", m_continue_button);
  m_continue_button->signal_clicked().connect (sigc::mem_fun(*this, &View::continue_clicked));

  // Interactive tab
  connect_button ("i_home_all",        sigc::mem_fun(*this, &View::home_all));
  connect_toggled ("Misc.FileLoggingEnabled", sigc::mem_fun(*this, &View::enable_logging_toggled));
  connect_button ("i_clear_logs",      sigc::mem_fun(*this, &View::clear_logs) );
  m_builder->get_widget ("i_reverse", m_extruder_reverse);
  m_builder->get_widget ("i_ex_speed", m_extruder_speed);
  m_extruder_speed->set_range(100.0, 10000.0);
  m_extruder_speed->set_increments (100, 500);
  m_extruder_speed->set_value (3000.0);
  m_builder->get_widget ("i_ex_length", m_extruder_length);
  m_extruder_length->set_range(0.0, 1000.0);
  m_extruder_length->set_increments (5, 20);
  m_extruder_length->set_value (150.0);
  // FIXME: connect i_update_interval (etc.)
  connect_toggled ("i_fan_enabled", sigc::mem_fun(*this, &View::fan_enabled_toggled));
  m_builder->get_widget ("i_fan_voltage", m_fan_voltage);
  m_fan_voltage->set_range(0.0, 25.0);
  m_fan_voltage->set_increments (1, 2);
  m_fan_voltage->set_value (5.0);

  connect_button ("i_extrude_length", sigc::mem_fun(*this, &View::run_extruder) );

  // 3D preview of the bed
  Gtk::Box *pBox = NULL;
  m_builder->get_widget("viewarea", pBox);
  if (!pBox)
    std::cerr << "missing box!";
  else {
    m_renderer = new Render (this, m_rfo_tree->get_selection());
    pBox->add (*m_renderer);
  }
  showAllWidgets();
}
示例#5
0
static void
setup_gui (ETableConfig *config)
{
	GladeXML *gui;
	gboolean can_group;
	gchar *filename;

	create_global_store (config);

	can_group = e_table_sort_info_get_can_group (config->state->sort_info);
	filename = g_build_filename (EVOLUTION_GLADEDIR,
					  "e-table-config.glade",
					  NULL);
	gui = glade_xml_new (filename, NULL, GETTEXT_PACKAGE);
	g_free (filename);

	g_object_unref (global_store);

	config->dialog_toplevel = glade_xml_get_widget (
		gui, "e-table-config");

	if (config->header)
		gtk_window_set_title (GTK_WINDOW (config->dialog_toplevel), config->header);

	config->dialog_show_fields = glade_xml_get_widget (
		gui, "dialog-show-fields");
	config->dialog_group_by =  glade_xml_get_widget (
		gui, "dialog-group-by");
	config->dialog_sort = glade_xml_get_widget (
		gui, "dialog-sort");

	config->sort_label = glade_xml_get_widget (
		gui, "label-sort");
	config->group_label = glade_xml_get_widget (
		gui, "label-group");
	config->fields_label = glade_xml_get_widget (
		gui, "label-fields");

	connect_button (config, gui, "button-sort", G_CALLBACK (config_button_sort));
	connect_button (config, gui, "button-group", G_CALLBACK (config_button_group));
	connect_button (config, gui, "button-fields", G_CALLBACK (config_button_fields));

	if (!can_group) {
		GtkWidget *w;

		w = glade_xml_get_widget (gui, "button-group");
		if (w)
			gtk_widget_hide (w);

		w = glade_xml_get_widget (gui, "label3");
		if (w)
			gtk_widget_hide (w);

		w = config->group_label;
		if (w)
			gtk_widget_hide (w);
	}

	configure_sort_dialog (config, gui);
	configure_group_dialog (config, gui);
	configure_fields_dialog (config, gui);

	g_object_weak_ref (G_OBJECT (config->dialog_toplevel),
			   dialog_destroyed, config);

	g_signal_connect (config->dialog_toplevel, "response",
			  G_CALLBACK (dialog_response), config);

	g_object_unref (gui);
}
示例#6
0
void
connection_dialog(gboolean auto_connect)
{
    gint i;
    connecting = NULL;
    wait_for_tuner = FALSE;

    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(dialog), "Connect");
    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(ui.window));
    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
    gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
    g_signal_connect(dialog, "destroy", G_CALLBACK(connection_dialog_destroy), NULL);

    content = gtk_vbox_new(FALSE, 3);
    gtk_container_add(GTK_CONTAINER(dialog), content);

    r_serial = gtk_radio_button_new_with_label(NULL, "Serial port");
    gtk_box_pack_start(GTK_BOX(content), r_serial, TRUE, TRUE, 2);
    c_serial = gtk_combo_box_text_new();
#ifdef G_OS_WIN32
    gchar tmp[10];
    for(i=1; i<=20; i++)
    {
        g_snprintf(tmp, sizeof(tmp), "COM%d", i);
        gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(c_serial), tmp);
        if(g_ascii_strcasecmp(tmp, conf.serial) == 0)
        {
            gtk_combo_box_set_active(GTK_COMBO_BOX(c_serial), i-1);
        }
    }
#else
    struct dirent *dir;
    DIR *d = opendir("/dev");
    i=0;
    if(d)
    {
        while((dir = readdir(d)))
        {
#ifdef __APPLE__
            if(!strncmp(dir->d_name, "cu.usbserial", 12))
#else
            if(!strncmp(dir->d_name, "ttyUSB", 6) || !strncmp(dir->d_name, "ttyACM", 6) || !strncmp(dir->d_name, "ttyS", 4) || !strncmp(dir->d_name, "rfcomm", 6))
#endif
            {
                gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(c_serial), dir->d_name);
                if(g_ascii_strcasecmp(dir->d_name, conf.serial) == 0)
                {
                    gtk_combo_box_set_active(GTK_COMBO_BOX(c_serial), i);
                }
                i++;
            }
        }
        closedir(d);
    }
#endif
    g_signal_connect(c_serial, "changed", G_CALLBACK(connection_dialog_select), r_serial);
    gtk_box_pack_start(GTK_BOX(content), c_serial, TRUE, TRUE, 0);

    r_tcp = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(r_serial), "TCP/IP");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(r_tcp), conf.network);
    gtk_box_pack_start(GTK_BOX(content), r_tcp, TRUE, TRUE, 2);
    box_tcp1 = gtk_hbox_new(FALSE, 5);
    gtk_container_add(GTK_CONTAINER(content), box_tcp1);
    l_host = gtk_label_new("Host:");
    gtk_box_pack_start(GTK_BOX(box_tcp1), l_host, TRUE, FALSE, 1);
    ls_host = gtk_list_store_new(1, G_TYPE_STRING);
    if(conf.host)
    {
        for(i=0; conf.host[i]; i++)
        {
            GtkTreeIter iter;
            gtk_list_store_append(ls_host, &iter);
            gtk_list_store_set(ls_host, &iter, 0, conf.host[i], -1);
        }
    }
    e_host = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(ls_host));
    gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(e_host), 0);
    gtk_combo_box_set_active(GTK_COMBO_BOX(e_host), 0);
    g_signal_connect(e_host, "changed", G_CALLBACK(connection_dialog_select), r_tcp);
    gtk_box_pack_start(GTK_BOX(box_tcp1), e_host, TRUE, FALSE, 1);
    l_port = gtk_label_new("Port:");
    gtk_box_pack_start(GTK_BOX(box_tcp1), l_port, TRUE, FALSE, 1);
    e_port = gtk_entry_new_with_max_length(5);
    gtk_entry_set_width_chars(GTK_ENTRY(e_port), 5);
    gchar *s_port = g_strdup_printf("%d", conf.port);
    gtk_entry_set_text(GTK_ENTRY(e_port), s_port);
    g_free(s_port);
    g_signal_connect(e_port, "changed", G_CALLBACK(connection_dialog_select), r_tcp);
    gtk_box_pack_start(GTK_BOX(box_tcp1), e_port, TRUE, FALSE, 1);

    box_tcp2 = gtk_hbox_new(FALSE, 5);
    gtk_container_add(GTK_CONTAINER(content), box_tcp2);
    l_password = gtk_label_new("Password:"******"changed", G_CALLBACK(connection_dialog_select), r_tcp);
    gtk_box_pack_start(GTK_BOX(box_tcp2), e_password, TRUE, TRUE, 1);
    c_password = gtk_check_button_new_with_label("Keep");
    if(conf.password && strlen(conf.password))
    {
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(c_password), TRUE);
    }
    g_signal_connect(c_password, "toggled", G_CALLBACK(connection_dialog_select), r_tcp);
    gtk_box_pack_start(GTK_BOX(box_tcp2), c_password, FALSE, FALSE, 1);

    box_status_wrapper = gtk_hbox_new(TRUE, 5);
    gtk_box_pack_start(GTK_BOX(content), box_status_wrapper, FALSE, FALSE, 1);

    box_status = gtk_hbox_new(FALSE, 5);
    gtk_box_pack_start(GTK_BOX(box_status_wrapper), box_status, FALSE, FALSE, 1);

    spinner = gtk_spinner_new();
    gtk_box_pack_start(GTK_BOX(box_status), spinner, FALSE, FALSE, 1);

    l_status = gtk_label_new(NULL);
    gtk_box_pack_start(GTK_BOX(box_status), l_status, FALSE, FALSE, 1);

    box_button = gtk_hbutton_box_new();
    gtk_button_box_set_layout(GTK_BUTTON_BOX(box_button), GTK_BUTTONBOX_END);
    gtk_box_set_spacing(GTK_BOX(box_button), 5);
    gtk_box_pack_start(GTK_BOX(content), box_button, FALSE, FALSE, 5);
    b_connect = gtk_button_new_from_stock(GTK_STOCK_OK);
    g_signal_connect(dialog, "key-press-event", G_CALLBACK(connection_dialog_key), b_connect);
    g_signal_connect(b_connect, "clicked", G_CALLBACK(connection_dialog_connect), NULL);
    gtk_container_add(GTK_CONTAINER(box_button), b_connect);
    b_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    g_signal_connect_swapped(b_cancel, "clicked", G_CALLBACK(gtk_widget_destroy), dialog);
    gtk_container_add(GTK_CONTAINER(box_button), b_cancel);

#ifdef G_OS_WIN32
    if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ui.b_ontop)))
    {
        gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
    }
#endif

    gtk_widget_show_all(dialog);
    gtk_widget_hide(spinner);
    gtk_widget_hide(l_status);
    connect_button(FALSE);
    if(auto_connect || (conf.auto_reconnect && successfully_connected))
    {
        gtk_button_clicked(GTK_BUTTON(b_connect));
    }
}