Commit 632b7f8a authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/display/gimpdisplayshell-callbacks.c app/display/gimpdisplayshell.[ch]

2003-03-11  Sven Neumann  <sven@gimp.org>

	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell.[ch]
	* app/gui/image-menu.c
	* app/gui/view-commands.[ch]: added a fullscreen mode for the
	image display by means of gtk_window_fullscreen/unfullscreen.
	Depends on the window manager implementing _NET_WM_STATE_FULLSCREEN.

	* app/tools/gimpcroptool.c: made gimp_crop_tool_draw() static.

	* app/tools/gimptexttool.[ch]: derive from GimpDrawTool, no real
	changes yet.
parent c21f8924
2003-03-11 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell.[ch]
* app/gui/image-menu.c
* app/gui/view-commands.[ch]: added a fullscreen mode for the
image display by means of gtk_window_fullscreen/unfullscreen.
Depends on the window manager implementing _NET_WM_STATE_FULLSCREEN.
* app/tools/gimpcroptool.c: made gimp_crop_tool_draw() static.
* app/tools/gimptexttool.[ch]: derive from GimpDrawTool, no real
changes yet.
2003-03-10 Sven Neumann <sven@gimp.org>
 
* plug-ins/common/xpm.c: don't add a transparent color entry for
......@@ -121,6 +121,29 @@ view_dot_for_dot_cmd_callback (GtkWidget *widget,
}
}
void
view_fullscreen_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
GimpDisplayShell *shell;
gboolean fullscreen;
return_if_no_display (gdisp, data);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_display_shell_toggle_fullscreen (shell);
fullscreen = shell->window_state & GDK_WINDOW_STATE_FULLSCREEN;
gimp_item_factory_set_active (GTK_ITEM_FACTORY (shell->menubar_factory),
"/View/Fullscreen",
fullscreen);
gimp_item_factory_set_active (GTK_ITEM_FACTORY (shell->popup_factory),
"/View/Fullscreen",
fullscreen);
}
void
view_info_window_cmd_callback (GtkWidget *widget,
gpointer data)
......
......@@ -31,6 +31,8 @@ void view_zoom_cmd_callback (GtkWidget *widget,
guint action);
void view_dot_for_dot_cmd_callback (GtkWidget *widget,
gpointer data);
void view_fullscreen_cmd_callback (GtkWidget *widget,
gpointer data);
void view_info_window_cmd_callback (GtkWidget *widget,
gpointer data);
void view_navigation_window_cmd_callback (GtkWidget *widget,
......
......@@ -165,6 +165,11 @@ gimp_display_shell_events (GtkWidget *widget,
case GDK_Control_L: case GDK_Control_R:
break;
case GDK_Escape:
if (shell->window_state & GDK_WINDOW_STATE_FULLSCREEN)
gimp_display_shell_toggle_fullscreen (shell);
break;
default:
if (shell->space_pressed)
return TRUE;
......@@ -179,6 +184,26 @@ gimp_display_shell_events (GtkWidget *widget,
set_display = TRUE;
break;
case GDK_WINDOW_STATE:
{
GdkEventWindowState *sevent;
gboolean fullscreen;
sevent = (GdkEventWindowState *) event;
shell->window_state = sevent->new_window_state;
fullscreen = shell->window_state & GDK_WINDOW_STATE_FULLSCREEN;
gimp_item_factory_set_active (GTK_ITEM_FACTORY (shell->menubar_factory),
"/View/Fullscreen",
fullscreen);
gimp_item_factory_set_active (GTK_ITEM_FACTORY (shell->popup_factory),
"/View/Fullscreen",
fullscreen);
}
break;
default:
break;
}
......
......@@ -252,6 +252,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->space_pressed = FALSE;
shell->space_release_pending = FALSE;
shell->window_state = 0;
gtk_window_set_wmclass (GTK_WINDOW (shell), "image_window", "Gimp");
gtk_window_set_resizable (GTK_WINDOW (shell), TRUE);
......@@ -271,6 +273,9 @@ gimp_display_shell_init (GimpDisplayShell *shell)
g_signal_connect (shell, "key_press_event",
G_CALLBACK (gimp_display_shell_events),
shell);
g_signal_connect (shell, "window_state_event",
G_CALLBACK (gimp_display_shell_events),
shell);
/* dnd stuff */
gimp_dnd_viewable_dest_add (GTK_WIDGET (shell), GIMP_TYPE_LAYER,
......@@ -1395,98 +1400,6 @@ gimp_display_shell_draw_guides (GimpDisplayShell *shell)
}
}
void
gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
{
gint disp_width, disp_height;
gint width, height;
gint shell_width, shell_height;
gint max_auto_width, max_auto_height;
gint border_x, border_y;
gint s_width, s_height;
gboolean resize = FALSE;
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
width = SCALEX (shell, shell->gdisp->gimage->width);
height = SCALEY (shell, shell->gdisp->gimage->height);
disp_width = shell->disp_width;
disp_height = shell->disp_height;
shell_width = GTK_WIDGET (shell)->allocation.width;
shell_height = GTK_WIDGET (shell)->allocation.height;
border_x = shell_width - disp_width;
border_y = shell_height - disp_height;
max_auto_width = (s_width - border_x) * 0.75;
max_auto_height = (s_height - border_y) * 0.75;
/* If one of the display dimensions has changed and one of the
* dimensions fits inside the screen
*/
if (((width + border_x) < s_width || (height + border_y) < s_height) &&
(width != disp_width || height != disp_height))
{
width = ((width + border_x) < s_width) ? width : max_auto_width;
height = ((height + border_y) < s_height) ? height : max_auto_height;
resize = TRUE;
}
/* If the projected dimension is greater than current, but less than
* 3/4 of the screen size, expand automagically
*/
else if ((width > disp_width || height > disp_height) &&
(disp_width < max_auto_width || disp_height < max_auto_height))
{
width = MIN (max_auto_width, width);
height = MIN (max_auto_height, height);
resize = TRUE;
}
if (resize)
{
if (width < shell->statusbar->requisition.width)
width = shell->statusbar->requisition.width;
gtk_window_resize (GTK_WINDOW (shell),
width + border_x,
height + border_y);
}
}
void
gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
GimpSelectionControl control)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (shell->select)
{
switch (control)
{
case GIMP_SELECTION_OFF:
gimp_display_shell_selection_invis (shell->select);
break;
case GIMP_SELECTION_LAYER_OFF:
gimp_display_shell_selection_layer_invis (shell->select);
break;
case GIMP_SELECTION_ON:
gimp_display_shell_selection_start (shell->select, TRUE);
break;
case GIMP_SELECTION_PAUSE:
gimp_display_shell_selection_pause (shell->select);
break;
case GIMP_SELECTION_RESUME:
gimp_display_shell_selection_resume (shell->select);
break;
}
}
}
void
gimp_display_shell_draw_area (GimpDisplayShell *shell,
gint x,
......@@ -1622,6 +1535,107 @@ gimp_display_shell_draw_cursor (GimpDisplayShell *shell)
x+1, y - 7, x+1, y + 7);
}
void
gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
{
gint disp_width, disp_height;
gint width, height;
gint shell_width, shell_height;
gint max_auto_width, max_auto_height;
gint border_x, border_y;
gint s_width, s_height;
gboolean resize = FALSE;
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
width = SCALEX (shell, shell->gdisp->gimage->width);
height = SCALEY (shell, shell->gdisp->gimage->height);
disp_width = shell->disp_width;
disp_height = shell->disp_height;
shell_width = GTK_WIDGET (shell)->allocation.width;
shell_height = GTK_WIDGET (shell)->allocation.height;
border_x = shell_width - disp_width;
border_y = shell_height - disp_height;
max_auto_width = (s_width - border_x) * 0.75;
max_auto_height = (s_height - border_y) * 0.75;
/* If one of the display dimensions has changed and one of the
* dimensions fits inside the screen
*/
if (((width + border_x) < s_width || (height + border_y) < s_height) &&
(width != disp_width || height != disp_height))
{
width = ((width + border_x) < s_width) ? width : max_auto_width;
height = ((height + border_y) < s_height) ? height : max_auto_height;
resize = TRUE;
}
/* If the projected dimension is greater than current, but less than
* 3/4 of the screen size, expand automagically
*/
else if ((width > disp_width || height > disp_height) &&
(disp_width < max_auto_width || disp_height < max_auto_height))
{
width = MIN (max_auto_width, width);
height = MIN (max_auto_height, height);
resize = TRUE;
}
if (resize)
{
if (width < shell->statusbar->requisition.width)
width = shell->statusbar->requisition.width;
gtk_window_resize (GTK_WINDOW (shell),
width + border_x,
height + border_y);
}
}
void
gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
GimpSelectionControl control)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (shell->select)
{
switch (control)
{
case GIMP_SELECTION_OFF:
gimp_display_shell_selection_invis (shell->select);
break;
case GIMP_SELECTION_LAYER_OFF:
gimp_display_shell_selection_layer_invis (shell->select);
break;
case GIMP_SELECTION_ON:
gimp_display_shell_selection_start (shell->select, TRUE);
break;
case GIMP_SELECTION_PAUSE:
gimp_display_shell_selection_pause (shell->select);
break;
case GIMP_SELECTION_RESUME:
gimp_display_shell_selection_resume (shell->select);
break;
}
}
}
void
gimp_display_shell_toggle_fullscreen (GimpDisplayShell *shell)
{
if (shell->window_state & GDK_WINDOW_STATE_FULLSCREEN)
gtk_window_unfullscreen (GTK_WINDOW (shell));
else
gtk_window_fullscreen (GTK_WINDOW (shell));
}
/* private functions */
......
......@@ -147,6 +147,8 @@ struct _GimpDisplayShell
/* the state of gimp_display_shell_tool_events() */
gboolean space_pressed;
gboolean space_release_pending;
GdkWindowState window_state; /* for fullscreen display */
};
struct _GimpDisplayShellClass
......@@ -231,6 +233,7 @@ void gimp_display_shell_shrink_wrap (GimpDisplayShell *shell);
void gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
GimpSelectionControl control);
void gimp_display_shell_toggle_fullscreen (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_H__ */
......@@ -252,6 +252,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->space_pressed = FALSE;
shell->space_release_pending = FALSE;
shell->window_state = 0;
gtk_window_set_wmclass (GTK_WINDOW (shell), "image_window", "Gimp");
gtk_window_set_resizable (GTK_WINDOW (shell), TRUE);
......@@ -271,6 +273,9 @@ gimp_display_shell_init (GimpDisplayShell *shell)
g_signal_connect (shell, "key_press_event",
G_CALLBACK (gimp_display_shell_events),
shell);
g_signal_connect (shell, "window_state_event",
G_CALLBACK (gimp_display_shell_events),
shell);
/* dnd stuff */
gimp_dnd_viewable_dest_add (GTK_WIDGET (shell), GIMP_TYPE_LAYER,
......@@ -1395,98 +1400,6 @@ gimp_display_shell_draw_guides (GimpDisplayShell *shell)
}
}
void
gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
{
gint disp_width, disp_height;
gint width, height;
gint shell_width, shell_height;
gint max_auto_width, max_auto_height;
gint border_x, border_y;
gint s_width, s_height;
gboolean resize = FALSE;
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
width = SCALEX (shell, shell->gdisp->gimage->width);
height = SCALEY (shell, shell->gdisp->gimage->height);
disp_width = shell->disp_width;
disp_height = shell->disp_height;
shell_width = GTK_WIDGET (shell)->allocation.width;
shell_height = GTK_WIDGET (shell)->allocation.height;
border_x = shell_width - disp_width;
border_y = shell_height - disp_height;
max_auto_width = (s_width - border_x) * 0.75;
max_auto_height = (s_height - border_y) * 0.75;
/* If one of the display dimensions has changed and one of the
* dimensions fits inside the screen
*/
if (((width + border_x) < s_width || (height + border_y) < s_height) &&
(width != disp_width || height != disp_height))
{
width = ((width + border_x) < s_width) ? width : max_auto_width;
height = ((height + border_y) < s_height) ? height : max_auto_height;
resize = TRUE;
}
/* If the projected dimension is greater than current, but less than
* 3/4 of the screen size, expand automagically
*/
else if ((width > disp_width || height > disp_height) &&
(disp_width < max_auto_width || disp_height < max_auto_height))
{
width = MIN (max_auto_width, width);
height = MIN (max_auto_height, height);
resize = TRUE;
}
if (resize)
{
if (width < shell->statusbar->requisition.width)
width = shell->statusbar->requisition.width;
gtk_window_resize (GTK_WINDOW (shell),
width + border_x,
height + border_y);
}
}
void
gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
GimpSelectionControl control)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (shell->select)
{
switch (control)
{
case GIMP_SELECTION_OFF:
gimp_display_shell_selection_invis (shell->select);
break;
case GIMP_SELECTION_LAYER_OFF:
gimp_display_shell_selection_layer_invis (shell->select);
break;
case GIMP_SELECTION_ON:
gimp_display_shell_selection_start (shell->select, TRUE);
break;
case GIMP_SELECTION_PAUSE:
gimp_display_shell_selection_pause (shell->select);
break;
case GIMP_SELECTION_RESUME:
gimp_display_shell_selection_resume (shell->select);
break;
}
}
}
void
gimp_display_shell_draw_area (GimpDisplayShell *shell,
gint x,
......@@ -1622,6 +1535,107 @@ gimp_display_shell_draw_cursor (GimpDisplayShell *shell)
x+1, y - 7, x+1, y + 7);
}
void
gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
{
gint disp_width, disp_height;
gint width, height;
gint shell_width, shell_height;
gint max_auto_width, max_auto_height;
gint border_x, border_y;
gint s_width, s_height;
gboolean resize = FALSE;
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
width = SCALEX (shell, shell->gdisp->gimage->width);
height = SCALEY (shell, shell->gdisp->gimage->height);
disp_width = shell->disp_width;
disp_height = shell->disp_height;
shell_width = GTK_WIDGET (shell)->allocation.width;
shell_height = GTK_WIDGET (shell)->allocation.height;
border_x = shell_width - disp_width;
border_y = shell_height - disp_height;
max_auto_width = (s_width - border_x) * 0.75;
max_auto_height = (s_height - border_y) * 0.75;
/* If one of the display dimensions has changed and one of the
* dimensions fits inside the screen
*/
if (((width + border_x) < s_width || (height + border_y) < s_height) &&
(width != disp_width || height != disp_height))
{
width = ((width + border_x) < s_width) ? width : max_auto_width;
height = ((height + border_y) < s_height) ? height : max_auto_height;
resize = TRUE;
}
/* If the projected dimension is greater than current, but less than
* 3/4 of the screen size, expand automagically
*/
else if ((width > disp_width || height > disp_height) &&
(disp_width < max_auto_width || disp_height < max_auto_height))
{
width = MIN (max_auto_width, width);
height = MIN (max_auto_height, height);
resize = TRUE;
}
if (resize)
{
if (width < shell->statusbar->requisition.width)
width = shell->statusbar->requisition.width;
gtk_window_resize (GTK_WINDOW (shell),
width + border_x,
height + border_y);
}
}
void
gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
GimpSelectionControl control)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (shell->select)
{
switch (control)
{
case GIMP_SELECTION_OFF:
gimp_display_shell_selection_invis (shell->select);
break;
case GIMP_SELECTION_LAYER_OFF:
gimp_display_shell_selection_layer_invis (shell->select);
break;
case GIMP_SELECTION_ON:
gimp_display_shell_selection_start (shell->select, TRUE);
break;
case GIMP_SELECTION_PAUSE:
gimp_display_shell_selection_pause (shell->select);
break;
case GIMP_SELECTION_RESUME:
gimp_display_shell_selection_resume (shell->select);
break;
}
}
}
void
gimp_display_shell_toggle_fullscreen (GimpDisplayShell *shell)
{
if (shell->window_state & GDK_WINDOW_STATE_FULLSCREEN)
gtk_window_unfullscreen (GTK_WINDOW (shell));
else
gtk_window_fullscreen (GTK_WINDOW (shell));
}
/* private functions */
......
......@@ -147,6 +147,8 @@ struct _GimpDisplayShell
/* the state of gimp_display_shell_tool_events() */
gboolean space_pressed;
gboolean space_release_pending;
GdkWindowState window_state; /* for fullscreen display */
};
struct _GimpDisplayShellClass
......@@ -231,6 +233,7 @@ void gimp_display_shell_shrink_wrap (GimpDisplayShell *shell);
void gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
GimpSelectionControl control);
void gimp_display_shell_toggle_fullscreen (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_H__ */
......@@ -355,6 +355,11 @@ GimpItemFactoryEntry image_menu_entries[] =
NULL,
"view/dot_for_dot.html", NULL },
{ { N_("/View/Fullscreen"), "F11",
view_fullscreen_cmd_callback, 0, "<ToggleItem>" },
NULL,
"view/fullscreen.html", NULL },
MENU_SEPARATOR ("/View/---"),
{ { N_("/View/Info Window..."), "<control><shift>I",
......@@ -1255,6 +1260,10 @@ image_menu_update (GtkItemFactory *item_factory,
SET_SENSITIVE ("/View/Dot for Dot", gdisp);
SET_ACTIVE ("/View/Dot for Dot", gdisp && shell->dot_for_dot);
SET_SENSITIVE ("/View/Fullscreen", gdisp);
SET_ACTIVE ("/View/Fullscreen",
gdisp && (shell->window_state & GDK_WINDOW_STATE_FULLSCREEN));