/** * gimp_ui_init: * @prog_name: The name of the plug-in which will be passed as argv[0] to * gtk_init(). It's a convention to use the name of the * executable and _not_ the PDB procedure name or something. * @preview: This parameter is unused and exists for historical * reasons only. * * This function initializes GTK+ with gtk_init() and initializes GDK's * image rendering subsystem (GdkRGB) to follow the GIMP main program's * colormap allocation/installation policy. * * GIMP's colormap policy can be determinded by the user with the * gimprc variables @min_colors and @install_cmap. **/ void gimp_ui_init (const gchar *prog_name, gboolean preview) { const gchar *display_name; gchar *themerc; GdkScreen *screen; g_return_if_fail (prog_name != NULL); if (gimp_ui_initialized) return; g_set_prgname (prog_name); display_name = gimp_display_name (); if (display_name) { #if defined (GDK_WINDOWING_X11) const gchar var_name[] = "DISPLAY"; #else const gchar var_name[] = "GDK_DISPLAY"; #endif putenv (g_strdup_printf ("%s=%s", var_name, display_name)); } gtk_init (NULL, NULL); themerc = gimp_personal_rc_file ("themerc"); gtk_rc_add_default_file (themerc); g_free (themerc); gdk_set_program_class (gimp_wm_class ()); gdk_rgb_set_min_colors (gimp_min_colors ()); gdk_rgb_set_install (gimp_install_cmap ()); screen = gdk_screen_get_default (); gtk_widget_set_default_colormap (gdk_screen_get_rgb_colormap (screen)); gimp_widgets_init (gimp_ui_help_func, gimp_context_get_foreground, gimp_context_get_background, gimp_ensure_modules); if (! gimp_show_tool_tips ()) gimp_help_disable_tooltips (); gimp_dialogs_show_help_button (gimp_show_help_button ()); gimp_ui_initialized = TRUE; }
/** * gimp_ui_init: * @prog_name: The name of the plug-in which will be passed as argv[0] to * gtk_init(). It's a convention to use the name of the * executable and _not_ the PDB procedure name. * @preview: This parameter is unused and exists for historical * reasons only. * * This function initializes GTK+ with gtk_init() and initializes GDK's * image rendering subsystem (GdkRGB) to follow the GIMP main program's * colormap allocation/installation policy. * * It also sets up various other things so that the plug-in user looks * and behaves like the GIMP core. This includes selecting the GTK+ * theme and setting up the help system as chosen in the GIMP * preferences. Any plug-in that provides a user interface should call * this function. **/ void gimp_ui_init (const gchar *prog_name, gboolean preview) { GdkScreen *screen; const gchar *display_name; gchar *themerc; g_return_if_fail (prog_name != NULL); if (gimp_ui_initialized) return; g_set_prgname (prog_name); display_name = gimp_display_name (); if (display_name) { #if defined (GDK_WINDOWING_X11) g_setenv ("DISPLAY", display_name, TRUE); #else g_setenv ("GDK_DISPLAY", display_name, TRUE); #endif } if (gimp_user_time ()) { /* Construct a fake startup ID as we only want to pass the * interaction timestamp, see _gdk_windowing_set_default_display(). */ gchar *startup_id = g_strdup_printf ("_TIME%u", gimp_user_time ()); g_setenv ("DESKTOP_STARTUP_ID", startup_id, TRUE); g_free (startup_id); } gtk_init (NULL, NULL); themerc = gimp_personal_rc_file ("themerc"); gtk_rc_add_default_file (themerc); g_free (themerc); gdk_set_program_class (gimp_wm_class ()); gdk_rgb_set_min_colors (gimp_min_colors ()); gdk_rgb_set_install (gimp_install_cmap ()); screen = gdk_screen_get_default (); gtk_widget_set_default_colormap (gdk_screen_get_rgb_colormap (screen)); gimp_widgets_init (gimp_ui_help_func, gimp_context_get_foreground, gimp_context_get_background, gimp_ensure_modules); if (! gimp_show_tool_tips ()) gimp_help_disable_tooltips (); gimp_dialogs_show_help_button (gimp_show_help_button ()); gimp_ui_initialized = TRUE; }
int ui_init( int *argc, char ***argv ) { GtkWidget *box, *menu_bar; GtkAccelGroup *accel_group; GtkSettings *settings; gtk_init(argc,argv); gdk_rgb_init(); gdk_rgb_set_install( TRUE ); gtk_widget_set_default_colormap( gdk_rgb_get_cmap() ); gtk_widget_set_default_visual( gdk_rgb_get_visual() ); gtkui_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); settings = gtk_widget_get_settings( GTK_WIDGET( gtkui_window ) ); g_object_set( settings, "gtk-menu-bar-accel", "F1", NULL ); gtk_window_set_title( GTK_WINDOW(gtkui_window), "Fuse" ); gtk_window_set_wmclass( GTK_WINDOW(gtkui_window), fuse_progname, "Fuse" ); gtk_signal_connect(GTK_OBJECT(gtkui_window), "delete-event", GTK_SIGNAL_FUNC(gtkui_delete), NULL); gtk_signal_connect(GTK_OBJECT(gtkui_window), "key-press-event", GTK_SIGNAL_FUNC(gtkkeyboard_keypress), NULL); gtk_widget_add_events( gtkui_window, GDK_KEY_RELEASE_MASK ); gtk_signal_connect(GTK_OBJECT(gtkui_window), "key-release-event", GTK_SIGNAL_FUNC(gtkkeyboard_keyrelease), NULL); /* If we lose the focus, disable all keys */ gtk_signal_connect( GTK_OBJECT( gtkui_window ), "focus-out-event", GTK_SIGNAL_FUNC( gtkui_lose_focus ), NULL ); gtk_signal_connect( GTK_OBJECT( gtkui_window ), "focus-in-event", GTK_SIGNAL_FUNC( gtkui_gain_focus ), NULL ); gtk_drag_dest_set( GTK_WIDGET( gtkui_window ), GTK_DEST_DEFAULT_ALL, drag_types, G_N_ELEMENTS( drag_types ), GDK_ACTION_COPY | GDK_ACTION_PRIVATE ); /* GDK_ACTION_PRIVATE alone DNW with ROX-Filer */ gtk_signal_connect( GTK_OBJECT( gtkui_window ), "drag-data-received", GTK_SIGNAL_FUNC( gtkui_drag_data_received ), NULL ); box = gtk_vbox_new( FALSE, 0 ); gtk_container_add(GTK_CONTAINER(gtkui_window), box); gtkui_make_menu( &accel_group, &menu_bar, gtkui_menu_data, gtkui_menu_data_size ); gtk_window_add_accel_group( GTK_WINDOW(gtkui_window), accel_group ); gtk_box_pack_start( GTK_BOX(box), menu_bar, FALSE, FALSE, 0 ); gtkui_drawing_area = gtk_drawing_area_new(); if(!gtkui_drawing_area) { fprintf(stderr,"%s: couldn't create drawing area at %s:%d\n", fuse_progname,__FILE__,__LINE__); return 1; } gtk_widget_add_events( GTK_WIDGET( gtkui_drawing_area ), GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK ); gtk_signal_connect( GTK_OBJECT( gtkui_drawing_area ), "motion-notify-event", GTK_SIGNAL_FUNC( gtkmouse_position ), NULL ); gtk_signal_connect( GTK_OBJECT( gtkui_drawing_area ), "button-press-event", GTK_SIGNAL_FUNC( gtkmouse_button ), NULL ); gtk_signal_connect( GTK_OBJECT( gtkui_drawing_area ), "button-release-event", GTK_SIGNAL_FUNC( gtkmouse_button ), NULL ); gtk_box_pack_start( GTK_BOX(box), gtkui_drawing_area, TRUE, TRUE, 0 ); /* Create the statusbar */ gtkstatusbar_create( GTK_BOX( box ) ); gtk_widget_show_all( gtkui_window ); gtkstatusbar_set_visibility( settings_current.statusbar ); ui_mouse_present = 1; return 0; }