blob: 0ca1a3d0a84d61abd3253890c77b8b57d3762faa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/**
* @file uri_entry.c GTK+ URI entry combo box
*
* Copyright (C) 2015 Charles E. Lehner
*/
#include <re.h>
#include <baresip.h>
#include <gtk/gtk.h>
#include "gtk_mod.h"
/**
* Create a URI combox box.
*
* The combo box has a menu of contacts, and a text entry for a URI.
*
* @return the combo box
*/
GtkWidget *uri_combo_box_new(void)
{
struct contacts *contacts = baresip_contacts();
struct le *le;
GtkEntry *uri_entry;
GtkWidget *uri_combobox;
uri_combobox = gtk_combo_box_text_new_with_entry();
uri_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(uri_combobox)));
gtk_entry_set_activates_default(uri_entry, TRUE);
for (le = list_head(contact_list(contacts)); le; le = le->next) {
struct contact *c = le->data;
gtk_combo_box_text_append_text(
GTK_COMBO_BOX_TEXT(uri_combobox),
contact_str(c));
}
return uri_combobox;
}
const char *uri_combo_box_get_text(GtkComboBox *box)
{
GtkEntry *entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(box)));
GtkEntryBuffer *buf = gtk_entry_get_buffer(entry);
return gtk_entry_buffer_get_text(buf);
}
|