summaryrefslogtreecommitdiffstats
path: root/avahi-discover-standalone
diff options
context:
space:
mode:
Diffstat (limited to 'avahi-discover-standalone')
-rw-r--r--avahi-discover-standalone/Makefile.am31
-rw-r--r--avahi-discover-standalone/avahi-discover.glade91
-rw-r--r--avahi-discover-standalone/avahi-discover.gladep8
-rw-r--r--avahi-discover-standalone/avahi-discover.ui84
-rw-r--r--avahi-discover-standalone/main.c57
5 files changed, 130 insertions, 141 deletions
diff --git a/avahi-discover-standalone/Makefile.am b/avahi-discover-standalone/Makefile.am
index 542aeae..3995c0a 100644
--- a/avahi-discover-standalone/Makefile.am
+++ b/avahi-discover-standalone/Makefile.am
@@ -1,7 +1,5 @@
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
@@ -20,13 +18,13 @@
AM_CFLAGS=-I$(top_srcdir)
interfaces = \
- avahi-discover.glade
+ avahi-discover.ui
# This cool debug trap works on i386/gcc only
AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
-if HAVE_GTK
-if HAVE_GLIB
+if HAVE_GTK2OR3
+if HAVE_GLIB
bin_PROGRAMS = \
avahi-discover-standalone
@@ -35,20 +33,30 @@ avahi_discover_standalone_SOURCES = \
avahi_discover_standalone_CFLAGS = \
$(AM_CFLAGS) \
- $(GLIB20_CFLAGS) $(GTK20_CFLAGS) $(GLADE20_CFLAGS)\
-DAVAHI_INTERFACES_DIR=\"$(interfacesdir)\"
avahi_discover_standalone_LDADD = \
$(AM_LDADD) \
../avahi-common/libavahi-common.la \
../avahi-glib/libavahi-glib.la \
- ../avahi-core/libavahi-core.la \
- $(GLIB20_LIBS) $(GTK20_LIBS) $(GLADE20_LIBS)
+ ../avahi-core/libavahi-core.la
+
+if HAVE_GTK3
+avahi_discover_standalone_CFLAGS += \
+ $(GLIB30_CFLAGS) $(GTK30_CFLAGS)
+avahi_discover_standalone_LDADD += \
+ $(GLIB30_LIBS) $(GTK30_LIBS)
+else
+avahi_discover_standalone_CFLAGS += \
+ $(GLIB20_CFLAGS) $(GTK20_CFLAGS)
+avahi_discover_standalone_LDADD += \
+ $(GLIB20_LIBS) $(GTK20_LIBS)
+endif
interfaces_DATA = $(interfaces)
endif # HAVE_GLIB
-else
+else
if HAVE_PYTHON_DBUS
@@ -58,5 +66,4 @@ endif
endif
EXTRA_DIST = \
- $(interfaces) \
- avahi-discover.gladep
+ $(interfaces)
diff --git a/avahi-discover-standalone/avahi-discover.glade b/avahi-discover-standalone/avahi-discover.glade
deleted file mode 100644
index bb456c2..0000000
--- a/avahi-discover-standalone/avahi-discover.glade
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
-<glade-interface>
-
-<widget class="GtkWindow" id="main_window">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Avahi Discovery</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="default_width">500</property>
- <property name="default_height">400</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <signal handler="gtk_main_quit" name="destroy" after="False"/>
-
- <child>
- <widget class="GtkVBox" id="vbox1">
- <property name="border_width">12</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">12</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="tree_view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">True</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">True</property>
- <property name="fixed_height_mode">False</property>
- <property name="hover_selection">False</property>
- <property name="hover_expand">False</property>
- <signal name="cursor_changed" handler="on_tree_view_cursor_changed" last_modification_time="Sat, 30 Jul 2005 21:39:13 GMT"/>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="info_label">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">&lt;i&gt;No service currently selected.&lt;/i&gt;</property>
- <property name="use_underline">False</property>
- <property name="use_markup">True</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-</glade-interface>
diff --git a/avahi-discover-standalone/avahi-discover.gladep b/avahi-discover-standalone/avahi-discover.gladep
deleted file mode 100644
index a9feaa6..0000000
--- a/avahi-discover-standalone/avahi-discover.gladep
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
-
-<glade-project>
- <name>Avahi-discover</name>
- <program_name>avahi-discover</program_name>
- <gnome_support>FALSE</gnome_support>
-</glade-project>
diff --git a/avahi-discover-standalone/avahi-discover.ui b/avahi-discover-standalone/avahi-discover.ui
new file mode 100644
index 0000000..b4b72f9
--- /dev/null
+++ b/avahi-discover-standalone/avahi-discover.ui
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<!--*- mode: xml -*-->
+<interface>
+ <object class="GtkWindow" id="main_window">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Avahi Discovery</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="default_width">500</property>
+ <property name="default_height">400</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <signal after="False" handler="gtk_main_quit" name="destroy"/>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="border_width">12</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+ <child>
+ <object class="GtkTreeView" id="tree_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">False</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
+ <property name="hover_selection">False</property>
+ <property name="hover_expand">False</property>
+ <signal handler="on_tree_view_cursor_changed" last_modification_time="Sat, 30 Jul 2005 21:39:13 GMT" name="cursor_changed"/>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="info_label">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">&lt;i&gt;No service currently selected.&lt;/i&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/avahi-discover-standalone/main.c b/avahi-discover-standalone/main.c
index 90c74f3..2f000a4 100644
--- a/avahi-discover-standalone/main.c
+++ b/avahi-discover-standalone/main.c
@@ -1,18 +1,16 @@
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -31,7 +29,6 @@
#include <unistd.h>
#include <gtk/gtk.h>
-#include <glade/glade.h>
#include <avahi-core/core.h>
#include <avahi-core/lookup.h>
@@ -83,7 +80,7 @@ static struct Service *get_service(const gchar *service_type, const gchar *servi
for (l = st->services; l; l = l->next) {
struct Service *s = l->data;
-
+
if (s->interface == interface &&
s->protocol == protocol &&
avahi_domain_equal(s->service_name, service_name) &&
@@ -105,17 +102,17 @@ static void free_service(struct Service *s) {
avahi_s_service_resolver_free(service_resolver);
service_resolver = NULL;
}
-
+
gtk_label_set_text(info_label, "<i>Service removed</i>");
}
-
+
s->service_type->services = g_list_remove(s->service_type->services, s);
if ((path = gtk_tree_row_reference_get_path(s->tree_ref))) {
gtk_tree_model_get_iter(GTK_TREE_MODEL(tree_store), &iter, path);
gtk_tree_path_free(path);
}
-
+
gtk_tree_store_remove(tree_store, &iter);
gtk_tree_row_reference_free(s->tree_ref);
@@ -142,7 +139,7 @@ static void service_browser_callback(
GtkTreePath *path, *ppath;
gchar iface[256];
char name[IF_NAMESIZE];
-
+
s = g_new(struct Service, 1);
s->service_name = g_strdup(service_name);
s->domain_name = g_strdup(domain_name);
@@ -150,7 +147,7 @@ static void service_browser_callback(
s->protocol = protocol;
s->service_type = g_hash_table_lookup(service_type_hash_table, service_type);
g_assert(s->service_type);
-
+
s->service_type->services = g_list_prepend(s->service_type->services, s);
ppath = gtk_tree_row_reference_get_path(s->service_type->tree_ref);
@@ -168,7 +165,7 @@ static void service_browser_callback(
gtk_tree_view_expand_row(tree_view, ppath, FALSE);
gtk_tree_path_free(ppath);
-
+
} else if (event == AVAHI_BROWSER_REMOVE) {
struct Service* s;
@@ -186,7 +183,7 @@ static void service_type_browser_callback(
const char *domain,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
AVAHI_GCC_UNUSED void * userdata) {
-
+
struct ServiceType *st;
GtkTreePath *path;
GtkTreeIter iter;
@@ -200,7 +197,7 @@ static void service_type_browser_callback(
st = g_new(struct ServiceType, 1);
st->service_type = g_strdup(service_type);
st->services = NULL;
-
+
gtk_tree_store_append(tree_store, &iter, NULL);
gtk_tree_store_set(tree_store, &iter, 0, st->service_type, 1, "", 2, NULL, -1);
@@ -230,7 +227,7 @@ static void update_label(struct Service *s, const gchar *hostname, const AvahiAd
snprintf(address, sizeof(address), "<i>n/a</i>");
txt_s = g_strdup("<i>n/a</i>");
}
-
+
snprintf(t, sizeof(t),
"<b>Service Type:</b> %s\n"
"<b>Service Name:</b> %s\n"
@@ -254,12 +251,12 @@ static struct Service *get_service_on_cursor(void) {
GtkTreePath *path;
struct Service *s;
GtkTreeIter iter;
-
+
gtk_tree_view_get_cursor(tree_view, &path, NULL);
if (!path)
return NULL;
-
+
gtk_tree_model_get_iter(GTK_TREE_MODEL(tree_store), &iter, path);
gtk_tree_model_get(GTK_TREE_MODEL(tree_store), &iter, 2, &s, -1);
gtk_tree_path_free(path);
@@ -279,9 +276,9 @@ static void service_resolver_callback(
const AvahiAddress *a,
uint16_t port,
AvahiStringList *txt,
- AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
+ AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void* userdata) {
-
+
struct Service *s;
g_assert(r);
@@ -302,7 +299,7 @@ static void service_resolver_callback(
static void tree_view_on_cursor_changed(AVAHI_GCC_UNUSED GtkTreeView *tv, AVAHI_GCC_UNUSED gpointer userdata) {
struct Service *s;
-
+
if (!(s = get_service_on_cursor()))
return;
@@ -320,27 +317,27 @@ static gboolean main_window_on_delete_event(AVAHI_GCC_UNUSED GtkWidget *widget,
}
int main(int argc, char *argv[]) {
- GladeXML *xml;
+ GtkBuilder *ui;
AvahiServerConfig config;
GtkTreeViewColumn *c;
gint error;
AvahiGLibPoll *poll_api;
gtk_init(&argc, &argv);
- glade_init();
avahi_set_allocator(avahi_glib_allocator());
poll_api = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT);
- xml = glade_xml_new(AVAHI_INTERFACES_DIR"avahi-discover.glade", NULL, NULL);
- main_window = glade_xml_get_widget(xml, "main_window");
+ ui = gtk_builder_new();
+ gtk_builder_add_from_file(ui, AVAHI_INTERFACES_DIR"avahi-discover.ui", NULL);
+ main_window = GTK_WIDGET(gtk_builder_get_object(ui, "main_window"));
g_signal_connect(main_window, "delete-event", (GCallback) main_window_on_delete_event, NULL);
-
- tree_view = GTK_TREE_VIEW(glade_xml_get_widget(xml, "tree_view"));
+
+ tree_view = GTK_TREE_VIEW(gtk_builder_get_object(ui, "tree_view"));
g_signal_connect(GTK_WIDGET(tree_view), "cursor-changed", (GCallback) tree_view_on_cursor_changed, NULL);
- info_label = GTK_LABEL(glade_xml_get_widget(xml, "info_label"));
+ info_label = GTK_LABEL(gtk_builder_get_object(ui, "info_label"));
tree_store = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
gtk_tree_view_set_model(tree_view, GTK_TREE_MODEL(tree_store));
@@ -350,9 +347,9 @@ int main(int argc, char *argv[]) {
gtk_tree_view_column_set_resizable(c = gtk_tree_view_get_column(tree_view, 0), TRUE);
gtk_tree_view_column_set_sizing(c, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
gtk_tree_view_column_set_expand(c, TRUE);
-
+
service_type_hash_table = g_hash_table_new((GHashFunc) avahi_domain_hash, (GEqualFunc) avahi_domain_equal);
-
+
avahi_server_config_init(&config);
config.publish_hinfo = config.publish_addresses = config.publish_domain = config.publish_workstation = FALSE;
server = avahi_server_new(avahi_glib_poll_get(poll_api), &config, NULL, NULL, &error);