Re: detaching a notebook tab
- From: Jim Charlton <charltn gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: detaching a notebook tab
- Date: Mon, 06 Jul 2015 09:59:50 -0700
It works fine for me on gtk3. I am running on linux and the version of
gtk3 is the most recent in the repository, I believe (3.10.8-0ubuntu1.5).
Depends: libgtk-3-common (>= 3.10.8), libatk-bridge2.0-0 (>= 2.5.3),
libatk1.0-0 (>= 2.7.5), libc6 (>= 2.14), libcairo-gobject2 (>= 1.10.0),
libcairo2 (>= 1.13.0~20140204), libcolord1 (>= 0.1.10),
libcups2 (>= 1.6.2), libfontconfig1 (>= 2.9.0), libgdk-pixbuf2.0-0 (>=
2.27.1), libglib2.0-0 (>= 2.39.4), libpango-1.0-0 (>= 1.32.4),
libpangocairo-1.0-0 (>= 1.32.4), libpangoft2-1.0-0 (>= 1.32.4),
libwayland-client0 (>= 1.3.92), libwayland-cursor0 (>= 1.2.0),
libx11-6 (>= 2:1.4.99.1), libxcomposite1 (>= 1:0.3-1), libxcursor1
(> 1.1.2), libxdamage1 (>= 1:1.1), libxext6, libxfixes3,
libxi6 (>= 2:1.2.99.4), libxinerama1, libxkbcommon0 (>= 0.2.0-0ubuntu3~),
libxrandr2 (>= 2:1.2.99.3), shared-mime-info
I saw your other message ... but I just used the code from your first
message and got the libs and cflags from `pkg-config gtk+-3.0 --libs`
`pkg-config gtk+-3.0 --cflags`.
jim...
On 15-07-06 08:36 AM, Allin Cottrell wrote:
Hello all,
My app has a collection of objects which can be viewed either
individually or in a tabbed viewer based on GtkNotebook. When objects
are being viewed in the latter way, the user is supposed to be able to
drag an object out of the tabbed viewer, with the effect of giving it
its own window.
This works fine with gtk 2.24.28, but I'm getting a segfault with the
same code on gtk 3.16.4. This looks like a gtk bug, but maybe I'm
doing something wrong and before I file a report I'd be grateful if
anyone could take a look at minimal test case below.
The idea is to start the program, switch to the second page in the
notebook, and try dragging the tab onto the root window. With gtk3
I get a crash, preceded by the message
Gtk-CRITICAL **: gtk_widget_get_frame_clock: assertion 'GTK_IS_WIDGET
(widget)' failed
Here's the minimal code:
#include <gtk/gtk.h>
/* Minimal test case for dragging a tab out of a
notebook onto the root window
Allin Cottrell <cottrell wfu edu>, 2015-07-06
*/
static GtkNotebook *detach_tab_callback (GtkNotebook *book,
GtkWidget *page,
gint x, gint y,
gpointer data)
{
GtkWidget *window;
gint pgnum;
g_object_ref(page);
pgnum = gtk_notebook_page_num(GTK_NOTEBOOK(book), page);
gtk_notebook_remove_page(GTK_NOTEBOOK(book), pgnum);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_add(GTK_CONTAINER(window), page);
g_object_unref(page);
gtk_widget_show_all(window);
/* return NULL since we're not adding the detached
tab to another GtkNotebook */
return NULL;
}
int main (int argc, char **argv)
{
GtkWidget *window, *notebook, *child;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "destroy",
gtk_main_quit, NULL);
notebook = gtk_notebook_new();
g_signal_connect(G_OBJECT(notebook), "create-window",
G_CALLBACK(detach_tab_callback), NULL);
child = gtk_label_new("Content of first page");
gtk_widget_set_size_request(child, -1, 100);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child, NULL);
child = gtk_label_new("Content of second page");
gtk_widget_set_size_request(child, -1, 100);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child, NULL);
gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(notebook),
child, TRUE);
gtk_container_add(GTK_CONTAINER(window), notebook);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]