Commit 30ea5171 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

removed the calls to g_log_set_handler().

2003-05-29  Michael Natterer  <mitch@gimp.org>

	* app/main.c (main): removed the calls to g_log_set_handler().

	* app/app_procs.[ch] (app_init): added the g_log_set_handler()
	calls and pass them the global Gimp instance as user_data.
	Renamed app_gui_init() to app_gui_libs_init().

	* app/errors.c: use the passed Gimp pointer instead of using
	"the_gimp". Don't #include "app_procs.h".

	* app/gui/gui.[ch]: removed gui_get_screen_resolution().

	* app/widgets/gimpwidgets-utils.[ch]: added
	gimp_get_screen_resolution().

	* app/display/gimpdisplayshell-handlers.c
	* app/display/gimpdisplayshell.c
	* app/gui/preferences-dialog.c
	* app/gui/user-install-dialog.c: changed accordingly.

	* app/display/gimpdisplayshell.c: don't #include "gui/gui.h".
parent 737d54fa
2003-05-29 Michael Natterer <mitch@gimp.org>
* app/main.c (main): removed the calls to g_log_set_handler().
* app/app_procs.[ch] (app_init): added the g_log_set_handler()
calls and pass them the global Gimp instance as user_data.
Renamed app_gui_init() to app_gui_libs_init().
* app/errors.c: use the passed Gimp pointer instead of using
"the_gimp". Don't #include "app_procs.h".
* app/gui/gui.[ch]: removed gui_get_screen_resolution().
* app/widgets/gimpwidgets-utils.[ch]: added
gimp_get_screen_resolution().
* app/display/gimpdisplayshell-handlers.c
* app/display/gimpdisplayshell.c
* app/gui/preferences-dialog.c
* app/gui/user-install-dialog.c: changed accordingly.
* app/display/gimpdisplayshell.c: don't #include "gui/gui.h".
2003-05-29 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontainertreeview.c
......@@ -57,6 +57,7 @@
#include "appenv.h"
#include "app_procs.h"
#include "batch.h"
#include "errors.h"
#include "gimp-intl.h"
......@@ -79,6 +80,13 @@ Gimp *the_gimp = NULL;
/* public functions */
gboolean
app_gui_libs_init (gint *argc,
gchar ***argv)
{
return gui_libs_init (argc, argv);
}
void
app_init (gint gimp_argc,
gchar **gimp_argv)
......@@ -97,6 +105,60 @@ app_init (gint gimp_argc,
gimp_object_set_name (GIMP_OBJECT (the_gimp), prog_name);
g_log_set_handler ("Gimp",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-Base",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-Paint-Funcs",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-Core",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-PDB",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-Plug-In",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-File",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-XCF",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-Widgets",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-Display",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-Tools",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler ("Gimp-GUI",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
&the_gimp);
g_log_set_handler (NULL,
G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL,
gimp_error_log_func,
&the_gimp);
/* Check if the user's gimp_directory exists
*/
gimp_dir = gimp_directory ();
......@@ -279,12 +341,6 @@ app_init (gint gimp_argc,
}
}
gboolean
app_gui_init (gint *argc,
gchar ***argv)
{
return gui_libs_init (argc, argv);
}
/* private functions */
......
......@@ -34,11 +34,11 @@
extern Gimp *the_gimp;
void app_init (gint gimp_argc,
gchar **gimp_argv);
gboolean app_gui_libs_init (gint *gimp_argc,
gchar ***gimp_argv);
gboolean app_gui_init (gint *gimp_argc,
gchar ***gimp_argv);
void app_init (gint gimp_argc,
gchar **gimp_argv);
#endif /* __APP_PROCS_H__ */
......@@ -40,6 +40,7 @@
#include "widgets/gimpdevices.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui.h"
#include "menus.h"
......@@ -369,7 +370,7 @@ prefs_res_source_callback (GtkWidget *widget,
if (from_gdk)
{
gui_get_screen_resolution (NULL, &xres, &yres);
gimp_get_screen_resolution (NULL, &xres, &yres);
}
else
{
......@@ -1635,7 +1636,7 @@ prefs_dialog_new (Gimp *gimp,
gdouble xres, yres;
gchar *str;
gui_get_screen_resolution (NULL, &xres, &yres);
gimp_get_screen_resolution (NULL, &xres, &yres);
str = g_strdup_printf (_("(Currently %d x %d dpi)"),
ROUND (xres), ROUND (yres));
......
......@@ -44,8 +44,8 @@
#include "config/gimprc.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui.h"
#include "resolution-calibrate-dialog.h"
#include "user-install-dialog.h"
......@@ -1240,7 +1240,7 @@ user_install_resolution (GimpRc *gimprc)
gchar *pixels_per_unit;
gchar *str;
gui_get_screen_resolution (NULL, &xres, &yres);
gimp_get_screen_resolution (NULL, &xres, &yres);
add_label (GTK_BOX (resolution_page),
_("GIMP can obtain this information from the windowing system.\n"
......
......@@ -52,8 +52,8 @@
#include "widgets/gimpdnd.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui/gui.h"
#include "gui/info-window.h"
#include "tools/tool_manager.h"
......@@ -416,9 +416,9 @@ gimp_display_shell_realize (GtkWidget *widget)
*/
if (GIMP_DISPLAY_CONFIG (config)->monitor_res_from_gdk)
{
gui_get_screen_resolution (gtk_widget_get_screen (widget),
&shell->monitor_xres,
&shell->monitor_yres);
gimp_get_screen_resolution (gtk_widget_get_screen (widget),
&shell->monitor_xres,
&shell->monitor_yres);
}
else
{
......
......@@ -29,6 +29,8 @@
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-appearance.h"
......@@ -165,6 +167,10 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
"notify::navigation-preview-size",
G_CALLBACK (gimp_display_shell_nav_size_notify_handler),
shell);
g_signal_connect (gimage->gimp->config,
"notify::monitor-resolution-from-windowing-system",
G_CALLBACK (gimp_display_shell_monitor_res_notify_handler),
shell);
g_signal_connect (gimage->gimp->config,
"notify::monitor-xresolution",
G_CALLBACK (gimp_display_shell_monitor_res_notify_handler),
......@@ -424,9 +430,9 @@ gimp_display_shell_monitor_res_notify_handler (GObject *config,
{
if (GIMP_DISPLAY_CONFIG (config)->monitor_res_from_gdk)
{
gui_get_screen_resolution (gtk_widget_get_screen (shell),
&shell->monitor_xres,
&shell->monitor_yres);
gimp_get_screen_resolution (gtk_widget_get_screen (GTK_WIDGET (shell)),
&shell->monitor_xres,
&shell->monitor_yres);
}
else
{
......
......@@ -52,8 +52,8 @@
#include "widgets/gimpdnd.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui/gui.h"
#include "gui/info-window.h"
#include "tools/tool_manager.h"
......@@ -416,9 +416,9 @@ gimp_display_shell_realize (GtkWidget *widget)
*/
if (GIMP_DISPLAY_CONFIG (config)->monitor_res_from_gdk)
{
gui_get_screen_resolution (gtk_widget_get_screen (widget),
&shell->monitor_xres,
&shell->monitor_yres);
gimp_get_screen_resolution (gtk_widget_get_screen (widget),
&shell->monitor_xres,
&shell->monitor_yres);
}
else
{
......
......@@ -32,7 +32,6 @@
#include "core/gimp.h"
#include "app_procs.h"
#include "appenv.h"
#include "errors.h"
......@@ -57,9 +56,11 @@ gimp_message_log_func (const gchar *log_domain,
const gchar *message,
gpointer data)
{
if (! console_messages && GIMP_IS_GIMP (the_gimp))
Gimp *gimp = *((Gimp **) data);
if (! console_messages && GIMP_IS_GIMP (gimp))
{
gimp_message (the_gimp, message);
gimp_message (gimp, message);
return;
}
......
......@@ -280,8 +280,8 @@ gui_init (Gimp *gimp)
display_config->monitor_yres < GIMP_MIN_RESOLUTION)
{
gdouble xres, yres;
gui_get_screen_resolution (NULL, &xres, &yres);
gimp_get_screen_resolution (NULL, &xres, &yres);
g_object_set (gimp->config,
"monitor-xresolution", xres,
......@@ -346,60 +346,6 @@ gui_post_init (Gimp *gimp)
"gimp-tips-dialog", -1);
}
void
gui_get_screen_resolution (GdkScreen *screen,
gdouble *xres,
gdouble *yres)
{
gint width, height;
gint width_mm, height_mm;
gdouble x = 0.0;
gdouble y = 0.0;
g_return_if_fail (screen == NULL || GDK_IS_SCREEN (screen));
g_return_if_fail (xres != NULL);
g_return_if_fail (yres != NULL);
if (!screen)
screen = gdk_screen_get_default ();
width = gdk_screen_get_width (screen);
height = gdk_screen_get_height (screen);
width_mm = gdk_screen_get_width_mm (screen);
height_mm = gdk_screen_get_height_mm (screen);
/*
* From xdpyinfo.c:
*
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
*
* dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
* = N pixels / (M inch / 25.4)
* = N * 25.4 pixels / M inch
*/
if (width_mm > 0 && height_mm > 0)
{
x = (width * 25.4) / (gdouble) width_mm;
y = (height * 25.4) / (gdouble) height_mm;
}
if (x < GIMP_MIN_RESOLUTION || x > GIMP_MAX_RESOLUTION ||
y < GIMP_MIN_RESOLUTION || y > GIMP_MAX_RESOLUTION)
{
g_warning ("GDK returned bogus values for the screen resolution, "
"using 75 dpi instead.");
x = 75.0;
y = 75.0;
}
/* round the value to full integers to give more pleasant results */
*xres = ROUND (x);
*yres = ROUND (y);
}
/* private functions */
......
......@@ -20,22 +20,18 @@
#define __GUI_H__
gboolean gui_libs_init (gint *argc,
gchar ***argv);
gboolean gui_libs_init (gint *argc,
gchar ***argv);
void gui_environ_init (Gimp *gimp);
void gui_environ_init (Gimp *gimp);
void gui_themes_init (Gimp *gimp);
const gchar * gui_themes_get_theme_dir (Gimp *gimp);
void gui_themes_init (Gimp *gimp);
const gchar * gui_themes_get_theme_dir (Gimp *gimp);
void gui_init (Gimp *gimp);
void gui_restore (Gimp *gimp,
gboolean restore_session);
void gui_post_init (Gimp *gimp);
void gui_get_screen_resolution (GdkScreen *screen,
gdouble *xres,
gdouble *yres);
void gui_init (Gimp *gimp);
void gui_restore (Gimp *gimp,
gboolean restore_session);
void gui_post_init (Gimp *gimp);
#endif /* __GUI_H__ */
......@@ -40,6 +40,7 @@
#include "widgets/gimpdevices.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui.h"
#include "menus.h"
......@@ -369,7 +370,7 @@ prefs_res_source_callback (GtkWidget *widget,
if (from_gdk)
{
gui_get_screen_resolution (NULL, &xres, &yres);
gimp_get_screen_resolution (NULL, &xres, &yres);
}
else
{
......@@ -1635,7 +1636,7 @@ prefs_dialog_new (Gimp *gimp,
gdouble xres, yres;
gchar *str;
gui_get_screen_resolution (NULL, &xres, &yres);
gimp_get_screen_resolution (NULL, &xres, &yres);
str = g_strdup_printf (_("(Currently %d x %d dpi)"),
ROUND (xres), ROUND (yres));
......
......@@ -44,8 +44,8 @@
#include "config/gimprc.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui.h"
#include "resolution-calibrate-dialog.h"
#include "user-install-dialog.h"
......@@ -1240,7 +1240,7 @@ user_install_resolution (GimpRc *gimprc)
gchar *pixels_per_unit;
gchar *str;
gui_get_screen_resolution (NULL, &xres, &yres);
gimp_get_screen_resolution (NULL, &xres, &yres);
add_label (GTK_BOX (resolution_page),
_("GIMP can obtain this information from the windowing system.\n"
......
......@@ -167,7 +167,7 @@ main (int argc,
}
else
{
if (! app_gui_init (&argc, &argv))
if (! app_gui_libs_init (&argc, &argv))
{
const gchar *msg;
......@@ -349,60 +349,6 @@ main (int argc,
gimp_text_console_exit (TRUE);
}
g_log_set_handler ("Gimp",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-Base",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-Paint-Funcs",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-Core",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-PDB",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-Plug-In",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-File",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-XCF",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-Widgets",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-Display",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-Tools",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler ("Gimp-GUI",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
NULL);
g_log_set_handler (NULL,
G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL,
gimp_error_log_func,
NULL);
#ifndef G_OS_WIN32
/* No use catching these on Win32, the user won't get any
......
......@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
......@@ -422,3 +423,57 @@ gimp_get_mod_separator (void)
return (const gchar *) mod_separator;
}
void
gimp_get_screen_resolution (GdkScreen *screen,
gdouble *xres,
gdouble *yres)
{
gint width, height;
gint width_mm, height_mm;
gdouble x = 0.0;
gdouble y = 0.0;
g_return_if_fail (screen == NULL || GDK_IS_SCREEN (screen));
g_return_if_fail (xres != NULL);
g_return_if_fail (yres != NULL);
if (!screen)
screen = gdk_screen_get_default ();
width = gdk_screen_get_width (screen);
height = gdk_screen_get_height (screen);
width_mm = gdk_screen_get_width_mm (screen);
height_mm = gdk_screen_get_height_mm (screen);
/*
* From xdpyinfo.c:
*
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
*
* dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
* = N pixels / (M inch / 25.4)
* = N * 25.4 pixels / M inch
*/
if (width_mm > 0 && height_mm > 0)
{
x = (width * 25.4) / (gdouble) width_mm;
y = (height * 25.4) / (gdouble) height_mm;
}
if (x < GIMP_MIN_RESOLUTION || x > GIMP_MAX_RESOLUTION ||
y < GIMP_MIN_RESOLUTION || y > GIMP_MAX_RESOLUTION)
{
g_warning ("GDK returned bogus values for the screen resolution, "
"using 75 dpi instead.");
x = 75.0;
y = 75.0;
}
/* round the value to full integers to give more pleasant results */
*xres = ROUND (x);
*yres = ROUND (y);
}
......@@ -23,34 +23,38 @@
#define __GIMP_WIDGETS_UTILS_H__
void gimp_message_box (const gchar *message,
GtkCallback callback,
gpointer data);
void gimp_menu_position (GtkMenu *menu,
gint *x,
gint *y,
guint *button,
guint32 *activate_time);
void gimp_table_attach_stock (GtkTable *table,
gint row,
const gchar *label_text,
gdouble yalign,
GtkWidget *widget,
gint colspan,
const gchar *stock_id);
GtkIconSize gimp_get_icon_size (GtkWidget *widget,
const gchar *stock_id,
GtkIconSize max_size,
gint width,
gint height);
const gchar * gimp_get_mod_name_shift (void);
const gchar * gimp_get_mod_name_control (void);
const gchar * gimp_get_mod_name_alt (void);
const gchar * gimp_get_mod_separator (void);
void gimp_message_box (const gchar *message,
GtkCallback callback,
gpointer data);
void gimp_menu_position (GtkMenu *menu,
gint *x,
gint *y,
guint *button,
guint32 *activate_time);
void gimp_table_attach_stock (GtkTable *table,
gint row,
const gchar *label_text,
gdouble yalign,
GtkWidget *widget,
gint colspan,
const gchar *stock_id);
GtkIconSize gimp_get_icon_size (GtkWidget *widget,
const gchar *stock_id,
GtkIconSize max_size,
gint width,
gint height);
const gchar * gimp_get_mod_name_shift (void);
const gchar * gimp_get_mod_name_control (void);
const gchar * gimp_get_mod_name_alt (void);
const gchar * gimp_get_mod_separator (void);
void gimp_get_screen_resolution (GdkScreen *screen,
gdouble *xres,
gdouble *yres);
#endif /* __GIMP_WIDGETS_UTILS_H__ */
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