Mercurial > pidgin
comparison src/gtkprefs.c @ 8170:9d1a984681fe
[gaim-migrate @ 8883]
Gary Kramlich is probably getting sick of the prefs system, but at least
he made a nice interface for protocol prefs. Thanks Gary!
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 25 Jan 2004 22:15:42 +0000 |
parents | 3273ff25b645 |
children | cd9ea20cd8ed |
comparison
equal
deleted
inserted
replaced
8169:a64774143a42 | 8170:9d1a984681fe |
---|---|
30 #include "prefs.h" | 30 #include "prefs.h" |
31 #include "proxy.h" | 31 #include "proxy.h" |
32 #include "prpl.h" | 32 #include "prpl.h" |
33 #include "sound.h" | 33 #include "sound.h" |
34 #include "util.h" | 34 #include "util.h" |
35 #include "multi.h" | |
35 | 36 |
36 #include "gtkblist.h" | 37 #include "gtkblist.h" |
37 #include "gtkconv.h" | 38 #include "gtkconv.h" |
38 #include "gtkdebug.h" | 39 #include "gtkdebug.h" |
39 #include "gtkimhtml.h" | 40 #include "gtkimhtml.h" |
1543 gtk_widget_show_all(ret); | 1544 gtk_widget_show_all(ret); |
1544 | 1545 |
1545 return ret; | 1546 return ret; |
1546 } | 1547 } |
1547 | 1548 |
1549 static GtkWidget * | |
1550 protocol_page() { | |
1551 GtkWidget *ret; | |
1552 | |
1553 ret = gtk_label_new(NULL); | |
1554 gtk_widget_show(ret); | |
1555 | |
1556 return ret; | |
1557 } | |
1558 | |
1559 static gboolean | |
1560 protocol_pref_entry_cb(GtkWidget *entry, GdkEventFocus *event, gpointer data) { | |
1561 char *pref = data; | |
1562 | |
1563 gaim_prefs_set_string(pref, gtk_entry_get_text(GTK_ENTRY(entry))); | |
1564 | |
1565 return FALSE; | |
1566 } | |
1567 | |
1568 static GtkWidget * | |
1569 protocol_pref_page(GaimPluginProtocolInfo *prpl_info) { | |
1570 GtkWidget *ret, *parent, *frame, *hbox, *label, *misc; | |
1571 GtkSizeGroup *sg; | |
1572 GList *pp = NULL; | |
1573 | |
1574 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
1575 | |
1576 ret = gtk_vbox_new(FALSE, 18); | |
1577 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | |
1578 gtk_widget_show(ret); | |
1579 | |
1580 parent = ret; | |
1581 | |
1582 for(pp = prpl_info->protocol_prefs; pp != NULL; pp = pp->next) { | |
1583 struct proto_pref *pref = pp->data; | |
1584 | |
1585 if(pref->key != NULL) { | |
1586 switch(gaim_prefs_get_type(pref->key)) { | |
1587 case GAIM_PREF_BOOLEAN: | |
1588 misc = gaim_gtk_prefs_checkbox(pref->label, | |
1589 pref->key, | |
1590 parent); | |
1591 break; | |
1592 case GAIM_PREF_INT: | |
1593 misc = gaim_gtk_prefs_labeled_spin_button(parent, | |
1594 pref->label, | |
1595 pref->key, | |
1596 pref->min, | |
1597 pref->max, | |
1598 sg); | |
1599 break; | |
1600 case GAIM_PREF_STRING: | |
1601 hbox = gtk_hbox_new(FALSE, 6); | |
1602 gtk_widget_show(hbox); | |
1603 gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 0); | |
1604 | |
1605 label = gtk_label_new_with_mnemonic(pref->label); | |
1606 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
1607 gtk_size_group_add_widget(sg, label); | |
1608 gtk_widget_show(label); | |
1609 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
1610 | |
1611 misc = gtk_entry_new(); | |
1612 gtk_entry_set_text(GTK_ENTRY(misc), | |
1613 gaim_prefs_get_string(pref->key)); | |
1614 g_signal_connect(G_OBJECT(misc), "focus-out-event", | |
1615 G_CALLBACK(protocol_pref_entry_cb), | |
1616 (gpointer)pref->key); | |
1617 gtk_label_set_mnemonic_widget(GTK_LABEL(label), misc); | |
1618 gtk_widget_show(misc); | |
1619 gtk_box_pack_start(GTK_BOX(hbox), misc, FALSE, FALSE, 0); | |
1620 | |
1621 break; | |
1622 case GAIM_PREF_NONE: /* XXX No use for this, if you want a | |
1623 frame, set key to NULL */ | |
1624 case GAIM_PREF_STRING_LIST: /*XXX No one should need this */ | |
1625 default: | |
1626 break; | |
1627 } | |
1628 } else { | |
1629 frame = gaim_gtk_make_frame(ret, pref->label); | |
1630 gtk_widget_show(frame); | |
1631 | |
1632 parent = frame; | |
1633 } | |
1634 } | |
1635 | |
1636 return ret; | |
1637 } | |
1638 | |
1548 static GtkWidget *plugin_description=NULL, *plugin_details=NULL; | 1639 static GtkWidget *plugin_description=NULL, *plugin_details=NULL; |
1549 | 1640 |
1550 static void prefs_plugin_sel (GtkTreeSelection *sel, GtkTreeModel *model) | 1641 static void prefs_plugin_sel (GtkTreeSelection *sel, GtkTreeModel *model) |
1551 { | 1642 { |
1552 gchar *buf, *pname, *perr, *pdesc, *pauth, *pweb; | 1643 gchar *buf, *pname, *perr, *pdesc, *pauth, *pweb; |
2289 prefs_notebook_add_page(_("Sounds"), NULL, sound_page(), &p, NULL, notebook_page++); | 2380 prefs_notebook_add_page(_("Sounds"), NULL, sound_page(), &p, NULL, notebook_page++); |
2290 prefs_notebook_add_page(_("Sound Events"), NULL, sound_events_page(), &c, &p, notebook_page++); | 2381 prefs_notebook_add_page(_("Sound Events"), NULL, sound_events_page(), &c, &p, notebook_page++); |
2291 prefs_notebook_add_page(_("Away / Idle"), NULL, away_page(), &p, NULL, notebook_page++); | 2382 prefs_notebook_add_page(_("Away / Idle"), NULL, away_page(), &p, NULL, notebook_page++); |
2292 prefs_notebook_add_page(_("Away Messages"), NULL, away_message_page(), &c, &p, notebook_page++); | 2383 prefs_notebook_add_page(_("Away Messages"), NULL, away_message_page(), &c, &p, notebook_page++); |
2293 | 2384 |
2385 prefs_notebook_add_page(_("Protocols"), NULL, protocol_page(), &p, NULL, notebook_page++); | |
2386 for (l = gaim_plugins_get_protocols(); l != NULL; l = l->next) { | |
2387 plug = l->data; | |
2388 | |
2389 if (GAIM_IS_PROTOCOL_PLUGIN(plug)) { | |
2390 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plug); | |
2391 | |
2392 if (prpl_info->protocol_prefs != NULL) { | |
2393 prefs_notebook_add_page(_(plug->info->name), NULL, | |
2394 protocol_pref_page(prpl_info), &c, | |
2395 &p, notebook_page++); | |
2396 } | |
2397 } | |
2398 } | |
2399 | |
2294 if (gaim_plugins_enabled()) { | 2400 if (gaim_plugins_enabled()) { |
2295 prefs_notebook_add_page(_("Plugins"), NULL, plugin_page(), &plugin_iter, NULL, notebook_page++); | 2401 prefs_notebook_add_page(_("Plugins"), NULL, plugin_page(), &plugin_iter, NULL, notebook_page++); |
2296 | 2402 |
2297 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { | 2403 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { |
2298 plug = l->data; | 2404 plug = l->data; |