Всем добра! Пишу тут одну прогу с использованием GTK+.
пишу на Vala (но т.к. использую GTK+ 3.0, а он везде одинаков), виджеты помещаю в Grid
using Gtk;
public class Test : Gtk.Window
{
public Test ()
{
this.title = "Test application";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
this.set_default_size (50, 50);
Gtk.Grid grid = new Gtk.Grid();
var display = this.get_display();
var clipboard = Clipboard.get_for_display(display, Gdk.SELECTION_CLIPBOARD);
Gtk.Entry reference_entry = new Gtk.Entry();
reference_entry.set_alignment((float)0.5);
reference_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
reference_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(reference_entry.text, -1);
}
});
Gtk.Label reference_label = new Gtk.Label.with_mnemonic("Опорная частота");
grid.attach(reference_label, 0, 0, 1, 1);
grid.attach(reference_entry, 1, 0, 3, 1);
Gtk.Entry frequency_entry = new Gtk.Entry();
frequency_entry.set_alignment((float)0.5);
frequency_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
frequency_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(frequency_entry.text, -1);
}
});
Gtk.Label frequency_label = new Gtk.Label.with_mnemonic("Синтезируемая частота");
grid.attach(frequency_label, 0, 1, 1, 1);
grid.attach(frequency_entry, 1, 1, 3, 1);
Gtk.Entry dds_code_h_entry = new Gtk.Entry();
dds_code_h_entry.set_alignment((float)0.5);
dds_code_h_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
dds_code_h_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(dds_code_h_entry.text, -1);
}
});
Gtk.Entry dds_code_m_entry = new Gtk.Entry();
dds_code_m_entry.set_alignment((float)0.5);
dds_code_m_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
dds_code_m_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(dds_code_m_entry.text, -1);
}
});
Gtk.Entry dds_code_l_entry = new Gtk.Entry();
dds_code_l_entry.set_alignment((float)0.5);
dds_code_l_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
dds_code_l_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(dds_code_l_entry.text, -1);
}
});
Gtk.Label dds_code_label = new Gtk.Label.with_mnemonic("Коды DDS");
grid.attach(dds_code_label , 0, 2, 1, 1);
grid.attach(dds_code_h_entry, 1, 2, 1, 1);
grid.attach(dds_code_m_entry, 2, 2, 1, 1);
grid.attach(dds_code_l_entry, 3, 2, 1, 1);
Gtk.Entry deviation_entry = new Gtk.Entry();
deviation_entry.set_alignment((float)0.5);
deviation_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
deviation_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(deviation_entry.text, -1);
}
});
Gtk.Label deviation_label = new Gtk.Label.with_mnemonic("Девиация");
Gtk.RadioButton deviation_radiobutton = new Gtk.RadioButton.with_label_from_widget(null, "");
grid.attach(deviation_label, 0, 3, 1, 1);
grid.attach(deviation_entry, 1, 3, 2, 1);
grid.attach(deviation_radiobutton, 3, 3, 1, 1);
Gtk.Entry steepness_entry = new Gtk.Entry();
steepness_entry.set_alignment((float)0.5);
steepness_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
steepness_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(steepness_entry.text, -1);
}
});
Gtk.Label steepness_label = new Gtk.Label.with_mnemonic("Крутизна");
Gtk.RadioButton steepness_radiobutton = new Gtk.RadioButton.with_label_from_widget(null, "");
grid.attach(steepness_label, 0, 4, 1, 1);
grid.attach(steepness_entry, 1, 4, 2, 1);
grid.attach(steepness_radiobutton, 3, 4, 1, 1);
Gtk.Entry duration_entry = new Gtk.Entry();
duration_entry.set_alignment((float)0.5);
duration_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
duration_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(duration_entry.text, -1);
}
});
Gtk.Label duration_label = new Gtk.Label.with_mnemonic("Длительность");
Gtk.RadioButton duration_radiobutton = new Gtk.RadioButton.with_label_from_widget(null, "");
grid.attach(duration_label, 0, 5, 1, 1);
grid.attach(duration_entry, 1, 5, 2, 1);
grid.attach(duration_radiobutton, 3, 5, 1, 1);
Gtk.Entry duration_lfm_h_entry = new Gtk.Entry();
duration_lfm_h_entry.set_alignment((float)0.5);
duration_lfm_h_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
duration_lfm_h_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(duration_lfm_h_entry.text, -1);
}
});
Gtk.Entry duration_lfm_m_entry = new Gtk.Entry();
duration_lfm_m_entry.set_alignment((float)0.5);
duration_lfm_m_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
duration_lfm_m_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(duration_lfm_m_entry.text, -1);
}
});
Gtk.Entry duration_lfm_l_entry = new Gtk.Entry();
duration_lfm_l_entry.set_alignment((float)0.5);
duration_lfm_l_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
duration_lfm_l_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(duration_lfm_l_entry.text, -1);
}
});
Gtk.Label duration_lfm_label = new Gtk.Label.with_mnemonic("Длительность ЛЧМ");
grid.attach(duration_lfm_label, 0, 6, 1, 1);
grid.attach(duration_lfm_h_entry, 1, 6, 1, 1);
grid.attach(duration_lfm_m_entry, 2, 6, 1, 1);
grid.attach(duration_lfm_l_entry, 3, 6, 1, 1);
Gtk.Entry increment_freq_h_entry = new Gtk.Entry();
increment_freq_h_entry.set_alignment((float)0.5);
increment_freq_h_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
increment_freq_h_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(increment_freq_h_entry.text, -1);
}
});
Gtk.Entry increment_freq_m_entry = new Gtk.Entry();
increment_freq_m_entry.set_alignment((float)0.5);
increment_freq_m_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
increment_freq_m_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(increment_freq_m_entry.text, -1);
}
});
Gtk.Entry increment_freq_l_entry = new Gtk.Entry();
increment_freq_l_entry.set_alignment((float)0.5);
increment_freq_l_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "gtk-copy");
increment_freq_l_entry.icon_press.connect ((pos, event) =>
{
if (pos == Gtk.EntryIconPosition.SECONDARY)
{
clipboard.set_text(increment_freq_l_entry.text, -1);
}
});
Gtk.Label increment_freq_label = new Gtk.Label.with_mnemonic("Приращение частоты");
grid.attach(increment_freq_label, 0, 7, 1, 1);
grid.attach(increment_freq_h_entry, 1, 7, 1, 1);
grid.attach(increment_freq_m_entry, 2, 7, 1, 1);
grid.attach(increment_freq_l_entry, 3, 7, 1, 1);
Gtk.Label label_status = new Gtk.Label.with_mnemonic("пока что нечего не работает");
grid.attach(label_status, 0, 8, 4, 1);
this.add (grid);
}
public static int main (string[] args)
{
Gtk.init (ref args);
Test app = new Test();
app.show_all ();
Gtk.main ();
return 0;
}
}