Commit e9343d93 authored by Steve Frécinaux's avatar Steve Frécinaux Committed by Paolo Borelli

handle the visibility changes of panels, toolbar and statusbar connecting

2006-02-12  Steve Frécinaux <steve@istique.net>

	* gedit/gedit-window.[ch]: handle the visibility changes of panels,
	toolbar and statusbar connecting to the show and hide signals.

	* gedit/gedit-commands-view.c:
	* gedit/gedit-session.c:

	adapt for above changes (use directly gtk_widget_show/hide instead of a
	custom function)
parent 1d3f5029
2006-02-12 Steve Frécinaux <steve@istique.net>
* gedit/gedit-window.[ch]: handle the visibility changes of panels,
toolbar and statusbar connecting to the show and hide signals.
* gedit/gedit-commands-view.c:
* gedit/gedit-session.c:
adapt for above changes (use directly gtk_widget_show/hide instead of a
custom function)
2006-02-12 Paolo Maggi <paolo@gnome.org>
* plugins/externaltools/tools/tools.glade: use GTK_SHADOW_IN for
......
......@@ -37,8 +37,10 @@
#include <gtk/gtk.h>
#include "gedit-commands.h"
#include "gedit-window.h"
#include "gedit-debug.h"
#include "gedit-window.h"
#include "gedit-window-private.h"
void
gedit_cmd_view_show_toolbar (GtkAction *action,
......@@ -50,7 +52,10 @@ gedit_cmd_view_show_toolbar (GtkAction *action,
visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
_gedit_window_set_toolbar_visible (window, visible);
if (visible)
gtk_widget_show (window->priv->toolbar);
else
gtk_widget_hide (window->priv->toolbar);
}
void
......@@ -63,7 +68,10 @@ gedit_cmd_view_show_statusbar (GtkAction *action,
visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
_gedit_window_set_statusbar_visible (window, visible);
if (visible)
gtk_widget_show (window->priv->statusbar);
else
gtk_widget_hide (window->priv->statusbar);
}
void
......@@ -71,12 +79,23 @@ gedit_cmd_view_show_side_pane (GtkAction *action,
GeditWindow *window)
{
gboolean visible;
GeditPanel *panel;
gedit_debug (DEBUG_COMMANDS);
visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
_gedit_window_set_side_panel_visible (window, visible);
panel = gedit_window_get_side_panel (window);
if (visible)
{
gtk_widget_show (panel);
gtk_widget_grab_focus (panel);
}
else
{
gtk_widget_hide (panel);
}
}
void
......@@ -84,10 +103,21 @@ gedit_cmd_view_show_bottom_panel (GtkAction *action,
GeditWindow *window)
{
gboolean visible;
GeditPanel *panel;
gedit_debug (DEBUG_COMMANDS);
visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
_gedit_window_set_bottom_panel_visible (window, visible);
panel = gedit_window_get_bottom_panel (window);
if (visible)
{
gtk_widget_show (panel);
gtk_widget_grab_focus (panel);
}
else
{
gtk_widget_hide (panel);
}
}
......@@ -694,22 +694,21 @@ parse_window (xmlNodePtr node)
if (strcmp ((char *) child->name, "side-pane") == 0)
{
xmlChar *visible;
GeditPanel *panel;
visible = xmlGetProp (child, (const xmlChar *) "visible");
panel = gedit_window_get_side_panel (window);
if ((visible != NULL) &&
(strcmp ((char *) visible, "yes") == 0))
{
gedit_debug_message (DEBUG_SESSION, "Side panel visible");
_gedit_window_set_side_panel_visible (window,
TRUE);
gtk_widget_show (GTK_WIDGET (panel));
}
else
{
gedit_debug_message (DEBUG_SESSION, "Side panel _NOT_ visible");
_gedit_window_set_side_panel_visible (window,
FALSE);
gtk_widget_hide (GTK_WIDGET (panel));
}
if (visible != NULL)
......@@ -718,22 +717,21 @@ parse_window (xmlNodePtr node)
else if (strcmp ((char *) child->name, "bottom-panel") == 0)
{
xmlChar *visible;
GeditPanel *panel;
visible = xmlGetProp (child, (const xmlChar *) "visible");
panel = gedit_window_get_bottom_panel (window);
if ((visible != NULL) &&
(strcmp ((char *) visible, "yes") == 0))
{
gedit_debug_message (DEBUG_SESSION, "Bottom panel visible");
_gedit_window_set_bottom_panel_visible (window,
TRUE);
gtk_widget_show (GTK_WIDGET (panel));
}
else
{
gedit_debug_message (DEBUG_SESSION, "Bottom panel _NOT_ visible");
_gedit_window_set_bottom_panel_visible (window,
FALSE);
gtk_widget_hide (GTK_WIDGET (panel));
}
if (visible != NULL)
......
......@@ -929,6 +929,25 @@ set_non_homogeneus (GtkWidget *widget, gpointer data)
gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (widget), FALSE);
}
static void
toolbar_visibility_changed (GtkWidget *toolbar,
GeditWindow *window)
{
gboolean visible;
GtkAction *action;
visible = GTK_WIDGET_VISIBLE (toolbar);
if (gedit_prefs_manager_toolbar_visible_can_set ())
gedit_prefs_manager_set_toolbar_visible (visible);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
"ViewToolbar");
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
}
static void
create_menu_bar_and_toolbar (GeditWindow *window,
GtkWidget *main_box)
......@@ -1104,7 +1123,16 @@ create_menu_bar_and_toolbar (GeditWindow *window,
gtk_container_foreach (GTK_CONTAINER (window->priv->toolbar),
(GtkCallback)set_non_homogeneus,
NULL);
NULL);
g_signal_connect_after (G_OBJECT (window->priv->toolbar),
"show",
G_CALLBACK (toolbar_visibility_changed),
window);
g_signal_connect_after (G_OBJECT (window->priv->toolbar),
"hide",
G_CALLBACK (toolbar_visibility_changed),
window);
}
static void
......@@ -1250,6 +1278,25 @@ set_statusbar_style (GeditWindow *window,
return visible;
}
static void
statusbar_visibility_changed (GtkWidget *statusbar,
GeditWindow *window)
{
gboolean visible;
GtkAction *action;
visible = GTK_WIDGET_VISIBLE (statusbar);
if (gedit_prefs_manager_statusbar_visible_can_set ())
gedit_prefs_manager_set_statusbar_visible (visible);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
"ViewStatusbar");
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
}
static void
create_statusbar (GeditWindow *window,
GtkWidget *main_box)
......@@ -1267,9 +1314,18 @@ create_statusbar (GeditWindow *window,
window->priv->statusbar,
FALSE,
TRUE,
0);
0);
g_signal_connect_after (G_OBJECT (window->priv->statusbar),
"show",
G_CALLBACK (statusbar_visibility_changed),
window);
g_signal_connect_after (G_OBJECT (window->priv->statusbar),
"hide",
G_CALLBACK (statusbar_visibility_changed),
window);
set_statusbar_style (window, NULL);
set_statusbar_style (window, NULL);
}
static GeditWindow *
......@@ -2430,6 +2486,30 @@ vpaned_restore_position (GtkWidget *widget,
g_signal_handlers_disconnect_by_func (widget, vpaned_restore_position, window);
}
static void
side_panel_visibility_changed (GtkWidget *side_panel,
GeditWindow *window)
{
gboolean visible;
GtkAction *action;
visible = GTK_WIDGET_VISIBLE (side_panel);
if (gedit_prefs_manager_side_pane_visible_can_set ())
gedit_prefs_manager_set_side_pane_visible (visible);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
"ViewSidePane");
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
/* focus the document */
if (!visible && window->priv->active_tab != NULL)
gtk_widget_grab_focus (GTK_WIDGET (
gedit_tab_get_view (GEDIT_TAB (window->priv->active_tab))));
}
static void
side_panel_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
......@@ -2438,13 +2518,6 @@ side_panel_size_allocate (GtkWidget *widget,
window->priv->side_panel_size = allocation->width;
}
static void
side_panel_hide (GtkWidget *panel,
GeditWindow *window)
{
_gedit_window_set_side_panel_visible (window, FALSE);
}
static void
create_side_panel (GeditWindow *window)
{
......@@ -2461,14 +2534,18 @@ create_side_panel (GeditWindow *window)
gtk_widget_set_size_request (window->priv->side_panel, 100, -1);
g_signal_connect (window->priv->side_panel,
"size_allocate",
"size-allocate",
G_CALLBACK (side_panel_size_allocate),
window);
g_signal_connect (window->priv->side_panel,
"hide",
G_CALLBACK (side_panel_hide),
window);
g_signal_connect_after (window->priv->side_panel,
"show",
G_CALLBACK (side_panel_visibility_changed),
window);
g_signal_connect_after (window->priv->side_panel,
"hide",
G_CALLBACK (side_panel_visibility_changed),
window);
gtk_paned_set_position (GTK_PANED (window->priv->hpaned),
MAX (100, gedit_prefs_manager_get_side_panel_size ()));
......@@ -2481,18 +2558,35 @@ create_side_panel (GeditWindow *window)
}
static void
bottom_panel_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
GeditWindow *window)
bottom_panel_visibility_changed (GeditPanel *bottom_panel,
GeditWindow *window)
{
window->priv->bottom_panel_size = allocation->height;
gboolean visible;
GtkAction *action;
visible = GTK_WIDGET_VISIBLE (bottom_panel);
if (gedit_prefs_manager_bottom_panel_visible_can_set ())
gedit_prefs_manager_set_bottom_panel_visible (visible);
action = gtk_action_group_get_action (window->priv->action_group,
"ViewBottomPanel");
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
/* focus the document */
if (!visible && window->priv->active_tab != NULL)
gtk_widget_grab_focus (GTK_WIDGET (
gedit_tab_get_view (GEDIT_TAB (window->priv->active_tab))));
}
static void
bottom_panel_hide (GtkWidget *panel,
GeditWindow *window)
bottom_panel_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
GeditWindow *window)
{
_gedit_window_set_bottom_panel_visible (window, FALSE);
window->priv->bottom_panel_size = allocation->height;
}
static void
......@@ -2504,7 +2598,7 @@ bottom_panel_item_removed (GeditPanel *panel,
{
GtkAction *action;
_gedit_window_set_bottom_panel_visible (window, FALSE);
gtk_widget_hide (GTK_WIDGET (panel));
action = gtk_action_group_get_action (window->priv->action_group,
"ViewBottomPanel");
......@@ -2529,7 +2623,8 @@ bottom_panel_item_added (GeditPanel *panel,
gtk_action_set_sensitive (action, TRUE);
show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
_gedit_window_set_bottom_panel_visible (window, show);
if (show)
gtk_widget_show (GTK_WIDGET (panel));
}
}
......@@ -2546,54 +2641,43 @@ create_bottom_panel (GeditWindow *window)
FALSE);
g_signal_connect (window->priv->bottom_panel,
"size_allocate",
"size-allocate",
G_CALLBACK (bottom_panel_size_allocate),
window);
g_signal_connect (window->priv->bottom_panel,
"hide",
G_CALLBACK (bottom_panel_hide),
window);
g_signal_connect_after (window->priv->bottom_panel,
"show",
G_CALLBACK (bottom_panel_visibility_changed),
window);
g_signal_connect_after (window->priv->bottom_panel,
"hide",
G_CALLBACK (bottom_panel_visibility_changed),
window);
gtk_paned_set_position (GTK_PANED (window->priv->vpaned),
MAX (50, gedit_prefs_manager_get_bottom_panel_size ()));
}
static void
init_panes_visibility (GeditWindow *window)
init_panels_visibility (GeditWindow *window)
{
GtkAction *action;
gboolean visible;
gedit_debug (DEBUG_WINDOW);
/* side pane */
visible = gedit_prefs_manager_get_side_pane_visible ();
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
"ViewSidePane");
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
if (visible)
if (gedit_prefs_manager_get_side_pane_visible ())
gtk_widget_show (window->priv->side_panel);
/* bottom pane, it can be empty */
action = gtk_action_group_get_action (window->priv->action_group,
"ViewBottomPanel");
if (gedit_panel_get_n_items (GEDIT_PANEL (window->priv->bottom_panel)) > 0)
{
visible = gedit_prefs_manager_get_bottom_panel_visible();
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
if(visible)
if (gedit_prefs_manager_get_bottom_panel_visible ())
gtk_widget_show (window->priv->bottom_panel);
}
else
{
GtkAction *action;
action = gtk_action_group_get_action (window->priv->action_group,
"ViewBottomPanel");
gtk_action_set_sensitive (action, FALSE);
}
......@@ -2739,7 +2823,7 @@ gedit_window_init (GeditWindow *window)
/* set visibility of panes.
* This needs to be done after plugins activatation */
init_panes_visibility (window);
init_panels_visibility (window);
gedit_debug_message (DEBUG_WINDOW, "END");
}
......@@ -2930,193 +3014,21 @@ gedit_window_close_tabs (GeditWindow *window,
if (tabs == NULL)
return;
window->priv->removing_tabs = TRUE;
while (tabs != NULL)
{
if (tabs->next == NULL)
window->priv->removing_tabs = FALSE;
gedit_notebook_remove_tab (GEDIT_NOTEBOOK (window->priv->notebook),
GEDIT_TAB (tabs->data));
tabs = g_list_next (tabs);
}
g_return_if_fail (window->priv->removing_tabs == FALSE);
}
void
_gedit_window_set_statusbar_visible (GeditWindow *window,
gboolean visible)
{
GtkAction *action;
static gboolean recursion_guard = FALSE;
gedit_debug (DEBUG_WINDOW);
g_return_if_fail (GEDIT_IS_WINDOW (window));
if (recursion_guard)
return;
recursion_guard = TRUE;
visible = (visible != FALSE);
if (visible)
gtk_widget_show (window->priv->statusbar);
else
gtk_widget_hide (window->priv->statusbar);
if (gedit_prefs_manager_statusbar_visible_can_set ())
gedit_prefs_manager_set_statusbar_visible (visible);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
"ViewStatusbar");
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
recursion_guard = FALSE;
}
void
_gedit_window_set_toolbar_visible (GeditWindow *window,
gboolean visible)
{
GtkAction *action;
static gboolean recursion_guard = FALSE;
gedit_debug (DEBUG_WINDOW);
g_return_if_fail (GEDIT_IS_WINDOW (window));
if (recursion_guard)
return;
recursion_guard = TRUE;
visible = (visible != FALSE);
if (visible)
gtk_widget_show (window->priv->toolbar);
else
gtk_widget_hide (window->priv->toolbar);
if (gedit_prefs_manager_toolbar_visible_can_set ())
gedit_prefs_manager_set_toolbar_visible (visible);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
"ViewToolbar");
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
recursion_guard = FALSE;
}
void
_gedit_window_set_side_panel_visible (GeditWindow *window,
gboolean visible)
{
GtkAction *action;
static gboolean recursion_guard = FALSE;
gboolean show = FALSE;
gedit_debug (DEBUG_WINDOW);
g_return_if_fail (GEDIT_IS_WINDOW (window));
if (recursion_guard)
return;
recursion_guard = TRUE;
visible = (visible != FALSE);
if (visible &&
(GTK_WIDGET_VISIBLE (window->priv->side_panel) != visible))
{
gtk_widget_show (window->priv->side_panel);
show = TRUE;
}
else
{
gtk_widget_hide (window->priv->side_panel);
if (window->priv->active_tab)
gtk_widget_grab_focus (GTK_WIDGET (
gedit_tab_get_view (GEDIT_TAB (window->priv->active_tab))));
}
if (gedit_prefs_manager_side_pane_visible_can_set ())
gedit_prefs_manager_set_side_pane_visible (visible);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
"ViewSidePane");
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
if (show)
{
/* g_print ("GRAB side panel\n"); */
gtk_widget_grab_focus (window->priv->side_panel);
}
recursion_guard = FALSE;
}
void
_gedit_window_set_bottom_panel_visible (GeditWindow *window,
gboolean visible)
{
GtkAction *action;
static gboolean recursion_guard = FALSE;
gboolean show = FALSE;
gedit_debug (DEBUG_WINDOW);
g_return_if_fail (GEDIT_IS_WINDOW (window));
if (recursion_guard)
return;
recursion_guard = TRUE;
visible = (visible != FALSE);
if (visible &&
(GTK_WIDGET_VISIBLE (window->priv->bottom_panel) != visible))
{
gtk_widget_show (window->priv->bottom_panel);
show = TRUE;
}
else
{
gtk_widget_hide (window->priv->bottom_panel);
if (window->priv->active_tab)
gtk_widget_grab_focus (GTK_WIDGET (
gedit_tab_get_view (GEDIT_TAB (window->priv->active_tab))));
}
if (gedit_prefs_manager_bottom_panel_visible_can_set ())
gedit_prefs_manager_set_bottom_panel_visible (visible);
action = gtk_action_group_get_action (window->priv->action_group,
"ViewBottomPanel");
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
if (show)
{
/* g_print ("GRAB bottom panel\n"); */
gtk_widget_grab_focus (window->priv->bottom_panel);
}
recursion_guard = FALSE;
g_return_if_fail (window->priv->removing_tabs == FALSE);
}
GeditWindow *
......
......@@ -155,14 +155,6 @@ GeditWindowState gedit_window_get_state (GeditWindow *window);
*/
GtkWidget *_gedit_window_get_notebook (GeditWindow *window);
void _gedit_window_set_statusbar_visible (GeditWindow *window,
gboolean visible);
void _gedit_window_set_toolbar_visible (GeditWindow *window,
gboolean visible);
void _gedit_window_set_side_panel_visible (GeditWindow *window,
gboolean visible);
void _gedit_window_set_bottom_panel_visible (GeditWindow *window,
gboolean visible);
GeditWindow *_gedit_window_move_tab_to_new_window (GeditWindow *window,
GeditTab *tab);
gboolean _gedit_window_is_removing_tabs (GeditWindow *window);
......
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