Ticket #180: 0002-Add-aui_service_dialog_set_service_type_name-and-re.patch
| File 0002-Add-aui_service_dialog_set_service_type_name-and-re.patch, 6.1 kB (added by MathiasHasselmann, 1 year ago) |
|---|
-
a/avahi-ui/avahi-ui.c
old new 73 73 GtkWidget *service_progress_bar; 74 74 75 75 GtkListStore *service_list_store, *domain_list_store; 76 GHashTable *service_type_names; 76 77 77 78 guint service_pulse_timeout; 78 79 guint domain_pulse_timeout; … … 410 411 411 412 case AVAHI_BROWSER_NEW: { 412 413 gchar *ifs; 413 const gchar *pretty_type ;414 const gchar *pretty_type = NULL; 414 415 char ifname[IFNAMSIZ]; 415 416 GtkTreeIter iter; 416 417 GtkTreeSelection *selection; … … 420 421 421 422 ifs = g_strdup_printf("%s %s", ifname, protocol == AVAHI_PROTO_INET ? "IPv4" : "IPv6"); 422 423 424 if (d->priv->service_type_names) 425 pretty_type = g_hash_table_lookup (d->priv->service_type_names, type); 426 427 if (!pretty_type) { 423 428 #if defined(HAVE_GDBM) || defined(HAVE_DBM) 424 pretty_type = stdb_lookup(type);429 pretty_type = stdb_lookup(type); 425 430 #else 426 pretty_type = type; 427 #endif 431 pretty_type = type; 432 #endif 433 } 428 434 429 435 gtk_list_store_append(d->priv->service_list_store, &iter); 430 436 … … 817 823 if (d->priv->glib_poll) 818 824 avahi_glib_poll_free(d->priv->glib_poll); 819 825 826 if (d->priv->service_list_store) 827 g_object_unref(d->priv->service_list_store); 828 if (d->priv->domain_list_store) 829 g_object_unref(d->priv->domain_list_store); 830 if (d->priv->service_type_names) 831 g_hash_table_unref (d->priv->service_type_names); 832 820 833 g_free(d->priv); 821 834 d->priv = NULL; 822 835 … … 1089 1102 p->forward_response_id = GTK_RESPONSE_NONE; 1090 1103 1091 1104 p->service_list_store = p->domain_list_store = NULL; 1105 p->service_type_names = NULL; 1092 1106 1093 1107 gtk_widget_push_composite_child(); 1094 1108 … … 1236 1250 return (const char* const*) d->priv->browse_service_types; 1237 1251 } 1238 1252 1253 void aui_service_dialog_set_service_type_name(AuiServiceDialog *d, const gchar *type, const gchar *name) { 1254 GtkTreeModel *m = NULL; 1255 GtkTreeIter iter; 1256 1257 g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); 1258 g_return_if_fail(NULL != type); 1259 g_return_if_fail(NULL != name); 1260 1261 if (NULL == d->priv->service_type_names) 1262 d->priv->service_type_names = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 1263 1264 g_hash_table_insert(d->priv->service_type_names, g_strdup(type), g_strdup(name)); 1265 1266 if (d->priv->service_list_store) 1267 m = GTK_TREE_MODEL(d->priv->service_list_store); 1268 1269 if (m && gtk_tree_model_get_iter_first(m, &iter)) { 1270 do { 1271 char *stored_type = NULL; 1272 1273 gtk_tree_model_get(m, &iter, SERVICE_COLUMN_TYPE, &stored_type, -1); 1274 1275 if (stored_type && g_str_equal(stored_type, type)) 1276 gtk_list_store_set(d->priv->service_list_store, &iter, SERVICE_COLUMN_PRETTY_TYPE, name, -1); 1277 } while (gtk_tree_model_iter_next(m, &iter)); 1278 } 1279 } 1280 1239 1281 void aui_service_dialog_set_domain(AuiServiceDialog *d, const char *domain) { 1240 1282 g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); 1241 1283 g_return_if_fail(!domain || is_valid_domain_suffix(domain)); -
a/avahi-ui/avahi-ui.h
old new 95 95 void aui_service_dialog_set_browse_service_typesv(AuiServiceDialog *d, const gchar *const*type); 96 96 /** Return the service types currently browsed for. i.e. what was previously set with aui_service_dialog_set_browse_service_types() */ 97 97 const gchar*const* aui_service_dialog_get_browse_service_types(AuiServiceDialog *d); 98 void aui_service_dialog_set_service_type_name(AuiServiceDialog *d, const gchar *type, const gchar *name); 98 99 99 100 /** @} */ 100 101 -
a/avahi-ui/bssh.c
old new 41 41 GtkWidget *d; 42 42 43 43 gtk_init(&argc, &argv); 44 45 if (g_str_has_suffix(argv[0], "bvnc")) { 44 g_print ("%s\n", argv[0]); 45 46 if (g_str_has_suffix(argv[0], "bshell")) { 47 d = aui_service_dialog_new("Choose shell server", NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, NULL); 48 aui_service_dialog_set_browse_service_types(AUI_SERVICE_DIALOG(d), "_rfb._tcp", "_ssh._tcp", NULL); 49 aui_service_dialog_set_service_type_name(AUI_SERVICE_DIALOG(d), "_rfb._tcp", "Desktop"); 50 aui_service_dialog_set_service_type_name(AUI_SERVICE_DIALOG(d), "_ssh._tcp", "Terminal"); 51 } else if (g_str_has_suffix(argv[0], "bvnc")) { 46 52 d = aui_service_dialog_new("Choose VNC server", NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, NULL); 47 53 aui_service_dialog_set_browse_service_types(AUI_SERVICE_DIALOG(d), "_rfb._tcp", NULL); 48 54 } else { … … 59 65 char a[AVAHI_ADDRESS_STR_MAX], *u = NULL, *n = NULL; 60 66 char *h = NULL, *t = NULL; 61 67 const AvahiStringList *txt; 62 68 63 69 t = g_strdup(aui_service_dialog_get_service_type(AUI_SERVICE_DIALOG(d))); 64 70 n = g_strdup(aui_service_dialog_get_service_name(AUI_SERVICE_DIALOG(d))); 65 71
