diff options
author | Jens Georg <mail@jensge.org> | 2020-12-24 10:54:48 +0100 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2020-12-24 10:54:48 +0100 |
commit | 0b45a50308a3718f423fb388a702f2da034693a0 (patch) | |
tree | 34127513dd115ba8bd3f7da52b7f07bf2355889e | |
parent | 8e6e0ca1b6bbfcd9fd653b65a313dbf3d8df6278 (diff) | |
download | gssdp-wip/modern-gtk.tar.gz |
-rw-r--r-- | tools/gssdp-device-sniffer.c | 31 | ||||
-rw-r--r-- | tools/main-window.c | 72 |
2 files changed, 102 insertions, 1 deletions
diff --git a/tools/gssdp-device-sniffer.c b/tools/gssdp-device-sniffer.c index d30687e..8664729 100644 --- a/tools/gssdp-device-sniffer.c +++ b/tools/gssdp-device-sniffer.c @@ -722,6 +722,7 @@ deinit_upnp (void) static void on_activate (GtkApplication *app) { + printf ("on_activate\n"); GtkWindow *window; window = gtk_application_get_active_window (app); @@ -735,6 +736,25 @@ on_activate (GtkApplication *app) gtk_window_present (window); } +static int +on_command_line (GtkApplication *app, + GApplicationCommandLine *cmdline, + gpointer user_data) +{ + const char *interface = NULL; + GSocketFamily family = G_SOCKET_FAMILY_INVALID; + GVariantDict *options = + g_application_command_line_get_options_dict (cmdline); + gboolean four = FALSE; + gboolean six = FALSE; + + printf ("on_commandline\n"); + + on_activate (app); + + return EXIT_SUCCESS; +} + gint main (gint argc, gchar *argv[]) { @@ -742,9 +762,18 @@ main (gint argc, gchar *argv[]) GtkApplication *app = gtk_application_new ("org.gupnp.GSSDP.DeviceSniffer", - G_APPLICATION_FLAGS_NONE); + G_APPLICATION_HANDLES_COMMAND_LINE); + + g_application_add_main_option_entries (G_APPLICATION (app), entries); + g_application_set_option_context_parameter_string ( + G_APPLICATION (app), + "- graphical SSDP debug tool"); g_signal_connect (G_OBJECT (app), + "command-line", + G_CALLBACK (on_command_line), + NULL); + g_signal_connect (G_OBJECT (app), "activate", G_CALLBACK (on_activate), NULL); diff --git a/tools/main-window.c b/tools/main-window.c index 689af7d..244d741 100644 --- a/tools/main-window.c +++ b/tools/main-window.c @@ -2,6 +2,7 @@ #include "main-window.h" +#include <gio/gio.h> #include <glib.h> #include <libsoup/soup.h> @@ -17,9 +18,21 @@ typedef enum PACKET_STORE_COLUMN_RAW_ARRIVAL_TIME } PACKET_STORE_COLUMNS; +enum +{ + PROP_0, + PROP_INTERFACE, + PROP_ADDRESS_FAMILY, +}; + struct _GSSDPDeviceSnifferMainWindow { GtkApplicationWindow parent_instance; + // SSDP related parameters + char *interface; + GSocketFamily family; + + // Bound child widgets GtkWidget *packet_treeview; GtkWidget *packet_textview; }; @@ -29,6 +42,39 @@ G_DEFINE_TYPE (GSSDPDeviceSnifferMainWindow, GTK_TYPE_APPLICATION_WINDOW) static void +main_window_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +main_window_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GSSDPDeviceSnifferMainWindow *self = + GSSDP_DEVICE_SNIFFER_MAIN_WINDOW (object); + + switch (property_id) { + case PROP_INTERFACE: + self->interface = g_value_dup_string (value); + break; + case PROP_ADDRESS_FAMILY: + self->family = g_value_get_enum (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void gssdp_device_sniffer_main_window_class_init ( GSSDPDeviceSnifferMainWindowClass *klass) { @@ -43,6 +89,32 @@ gssdp_device_sniffer_main_window_class_init ( gtk_widget_class_bind_template_child (widget_class, GSSDPDeviceSnifferMainWindow, packet_textview); + + GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->set_property = main_window_set_property; + object_class->get_property = main_window_get_property; + + g_object_class_install_property ( + object_class, + PROP_ADDRESS_FAMILY, + g_param_spec_enum ( + "address-family", + "Socket address familiy", + "The socket address familiy of the SSDP client", + G_TYPE_SOCKET_FAMILY, + G_SOCKET_FAMILY_INVALID, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property ( + object_class, + PROP_INTERFACE, + g_param_spec_string ("interface", + "Network interface", + "The network interface of the SSDP client", + NULL, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); } static void |