* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-#undef GTK_DISABLE_DEPRECATED
#include "config.h"
#include <gtk/gtk.h>
static void
add_random (GtkToolbar *toolbar, gint n)
{
+ gint n_items;
gint position;
gchar *label = g_strdup_printf ("Button %d", n);
- GtkWidget *widget = gtk_button_new_with_label (label);
+ GtkToolItem *toolitem = gtk_tool_button_new (NULL, label);
+ gtk_tool_item_set_tooltip_text (toolitem, "Bar");
g_free (label);
- gtk_widget_show_all (widget);
+ gtk_widget_show_all (GTK_WIDGET (toolitem));
- if (g_list_length (toolbar->children) == 0)
+ n_items = gtk_toolbar_get_n_items (toolbar);
+ if (n_items == 0)
position = 0;
else
- position = g_random_int_range (0, g_list_length (toolbar->children));
+ position = g_random_int_range (0, n_items);
- gtk_toolbar_insert_widget (toolbar, widget, "Bar", "Baz", position);
+ gtk_toolbar_insert (toolbar, toolitem, position);
}
static void
remove_random (GtkToolbar *toolbar)
{
- GtkToolbarChild *child;
+ GtkToolItem *tool_item;
+ gint n_items;
gint position;
- if (!toolbar->children)
+ n_items = gtk_toolbar_get_n_items (toolbar);
+
+ if (n_items == 0)
return;
- position = g_random_int_range (0, g_list_length (toolbar->children));
+ position = g_random_int_range (0, n_items);
- child = g_list_nth_data (toolbar->children, position);
-
- gtk_container_remove (GTK_CONTAINER (toolbar), child->widget);
+ tool_item = gtk_toolbar_get_nth_item (toolbar, position);
+
+ gtk_container_remove (GTK_CONTAINER (toolbar),
+ GTK_WIDGET (tool_item));
}
static gboolean
Info *info = data;
Action action;
-
+ gint n_items;
+
if (info->counter++ == 200)
{
gtk_main_quit ();
gtk_widget_show (GTK_WIDGET (info->toolbar));
}
- if (!info->toolbar->children)
+ n_items = gtk_toolbar_get_n_items (info->toolbar);
+ if (n_items == 0)
{
add_random (info->toolbar, info->counter);
return TRUE;
}
- else if (g_list_length (info->toolbar->children) > 50)
+ else if (n_items > 50)
{
int i;
for (i = 0; i < 25; i++)