本文整理汇总了C++中GTK_COMBO_BOX_TEXT函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_COMBO_BOX_TEXT函数的具体用法?C++ GTK_COMBO_BOX_TEXT怎么用?C++ GTK_COMBO_BOX_TEXT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GTK_COMBO_BOX_TEXT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: entry_print_result
void
entry_print_result (void)
{
if (options.entry_data.numeric)
{
guint prec = gtk_spin_button_get_digits (GTK_SPIN_BUTTON (entry));
g_print ("%.*f\n", prec, gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)));
}
else if (is_combo)
{
if (options.common_data.num_output)
g_print ("%d\n", gtk_combo_box_get_active (GTK_COMBO_BOX (entry)) + 1);
else
{
#if GTK_CHECK_VERSION(2,24,0)
g_print ("%s\n", gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)));
#else
g_print ("%s\n", gtk_combo_box_get_active_text (GTK_COMBO_BOX (entry)));
#endif
}
}
else
g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry)));
}
示例2: gnc_period_select_new
/* Create a new GncPeriodSelect widget which is used to select a
* accounting period like "previous month" or "this year".
*
* @param starting_labels If set to TRUE then all the labels will
* refer to the "Start of...". If FALSE, labels will refer to "End
* of...".
*
* @return A GncPeriodSelect widget.
*/
GtkWidget *
gnc_period_select_new (gboolean starting_labels)
{
GncPeriodSelectPrivate *priv;
GncPeriodSelect *period;
const gchar *label;
gint i;
period = g_object_new(GNC_TYPE_PERIOD_SELECT, NULL);
/* Set up private data structures */
priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
priv->selector = gtk_combo_box_text_new();
priv->start = starting_labels;
/* Add the internal widgets to the hbox */
gtk_box_pack_start(GTK_BOX(period), priv->selector, TRUE, TRUE, 0);
gtk_widget_show(priv->selector);
/* Find out when the combo box changes */
g_signal_connect(G_OBJECT(priv->selector), "changed",
G_CALLBACK(gnc_period_sample_combobox_changed), period);
/* Build all the labels except the fiscal year labels */
for (i = 0; i < GNC_ACCOUNTING_PERIOD_CYEAR_LAST; i++)
{
label = starting_labels ? _(start_strings[i]) : _(end_strings[i]);
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(priv->selector), label);
}
/* Track changes to date formatting */
gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_FORMAT,
gnc_period_sample_new_date_format, period);
return GTK_WIDGET (period);
}
示例3: matedialog_entry_dialog_response
static void
matedialog_entry_dialog_response (GtkWidget *widget, int response, gpointer data)
{
MateDialogData *zen_data = data;
const gchar *text;
switch (response) {
case GTK_RESPONSE_OK:
zen_data->exit_code = matedialog_util_return_exit_code (MATEDIALOG_OK);
if (n_entries > 1) {
#if GTK_CHECK_VERSION(2,24,0)
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry));
#else
text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (entry));
#endif
}
else {
text = gtk_entry_get_text (GTK_ENTRY (entry));
}
if (text != NULL)
g_print ("%s\n", text);
break;
case GTK_RESPONSE_CANCEL:
zen_data->exit_code = matedialog_util_return_exit_code (MATEDIALOG_CANCEL);
break;
default:
/* Esc dialog */
zen_data->exit_code = matedialog_util_return_exit_code (MATEDIALOG_ESC);
break;
}
gtk_main_quit ();
}
示例4: main
int main( int argc, char * argv[] ) {
GtkWidget * window;
GtkWidget * fixed;
GtkWidget * combo;
GtkWidget * label;
gtk_init( &argc, &argv );
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_title( GTK_WINDOW(window), "GtkCombo" );
gtk_window_set_position( GTK_WINDOW(window), GTK_WIN_POS_CENTER );
gtk_window_set_default_size( GTK_WINDOW(window), 230, 150 );
fixed = gtk_fixed_new();
combo = gtk_combo_box_text_new();
gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(combo), "Ubuntu" );
gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(combo), "Mandriva" );
gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(combo), "Fedora" );
gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(combo), "Mint" );
gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(combo), "Gentoo" );
gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(combo), "Debian" );
gtk_fixed_put( GTK_FIXED(fixed), combo, 50, 50 );
gtk_container_add( GTK_CONTAINER(window), fixed );
label = gtk_label_new( "-" );
gtk_fixed_put( GTK_FIXED(fixed), label, 50, 110 );
g_signal_connect_swapped( G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), G_OBJECT(window) );
g_signal_connect( G_OBJECT(combo), "changed",
G_CALLBACK(combo_selected), (gpointer) label );
gtk_widget_show_all( window );
gtk_main();
return 0;
}
示例5: connect_wifi_page
static void
connect_wifi_page (CEPageWifi *page)
{
NMSettingConnection *sc;
GtkWidget *widget;
const GByteArray *ssid;
gchar *utf8_ssid;
GPtrArray *bssid_array;
gchar **bssid_list;
const GByteArray *s_bssid;
gchar *s_bssid_str;
gchar **mac_list;
const GByteArray *s_mac;
gchar *s_mac_str;
gint i;
widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
"entry_ssid"));
ssid = nm_setting_wireless_get_ssid (page->setting);
if (ssid)
utf8_ssid = nm_utils_ssid_to_utf8 (ssid);
else
utf8_ssid = g_strdup ("");
gtk_entry_set_text (GTK_ENTRY (widget), utf8_ssid);
g_free (utf8_ssid);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
"combo_bssid"));
bssid_array = g_ptr_array_new ();
for (i = 0; i < nm_setting_wireless_get_num_seen_bssids (page->setting); i++) {
g_ptr_array_add (bssid_array, g_strdup (nm_setting_wireless_get_seen_bssid (page->setting, i)));
}
g_ptr_array_add (bssid_array, NULL);
bssid_list = (gchar **) g_ptr_array_free (bssid_array, FALSE);
s_bssid = nm_setting_wireless_get_bssid (page->setting);
s_bssid_str = s_bssid ? nm_utils_hwaddr_ntoa (s_bssid->data, ARPHRD_ETHER) : NULL;
ce_page_setup_mac_combo (GTK_COMBO_BOX_TEXT (widget), s_bssid_str, bssid_list);
g_free (s_bssid_str);
g_strfreev (bssid_list);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
"combo_mac"));
mac_list = ce_page_get_mac_list (CE_PAGE (page)->client, NM_TYPE_DEVICE_WIFI,
NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS);
s_mac = nm_setting_wireless_get_mac_address (page->setting);
s_mac_str = s_mac ? nm_utils_hwaddr_ntoa (s_mac->data, ARPHRD_ETHER) : NULL;
ce_page_setup_mac_combo (GTK_COMBO_BOX_TEXT (widget), s_mac_str, mac_list);
g_free (s_mac_str);
g_strfreev (mac_list);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
"entry_cloned_mac"));
ce_page_mac_to_entry (nm_setting_wireless_get_cloned_mac_address (page->setting),
ARPHRD_ETHER, GTK_ENTRY (widget));
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
"auto_connect_check"));
sc = nm_connection_get_setting_connection (CE_PAGE (page)->connection);
g_object_bind_property (sc, "autoconnect",
widget, "active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ce_page_changed), page);
widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
"all_user_check"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
nm_setting_connection_get_num_permissions (sc) == 0);
g_signal_connect (widget, "toggled",
G_CALLBACK (all_user_changed), page);
g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ce_page_changed), page);
widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "combo_zone"));
firewall_ui_setup (sc, widget, CE_PAGE (page)->cancellable);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
}
示例6: configure_response_cb
static void configure_response_cb(GtkDialog *dialog, gint response, gpointer user_data)
{
if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
{
GKeyFile *config = g_key_file_new();
gchar *data;
gchar *config_dir = g_path_get_dirname(sc_info->config_file);
GtkComboBox *combo = GTK_COMBO_BOX(g_object_get_data(G_OBJECT(dialog), "combo"));
setptr(sc_info->default_language, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo)));
#ifdef HAVE_ENCHANT_1_5
setptr(sc_info->dictionary_dir, g_strdup(gtk_entry_get_text(GTK_ENTRY(
g_object_get_data(G_OBJECT(dialog), "dict_dir")))));
#endif
sc_speller_reinit_enchant_dict();
sc_info->check_while_typing = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
g_object_get_data(G_OBJECT(dialog), "check_type"))));
sc_info->use_msgwin = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
g_object_get_data(G_OBJECT(dialog), "check_msgwin"))));
sc_info->show_toolbar_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
g_object_get_data(G_OBJECT(dialog), "check_toolbar"))));
sc_info->show_editor_menu_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
g_object_get_data(G_OBJECT(dialog), "check_editor_menu"))));
g_key_file_load_from_file(config, sc_info->config_file, G_KEY_FILE_NONE, NULL);
if (sc_info->default_language != NULL) /* lang may be NULL */
g_key_file_set_string(config, "spellcheck", "language", sc_info->default_language);
g_key_file_set_boolean(config, "spellcheck", "check_while_typing",
sc_info->check_while_typing);
g_key_file_set_boolean(config, "spellcheck", "use_msgwin",
sc_info->use_msgwin);
g_key_file_set_boolean(config, "spellcheck", "show_toolbar_item",
sc_info->show_toolbar_item);
g_key_file_set_boolean(config, "spellcheck", "show_editor_menu_item",
sc_info->show_editor_menu_item);
if (sc_info->dictionary_dir != NULL)
g_key_file_set_string(config, "spellcheck", "dictionary_dir",
sc_info->dictionary_dir);
sc_gui_update_toolbar();
sc_gui_update_menu();
populate_dict_combo(combo);
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("Plugin configuration directory could not be created."));
}
else
{
/* write config to file */
data = g_key_file_to_data(config, NULL, NULL);
utils_write_file(sc_info->config_file, data);
g_free(data);
}
g_free(config_dir);
g_key_file_free(config);
}
}
示例7: gui_attach_gtk3_v4l2ctrls
//.........这里部分代码省略.........
if(!current->menu)
current->menu = calloc(4+1, sizeof(struct v4l2_querymenu));
else
current->menu = realloc(current->menu, (4+1) * sizeof(struct v4l2_querymenu));
if(current->menu == NULL)
{
fprintf(stderr,"GUVCVIEW: FATAL memory allocation failure (gui_attach_gtk3_v4l2ctrls): %s\n", strerror(errno));
exit(-1);
}
current->menu[0].id = current->control.id;
current->menu[0].index = 0;
current->menu[0].name[0] = 'N'; /*just set something here*/
current->menu[1].id = current->control.id;
current->menu[1].index = 1;
current->menu[1].name[0] = 'O';
current->menu[2].id = current->control.id;
current->menu[2].index = 2;
current->menu[2].name[0] = 'B';
current->menu[3].id = current->control.id;
current->menu[3].index = 3;
current->menu[3].name[0] = 'A';
current->menu[4].id = current->control.id;
current->menu[4].index = current->control.maximum+1;
current->menu[4].name[0] = '\0';
int j = 0;
int def = 0;
control_widgets_list[n].widget = gtk_combo_box_text_new ();
for (j = 0; current->menu[j].index <= current->control.maximum; j++)
{
gtk_combo_box_text_append_text (
GTK_COMBO_BOX_TEXT (control_widgets_list[n].widget),
(char *) LEDMenu[j]);
if(current->value == current->menu[j].index)
def = j;
}
gtk_combo_box_set_active (GTK_COMBO_BOX(control_widgets_list[n].widget), def);
gtk_widget_show (control_widgets_list[n].widget);
g_object_set_data (G_OBJECT (control_widgets_list[n].widget), "control_info",
GINT_TO_POINTER(current->control.id));
/*connect signal*/
g_signal_connect (GTK_COMBO_BOX_TEXT(control_widgets_list[n].widget), "changed",
G_CALLBACK (combo_changed), NULL);
break;
}
case V4L2_CID_RAW_BITS_PER_PIXEL_LOGITECH:
{
/*turn it into a menu control*/
char* BITSMenu[2] = {_("8 bit"),_("12 bit")};
/*turn it into a menu control*/
if(!current->menu)
current->menu = calloc(2+1, sizeof(struct v4l2_querymenu));
else
current->menu = realloc(current->menu, (2+1) * sizeof(struct v4l2_querymenu));
if(current->menu == NULL)
{
fprintf(stderr,"GUVCVIEW: FATAL memory allocation failure (gui_attach_gtk3_v4l2ctrls): %s\n", strerror(errno));
exit(-1);
}
示例8: gtk_box_new
//.........这里部分代码省略.........
gtk_box_pack_start (GTK_BOX (vbox4), table1, FALSE, TRUE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table1), 4);
style_om = gtk_combo_box_text_new();
gtk_widget_show (style_om);
gtk_table_attach (GTK_TABLE (table1), style_om, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
m_wListStyleNone_menu = gtk_list_store_new(2, G_TYPE_STRING,
G_TYPE_INT);
_fillNoneStyleMenu(m_wListStyleNone_menu.obj());
m_wListStyleNumbered_menu = gtk_list_store_new (2, G_TYPE_STRING,
G_TYPE_INT);
_fillNumberedStyleMenu(m_wListStyleNumbered_menu.obj());
m_wListStyleBulleted_menu = gtk_list_store_new(2, G_TYPE_STRING,
G_TYPE_INT);
_fillBulletedStyleMenu(m_wListStyleBulleted_menu.obj());
// This is the default list. Change if the list style changes
//
m_wListStyle_menu = m_wListStyleNumbered_menu;
gtk_combo_box_set_model(GTK_COMBO_BOX (style_om),
GTK_TREE_MODEL(m_wListStyleNumbered_menu.obj()));
type_om = gtk_combo_box_text_new();
gtk_widget_show (type_om);
gtk_table_attach (GTK_TABLE (table1), type_om, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Type_none,s);
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_om), s.utf8_str());
pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Type_bullet,s);
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_om), s.utf8_str());
pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Type_numbered,s);
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_om), s.utf8_str());
gtk_combo_box_set_active(GTK_COMBO_BOX(type_om), 0);
pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Type,s);
type_lb = gtk_label_new (s.utf8_str());
gtk_widget_show (type_lb);
gtk_table_attach (GTK_TABLE (table1), type_lb, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (type_lb), 0, 0.5);
pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Style,s);
style_lb = gtk_label_new (s.utf8_str());
gtk_widget_show (style_lb);
gtk_table_attach (GTK_TABLE (table1), style_lb, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (style_lb), 0, 0.5);
pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_SetDefault,s);
customized_cb = gtk_dialog_add_button (GTK_DIALOG(m_wMainWindow), s.utf8_str(), BUTTON_RESET);
gtk_widget_show (customized_cb);
/* todo
gtk_table_attach (GTK_TABLE (table1), customized_cb, 0, 2, 2, 3,
(GtkAttachOptions) (GTK_SHRINK),
(GtkAttachOptions) (0), 0, 0);
*/
frame1 = gtk_frame_new (NULL);
示例9: WhatCheck
/**
Sprawdzenie słowa, na którym aktualnie znajduje się kursor. Ewentualne dodanie do słownika.
@param[in] item element menu.
@param[in] data wskaźnik na wartość.
*/
static void WhatCheck (GtkMenuItem *item, gpointer data) {
GtkWidget *dialog;
GtkTextIter start, end;
char *word;
gunichar *wword;
//load_dictionary_from_menu(&dict);
// Znajdujemy pozycję kursora
gtk_text_buffer_get_iter_at_mark(editor_buf, &start,
gtk_text_buffer_get_insert(editor_buf));
// Jeśli nie wewnątrz słowa, kończymy
if (!gtk_text_iter_inside_word(&start)) {
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
"Kursor musi być w środku słowa");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
return;
}
// Znajdujemy początek i koniec słowa, a potem samo słowo
end = start;
gtk_text_iter_backward_word_start(&start);
gtk_text_iter_forward_word_end(&end);
word = gtk_text_iter_get_text(&start, &end);
// Zamieniamy na wide char (no prawie)
wword = g_utf8_to_ucs4_fast(word, -1, NULL);
if (!make_lowercase(wword)) {
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
"Podane słowo nie jest słowem słownikowym.");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
else {
// Sprawdzamy
if (dictionary_find(dict, (wchar_t *)wword)) {
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
"Wszystko w porządku,\nśpij spokojnie");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
else {
// Czas korekty
GtkWidget *vbox, *label, *combo;
struct word_list hints;
int i;
wchar_t **words;
dictionary_hints(dict, (wchar_t *)wword, &hints);
words = (wchar_t **) word_list_get(&hints);
dialog = gtk_dialog_new_with_buttons("Korekta", NULL, 0,
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
GTK_STOCK_ADD,
GTK_RESPONSE_APPLY,
GTK_STOCK_CANCEL,
GTK_RESPONSE_REJECT,
NULL);
// W treści dialogu dwa elementy
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
// Tekst
label = gtk_label_new("Słowo nie znajduje się w słowniku. Wybierz \njedną z propozycji lub dodaj słowa do słownika.");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 1);
// Spuszczane menu
combo = gtk_combo_box_text_new();
for (i = 0; i < word_list_size(&hints); i++) {
// Combo box lubi mieć Gtk
char *uword = g_ucs4_to_utf8((gunichar *)words[i], -1, NULL, NULL, NULL);
// Dodajemy kolejny element
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), uword);
g_free(uword);
}
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 1);
gtk_widget_show(combo);
gint click = gtk_dialog_run(GTK_DIALOG(dialog));
if (click == GTK_RESPONSE_ACCEPT) {
char *korekta =
gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo));
// Usuwamy stare
gtk_text_buffer_delete(editor_buf, &start, &end);
// Wstawiamy nowe
gtk_text_buffer_insert(editor_buf, &start, korekta, -1);
g_free(korekta);
}
//.........这里部分代码省略.........
示例10: check_v4l2_udev_events
/* check for udev events for v4l2 devices*/
gboolean
check_v4l2_udev_events(gpointer data)
{
struct ALL_DATA * all_data = (struct ALL_DATA *) data;
struct vdIn *videoIn = all_data->videoIn;
struct GLOBAL *global = all_data->global;
struct GWIDGET *gwidget = all_data->gwidget;
fd_set fds;
struct timeval tv;
int ret;
FD_ZERO(&fds);
FD_SET(videoIn->udev_fd, &fds);
tv.tv_sec = 0;
tv.tv_usec = 0;
ret = select(videoIn->udev_fd+1, &fds, NULL, NULL, &tv);
/* Check if our file descriptor has received data. */
if (ret > 0 && FD_ISSET(videoIn->udev_fd, &fds))
{
/* Make the call to receive the device.
select() ensured that this will not block. */
struct udev_device *dev = udev_monitor_receive_device(videoIn->udev_mon);
if (dev)
{
if (global->debug)
{
g_print("Got Device event\n");
g_print(" Node: %s\n", udev_device_get_devnode(dev));
g_print(" Subsystem: %s\n", udev_device_get_subsystem(dev));
g_print(" Devtype: %s\n", udev_device_get_devtype(dev));
g_print(" Action: %s\n",udev_device_get_action(dev));
}
/*update device list*/
g_signal_handlers_block_by_func(GTK_COMBO_BOX_TEXT(gwidget->Devices),
G_CALLBACK (Devices_changed), all_data);
/* clear out the old device list... */
if(videoIn->listDevices != NULL) freeDevices(videoIn->listDevices);
GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model (GTK_COMBO_BOX(gwidget->Devices)));
gtk_list_store_clear(store);
/*create new device list*/
videoIn->listDevices = enum_devices( videoIn->videodevice, videoIn->udev, global->debug );
if (videoIn->listDevices->num_devices < 1)
{
//use current
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->Devices),
videoIn->videodevice);
gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->Devices),0);
}
else
{
int i=0;
for(i=0;i<(videoIn->listDevices->num_devices);i++)
{
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->Devices),
videoIn->listDevices->listVidDevices[i].name);
if(videoIn->listDevices->listVidDevices[i].current)
gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->Devices),i);
}
}
g_signal_handlers_unblock_by_func(GTK_COMBO_BOX_TEXT(gwidget->Devices),
G_CALLBACK (Devices_changed), all_data);
udev_device_unref(dev);
}
else
g_printerr("No Device from receive_device(). An error occured.\n");
}
return(TRUE);
}
示例11: main
int
main (int argc, char *argv[])
{
GtkWidget *win;
GtkWidget *box;
GtkWidget *button;
GtkWidget *button2;
GtkBuilder *builder;
GMenuModel *model;
GSimpleActionGroup *actions;
GtkWidget *overlay;
GtkWidget *grid;
GtkWidget *popover;
GtkWidget *popover2;
GtkWidget *label;
GtkWidget *check;
GtkWidget *combo;
gtk_init (&argc, &argv);
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (win), 400, 600);
actions = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), NULL);
gtk_widget_insert_action_group (win, "top", G_ACTION_GROUP (actions));
overlay = gtk_overlay_new ();
gtk_container_add (GTK_CONTAINER (win), overlay);
grid = gtk_grid_new ();
gtk_widget_set_halign (grid, GTK_ALIGN_FILL);
gtk_widget_set_valign (grid, GTK_ALIGN_FILL);
gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
gtk_container_add (GTK_CONTAINER (overlay), grid);
label = gtk_label_new ("");
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
label = gtk_label_new ("");
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (grid), label, 3, 6, 1, 1);
builder = gtk_builder_new_from_file ("popover.ui");
model = (GMenuModel *)gtk_builder_get_object (builder, "menu");
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
button = gtk_menu_button_new ();
gtk_container_add (GTK_CONTAINER (box), button);
button2 = gtk_menu_button_new ();
gtk_container_add (GTK_CONTAINER (box), button2);
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), model);
gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (button), TRUE);
popover = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button)));
builder = gtk_builder_new_from_file ("popover2.ui");
popover2 = (GtkWidget *)gtk_builder_get_object (builder, "popover");
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button2), popover2);
g_object_set (box, "margin", 10, NULL);
gtk_widget_set_halign (box, GTK_ALIGN_END);
gtk_widget_set_valign (box, GTK_ALIGN_START);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), box);
label = gtk_label_new ("Popover hexpand");
check = gtk_check_button_new ();
g_object_bind_property (check, "active", popover, "hexpand", G_BINDING_DEFAULT);
g_object_bind_property (check, "active", popover2, "hexpand", G_BINDING_DEFAULT);
gtk_grid_attach (GTK_GRID (grid), label , 1, 1, 1, 1);
gtk_grid_attach (GTK_GRID (grid), check, 2, 1, 1, 1);
label = gtk_label_new ("Popover vexpand");
check = gtk_check_button_new ();
g_object_bind_property (check, "active", popover, "vexpand", G_BINDING_DEFAULT);
g_object_bind_property (check, "active", popover2, "vexpand", G_BINDING_DEFAULT);
gtk_grid_attach (GTK_GRID (grid), label , 1, 2, 1, 1);
gtk_grid_attach (GTK_GRID (grid), check, 2, 2, 1, 1);
label = gtk_label_new ("Button direction");
combo = gtk_combo_box_text_new ();
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "up", "Up");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "down", "Down");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right");
g_object_bind_property (combo, "active", button, "direction", G_BINDING_DEFAULT);
g_object_bind_property (combo, "active", button2, "direction", G_BINDING_DEFAULT);
gtk_grid_attach (GTK_GRID (grid), label , 1, 3, 1, 1);
gtk_grid_attach (GTK_GRID (grid), combo, 2, 3, 1, 1);
label = gtk_label_new ("Button halign");
combo = gtk_combo_box_text_new ();
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End");
//.........这里部分代码省略.........
示例12: _lib_geotagging_gpx_callback
static void _lib_geotagging_gpx_callback(GtkWidget *widget, dt_lib_module_t *self)
{
dt_lib_geotagging_t *d = (dt_lib_geotagging_t *)self->data;
/* bring a filechooser to select the gpx file to apply to selection */
GtkWidget *win = dt_ui_main_window(darktable.gui->ui);
GtkWidget *filechooser = gtk_file_chooser_dialog_new(
_("open GPX file"), GTK_WINDOW(win), GTK_FILE_CHOOSER_ACTION_OPEN, _("_cancel"), GTK_RESPONSE_CANCEL,
_("_open"), GTK_RESPONSE_ACCEPT, (char *)NULL);
char *last_directory = dt_conf_get_string("ui_last/gpx_last_directory");
if(last_directory != NULL)
{
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filechooser), last_directory);
g_free(last_directory);
}
GtkFileFilter *filter;
filter = GTK_FILE_FILTER(gtk_file_filter_new());
gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME | GTK_FILE_FILTER_MIME_TYPE,
_lib_geotagging_filter_gpx, NULL, NULL);
gtk_file_filter_set_name(filter, _("GPS data exchange format"));
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filechooser), filter);
filter = GTK_FILE_FILTER(gtk_file_filter_new());
gtk_file_filter_add_pattern(filter, "*");
gtk_file_filter_set_name(filter, _("all files"));
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filechooser), filter);
// add time zone selection
GtkWidget *extra_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
GtkWidget *label = gtk_label_new(_("camera time zone"));
gtk_widget_set_tooltip_text(label, _("most cameras don't store the time zone in EXIF. "
"give the correct time zone so the GPX data can be correctly matched"));
GtkWidget *tz_selection = gtk_combo_box_text_new();
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(tz_selection), "UTC");
gtk_combo_box_set_active(GTK_COMBO_BOX(tz_selection), 0);
GList *iter = d->timezones;
int i = 0;
gchar *old_tz = dt_conf_get_string("plugins/lighttable/geotagging/tz");
if(iter)
{
do
{
i++;
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(tz_selection), (gchar *)iter->data);
if(!strcmp((gchar *)iter->data, old_tz)) gtk_combo_box_set_active(GTK_COMBO_BOX(tz_selection), i);
} while((iter = g_list_next(iter)) != NULL);
}
g_free(old_tz);
gtk_box_pack_start(GTK_BOX(extra_box), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(extra_box), tz_selection, FALSE, FALSE, 0);
gtk_widget_show_all(extra_box);
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(filechooser), extra_box);
if(gtk_dialog_run(GTK_DIALOG(filechooser)) == GTK_RESPONSE_ACCEPT)
{
gchar *folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(filechooser));
dt_conf_set_string("ui_last/gpx_last_directory", folder);
g_free(folder);
gchar *tz = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(tz_selection));
dt_conf_set_string("plugins/lighttable/geotagging/tz", tz);
gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser));
dt_control_gpx_apply(filename, -1, tz);
g_free(filename);
g_free(tz);
}
gtk_widget_destroy(extra_box);
gtk_widget_destroy(filechooser);
// dt_control_queue_redraw_center();
}
示例13: create_integrated_ui_toolbar
/**
* Create the toolbar for the integrated UI
* @return Main toolbar (GtkToolbar*) for the integrated UI main window
*/
static GtkWidget *
create_integrated_ui_toolbar (void)
{
GtkToolbar *toolbar;
GtkToolItem *sep;
GtkWidget *w;
GError *error = NULL;
gchar *uifile;
uifile = build_ui_filename ("ui/toolbar-ui.xml");
if (!gtk_ui_manager_add_ui_from_file (_ui_manager, uifile, &error)) {
g_warning ("building menus failed: %s", error->message);
g_error_free (error);
error = NULL;
toolbar = GTK_TOOLBAR (gtk_toolbar_new ());
}
else {
toolbar = GTK_TOOLBAR(gtk_ui_manager_get_widget (_ui_manager, "/Toolbar"));
}
g_free (uifile);
/* Zoom Combo Box Entry */
w = gtk_combo_box_text_new_with_entry ();
g_object_set_data (G_OBJECT (toolbar),
DIA_INTEGRATED_TOOLBAR_ZOOM_COMBO,
w);
integrated_ui_toolbar_add_custom_item (toolbar, w);
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), ZOOM_FIT);
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("800%"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("400%"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("300%"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("200%"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("150%"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("100%"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("75%"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("50%"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("25%"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), _("10%"));
g_signal_connect (G_OBJECT (w),
"changed",
G_CALLBACK (integrated_ui_toolbar_zoom_combo_selection_changed),
NULL);
/* Get the combo's GtkEntry child to set the width for the widget */
w = gtk_bin_get_child (GTK_BIN (w));
gtk_entry_set_width_chars (GTK_ENTRY (w), 6);
g_signal_connect (G_OBJECT (w), "activate",
G_CALLBACK(integrated_ui_toolbar_zoom_activate),
NULL);
/* Seperator */
sep = gtk_separator_tool_item_new ();
gtk_toolbar_insert (toolbar, sep, -1);
gtk_widget_show (GTK_WIDGET (sep));
/* Snap to grid */
w = dia_toggle_button_new_with_icon_names ("dia-grid-on",
"dia-grid-off");
g_signal_connect (G_OBJECT (w), "toggled",
G_CALLBACK (integrated_ui_toolbar_grid_snap_toggle), toolbar);
gtk_widget_set_tooltip_text (w, _("Toggles snap-to-grid."));
g_object_set_data (G_OBJECT (toolbar),
DIA_INTEGRATED_TOOLBAR_SNAP_GRID,
w);
integrated_ui_toolbar_add_custom_item (toolbar, w);
/* Object Snapping */
w = dia_toggle_button_new_with_icon_names ("dia-mainpoints-on",
"dia-mainpoints-off");
g_signal_connect (G_OBJECT (w), "toggled",
G_CALLBACK (integrated_ui_toolbar_object_snap_toggle), toolbar);
gtk_widget_set_tooltip_text (w, _("Toggles object snapping."));
g_object_set_data (G_OBJECT (toolbar),
DIA_INTEGRATED_TOOLBAR_OBJECT_SNAP,
w);
integrated_ui_toolbar_add_custom_item (toolbar, w);
sep = gtk_separator_tool_item_new ();
gtk_toolbar_insert (toolbar, sep, -1);
gtk_widget_show (GTK_WIDGET (sep));
return GTK_WIDGET (toolbar);
}
示例14: gtk_window_present
{
gtk_window_present(GTK_WINDOW(man_addr_resolv_dlg));
}
static void
man_addr_resolv_ok(GtkWidget *w _U_, gpointer data _U_)
{
GtkWidget *addr_cb, *name_te, *resolv_cb;
const gchar *name;
gchar *addr;
gboolean active, redissect = FALSE;
addr_cb = (GtkWidget *)g_object_get_data(G_OBJECT(man_addr_resolv_dlg), "address");
name_te = (GtkWidget *)g_object_get_data(G_OBJECT(man_addr_resolv_dlg), "name");
addr = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(addr_cb));
name = gtk_entry_get_text(GTK_ENTRY(name_te));
if (strlen(addr) && strlen(name)) {
if (!add_ip_name_from_string(addr, name)) {
GtkWidget *dialog = (GtkWidget *)simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Illegal IP address: \"%s\".", addr);
simple_dialog_set_cb(dialog, man_addr_ill_addr_cb, NULL);
g_free(addr);
return;
} else {
redissect = TRUE;
}
}
g_free(addr);
示例15: gtk_grid_new
static GtkWidget *create_editor_widgets(radio_conf_t * conf)
{
GtkWidget *table;
GtkWidget *label;
table = gtk_grid_new();
gtk_container_set_border_width(GTK_CONTAINER(table), 5);
gtk_grid_set_column_homogeneous(GTK_GRID(table), FALSE);
gtk_grid_set_row_homogeneous(GTK_GRID(table), FALSE);
gtk_grid_set_column_spacing(GTK_GRID(table), 5);
gtk_grid_set_row_spacing(GTK_GRID(table), 5);
/* Config name */
label = gtk_label_new(_("Name"));
g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
name = gtk_entry_new();
gtk_entry_set_max_length(GTK_ENTRY(name), 25);
g_signal_connect(name, "changed", G_CALLBACK(name_changed), NULL);
gtk_widget_set_tooltip_text(name,
_("Enter a short name for this configuration, "
"e.g. IC910-1.\n"
"Allowed characters: "
"0..9, a..z, A..Z, - and _"));
gtk_grid_attach(GTK_GRID(table), name, 1, 0, 3, 1);
/* Host */
label = gtk_label_new(_("Host"));
g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
host = gtk_entry_new();
gtk_entry_set_max_length(GTK_ENTRY(host), 50);
gtk_entry_set_text(GTK_ENTRY(host), "localhost");
gtk_widget_set_tooltip_text(host,
_("Enter the host where rigctld is running. "
"You can use both host name and IP address, "
"e.g. 192.168.1.100\n\n"
"If gpredict and rigctld are running on the "
"same computer use localhost"));
gtk_grid_attach(GTK_GRID(table), host, 1, 1, 3, 1);
/* port */
label = gtk_label_new(_("Port"));
g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
gtk_grid_attach(GTK_GRID(table), label, 0, 2, 1, 1);
port = gtk_spin_button_new_with_range(1024, 65535, 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(port), 4532);
gtk_spin_button_set_digits(GTK_SPIN_BUTTON(port), 0);
gtk_widget_set_tooltip_text(port,
_("Enter the port number where rigctld is "
"listening"));
gtk_grid_attach(GTK_GRID(table), port, 1, 2, 1, 1);
/* radio type */
label = gtk_label_new(_("Radio type"));
g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
//gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
gtk_grid_attach(GTK_GRID(table), label, 0, 3, 1, 1);
type = gtk_combo_box_text_new();
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type), _("RX only"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type), _("TX only"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type), _("Simplex TRX"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type), _("Duplex TRX"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type),
_("FT817/857/897 (auto)"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type),
_("FT817/857/897 (manual)"));
gtk_combo_box_set_active(GTK_COMBO_BOX(type), RIG_TYPE_RX);
g_signal_connect(type, "changed", G_CALLBACK(type_changed), NULL);
gtk_widget_set_tooltip_markup(type,
_("<b>RX only:</b> The radio shall only be "
"used as receiver. If <i>Monitor PTT "
"status</i> is checked the doppler tuning "
"will be suspended while PTT is ON "
"(manual TX). If not, the controller will "
"always perform doppler tuning and "
"you cannot use the same RIG for uplink.\n\n"
"<b>TX only:</b> The radio shall only be "
"used for uplink. If <i>Monitor PTT status</i>"
" is checked the doppler tuning will be "
"suspended while PTT is OFF (manual RX).\n\n"
"<b>Simplex TRX:</b> The radio should be "
"used for both up- and downlink but in "
"simplex mode only. This option requires "
"that the PTT status is monitored (otherwise "
"gpredict cannot know whether to tune the "
"RX or the TX).\n\n"
"<b>Duplex:</b> The radio is a full duplex "
"radio, such as the IC910H. Gpredict will "
"be continuously tuning both uplink and "
"downlink simultaneously and not care about "
"PTT setting.\n\n"
"<b>FT817/857/897 (auto):</b> "
"This is a special mode that can be used with "
"YAESU FT-817, 857 and 897 radios. These radios"
" do not allow computer control while in TX mode."
//.........这里部分代码省略.........