Skip to content

Commit

Permalink
Fix segfault when closing tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdd committed Sep 25, 2011
1 parent e04a996 commit 0b0560c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
4 changes: 3 additions & 1 deletion src/Notebook.c
Expand Up @@ -135,9 +135,10 @@ void notebook_tabopen (Notebook *obj, const gchar *url)
webview_load_uri (CREAM_WEBVIEW (webview), url);

tablabel = g_object_new (CREAM_TYPE_NOTEBOOK_TAB_LABEL, NULL);
gtk_widget_show_all (tablabel);
gtk_notebook_append_page_menu (GTK_NOTEBOOK (obj), webview,
tablabel,
CREAM_NOTEBOOK_TAB_LABEL (tablabel)->lbl
gtk_label_new ("")
);

g_signal_connect (G_OBJECT (webview), "module-changed", G_CALLBACK (ui_show), NULL);
Expand Down Expand Up @@ -176,6 +177,7 @@ static void notebook_signal_title_changed_cb (WebView *webview, const gchar *tit
{
NotebookTabLabel *tablabel = CREAM_NOTEBOOK_TAB_LABEL (gtk_notebook_get_tab_label (GTK_NOTEBOOK (obj), GTK_WIDGET (webview)));
notebook_tab_label_set_text (tablabel, title);
gtk_notebook_set_menu_label_text (GTK_NOTEBOOK (obj), GTK_WIDGET (webview), title);
}

static void notebook_signal_favicon_changed_cb (WebView *webview, GdkPixbuf *favicon, Notebook *obj)
Expand Down
25 changes: 3 additions & 22 deletions src/NotebookTabLabel.c
Expand Up @@ -39,33 +39,14 @@ static void notebook_tab_label_class_init (NotebookTabLabelClass *klass)

static void notebook_tab_label_init (NotebookTabLabel *self)
{
GtkIconTheme *icons = gtk_icon_theme_get_default ();
GError *error = NULL;

gtk_box_set_homogeneous (GTK_BOX (self), FALSE);
gtk_box_set_spacing (GTK_BOX (self), 2);

self->img = gtk_image_new_from_pixbuf (
gtk_icon_theme_load_icon (icons,
GTK_STOCK_FILE,
GTK_ICON_SIZE_MENU,
GTK_ICON_LOOKUP_FORCE_SIZE,
&error
)
);

if (error != NULL)
print_error (error, FALSE, "notebook.tab.label");

self->img = gtk_image_new_from_stock (GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU);
self->lbl = gtk_label_new ("");
self->close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);

gtk_button_set_label (GTK_BUTTON (self->close), "");
gtk_button_set_relief (GTK_BUTTON (self->close), GTK_RELIEF_NONE);

gtk_box_pack_start (GTK_BOX (self), self->img, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (self), self->lbl, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (self), self->close, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (self), self->img, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (self), self->lbl, TRUE, TRUE, 5);
}

/* methods */
Expand Down
1 change: 0 additions & 1 deletion src/NotebookTabLabel.h
Expand Up @@ -55,7 +55,6 @@ struct _NotebookTabLabel

GtkWidget *img;
GtkWidget *lbl;
GtkWidget *close;
};

struct _NotebookTabLabelClass
Expand Down

0 comments on commit 0b0560c

Please sign in to comment.