The settings window for the profiles plug-in is almost functional
This commit is contained in:
parent
cade56fad6
commit
dbbb9d4ff6
@ -299,49 +299,81 @@ static gboolean _event_call_incoming_timeout(gpointer data)
|
|||||||
|
|
||||||
|
|
||||||
/* profiles_settings */
|
/* profiles_settings */
|
||||||
static gboolean _on_profiles_closex(gpointer data);
|
static gboolean _on_settings_closex(gpointer data);
|
||||||
|
static void _on_settings_cancel(gpointer data);
|
||||||
|
static void _on_settings_ok(gpointer data);
|
||||||
|
|
||||||
static void _profiles_settings(PhonePlugin * plugin)
|
static void _profiles_settings(PhonePlugin * plugin)
|
||||||
{
|
{
|
||||||
Profiles * profiles = plugin->priv;
|
Profiles * profiles = plugin->priv;
|
||||||
GtkWidget * vbox;
|
GtkWidget * vbox;
|
||||||
|
GtkWidget * bbox;
|
||||||
|
GtkWidget * widget;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, plugin->name);
|
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, plugin->name);
|
||||||
#endif
|
#endif
|
||||||
if(profiles->window == NULL)
|
if(profiles->window != NULL)
|
||||||
{
|
{
|
||||||
|
gtk_window_present(GTK_WINDOW(profiles->window));
|
||||||
|
return;
|
||||||
|
}
|
||||||
profiles->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
profiles->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(profiles->window),
|
gtk_container_set_border_width(GTK_CONTAINER(profiles->window), 4);
|
||||||
4);
|
gtk_window_set_default_size(GTK_WINDOW(profiles->window), 200, 300);
|
||||||
gtk_window_set_default_size(GTK_WINDOW(profiles->window), 200,
|
|
||||||
300);
|
|
||||||
gtk_window_set_title(GTK_WINDOW(profiles->window), "Profiles");
|
gtk_window_set_title(GTK_WINDOW(profiles->window), "Profiles");
|
||||||
g_signal_connect_swapped(G_OBJECT(profiles->window),
|
g_signal_connect_swapped(G_OBJECT(profiles->window), "delete-event",
|
||||||
"delete-event", G_CALLBACK(_on_profiles_closex),
|
G_CALLBACK(_on_settings_closex), profiles);
|
||||||
profiles);
|
|
||||||
vbox = gtk_vbox_new(FALSE, 0);
|
vbox = gtk_vbox_new(FALSE, 0);
|
||||||
/* entry */
|
/* entry */
|
||||||
profiles->combo = gtk_combo_box_new_text();
|
profiles->combo = gtk_combo_box_new_text();
|
||||||
for(i = 0; i < profiles->profiles_cnt; i++)
|
for(i = 0; i < profiles->profiles_cnt; i++)
|
||||||
gtk_combo_box_append_text(GTK_COMBO_BOX(
|
gtk_combo_box_append_text(GTK_COMBO_BOX(profiles->combo),
|
||||||
profiles->combo),
|
|
||||||
profiles->profiles[i].name);
|
profiles->profiles[i].name);
|
||||||
gtk_combo_box_set_active(GTK_COMBO_BOX(profiles->combo),
|
gtk_box_pack_start(GTK_BOX(vbox), profiles->combo, FALSE, TRUE, 0);
|
||||||
profiles->profiles_cur);
|
bbox = gtk_hbutton_box_new();
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), profiles->combo, FALSE, TRUE,
|
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
|
||||||
0);
|
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 4);
|
||||||
|
widget = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
|
||||||
|
g_signal_connect_swapped(G_OBJECT(widget), "clicked", G_CALLBACK(
|
||||||
|
_on_settings_cancel), plugin);
|
||||||
|
gtk_container_add(GTK_CONTAINER(bbox), widget);
|
||||||
|
widget = gtk_button_new_from_stock(GTK_STOCK_OK);
|
||||||
|
g_signal_connect_swapped(G_OBJECT(widget), "clicked", G_CALLBACK(
|
||||||
|
_on_settings_ok), plugin);
|
||||||
|
gtk_container_add(GTK_CONTAINER(bbox), widget);
|
||||||
|
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
|
||||||
gtk_container_add(GTK_CONTAINER(profiles->window), vbox);
|
gtk_container_add(GTK_CONTAINER(profiles->window), vbox);
|
||||||
gtk_widget_show_all(vbox);
|
gtk_widget_show_all(vbox);
|
||||||
}
|
_on_settings_cancel(plugin);
|
||||||
gtk_window_present(GTK_WINDOW(profiles->window));
|
gtk_window_present(GTK_WINDOW(profiles->window));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean _on_profiles_closex(gpointer data)
|
static gboolean _on_settings_closex(gpointer data)
|
||||||
{
|
{
|
||||||
Profiles * profiles = data;
|
Profiles * profiles = data;
|
||||||
|
|
||||||
gtk_widget_hide(profiles->window);
|
_on_settings_cancel(profiles);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _on_settings_cancel(gpointer data)
|
||||||
|
{
|
||||||
|
PhonePlugin * plugin = data;
|
||||||
|
Profiles * profiles = plugin->priv;
|
||||||
|
|
||||||
|
gtk_widget_hide(profiles->window);
|
||||||
|
gtk_combo_box_set_active(GTK_COMBO_BOX(profiles->combo),
|
||||||
|
profiles->profiles_cur);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _on_settings_ok(gpointer data)
|
||||||
|
{
|
||||||
|
PhonePlugin * plugin = data;
|
||||||
|
Profiles * profiles = plugin->priv;
|
||||||
|
|
||||||
|
gtk_widget_hide(profiles->window);
|
||||||
|
profiles->profiles_cur = gtk_combo_box_get_active(GTK_COMBO_BOX(
|
||||||
|
profiles->combo));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user