comparison src/bar_keywords.c @ 1469:607c60506863

added a possibility to update existing bars from config
author nadvornik
date Fri, 20 Mar 2009 21:28:31 +0000
parents 400ecfc3d8b1
children 65a5c27823c2
comparison
equal deleted inserted replaced
1468:e9f9d3da3f43 1469:607c60506863
246 246
247 pkd = g_object_get_data(G_OBJECT(pane), "pane_data"); 247 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
248 if (!pkd) return; 248 if (!pkd) return;
249 249
250 WRITE_NL(); WRITE_STRING("<pane_keywords "); 250 WRITE_NL(); WRITE_STRING("<pane_keywords ");
251 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(pkd->pane.title))); 251 write_char_option(outstr, indent, "id", pkd->pane.id);
252 WRITE_BOOL(*pkd, pane.expanded); 252 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pkd->pane.title)));
253 WRITE_BOOL(pkd->pane, expanded);
253 WRITE_CHAR(*pkd, key); 254 WRITE_CHAR(*pkd, key);
254 WRITE_STRING("/>"); 255 WRITE_STRING("/>");
255 } 256 }
256 257
257 gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event) 258 gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event)
1179 { 1180 {
1180 PaneKeywordsData *pkd; 1181 PaneKeywordsData *pkd;
1181 1182
1182 pkd = g_object_get_data(G_OBJECT(bar), "pane_data"); 1183 pkd = g_object_get_data(G_OBJECT(bar), "pane_data");
1183 if (!pkd) return; 1184 if (!pkd) return;
1184 1185
1186 g_free(pkd->pane.id);
1185 gtk_widget_destroy(pkd->widget); 1187 gtk_widget_destroy(pkd->widget);
1186 } 1188 }
1187 1189
1188 static void bar_pane_keywords_destroy(GtkWidget *widget, gpointer data) 1190 static void bar_pane_keywords_destroy(GtkWidget *widget, gpointer data)
1189 { 1191 {
1198 1200
1199 g_free(pkd); 1201 g_free(pkd);
1200 } 1202 }
1201 1203
1202 1204
1203 GtkWidget *bar_pane_keywords_new(const gchar *title, const gchar *key, gboolean expanded) 1205 GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded)
1204 { 1206 {
1205 PaneKeywordsData *pkd; 1207 PaneKeywordsData *pkd;
1206 GtkWidget *hbox; 1208 GtkWidget *hbox;
1207 GtkWidget *scrolled; 1209 GtkWidget *scrolled;
1208 GtkTextBuffer *buffer; 1210 GtkTextBuffer *buffer;
1214 1216
1215 pkd->pane.pane_set_fd = bar_pane_keywords_set_fd; 1217 pkd->pane.pane_set_fd = bar_pane_keywords_set_fd;
1216 pkd->pane.pane_event = bar_pane_keywords_event; 1218 pkd->pane.pane_event = bar_pane_keywords_event;
1217 pkd->pane.pane_write_config = bar_pane_keywords_write_config; 1219 pkd->pane.pane_write_config = bar_pane_keywords_write_config;
1218 pkd->pane.title = bar_pane_expander_title(title); 1220 pkd->pane.title = bar_pane_expander_title(title);
1221 pkd->pane.id = g_strdup(id);
1222 pkd->pane.type = PANE_KEYWORDS;
1219 1223
1220 pkd->pane.expanded = expanded; 1224 pkd->pane.expanded = expanded;
1221 1225
1222 pkd->key = g_strdup(key); 1226 pkd->key = g_strdup(key);
1223 1227
1343 return pkd->widget; 1347 return pkd->widget;
1344 } 1348 }
1345 1349
1346 GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values) 1350 GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
1347 { 1351 {
1348 gchar *title = g_strdup(_("NoName")); 1352 gchar *id = g_strdup("keywords");
1353 gchar *title = g_strdup(_("Keywords"));
1349 gchar *key = g_strdup(COMMENT_KEY); 1354 gchar *key = g_strdup(COMMENT_KEY);
1350 gboolean expanded = TRUE; 1355 gboolean expanded = TRUE;
1356 GtkWidget *ret;
1351 1357
1352 while (*attribute_names) 1358 while (*attribute_names)
1353 { 1359 {
1354 const gchar *option = *attribute_names++; 1360 const gchar *option = *attribute_names++;
1355 const gchar *value = *attribute_values++; 1361 const gchar *value = *attribute_values++;
1356 1362
1357 if (READ_CHAR_FULL("pane.title", title)) continue; 1363 if (READ_CHAR_FULL("id", id)) continue;
1364 if (READ_CHAR_FULL("title", title)) continue;
1358 if (READ_CHAR_FULL("key", key)) continue; 1365 if (READ_CHAR_FULL("key", key)) continue;
1359 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; 1366 if (READ_BOOL_FULL("expanded", expanded)) continue;
1360 1367
1361 1368
1362 log_printf("unknown attribute %s = %s\n", option, value); 1369 log_printf("unknown attribute %s = %s\n", option, value);
1363 } 1370 }
1364 1371
1365 return bar_pane_keywords_new(title, key, expanded); 1372 ret = bar_pane_keywords_new(id, title, key, expanded);
1366 } 1373 g_free(id);
1374 g_free(title);
1375 g_free(key);
1376 return ret;
1377 }
1378
1379 void bar_pane_keywords_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
1380 {
1381 PaneKeywordsData *pkd;
1382
1383 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
1384 if (!pkd) return;
1385
1386 gchar *title = NULL;
1387
1388 while (*attribute_names)
1389 {
1390 const gchar *option = *attribute_names++;
1391 const gchar *value = *attribute_values++;
1392
1393 if (READ_CHAR_FULL("title", title)) continue;
1394 if (READ_CHAR_FULL("key", pkd->key)) continue;
1395 if (READ_BOOL_FULL("expanded", pkd->pane.expanded)) continue;
1396 if (READ_CHAR_FULL("id", pkd->pane.id)) continue;
1397
1398
1399 log_printf("unknown attribute %s = %s\n", option, value);
1400 }
1401
1402 if (title)
1403 {
1404 gtk_label_set_text(GTK_LABEL(pkd->pane.title), title);
1405 g_free(title);
1406 }
1407
1408 bar_update_expander(pane);
1409 bar_pane_keywords_update(pkd);
1410 }
1411
1367 1412
1368 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ 1413 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */