app/gui/Makefile.am new files.

2003-09-11  Michael Natterer  <mitch@gimp.org>

	* app/gui/Makefile.am
	* app/gui/themes.[ch]: new files.

	* app/gui/gui.[ch]: code taken from here. It was getting too large.

	* app/gui/preferences-dialog.c; changed accordingly.
This commit is contained in:
Michael Natterer 2003-09-10 23:42:59 +00:00 committed by Michael Natterer
parent 2e33617669
commit 82321d4a2f
8 changed files with 290 additions and 188 deletions

View File

@ -1,3 +1,12 @@
2003-09-11 Michael Natterer <mitch@gimp.org>
* app/gui/Makefile.am
* app/gui/themes.[ch]: new files.
* app/gui/gui.[ch]: code taken from here. It was getting too large.
* app/gui/preferences-dialog.c; changed accordingly.
2003-09-11 Sven Neumann <sven@gimp.org>
* app/vectors/Makefile.am (INCLUDES): replaced GTK_CFLAGS by

View File

@ -45,10 +45,10 @@
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui.h"
#include "menus.h"
#include "resolution-calibrate-dialog.h"
#include "session.h"
#include "themes.h"
#include "gimp-intl.h"
@ -471,10 +471,10 @@ prefs_notebook_append_page (Gimp *gimp,
GtkTreeIter *iter,
gint page_index)
{
GtkWidget *event_box;
GtkWidget *vbox;
GdkPixbuf *pixbuf = NULL;
GdkPixbuf *small_pixbuf = NULL;
GtkWidget *event_box;
GtkWidget *vbox;
GdkPixbuf *pixbuf = NULL;
GdkPixbuf *small_pixbuf = NULL;
event_box = gtk_event_box_new ();
gtk_notebook_append_page (notebook, event_box, NULL);
@ -491,10 +491,8 @@ prefs_notebook_append_page (Gimp *gimp,
{
gchar *filename;
filename = g_build_filename (gui_themes_get_theme_dir (gimp),
"images",
"preferences",
notebook_icon,
filename = g_build_filename (themes_get_theme_dir (gimp),
"images", "preferences", notebook_icon,
NULL);
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
@ -505,11 +503,9 @@ prefs_notebook_append_page (Gimp *gimp,
g_free (filename);
if (pixbuf)
{
small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
18, 18,
GDK_INTERP_BILINEAR);
}
small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
18, 18,
GDK_INTERP_BILINEAR);
}
gtk_tree_store_append (tree, iter, parent);

View File

@ -170,7 +170,9 @@ libappgui_a_SOURCES = \
session.c \
session.h \
splash.c \
splash.h
splash.h \
themes.c \
themes.h
EXTRA_DIST = makefile.msc

View File

@ -30,7 +30,6 @@
#include "gui-types.h"
#include "config/gimpguiconfig.h"
#include "config/gimpconfig-path.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
@ -65,6 +64,7 @@
#include "pattern-select.h"
#include "plug-in-menus.h"
#include "session.h"
#include "themes.h"
#include "app_procs.h" /* FIXME */
@ -73,73 +73,69 @@
/* local function prototypes */
static void gui_help_func (const gchar *help_id,
gpointer help_data);
static gboolean gui_get_background_func (GimpRGB *color);
static gboolean gui_get_foreground_func (GimpRGB *color);
static void gui_help_func (const gchar *help_id,
gpointer help_data);
static gboolean gui_get_background_func (GimpRGB *color);
static gboolean gui_get_foreground_func (GimpRGB *color);
static void gui_threads_enter (Gimp *gimp);
static void gui_threads_leave (Gimp *gimp);
static void gui_set_busy (Gimp *gimp);
static void gui_unset_busy (Gimp *gimp);
static void gui_message (Gimp *gimp,
const gchar *domain,
const gchar *message);
static GimpObject * gui_display_new (GimpImage *gimage,
guint scale);
static void gui_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *std_plugins_domain);
static void gui_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def,
const gchar *locale_domain,
const gchar *help_domain);
static void gui_menus_delete_entry (Gimp *gimp,
const gchar *menu_path);
static GimpProgress * gui_start_progress (Gimp *gimp,
gint gdisp_ID,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
static GimpProgress * gui_restart_progress (Gimp *gimp,
GimpProgress *progress,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
static void gui_update_progress (Gimp *gimp,
GimpProgress *progress,
gdouble percentage);
static void gui_end_progress (Gimp *gimp,
GimpProgress *progress);
static void gui_pdb_dialogs_check (Gimp *gimp);
static void gui_threads_enter (Gimp *gimp);
static void gui_threads_leave (Gimp *gimp);
static void gui_set_busy (Gimp *gimp);
static void gui_unset_busy (Gimp *gimp);
static void gui_message (Gimp *gimp,
const gchar *domain,
const gchar *message);
static GimpObject * gui_display_new (GimpImage *gimage,
guint scale);
static void gui_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *plugins_domain);
static void gui_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def,
const gchar *locale_domain,
const gchar *help_domain);
static void gui_menus_delete_entry (Gimp *gimp,
const gchar *menu_path);
static GimpProgress * gui_start_progress (Gimp *gimp,
gint gdisp_ID,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
static GimpProgress * gui_restart_progress (Gimp *gimp,
GimpProgress *progress,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
static void gui_update_progress (Gimp *gimp,
GimpProgress *progress,
gdouble percentage);
static void gui_end_progress (Gimp *gimp,
GimpProgress *progress);
static void gui_pdb_dialogs_check (Gimp *gimp);
static void gui_themes_dir_foreach_func (const GimpDatafileData *file_data,
gpointer user_data);
static gboolean gui_exit_callback (Gimp *gimp,
gboolean kill_it);
static gboolean gui_exit_finish_callback (Gimp *gimp,
gboolean kill_it);
static void gui_really_quit_callback (GtkWidget *button,
gboolean quit,
gpointer data);
static void gui_show_tooltips_notify (GObject *config,
GParamSpec *param_spec,
Gimp *gimp);
static void gui_device_change_notify (Gimp *gimp);
static gboolean gui_exit_callback (Gimp *gimp,
gboolean kill_it);
static gboolean gui_exit_finish_callback (Gimp *gimp,
gboolean kill_it);
static void gui_really_quit_callback (GtkWidget *button,
gboolean quit,
gpointer data);
static void gui_show_tooltips_notify (GObject *config,
GParamSpec *param_spec,
Gimp *gimp);
static void gui_device_change_notify (Gimp *gimp);
static void gui_display_changed (GimpContext *context,
GimpDisplay *display,
Gimp *gimp);
static void gui_image_disconnect (GimpImage *gimage,
Gimp *gimp);
static void gui_display_changed (GimpContext *context,
GimpDisplay *display,
Gimp *gimp);
static void gui_image_disconnect (GimpImage *gimage,
Gimp *gimp);
/* private variables */
static GQuark image_disconnect_handler_id = 0;
static GHashTable *themes_hash = NULL;
static GimpItemFactory *toolbox_item_factory = NULL;
static GimpItemFactory *image_item_factory = NULL;
@ -159,7 +155,7 @@ gui_libs_init (gint *argc,
return FALSE;
/* Initialize the eeky vtable needed by libgimpwidgets */
vtable.unit_get_number_of_units = gimp_unit_get_number_of_units;
vtable.unit_get_number_of_units = gimp_unit_get_number_of_units;
vtable.unit_get_number_of_built_in_units = gimp_unit_get_number_of_built_in_units;
vtable.unit_get_factor = gimp_unit_get_factor;
vtable.unit_get_digits = gimp_unit_get_digits;
@ -182,7 +178,9 @@ gui_libs_init (gint *argc,
void
gui_environ_init (Gimp *gimp)
{
gchar *display, *name = NULL;
const gchar *name = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
#if defined (GDK_WINDOWING_X11)
name = "DISPLAY";
@ -194,6 +192,8 @@ gui_environ_init (Gimp *gimp)
if (name)
{
gchar *display;
display = gdk_get_display ();
gimp_environ_table_add (gimp->environ_table, name, display, NULL);
g_free (display);
@ -203,65 +203,11 @@ gui_environ_init (Gimp *gimp)
void
gui_themes_init (Gimp *gimp)
{
GimpGuiConfig *config;
const gchar *theme_dir;
gchar *gtkrc;
g_return_if_fail (GIMP_IS_GIMP (gimp));
config = GIMP_GUI_CONFIG (gimp->config);
themes_init (gimp);
themes_hash = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
g_free);
if (config->theme_path)
{
gchar *path;
path = gimp_config_path_expand (config->theme_path, TRUE, NULL);
gimp_datafiles_read_directories (path,
G_FILE_TEST_IS_DIR,
gui_themes_dir_foreach_func,
gimp);
g_free (path);
}
theme_dir = gui_themes_get_theme_dir (gimp);
if (theme_dir)
{
gtkrc = g_build_filename (theme_dir, "gtkrc", NULL);
}
else
{
/* get the hardcoded default theme gtkrc */
gtkrc = g_strdup (gimp_gtkrc ());
}
if (gimp->be_verbose)
g_print (_("Parsing '%s'\n"), gtkrc);
gtk_rc_parse (gtkrc);
g_free (gtkrc);
/* parse the user gtkrc */
gtkrc = gimp_personal_rc_file ("gtkrc");
if (gimp->be_verbose)
g_print (_("Parsing '%s'\n"), gtkrc);
gtk_rc_parse (gtkrc);
g_free (gtkrc);
if (! config->show_tool_tips)
if (! GIMP_GUI_CONFIG (gimp->config)->show_tool_tips)
gimp_help_disable_tooltips ();
g_signal_connect (gimp->config, "notify::show-tool-tips",
@ -274,17 +220,6 @@ gui_themes_init (Gimp *gimp)
gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());
}
const gchar *
gui_themes_get_theme_dir (Gimp *gimp)
{
GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
if (config->theme)
return g_hash_table_lookup (themes_hash, config->theme);
return g_hash_table_lookup (themes_hash, "Default");
}
void
gui_init (Gimp *gimp)
{
@ -587,23 +522,6 @@ gui_pdb_dialogs_check (Gimp *gimp)
pattern_select_dialogs_check ();
}
static void
gui_themes_dir_foreach_func (const GimpDatafileData *file_data,
gpointer user_data)
{
Gimp *gimp;
gimp = GIMP (user_data);
if (gimp->be_verbose)
g_print (_("Adding theme '%s' (%s)\n"),
file_data->basename, file_data->filename);
g_hash_table_insert (themes_hash,
g_strdup (file_data->basename),
g_strdup (file_data->filename));
}
static gboolean
gui_exit_callback (Gimp *gimp,
gboolean kill_it)
@ -667,11 +585,7 @@ gui_exit_finish_callback (Gimp *gimp,
dialogs_exit (gimp);
gimp_devices_exit (gimp);
if (themes_hash)
{
g_hash_table_destroy (themes_hash);
themes_hash = NULL;
}
themes_exit (gimp);
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));

View File

@ -20,18 +20,17 @@
#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);
void gui_init (Gimp *gimp);
void gui_restore (Gimp *gimp,
gboolean restore_session);
void gui_post_init (Gimp *gimp);
void gui_init (Gimp *gimp);
void gui_restore (Gimp *gimp,
gboolean restore_session);
void gui_post_init (Gimp *gimp);
#endif /* __GUI_H__ */

View File

@ -45,10 +45,10 @@
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui.h"
#include "menus.h"
#include "resolution-calibrate-dialog.h"
#include "session.h"
#include "themes.h"
#include "gimp-intl.h"
@ -471,10 +471,10 @@ prefs_notebook_append_page (Gimp *gimp,
GtkTreeIter *iter,
gint page_index)
{
GtkWidget *event_box;
GtkWidget *vbox;
GdkPixbuf *pixbuf = NULL;
GdkPixbuf *small_pixbuf = NULL;
GtkWidget *event_box;
GtkWidget *vbox;
GdkPixbuf *pixbuf = NULL;
GdkPixbuf *small_pixbuf = NULL;
event_box = gtk_event_box_new ();
gtk_notebook_append_page (notebook, event_box, NULL);
@ -491,10 +491,8 @@ prefs_notebook_append_page (Gimp *gimp,
{
gchar *filename;
filename = g_build_filename (gui_themes_get_theme_dir (gimp),
"images",
"preferences",
notebook_icon,
filename = g_build_filename (themes_get_theme_dir (gimp),
"images", "preferences", notebook_icon,
NULL);
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
@ -505,11 +503,9 @@ prefs_notebook_append_page (Gimp *gimp,
g_free (filename);
if (pixbuf)
{
small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
18, 18,
GDK_INTERP_BILINEAR);
}
small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
18, 18,
GDK_INTERP_BILINEAR);
}
gtk_tree_store_append (tree, iter, parent);

157
app/gui/themes.c Normal file
View File

@ -0,0 +1,157 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "gui-types.h"
#include "config/gimpconfig-path.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "themes.h"
#include "gimp-intl.h"
/* local function prototypes */
static void gui_themes_dir_foreach_func (const GimpDatafileData *file_data,
gpointer user_data);
/* private variables */
static GHashTable *themes_hash = NULL;
/* public functions */
void
themes_init (Gimp *gimp)
{
GimpGuiConfig *config;
const gchar *theme_dir;
gchar *gtkrc;
g_return_if_fail (GIMP_IS_GIMP (gimp));
config = GIMP_GUI_CONFIG (gimp->config);
themes_hash = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
g_free);
if (config->theme_path)
{
gchar *path;
path = gimp_config_path_expand (config->theme_path, TRUE, NULL);
gimp_datafiles_read_directories (path,
G_FILE_TEST_IS_DIR,
gui_themes_dir_foreach_func,
gimp);
g_free (path);
}
theme_dir = themes_get_theme_dir (gimp);
if (theme_dir)
{
gtkrc = g_build_filename (theme_dir, "gtkrc", NULL);
}
else
{
/* get the hardcoded default theme gtkrc */
gtkrc = g_strdup (gimp_gtkrc ());
}
if (gimp->be_verbose)
g_print (_("Parsing '%s'\n"), gtkrc);
gtk_rc_parse (gtkrc);
g_free (gtkrc);
/* parse the user gtkrc */
gtkrc = gimp_personal_rc_file ("gtkrc");
if (gimp->be_verbose)
g_print (_("Parsing '%s'\n"), gtkrc);
gtk_rc_parse (gtkrc);
g_free (gtkrc);
}
void
themes_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (themes_hash)
{
g_hash_table_destroy (themes_hash);
themes_hash = NULL;
}
}
const gchar *
themes_get_theme_dir (Gimp *gimp)
{
GimpGuiConfig *config;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
config = GIMP_GUI_CONFIG (gimp->config);
if (config->theme)
return g_hash_table_lookup (themes_hash, config->theme);
return g_hash_table_lookup (themes_hash, "Default");
}
/* private functions */
static void
gui_themes_dir_foreach_func (const GimpDatafileData *file_data,
gpointer user_data)
{
Gimp *gimp;
gimp = GIMP (user_data);
if (gimp->be_verbose)
g_print (_("Adding theme '%s' (%s)\n"),
file_data->basename, file_data->filename);
g_hash_table_insert (themes_hash,
g_strdup (file_data->basename),
g_strdup (file_data->filename));
}

29
app/gui/themes.h Normal file
View File

@ -0,0 +1,29 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __THEMES_H__
#define __THEMES_H__
void themes_init (Gimp *gimp);
void themes_exit (Gimp *gimp);
const gchar * themes_get_theme_dir (Gimp *gimp);
#endif /* __THEMES_H__ */