"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/info_windows.c" between
etherape-0.9.17.tar.gz and etherape-0.9.18.tar.gz

About: EtherApe is a GNOME/pcap-based graphical network monitor (etherman clone).

info_windows.c  (etherape-0.9.17):info_windows.c  (etherape-0.9.18)
skipping to change at line 66 skipping to change at line 66
{ {
gchar *prot_name; gchar *prot_name;
GtkWidget *window; GtkWidget *window;
} }
prot_info_window_t; prot_info_window_t;
typedef struct protocol_list_item_t_tag typedef struct protocol_list_item_t_tag
{ {
gchar *name; /* protocol name */ gchar *name; /* protocol name */
uint port; /* protocol port */ uint port; /* protocol port */
GdkColor color; /* protocol color */ GdkRGBA color; /* protocol color */
basic_stats_t rowstats; basic_stats_t rowstats;
} protocol_list_item_t; } protocol_list_item_t;
/* list of active node/link info windows */ /* list of active node/link info windows */
static GList *stats_info_windows = NULL; static GList *stats_info_windows = NULL;
/* list of active protocol info windows */ /* list of active protocol info windows */
static GList *prot_info_windows = NULL; static GList *prot_info_windows = NULL;
/* private functions */ /* private functions */
skipping to change at line 100 skipping to change at line 100
---------------------------------------------------------- */ ---------------------------------------------------------- */
/* Comparison function used to compare prot_info_windows */ /* Comparison function used to compare prot_info_windows */
static gint static gint
prot_info_compare (gconstpointer a, gconstpointer b) prot_info_compare (gconstpointer a, gconstpointer b)
{ {
g_assert (a != NULL); g_assert (a != NULL);
g_assert (b != NULL); g_assert (b != NULL);
return strcmp (((prot_info_window_t *) a)->prot_name, (gchar *) b); return strcmp (((prot_info_window_t *) a)->prot_name, (gchar *) b);
} /* prot_info_compare */ } /* prot_info_compare */
static void static GtkBuilder *new_bldr_instance(const gchar *id)
create_prot_info_window (protocol_t * protocol) {
GtkBuilder *bldr;
gchar *ids[2];
ids[0] = id;
ids[1] = NULL;
bldr = gtk_builder_new();
if (!bldr)
{
g_error(_("We could not load the interface! (%s)"),
appdata.itf_file);
return NULL;
}
if (!gtk_builder_add_objects_from_file(bldr, appdata.itf_file, ids, NULL)) {
g_error(_("Cannot create widget %s from file %s!"),
id,
appdata.itf_file);
g_object_unref(bldr);
return NULL;
}
gtk_builder_connect_signals(bldr, NULL);
return bldr;
}
static void create_prot_info_window(protocol_t * protocol)
{ {
GtkWidget *window; GtkWidget *window;
prot_info_window_t *prot_info_window; prot_info_window_t *prot_info_window;
GladeXML *xml_info_window;
GtkWidget *widget; GtkWidget *widget;
GList *list_item; GList *list_item;
/* If there is already a window, we don't need to create it again */ /* If there is already a window, we don't need to create it again */
if (!(list_item = if (!(list_item =
g_list_find_custom (prot_info_windows, g_list_find_custom (prot_info_windows,
protocol->name, prot_info_compare))) protocol->name, prot_info_compare)))
{ {
xml_info_window = /* GtkWidget *protwin;
glade_xml_new (appdata.glade_file, "prot_info", NULL); protwin =
GTK_WIDGET(gtk_builder_get_object(appdata.xml, "prot_info"));*/
/* guint err;
GError *gerror = NULL;
static gchar *objs[] = {"prot_info", NULL};
err = gtk_builder_add_objects_from_file(GtkBuilder *builder,
const gchar *filename,
objs,
&gerror);
xml_info_window =
GTK_WIDGET(glade_xml_new(appdata.itf_file, "prot_info", NULL));
if (!xml_info_window) if (!xml_info_window)
{ {
g_error (_("We could not load the interface! (%s)"), g_error (_("We could not load the interface! (%s)"),
appdata.glade_file); appdata.itf_file);
return; return;
} }
glade_xml_signal_autoconnect (xml_info_window); glade_xml_signal_autoconnect (xml_info_window);
window = glade_xml_get_widget (xml_info_window, "prot_info"); */
window = GTK_WIDGET(gtk_builder_get_object(appdata.xml, "prot_info"));
gtk_widget_show (window); gtk_widget_show (window);
widget = glade_xml_get_widget (xml_info_window, "prot_info_name_label"); widget = GTK_WIDGET(gtk_builder_get_object(appdata.xml, "prot_info_name_la
g_object_set_data (G_OBJECT (window), "name_label", widget); bel"));
g_object_set_data(G_OBJECT(window), "name_label", widget);
widget = widget =
glade_xml_get_widget (xml_info_window, "prot_info_last_heard_label"); GTK_WIDGET(gtk_builder_get_object(appdata.xml, "prot_info_last_he
g_object_set_data (G_OBJECT (window), "last_heard_label", widget); ard_label"));
widget = glade_xml_get_widget (xml_info_window, "prot_info_average"); g_object_set_data(G_OBJECT(window), "last_heard_label", widget);
g_object_set_data (G_OBJECT (window), "average", widget); widget = GTK_WIDGET(gtk_builder_get_object(appdata.xml, "prot_info_average
"));
g_object_set_data(G_OBJECT(window), "average", widget);
widget = widget =
glade_xml_get_widget (xml_info_window, "prot_info_accumulated"); GTK_WIDGET(gtk_builder_get_object(appdata.xml, "prot_info_accumul
g_object_set_data (G_OBJECT (window), "accumulated", widget); ated"));
g_object_unref (xml_info_window); g_object_set_data(G_OBJECT (window), "accumulated", widget);
prot_info_window = g_malloc (sizeof (prot_info_window_t)); prot_info_window = g_malloc (sizeof (prot_info_window_t));
prot_info_window->prot_name = g_strdup (protocol->name); prot_info_window->prot_name = g_strdup (protocol->name);
g_object_set_data (G_OBJECT (window), "prot_name", g_object_set_data(G_OBJECT (window), "prot_name",
prot_info_window->prot_name); prot_info_window->prot_name);
prot_info_window->window = window; prot_info_window->window = window;
prot_info_windows = prot_info_windows =
g_list_prepend (prot_info_windows, prot_info_window); g_list_prepend (prot_info_windows, prot_info_window);
} }
else else
prot_info_window = (prot_info_window_t *) list_item->data; prot_info_window = (prot_info_window_t *) list_item->data;
update_prot_info_window (prot_info_window); update_prot_info_window (prot_info_window);
skipping to change at line 375 skipping to change at line 412
gv = retrieve_treeview(window); gv = retrieve_treeview(window);
if (!gv) if (!gv)
return NULL; return NULL;
gs = GTK_LIST_STORE (gtk_tree_view_get_model (gv)); gs = GTK_LIST_STORE (gtk_tree_view_get_model (gv));
if (gs) if (gs)
return gs; return gs;
/* create the store - it uses 9 values, 7 displayable, one proto color /* create the store - it uses 9 values, 7 displayable, one proto color
and the data pointer */ and the data pointer */
gs = gtk_list_store_new (9, GDK_TYPE_COLOR, G_TYPE_STRING, G_TYPE_STRING, gs = gtk_list_store_new (9, GDK_TYPE_RGBA, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
gtk_tree_view_set_model (gv, GTK_TREE_MODEL (gs)); gtk_tree_view_set_model (gv, GTK_TREE_MODEL (gs));
/* the view columns and cell renderers must be also created ... /* the view columns and cell renderers must be also created ...
the first column is the proto color; is a text column wich renders the first column is the proto color; is a text column wich renders
only a space with a colored background. We must set some special properties only a space with a colored background. We must set some special properties
*/ */
gc = gtk_tree_view_column_new_with_attributes gc = gtk_tree_view_column_new_with_attributes
(" ", gtk_cell_renderer_text_new(), "background-gdk", PROTO_COLUMN_COLOR, (" ", gtk_cell_renderer_text_new(), "background-rgba", PROTO_COLUMN_COLOR,
NULL); NULL);
g_object_set (G_OBJECT (gc), "resizable", TRUE, g_object_set (G_OBJECT (gc), "resizable", TRUE,
"reorderable", TRUE, "reorderable", TRUE,
NULL); NULL);
// gtk_tree_view_column_set_sort_column_id(gc, PROTO_COLUMN_COLOR); // gtk_tree_view_column_set_sort_column_id(gc, PROTO_COLUMN_COLOR);
gtk_tree_view_append_column (gv, gc); gtk_tree_view_append_column (gv, gc);
create_add_text_column(gv, "Protocol", PROTO_COLUMN_NAME, FALSE); create_add_text_column(gv, "Protocol", PROTO_COLUMN_NAME, FALSE);
create_add_text_column(gv, "Port", PROTO_COLUMN_PORT, TRUE); create_add_text_column(gv, "Port", PROTO_COLUMN_PORT, TRUE);
create_add_text_column(gv, "Inst Traffic", PROTO_COLUMN_INSTANTANEOUS, FALSE); create_add_text_column(gv, "Inst Traffic", PROTO_COLUMN_INSTANTANEOUS, FALSE);
skipping to change at line 518 skipping to change at line 555
/* retrieve current stack proto */ /* retrieve current stack proto */
stack_proto = item->data; stack_proto = item->data;
if (!res) if (!res)
{ {
/* current protocol missing on list, create a new row */ /* current protocol missing on list, create a new row */
row_proto = g_malloc(sizeof(protocol_list_item_t)); row_proto = g_malloc(sizeof(protocol_list_item_t));
g_assert(row_proto); g_assert(row_proto);
row_proto->name = g_strdup(stack_proto->name); row_proto->name = g_strdup(stack_proto->name);
row_proto->color = protohash_color(stack_proto->name); row_proto->color = *protohash_color(stack_proto->name);
gtk_list_store_append(gs, &it); gtk_list_store_append(gs, &it);
gtk_list_store_set (gs, &it, gtk_list_store_set (gs, &it,
PROTO_COLUMN_NAME, row_proto->name, PROTO_COLUMN_NAME, row_proto->name,
PROTO_COLUMN_COLOR, &row_proto->color, PROTO_COLUMN_COLOR, &row_proto->color,
PROTO_COLUMN_N, row_proto, PROTO_COLUMN_N, row_proto,
-1); -1);
} }
else else
{ {
skipping to change at line 564 skipping to change at line 601
Displays the global protocol table Displays the global protocol table
---------------------------------------------------------- */ ---------------------------------------------------------- */
static void static void
update_protocols_window (void) update_protocols_window (void)
{ {
GtkWidget *window; GtkWidget *window;
GtkTreeView *gv; GtkTreeView *gv;
window = glade_xml_get_widget (appdata.xml, "protocols_window"); window = GTK_WIDGET(gtk_builder_get_object(appdata.xml, "protocols_window"));
gv = retrieve_treeview(window); gv = retrieve_treeview(window);
if (!gv) if (!gv)
{ {
/* register gv */ /* register gv */
gv = GTK_TREE_VIEW (glade_xml_get_widget (appdata.xml, "prot_clist")); gv = GTK_TREE_VIEW (gtk_builder_get_object (appdata.xml, "prot_clist"));
if (!gv) if (!gv)
{ {
g_critical("can't find prot_clist"); g_critical("can't find prot_clist");
return; return;
} }
register_treeview(window, gv); register_treeview(window, gv);
} }
update_protocols_table(window, protocol_summary_stack()); update_protocols_table(window, protocol_summary_stack());
} /* update_protocols_window */ } /* update_protocols_window */
void void
toggle_protocols_window (void) toggle_protocols_window (void)
{ {
GtkWidget *protocols_check = glade_xml_get_widget (appdata.xml, "protocols_che ck"); GtkWidget *protocols_check = GTK_WIDGET(gtk_builder_get_object(appdata.xml, "p rotocols_check"));
if (!protocols_check) if (!protocols_check)
return; return;
gtk_menu_item_activate (GTK_MENU_ITEM (protocols_check)); gtk_menu_item_activate (GTK_MENU_ITEM (protocols_check));
} /* toggle_protocols_window */ } /* toggle_protocols_window */
gboolean gboolean
on_delete_protocol_window (GtkWidget * wdg, GdkEvent * evt, gpointer ud) on_delete_protocol_window (GtkWidget * wdg, GdkEvent * evt, gpointer ud)
{ {
toggle_protocols_window (); toggle_protocols_window ();
return TRUE; /* ignore signal */ return TRUE; /* ignore signal */
} }
void void
on_protocols_check_activate (GtkCheckMenuItem * menuitem, gpointer user_data) on_protocols_check_activate (GtkCheckMenuItem * menuitem, gpointer user_data)
{ {
GtkWidget *protocols_window = glade_xml_get_widget (appdata.xml, "protocols_wi ndow"); GtkWidget *protocols_window = GTK_WIDGET(gtk_builder_get_object(appdata.xml, " protocols_window"));
if (!protocols_window) if (!protocols_window)
return; return;
if (gtk_check_menu_item_get_active (menuitem)) if (gtk_check_menu_item_get_active (menuitem))
{ {
gtk_widget_show(protocols_window); gtk_widget_show(protocols_window);
gdk_window_raise(gtk_widget_get_window(protocols_window)); gdk_window_raise(gtk_widget_get_window(protocols_window));
update_protocols_window (); update_protocols_window ();
} }
else else
{ {
/* retrieve view and model (store) */ /* retrieve view and model (store) */
GtkListStore *gs; GtkListStore *gs;
GtkTreeView *gv = GTK_TREE_VIEW(glade_xml_get_widget(appdata.xml, "prot_cl ist")); GtkTreeView *gv = GTK_TREE_VIEW(gtk_builder_get_object(appdata.xml, "prot_ clist"));
if (gv) if (gv)
{ {
gs = GTK_LIST_STORE (gtk_tree_view_get_model (gv)); gs = GTK_LIST_STORE (gtk_tree_view_get_model (gv));
if (gs) if (gs)
protocols_table_clear(gs); protocols_table_clear(gs);
} }
gtk_widget_hide (protocols_window); gtk_widget_hide (protocols_window);
} }
} /* on_protocols_check_activate */ } /* on_protocols_check_activate */
skipping to change at line 761 skipping to change at line 798
} }
last_update_time = appdata.now; last_update_time = appdata.now;
} /* update_stats_info_windows */ } /* update_stats_info_windows */
/**************************************************************************** /****************************************************************************
* *
* node protocols display * node protocols display
* *
***************************************************************************/ ***************************************************************************/
static GtkWidget * static GtkWidget *stats_info_create(const gchar *idkey, gpointer key)
stats_info_create(const gchar *idkey, gpointer key)
{ {
GtkBuilder *bldr;
GtkWidget *window; GtkWidget *window;
GladeXML *xml_info_window;
GtkTreeView *gv; GtkTreeView *gv;
xml_info_window = bldr = new_bldr_instance("node_proto_info");
glade_xml_new (appdata.glade_file, "node_proto_info", NULL); if (!bldr)
if (!xml_info_window)
{ {
g_error (_("We could not load the interface! (%s)"), g_error(_("We could not load the interface! (%s)"),
appdata.glade_file); appdata.itf_file);
return NULL; return NULL;
} }
glade_xml_signal_autoconnect (xml_info_window); window = GTK_WIDGET(gtk_builder_get_object(bldr, "node_proto_info"));
window = glade_xml_get_widget (xml_info_window, "node_proto_info"); if (!window)
gtk_widget_show (window); {
g_error(_("We could not load the interface! (%s)"),
appdata.itf_file);
g_object_unref(bldr);
return NULL;
}
gtk_widget_show(window);
/* register the widgets in the window */ /* register the widgets in the window */
register_glade_widget(xml_info_window, G_OBJECT (window), "src_label"); register_glade_widget(bldr, window, "src_label");
register_glade_widget(xml_info_window, G_OBJECT (window), "dst_label"); register_glade_widget(bldr, window, "dst_label");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_name"); register_glade_widget(bldr, window, "node_iproto_name");
register_glade_widget(xml_info_window, G_OBJECT (window), register_glade_widget(bldr, window, "node_iproto_numeric_name");
"node_iproto_numeric_name"); register_glade_widget(bldr, window, "node_iproto_name_b");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_name_b" register_glade_widget(bldr, window, "node_iproto_numeric_name_b");
); register_glade_widget(bldr, window, "total_label");
register_glade_widget(xml_info_window, G_OBJECT (window), register_glade_widget(bldr, window, "inbound_label");
"node_iproto_numeric_name_b"); register_glade_widget(bldr, window, "outbound_label");
register_glade_widget(xml_info_window, G_OBJECT (window), "total_label"); register_glade_widget(bldr, window, "node_iproto_avg");
register_glade_widget(xml_info_window, G_OBJECT (window), "inbound_label"); register_glade_widget(bldr, window, "node_iproto_avg_in");
register_glade_widget(xml_info_window, G_OBJECT (window), "outbound_label"); register_glade_widget(bldr, window, "node_iproto_avg_out");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_avg"); register_glade_widget(bldr, window, "node_iproto_accum");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_avg_in" register_glade_widget(bldr, window, "node_iproto_accum_in");
); register_glade_widget(bldr, window, "node_iproto_accum_out");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_avg_out register_glade_widget(bldr, window, "node_iproto_avgsize");
"); register_glade_widget(bldr, window, "node_iproto_avgsize_in");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_accum") register_glade_widget(bldr, window, "node_iproto_avgsize_out");
;
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_accum_i
n");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_accum_o
ut");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_avgsize
");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_avgsize
_in");
register_glade_widget(xml_info_window, G_OBJECT (window), "node_iproto_avgsize
_out");
/* get and register the tree view */ /* get and register the tree view */
gv = GTK_TREE_VIEW (glade_xml_get_widget (xml_info_window, "node_iproto_proto" )); gv = GTK_TREE_VIEW(gtk_builder_get_object(bldr, "node_iproto_proto"));
register_treeview(window, gv); register_treeview(window, gv);
/* create columns of proto list */ /* create columns of proto list */
create_protocols_table (window); create_protocols_table(window);
g_object_unref (xml_info_window); // builder is not needed anymore
g_object_unref(bldr);
/* register key info */ /* register key info */
g_object_set_data (G_OBJECT (window), idkey, key); g_object_set_data(G_OBJECT (window), idkey, key);
/* insert into list */ /* insert into list */
stats_info_windows = g_list_prepend (stats_info_windows, window); stats_info_windows = g_list_prepend (stats_info_windows, window);
return window; return window;
} }
static void static void
stats_info_update(GtkWidget *window, const traffic_stats_t *stats) stats_info_update(GtkWidget *window, const traffic_stats_t *stats)
{ {
skipping to change at line 961 skipping to change at line 1002
window = stats_info_create("link_id", g_memdup(link_id, sizeof(link_id_t)) ); window = stats_info_create("link_id", g_memdup(link_id, sizeof(link_id_t)) );
if (!window) if (!window)
return; /* creation failed */ return; /* creation failed */
} }
else else
window = list_item->data; window = list_item->data;
update_link_info_window (window); update_link_info_window (window);
} }
static void static void
update_link_info_window (GtkWidget *window) update_link_info_window(GtkWidget *window)
{ {
const link_id_t *link_id; const link_id_t *link_id;
const link_t *link; const link_t *link;
const node_t *node; const node_t *node;
gchar *linkname; gchar *linkname;
/* updates column descriptions */ /* updates column descriptions */
show_widget(window, "src_label"); show_widget(window, "src_label");
show_widget(window, "dst_label"); show_widget(window, "dst_label");
update_gtklabel(window, "inbound_label", _("B->A")); update_gtklabel(window, "inbound_label", _("B->A"));
 End of changes. 30 change blocks. 
75 lines changed or deleted 111 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)