gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
GtkUtils.H
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 #ifndef GTKUTILS_H_
18 #define GTKUTILS_H_
19 #include <gtk/gtk.h>
20 #include <iostream>
21 
26 static GtkWidget *getContainersFirstVisibleWidget(GtkContainer *container) {
27  GList *box=gtk_container_get_children(container); // get all of the container's contents
28  GtkWidget *visible=NULL;
29  std::cout<<"getContainersFirstVisibleWidget : g_list_length(box)="<<g_list_length(box)<<std::endl;
30  for (int i=0; i<(int)g_list_length(box); i++) {
31  visible=static_cast<GtkWidget*>(g_list_nth_data(box,i)); // get the widget
32  if (gtk_widget_get_visible(visible)) {
33  return visible;
34  } else
35  visible=NULL;
36  }
37  return visible;
38 }
39 
44 static GtkWidget *getContainersFirstWidget(GtkContainer *widget) {
45  GList *box=gtk_container_get_children(widget); // get all of the container's contents
46  if (g_list_length(box)>1) // check we don't have more then one label displayed - which we shouldn't
47  std::cerr<<"More then one widget in the container - returning only the first"<<std::endl;
48  if (g_list_length(box)) // check there is something displayed
49  return (GtkWidget *)g_list_nth_data(box,0); // get the label
50  else
51  return (GtkWidget *)NULL;
52 }
53 
54 #endif // GTKUTILS_H_
static GtkWidget * getContainersFirstVisibleWidget(GtkContainer *container)
returns the first visible widget in a container
Definition: GtkUtils.H:26
static GtkWidget * getContainersFirstWidget(GtkContainer *widget)
Definition: GtkUtils.H:44
gtkIOStream: /tmp/gtkiostream/include/GtkUtils.H Source File
GTK+ IOStream  Beta