Sat, 18 Sep 2004 23:17:38 +0000
[gaim-migrate @ 10999]
" Post all three of these to the sf patch tracker as
three separate patches and assign the buddy list
changes and oscar changes to me, and the
gaim_status_is_online() changes to Luke. And in the
one assigned to Luke, ask him if he could pretty please
with sugar on top check through it quickly and
commit it if it looks sensible?
--KingAnt
This adds gaim_status_is_online so that we can check
statuses as well as presences for online status. It
also changes gaim_presence_is_online to use the new
function." --Dave West
committer: Luke Schierer <lschiere@pidgin.im>
| 8713 | 1 | /** |
| 2 | * gaim | |
| 3 | * | |
| 4 | * Gaim is the legal property of its developers, whose names are too numerous | |
| 5 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | */ | |
| 22 | #ifdef HAVE_CONFIG_H | |
| 23 | # include <config.h> | |
| 24 | #endif | |
| 25 | ||
| 26 | #include "debug.h" | |
| 27 | #include "internal.h" | |
| 28 | #include "pluginpref.h" | |
| 29 | #include "prefs.h" | |
| 30 | ||
| 31 | #include "gtkpluginpref.h" | |
| 32 | #include "gtkprefs.h" | |
| 33 | #include "gtkutils.h" | |
| 34 | ||
| 35 | static gboolean | |
| 36 | entry_cb(GtkWidget *entry, gpointer data) { | |
| 37 | char *pref = data; | |
| 38 | ||
| 39 | gaim_prefs_set_string(pref, gtk_entry_get_text(GTK_ENTRY(entry))); | |
| 40 | ||
| 41 | return FALSE; | |
| 42 | } | |
| 43 | ||
| 44 | static void | |
| 45 | make_string_pref(GtkWidget *parent, GaimPluginPref *pref, GtkSizeGroup *sg) { | |
| 46 | GtkWidget *hbox, *gtk_label, *entry; | |
| 47 | gchar *pref_name, *pref_label; | |
| 48 | ||
| 49 | pref_name = gaim_plugin_pref_get_name(pref); | |
| 50 | pref_label = gaim_plugin_pref_get_label(pref); | |
| 51 | ||
| 52 | switch(gaim_plugin_pref_get_type(pref)) { | |
| 53 | case GAIM_PLUGIN_PREF_CHOICE: | |
| 54 | gtk_label = gaim_gtk_prefs_dropdown_from_list(parent, pref_label, | |
| 55 | GAIM_PREF_STRING, pref_name, | |
| 56 | gaim_plugin_pref_get_choices(pref)); | |
| 57 | gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0.5); | |
| 58 | ||
| 59 | if(sg) | |
| 60 | gtk_size_group_add_widget(sg, gtk_label); | |
| 61 | ||
| 62 | break; | |
| 63 | case GAIM_PLUGIN_PREF_NONE: | |
| 64 | default: | |
| 65 | hbox = gtk_hbox_new(FALSE, 6); | |
| 66 | gtk_widget_show(hbox); | |
| 67 | gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 0); | |
| 68 | ||
| 69 | gtk_label = gtk_label_new_with_mnemonic(pref_label); | |
| 70 | gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0.5); | |
| 71 | gtk_widget_show(gtk_label); | |
| 72 | gtk_box_pack_start(GTK_BOX(hbox), gtk_label, FALSE, FALSE, 0); | |
| 73 | ||
| 74 | if(sg) | |
| 75 | gtk_size_group_add_widget(sg, gtk_label); | |
| 76 | ||
| 77 | entry = gtk_entry_new(); | |
| 78 | gtk_entry_set_text(GTK_ENTRY(entry), gaim_prefs_get_string(pref_name)); | |
| 79 | gtk_entry_set_max_length(GTK_ENTRY(entry), | |
| 80 | gaim_plugin_pref_get_max_length(pref)); | |
| 9841 | 81 | gtk_entry_set_visibility(GTK_ENTRY(entry), |
| 82 | !gaim_plugin_pref_get_masked(pref)); | |
| 8713 | 83 | g_signal_connect(G_OBJECT(entry), "changed", |
| 84 | G_CALLBACK(entry_cb), | |
| 85 | (gpointer)pref_name); | |
| 86 | gtk_label_set_mnemonic_widget(GTK_LABEL(gtk_label), entry); | |
| 87 | gtk_widget_show(entry); | |
| 88 | gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
| 89 | ||
| 90 | break; | |
| 91 | } | |
| 92 | } | |
| 93 | ||
| 94 | static void | |
| 95 | make_int_pref(GtkWidget *parent, GaimPluginPref *pref, GtkSizeGroup *sg) { | |
| 96 | GtkWidget *gtk_label; | |
| 97 | gchar *pref_name, *pref_label; | |
| 98 | gint max, min; | |
| 99 | ||
| 100 | pref_name = gaim_plugin_pref_get_name(pref); | |
| 101 | pref_label = gaim_plugin_pref_get_label(pref); | |
| 102 | ||
| 103 | switch(gaim_plugin_pref_get_type(pref)) { | |
| 104 | case GAIM_PLUGIN_PREF_CHOICE: | |
| 105 | gtk_label = gaim_gtk_prefs_dropdown_from_list(parent, pref_label, | |
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
106 | GAIM_PREF_INT, pref_name, gaim_plugin_pref_get_choices(pref)); |
| 8713 | 107 | gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0.5); |
| 108 | ||
| 109 | if(sg) | |
| 110 | gtk_size_group_add_widget(sg, gtk_label); | |
| 111 | ||
| 112 | break; | |
| 113 | case GAIM_PLUGIN_PREF_NONE: | |
| 114 | default: | |
| 115 | gaim_plugin_pref_get_bounds(pref, &min, &max); | |
| 116 | gaim_gtk_prefs_labeled_spin_button(parent, pref_label, | |
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
117 | pref_name, min, max, sg); |
| 8713 | 118 | break; |
| 119 | } | |
| 120 | } | |
| 121 | ||
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
122 | |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
123 | static void |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
124 | make_info_pref(GtkWidget *parent, GaimPluginPref *pref) { |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
125 | GtkWidget *gtk_label = gtk_label_new(gaim_plugin_pref_get_label(pref)); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
126 | gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
127 | gtk_label_set_line_wrap(GTK_LABEL(gtk_label), TRUE); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
128 | gtk_box_pack_start(GTK_BOX(parent), gtk_label, FALSE, FALSE, 0); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
129 | gtk_widget_show(gtk_label); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
130 | } |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
131 | |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
132 | |
| 8713 | 133 | GtkWidget * |
| 134 | gaim_gtk_plugin_pref_create_frame(GaimPluginPrefFrame *frame) { | |
| 135 | GaimPluginPref *pref; | |
| 136 | GtkWidget *ret, *parent; | |
| 137 | GtkSizeGroup *sg; | |
| 138 | GList *pp; | |
| 139 | gchar *name, *label; | |
| 140 | ||
| 141 | g_return_val_if_fail(frame, NULL); | |
| 142 | ||
| 143 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 144 | ||
| 145 | parent = ret = gtk_vbox_new(FALSE, 16); | |
| 146 | gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
| 147 | gtk_widget_show(ret); | |
| 148 | ||
| 149 | for(pp = gaim_plugin_pref_frame_get_prefs(frame); | |
| 150 | pp != NULL; | |
| 151 | pp = pp->next) | |
| 152 | { | |
| 153 | pref = (GaimPluginPref *)pp->data; | |
| 154 | ||
| 155 | name = gaim_plugin_pref_get_name(pref); | |
| 156 | label = gaim_plugin_pref_get_label(pref); | |
| 157 | ||
| 158 | if(name == NULL) { | |
| 159 | if(label == NULL) | |
| 160 | continue; | |
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
161 | |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
162 | if(gaim_plugin_pref_get_type(pref) == GAIM_PLUGIN_PREF_INFO) { |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
163 | make_info_pref(parent, pref); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
164 | } else { |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
165 | parent = gaim_gtk_make_frame(ret, label); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
166 | gtk_widget_show(parent); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
167 | } |
| 8713 | 168 | |
| 169 | continue; | |
| 170 | } | |
| 171 | ||
| 172 | switch(gaim_prefs_get_type(name)) { | |
| 173 | case GAIM_PREF_BOOLEAN: | |
| 174 | gaim_gtk_prefs_checkbox(label, name, parent); | |
| 175 | break; | |
| 176 | case GAIM_PREF_INT: | |
| 177 | make_int_pref(parent, pref, sg); | |
| 178 | break; | |
| 179 | case GAIM_PREF_STRING: | |
| 180 | make_string_pref(parent, pref, sg); | |
| 181 | break; | |
| 182 | default: | |
| 183 | break; | |
| 184 | } | |
| 185 | } | |
| 186 | ||
| 187 | return ret; | |
| 188 | } |