aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fs/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/fs/namespace.c')
-rw-r--r--src/plugins/fs/namespace.c142
1 files changed, 142 insertions, 0 deletions
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index 3cbdd65d..f812488e 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -1208,6 +1208,148 @@ void on_trackingCheckButton_toggled_fs(GtkWidget * dummy1,
1208 YES : NO); 1208 YES : NO);
1209} 1209}
1210 1210
1211/**
1212 * The spin button giving the rating for a particular namespace
1213 * has been changed. Store the new rating for the namespace.
1214 */
1215void on_namespaceRatingSpinButton_changed_fs(GtkWidget * dummy,
1216 GtkWidget * dummy2) {
1217 GtkWidget * spin;
1218 GtkWidget * ncbe;
1219 GtkTreeModel * model;
1220 GtkTreeIter iter;
1221 char * encStr;
1222 char * description;
1223 int rating;
1224 int newrating;
1225
1226 DEBUG_BEGIN();
1227 spin
1228 = glade_xml_get_widget(getMainXML(),
1229 "namespaceRatingSpinButton");
1230 ncbe
1231 = glade_xml_get_widget(getMainXML(),
1232 "searchNamespaceComboBoxEntry");
1233 model = gtk_combo_box_get_model(GTK_COMBO_BOX(ncbe));
1234 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(ncbe),
1235 &iter)) {
1236 gtk_tree_model_get(model,
1237 &iter,
1238 NS_SEARCH_DESCRIPTION, &description,
1239 NS_SEARCH_ENCNAME, &encStr,
1240 NS_SEARCH_RATING, &rating,
1241 -1);
1242 if ( (description != NULL) &&
1243 (0 == strcmp(description,
1244 _("globally"))) ) {
1245 /* just to be sure */
1246 gtk_widget_set_sensitive(spin,
1247 FALSE);
1248 } else {
1249 if (encStr != NULL) {
1250 newrating = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
1251 rating = NS_rankNamespace(ectx,
1252 cfg,
1253 encStr,
1254 newrating - rating);
1255 if (rating != newrating) {
1256 /* concurrent modification? */
1257 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1258 rating);
1259 GE_BREAK(ectx, 0);
1260 }
1261 gtk_list_store_set(GTK_LIST_STORE(model),
1262 &iter,
1263 NS_SEARCH_RATING, rating,
1264 -1);
1265 }
1266 }
1267 } else {
1268 /* FIXME: if enc2hash succeeds, we may want to keep this
1269 active */
1270 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1271 0);
1272 gtk_widget_set_sensitive(spin,
1273 FALSE);
1274 }
1275 DEBUG_END();
1276}
1277
1278
1279/**
1280 * The namespace in the search window has changed.
1281 * Update the trust level (possibly changing sensitivity)
1282 * and set the search string to the root (if available).
1283 */
1284void on_searchNamespaceComboBoxEntry_changed_fs(GtkWidget * dummy,
1285 GtkWidget * dummy2) {
1286 GtkWidget * keyword;
1287 GtkWidget * spin;
1288 GtkWidget * ncbe;
1289 GtkTreeModel * model;
1290 GtkTreeIter iter;
1291 int rating;
1292 char * encStr;
1293 char * descStr;
1294 HashCode512 ns;
1295 HashCode512 root;
1296 EncName enc;
1297
1298 DEBUG_BEGIN();
1299 spin
1300 = glade_xml_get_widget(getMainXML(),
1301 "namespaceRatingSpinButton");
1302 ncbe
1303 = glade_xml_get_widget(getMainXML(),
1304 "searchNamespaceComboBoxEntry");
1305 model = gtk_combo_box_get_model(GTK_COMBO_BOX(ncbe));
1306 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(ncbe),
1307 &iter)) {
1308 encStr = NULL;
1309 descStr = NULL;
1310 gtk_tree_model_get(model,
1311 &iter,
1312 NS_SEARCH_DESCRIPTION, &descStr,
1313 NS_SEARCH_ENCNAME, &encStr,
1314 NS_SEARCH_RATING, &rating,
1315 -1);
1316 if ( (descStr != NULL) &&
1317 (0 == strcmp(descStr,
1318 _("globally"))) ) {
1319 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1320 0);
1321 gtk_widget_set_sensitive(spin,
1322 FALSE);
1323 } else if (encStr != NULL) {
1324 enc2hash(encStr,
1325 &ns);
1326 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1327 rating);
1328 gtk_widget_set_sensitive(spin,
1329 TRUE);
1330 if (OK == NS_getNamespaceRoot(ectx,
1331 cfg,
1332 encStr,
1333 &root)) {
1334 hash2enc(&root,
1335 &enc);
1336 keyword
1337 = glade_xml_get_widget(getMainXML(),
1338 "fssearchKeywordComboBoxEntry");
1339 gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(keyword))),
1340 (const gchar*) &enc);
1341 }
1342 }
1343 } else {
1344 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1345 0);
1346 gtk_widget_set_sensitive(spin,
1347 FALSE);
1348 }
1349 DEBUG_END();
1350}
1351
1352
1211 1353
1212void fs_namespace_start(struct GE_Context * e, 1354void fs_namespace_start(struct GE_Context * e,
1213 struct GC_Configuration * c) { 1355 struct GC_Configuration * c) {