Revert "Remove hack to collapse the right border."

This reverts commit 8c7f5cf4.
parent d709062e
......@@ -36,6 +36,7 @@ struct _GeditMultiNotebookPrivate
GeditTab *active_tab;
guint removing_notebook : 1;
guint collapse : 1;
};
enum
......@@ -451,6 +452,7 @@ add_notebook (GeditMultiNotebook *mnb,
GtkAllocation allocation;
GtkWidget *active_notebook = mnb->priv->active_notebook;
gint active_nb_pos;
gboolean collapse_new_notebook = FALSE;
paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_widget_show (paned);
......@@ -473,11 +475,26 @@ add_notebook (GeditMultiNotebook *mnb,
gtk_paned_set_position (GTK_PANED (paned),
allocation.width / 2);
/* check if we need to uncollapse the active notebook */
if (active_notebook == g_list_last (mnb->priv->notebooks)->data &&
mnb->priv->collapse)
{
collapse_new_notebook = TRUE;
gedit_notebook_collapse_border (GEDIT_NOTEBOOK (active_notebook),
FALSE);
}
active_nb_pos = g_list_index (mnb->priv->notebooks,
active_notebook);
mnb->priv->notebooks = g_list_insert (mnb->priv->notebooks,
notebook,
active_nb_pos + 1);
if (collapse_new_notebook)
{
gedit_notebook_collapse_border (GEDIT_NOTEBOOK (notebook),
TRUE);
}
}
gtk_widget_show (notebook);
......@@ -513,6 +530,10 @@ remove_notebook (GeditMultiNotebook *mnb,
else
{
new_notebook = GTK_WIDGET (mnb->priv->notebooks->data);
/* we must check if we need to collapse the new last notebook */
gedit_notebook_collapse_border (GEDIT_NOTEBOOK (current->prev->data),
mnb->priv->collapse);
}
parent = gtk_widget_get_parent (notebook);
......@@ -881,6 +902,21 @@ gedit_multi_notebook_next_notebook (GeditMultiNotebook *mnb)
gtk_widget_grab_focus (notebook);
}
void
gedit_multi_notebook_collapse_notebook_border (GeditMultiNotebook *mnb,
gboolean collapse)
{
GeditNotebook *notebook;
g_return_if_fail (GEDIT_IS_MULTI_NOTEBOOK (mnb));
mnb->priv->collapse = (collapse != FALSE);
notebook = GEDIT_NOTEBOOK (g_list_last (mnb->priv->notebooks)->data);
gedit_notebook_collapse_border (notebook, collapse);
}
void
gedit_multi_notebook_foreach_notebook (GeditMultiNotebook *mnb,
GtkCallback callback,
......
......@@ -124,6 +124,9 @@ void gedit_multi_notebook_remove_active_notebook (GeditMultiNotebook *mnb);
void gedit_multi_notebook_previous_notebook (GeditMultiNotebook *mnb);
void gedit_multi_notebook_next_notebook (GeditMultiNotebook *mnb);
void gedit_multi_notebook_collapse_notebook_border (GeditMultiNotebook *mnb,
gboolean collapse);
void gedit_multi_notebook_foreach_notebook (GeditMultiNotebook *mnb,
GtkCallback callback,
gpointer callback_data);
......
......@@ -741,4 +741,66 @@ gedit_notebook_get_close_buttons_sensitive (GeditNotebook *nb)
return nb->priv->close_buttons_sensitive;
}
static void
remove_right_padding (GeditNotebook *nb)
{
GtkStyleContext *context;
GtkBorder padding;
gchar *modified_style;
GError *error = NULL;
const gchar style[] =
".notebook {\n"
"padding: %d 0 %d %d;\n"
"}";
/* FIXME: find out a css like way to do this, right now padding-right/left
doesn't work */
context = gtk_widget_get_style_context (GTK_WIDGET (nb));
gtk_style_context_get_padding (context, gtk_style_context_get_state (context),
&padding);
modified_style = g_strdup_printf (style, padding.top, padding.bottom, padding.left);
/* make it as small as possible */
if (nb->priv->css == NULL)
{
nb->priv->css = gtk_css_provider_new ();
}
if (gtk_css_provider_load_from_data (nb->priv->css, modified_style, -1, &error))
{
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (nb->priv->css),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
else
{
g_warning ("%s", error->message);
g_error_free (error);
}
g_free (modified_style);
}
void
gedit_notebook_collapse_border (GeditNotebook *nb,
gboolean collapse)
{
g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
if (collapse)
{
remove_right_padding (nb);
}
/* if we made some modification put it back to the default state */
else if (nb->priv->css != NULL)
{
GtkStyleContext *context;
context = gtk_widget_get_style_context (GTK_WIDGET (nb));
gtk_style_context_remove_provider (context,
GTK_STYLE_PROVIDER (nb->priv->css));
}
}
/* ex:set ts=8 noet: */
......@@ -120,6 +120,9 @@ void gedit_notebook_set_close_buttons_sensitive
gboolean gedit_notebook_get_close_buttons_sensitive
(GeditNotebook *nb);
void gedit_notebook_collapse_border (GeditNotebook *nb,
gboolean collapse);
G_END_DECLS
#endif /* GEDIT_NOTEBOOK_H */
......
......@@ -348,7 +348,22 @@ gedit_window_window_state_event (GtkWidget *widget,
g_settings_set_int (window->priv->window_settings, GEDIT_SETTINGS_WINDOW_STATE,
window->priv->window_state);
return GTK_WIDGET_CLASS (gedit_window_parent_class)->window_state_event (widget, event);
if ((event->changed_mask &
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) != 0)
{
gboolean show;
show = !(event->new_window_state &
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN));
gedit_multi_notebook_collapse_notebook_border (window->priv->multi_notebook,
!show);
}
if (GTK_WIDGET_CLASS (gedit_window_parent_class)->window_state_event)
return GTK_WIDGET_CLASS (gedit_window_parent_class)->window_state_event (widget, event);
return FALSE;
}
static gboolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment