/** * Basic (i.e. minimal) initialization of libdia. * * It does not load any plug-ins but instead brings libdia to a state that plug-in loading can take place. * @param flags a set of DIA_INTERACTIVE, DIA_MESSAGE_STDERR */ void libdia_init (guint flags) { static gboolean initialized = FALSE; if (initialized) return; if (flags & DIA_MESSAGE_STDERR) set_message_func(stderr_message_internal); LIBXML_TEST_VERSION; #ifdef G_OS_WIN32 xmlSetGenericErrorFunc(NULL, myXmlErrorReporting); #endif if (flags & DIA_VERBOSE) { dia_log_message_enable (TRUE); dia_log_message ("initializing libdia"); } stdprops_init(); if (flags & DIA_INTERACTIVE) { char *diagtkrc; gtk_widget_set_default_colormap(gdk_rgb_get_cmap()); diagtkrc = dia_config_filename("diagtkrc"); dia_log_message ("Config from %s", diagtkrc); gtk_rc_parse(diagtkrc); g_free(diagtkrc); color_init(); } initialized = TRUE; object_registry_init(); /* The group_type is registered in app, but it needs to be exported anyway */ object_register_type(&stdpath_type); }
void themes_init (Gimp *gimp) { GimpGuiConfig *config; gchar *themerc; 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, themes_directories_foreach, gimp); g_free (path); } themes_apply_theme (gimp, config->theme); themerc = gimp_personal_rc_file ("themerc"); gtk_rc_parse (themerc); g_free (themerc); g_signal_connect (config, "notify::theme", G_CALLBACK (themes_theme_change_notify), gimp); }
int main(int argc, char **argv) { char cwd[PATH_MAX]; GtkWidget *main_window; gtk_init(&argc, &argv); gtk_rc_parse("fm.rc"); load_default_icons(); main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(handle_main_window_destroy), NULL); gtk_container_add(GTK_CONTAINER(main_window), create_main_view()); if (getcwd(cwd, sizeof cwd) == NULL) err(1, "getcwd"); change_dir(cwd); gtk_widget_show_all(main_window); gtk_main(); return 0; }
/** * Basic (i.e. minimal) initialization of libdia. * * It does not load any plug-ins but instead brings libdia to a state that plug-in loading can take place. * @param flags a set of DIA_INTERACTIVE, DIA_MESSAGE_STDERR */ void libdia_init (guint flags) { static gboolean initialized = FALSE; if (initialized) return; if (flags & DIA_MESSAGE_STDERR) set_message_func(stderr_message_internal); LIBXML_TEST_VERSION; #ifdef G_OS_WIN32 xmlSetGenericErrorFunc(NULL, myXmlErrorReporting); #endif if (flags & DIA_VERBOSE) { dia_log_message_enable (TRUE); dia_log_message ("initializing libdia"); } stdprops_init(); if (flags & DIA_INTERACTIVE) { char *diagtkrc; dia_image_init(); diagtkrc = dia_config_filename("diagtkrc"); dia_log_message ("Config from %s", diagtkrc); gtk_rc_parse(diagtkrc); g_free(diagtkrc); color_init(); } initialized = TRUE; object_registry_init(); }
int main(int argc, char* argv[]){ //Declaration of variables GtkWidget * window, *tableInitialing, *hboxHeader, *hboxLabel; GtkWidget * browserForm, *cancelButton, *addButton, *addButtonTest; //This function parses the command line arguments, removing the wants it recognizes gtk_init( &argc, &argv); //includes the resource file to modify GtkWidgets gtk_rc_parse("resourceFile.gtkrc"); //initialises the form notebook browserForm = gtk_notebook_new(); //This line of code sets the properties of the main window window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size( GTK_WINDOW(window), 1000, 700); gtk_widget_set_size_request( window, 900, 600); gtk_container_set_border_width( GTK_CONTAINER(window), 10); gtk_window_set_title(GTK_WINDOW(window), "One click browser Made to ease browsing"); gtk_window_set_resizable( GTK_WINDOW(window), TRUE); gtk_window_set_icon_from_file( GTK_WINDOW(window), "images/OneClickLogo.png", NULL); //Connects signals relating to the window g_signal_connect( G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); g_signal_connect( G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL); //Initialising the addButton and linking it with its callback function when clicked addButton = gtk_button_new_with_mnemonic("_+"); gtk_button_set_relief( GTK_BUTTON(addButton), GTK_RELIEF_NONE); g_signal_connect_swapped( G_OBJECT(addButton), "clicked", G_CALLBACK(addNewTab), (gpointer) browserForm); //Initialises the hbox-It contains the addButton, cancelButton and the hboxLabel hboxHeader = gtk_hbox_new( TRUE, 0); gtk_widget_set_size_request( hboxHeader, 200, 20); hboxLabel = gtk_label_new("New tab"); gtk_widget_set_size_request( hboxLabel, 95, 20); //Initialising the cancelButton and linking it with its callback function when clicked cancelButton = gtk_button_new_with_mnemonic("_x"); gtk_button_set_relief( GTK_BUTTON(cancelButton), GTK_RELIEF_NONE); g_signal_connect_swapped( G_OBJECT(cancelButton), "clicked", G_CALLBACK(delete_tab), (gpointer) browserForm); //Adding widgets to the hbox gtk_box_pack_start_defaults( GTK_BOX(hboxHeader), hboxLabel); gtk_box_pack_start_defaults( GTK_BOX(hboxHeader), cancelButton); gtk_box_pack_start_defaults( GTK_BOX(hboxHeader), addButton); gtk_widget_show_all(hboxHeader); //setPageLayout initialises the table and then table is then added to the browser notebook tableInitialing = setPageLayout(window, browserForm); gtk_notebook_append_page( GTK_NOTEBOOK(browserForm), tableInitialing, hboxHeader); gtk_notebook_set_scrollable( GTK_NOTEBOOK(browserForm), TRUE); gtk_container_add(GTK_CONTAINER(window), browserForm); gtk_widget_show_all(window); gtk_main(); return 0; } //End of main function
int main(int argc, char *argv[], char *env[]) { int i; const char* desktop_name; char *file; setlocale(LC_CTYPE, ""); #if !GLIB_CHECK_VERSION(2, 32, 0) g_thread_init(NULL); #endif /* gdk_threads_init(); gdk_threads_enter(); */ gtk_init(&argc, &argv); #ifdef ENABLE_NLS bindtextdomain ( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR ); bind_textdomain_codeset ( GETTEXT_PACKAGE, "UTF-8" ); textdomain ( GETTEXT_PACKAGE ); #endif XSetLocaleModifiers(""); XSetErrorHandler((XErrorHandler) panel_handle_x_error); resolve_atoms(); desktop_name = g_getenv("XDG_CURRENT_DESKTOP"); is_in_lxde = desktop_name && (0 == strcmp(desktop_name, "LXDE")); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { usage(); exit(0); } else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) { printf("lxpanel %s\n", version); exit(0); } else if (!strcmp(argv[i], "--log")) { i++; if (i == argc) { g_critical( "lxpanel: missing log level"); usage(); exit(1); } else { /* deprecated */ } } else if (!strcmp(argv[i], "--configure") || !strcmp(argv[i], "-C")) { config = 1; } else if (!strcmp(argv[i], "--profile") || !strcmp(argv[i], "-p")) { i++; if (i == argc) { g_critical( "lxpanel: missing profile name"); usage(); exit(1); } else { cprofile = g_strdup(argv[i]); } } else { printf("lxpanel: unknown option - %s\n", argv[i]); usage(); exit(1); } } /* Add a gtkrc file to be parsed too. */ file = _user_config_file_name("gtkrc", NULL); gtk_rc_parse(file); g_free(file); /* Check for duplicated lxpanel instances */ if (!check_main_lock() && !config) { printf("There is already an instance of LXPanel. Now to exit\n"); exit(1); } _ensure_user_config_dirs(); /* Add our own icons to the search path of icon theme */ gtk_icon_theme_append_search_path( gtk_icon_theme_get_default(), PACKAGE_DATA_DIR "/images" ); fbev = fb_ev_new(); is_restarting = FALSE; /* init LibFM */ fm_gtk_init(NULL); /* prepare modules data */ lxpanel_prepare_modules(); init_static_plugins(); load_global_config(); /* NOTE: StructureNotifyMask is required by XRandR * See init_randr_support() in gdkscreen-x11.c of gtk+ for detail. */ gdk_window_set_events(gdk_get_default_root_window(), GDK_STRUCTURE_MASK | GDK_SUBSTRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK); gdk_window_add_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, NULL); if( G_UNLIKELY( ! start_all_panels() ) ) g_warning( "Config files are not found.\n" ); /* * FIXME: configure?? if (config) configure(); */ gtk_main(); XSelectInput (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_ROOT_WINDOW(), NoEventMask); gdk_window_remove_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, NULL); /* destroy all panels */ g_slist_foreach( all_panels, (GFunc) gtk_widget_destroy, NULL ); g_slist_free( all_panels ); all_panels = NULL; g_free( cfgfile ); free_global_config(); lxpanel_unload_modules(); fm_gtk_finalize(); /* gdk_threads_leave(); */ g_object_unref(fbev); if (!is_restarting) return 0; if (strchr(argv[0], G_DIR_SEPARATOR)) execve(argv[0], argv, env); else execve(g_find_program_in_path(argv[0]), argv, env); return 1; }
static VALUE rg_m_parse(G_GNUC_UNUSED VALUE self, VALUE filename) { gtk_rc_parse(RVAL2CSTR(filename)); return filename; }
int main ( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *label; pthread_t thread; /* init threads */ g_thread_init (NULL); gdk_threads_init (); gdk_threads_enter (); /* init GTK+ */ gtk_init (&argc, &argv); gtk_set_locale (); gtk_rc_parse ("~/.presagegtkrc"); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "gpresagemate"); gtk_window_set_default_size (GTK_WINDOW(window), 150, 180); gtk_window_set_position (GTK_WINDOW(window), GTK_WIN_POS_NONE); /* When the window is given the "delete_event" signal (this is given * by the window manager, usually by the "close" option, or on the * titlebar), we ask it to call the delete_event () function * as defined above. The data passed to the callback * function is NULL and is ignored in the callback function. */ g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL); /* Here we connect the "destroy" event to a signal handler. * This event occurs when we call gtk_widget_destroy() on the window, * or if we return FALSE in the "delete_event" callback. */ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL); label = gtk_label_new ("gpresagemate"); gtk_widget_set_name(label, "presage_suggestions"); gtk_container_add (GTK_CONTAINER(window), label); gtk_widget_show (window); gtk_widget_show (label); init (); if (0 != pthread_create (&thread, NULL, presage_thread, label)) { perror("Failed to spawn presage thread"); exit(2); } gtk_main (); /* clean up threads */ gdk_threads_leave (); return 0; }
static gint sobel_dialog () { GtkWidget *dlg; GtkWidget *button; GtkWidget *toggle; GtkWidget *frame; GtkWidget *vbox; GtkWidget *hbox; gchar **argv; gint argc; argc = 1; argv = g_new (gchar *, 1); argv[0] = g_strdup ("sobel"); gtk_init (&argc, &argv); gtk_rc_parse (gimp_gtkrc ()); dlg = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dlg), _("Sobel Edge Detection")); gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE); gtk_signal_connect (GTK_OBJECT (dlg), "destroy", (GtkSignalFunc) sobel_close_callback, NULL); /* Action area */ button = gtk_button_new_with_label (_("OK")); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) sobel_ok_callback, dlg); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0); gtk_widget_grab_default (button); gtk_widget_show (button); button = gtk_button_new_with_label (_("Cancel")); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_signal_connect_object (GTK_OBJECT (button), "clicked", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT (dlg)); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0); gtk_widget_show (button); /* parameter settings */ frame = gtk_frame_new (_("Parameter Settings")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); gtk_container_border_width (GTK_CONTAINER (frame), 10); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0); vbox = gtk_vbox_new (FALSE, 5); gtk_container_border_width (GTK_CONTAINER (vbox), 10); gtk_container_add (GTK_CONTAINER (frame), vbox); toggle = gtk_check_button_new_with_label (_("Sobel Horizontally")); gtk_box_pack_start (GTK_BOX (vbox), toggle, TRUE, TRUE, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", (GtkSignalFunc) sobel_toggle_update, &bvals.horizontal); gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (toggle), bvals.horizontal); gtk_widget_show (toggle); toggle = gtk_check_button_new_with_label (_("Sobel Vertically")); gtk_box_pack_start (GTK_BOX (vbox), toggle, TRUE, TRUE, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", (GtkSignalFunc) sobel_toggle_update, &bvals.vertical); gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (toggle), bvals.vertical); gtk_widget_show (toggle); toggle = gtk_check_button_new_with_label (_("Keep sign of result (one direction only)")); gtk_box_pack_start (GTK_BOX (vbox), toggle, TRUE, TRUE, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", (GtkSignalFunc) sobel_toggle_update, &bvals.keep_sign); gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (toggle), bvals.vertical); gtk_widget_show (toggle); hbox = gtk_hbox_new (FALSE, 5); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); gtk_widget_show (vbox); gtk_widget_show (frame); gtk_widget_show (dlg); gtk_main (); gdk_flush (); return bint.run; }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env, jclass clazz __attribute__((unused)), jint portableNativeSync) { int argc = 1; char **argv; char *homedir, *rcpath = NULL; gtkgenericpeer = (*env)->FindClass(env, "gnu/java/awt/peer/gtk/GtkGenericPeer"); gtkgenericpeer = (*env)->NewGlobalRef(env, gtkgenericpeer); printCurrentThreadID = (*env)->GetStaticMethodID (env, gtkgenericpeer, "printCurrentThread", "()V"); NSA_INIT (env, gtkgenericpeer); g_assert((*env)->GetJavaVM(env, &java_vm) == 0); /* GTK requires a program's argc and argv variables, and requires that they be valid. Set it up. */ argv = (char **) g_malloc (sizeof (char *) * 2); argv[0] = (char *) g_malloc(1); argv[0][0] = '\0'; argv[1] = NULL; init_glib_threads(env, portableNativeSync); /* From GDK 2.0 onwards we have to explicitly call gdk_threads_init */ gdk_threads_init(); gtk_init (&argc, &argv); #if SYNCHRONIZE_GDK XSynchronize (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), True); #endif gtk_widget_set_default_colormap (gdk_rgb_get_colormap ()); /* Make sure queued calls don't get sent to GTK/GDK while we're shutting down. */ atexit (gdk_threads_enter); if ((homedir = getenv ("HOME"))) { rcpath = (char *) g_malloc (strlen (homedir) + strlen (RC_FILE) + 2); sprintf (rcpath, "%s/%s", homedir, RC_FILE); } gtk_rc_parse ((rcpath) ? rcpath : RC_FILE); g_free (rcpath); g_free (argv[0]); g_free (argv); /* On errors or warning print a whole stacktrace. */ #if GTK_MINOR_VERSION > 4 old_glog_func = g_log_set_default_handler (&glog_func, NULL); #endif cp_gtk_button_init_jni (); cp_gtk_checkbox_init_jni (); cp_gtk_choice_init_jni (); cp_gtk_component_init_jni (); cp_gtk_filedialog_init_jni (); cp_gtk_list_init_jni (); cp_gtk_menuitem_init_jni (); cp_gtk_scrollbar_init_jni (); cp_gtk_textcomponent_init_jni (); cp_gtk_window_init_jni (); cp_gtk_global_window_group = gtk_window_group_new (); init_dpi_conversion_factor (); }
void ags_test_init(int *argc, char ***argv, gchar *conf_str) { AgsConfig *config; gchar *filename; gboolean single_thread_enabled; gboolean builtin_theme_disabled; guint i; #ifdef AGS_WITH_RT struct sched_param param; struct rlimit rl; #endif struct passwd *pw; gchar *wdir, *config_file; gchar *rc_filename; gchar *base_dir; gchar *str, *data_dir; gchar path[PATH_MAX]; uint32_t size = sizeof(path); uid_t uid; int result; const rlim_t kStackSize = 64L * 1024L * 1024L; // min stack size = 64 Mb base_dir = strdup(SRCDIR); printf("base dir %s\n", base_dir); /* set some environment variables */ sprintf(path, "%s/gsequencer.share/styles", base_dir); data_dir = realpath(path, NULL); str = malloc(PATH_MAX * sizeof(gchar)); sprintf(str, "AGS_RC_FILENAME=%s/ags.rc", data_dir); putenv(str); sprintf(path, "%s/gsequencer.share/images", base_dir); data_dir = realpath(path, NULL); str = malloc(PATH_MAX * sizeof(gchar)); sprintf(str, "AGS_ANIMATION_FILENAME=%s/ags_supermoon-800x450.png", data_dir); putenv(str); sprintf(path, "%s/gsequencer.share/images", base_dir); data_dir = realpath(path, NULL); str = malloc(PATH_MAX * sizeof(gchar)); sprintf(str, "AGS_LOGO_FILENAME=%s/ags.png", data_dir); putenv(str); sprintf(path, "%s", base_dir); data_dir = realpath(path, NULL); str = malloc(PATH_MAX * sizeof(gchar)); sprintf(str, "AGS_LICENSE_FILENAME=%s/COPYING", data_dir); putenv(str); /* gettext */ setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); /* parameters */ single_thread_enabled = FALSE; builtin_theme_disabled = FALSE; // g_log_set_fatal_mask("GLib", // "Gtk" , // // G_LOG_LEVEL_CRITICAL); // G_LOG_LEVEL_WARNING #ifdef AGS_WITH_RT result = getrlimit(RLIMIT_STACK, &rl); /* set stack size 64M */ if(result == 0){ if(rl.rlim_cur < kStackSize){ rl.rlim_cur = kStackSize; result = setrlimit(RLIMIT_STACK, &rl); if(result != 0){ //TODO:JK } } } param.sched_priority = GSEQUENCER_RT_PRIORITY; if(sched_setscheduler(0, SCHED_FIFO, ¶m) == -1) { perror("sched_setscheduler failed"); } #endif //#ifdef AGS_WITH_X11 XInitThreads(); //#endif /* parse command line parameter */ filename = NULL; for(i = 0; i < argc[0]; i++){ if(!strncmp(argv[0][i], "--help", 7)){ printf("GSequencer is an audio sequencer and notation editor\n\n"); printf("Usage:\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\n", "Report bugs to <*****@*****.**>\n", "--filename file open file", "--single-thread run in single thread mode", "--no-builtin-theme disable built-in theme", "--help display this help and exit", "--version output version information and exit"); exit(0); }else if(!strncmp(argv[0][i], "--version", 10)){ printf("GSequencer %s\n\n", AGS_VERSION); printf("%s\n%s\n%s\n\n", "Copyright (C) 2005-2017 Joël Krähemann", "This is free software; see the source for copying conditions. There is NO", "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); printf("Written by Joël Krähemann\n"); exit(0); }else if(!strncmp(argv[0][i], "--single-thread", 16)){ single_thread_enabled = TRUE; }else if(!strncmp(argv[0][i], "--no-builtin-theme", 19)){ builtin_theme_disabled = TRUE; }else if(!strncmp(argv[0][i], "--filename", 11)){ filename = *argv[i + 1]; i++; } } uid = getuid(); pw = getpwuid(uid); /* parse rc file */ if(!builtin_theme_disabled){ rc_filename = g_strdup_printf("%s/%s/ags.rc", pw->pw_dir, AGS_DEFAULT_DIRECTORY); if(!g_file_test(rc_filename, G_FILE_TEST_IS_REGULAR)){ g_free(rc_filename); #ifdef AGS_RC_FILENAME rc_filename = g_strdup(AGS_RC_FILENAME); #else if((rc_filename = getenv("AGS_RC_FILENAME")) == NULL){ rc_filename = g_strdup_printf("%s%s", DESTDIR, "/gsequencer/styles/ags.rc"); }else{ rc_filename = g_strdup(rc_filename); } #endif } gtk_rc_parse(rc_filename); g_free(rc_filename); } /**/ LIBXML_TEST_VERSION; ags_gui_init(argc, argv); gtk_init(argc, argv); if(!builtin_theme_disabled){ g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Raleigh", NULL); g_signal_handlers_block_matched(gtk_settings_get_default(), G_SIGNAL_MATCH_DETAIL, g_signal_lookup("set-property", GTK_TYPE_SETTINGS), g_quark_from_string("gtk-theme-name"), NULL, NULL, NULL); } #ifdef AGS_WITH_LIBINSTPATCH ipatch_init(); #endif /* setup */ wdir = g_strdup_printf("%s/%s", pw->pw_dir, AGS_DEFAULT_DIRECTORY); config_file = g_strdup_printf("%s/%s", wdir, AGS_DEFAULT_CONFIG); config = ags_config_get_instance(); if(conf_str != NULL){ ags_config_load_from_data(config, conf_str, strlen(conf_str)); }else{ ags_config_load_from_file(config, config_file); } g_free(wdir); g_free(config_file); }
static void rc_load_gtkrc() { gtk_rc_parse(gtkrc_file); }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz) { int argc = 1; char **argv; char *homedir, *rcpath = NULL; /* jclass gtkgenericpeer; */ jclass gtkcomponentpeer, gtkchoicepeer, gtkwindowpeer, gtkscrollbarpeer, gtklistpeer, gtkmenuitempeer, gtktextcomponentpeer, window; NSA_INIT (env, clazz); /* GTK requires a program's argc and argv variables, and requires that they be valid. */ argv = (char **) malloc (sizeof (char *) * 2); argv[0] = ""; argv[1] = NULL; /* until we have JDK 1.2 JNI, assume we have a VM with threads that match what GLIB was compiled for */ #ifdef PORTABLE_NATIVE_SYNC (*env)->GetJavaVM( env, &gdk_vm ); g_thread_init ( &g_thread_jni_functions ); printf("called gthread init\n"); #else g_thread_init ( NULL ); #endif /* From GDK 2.0 onwards we have to explicitly call gdk_threads_init */ gdk_threads_init(); gtk_init (&argc, &argv); gdk_rgb_init (); gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); gtk_widget_set_default_visual (gdk_rgb_get_visual ()); /* Make sure queued calls don't get sent to GTK/GDK while we're shutting down. */ atexit (gdk_threads_enter); gdk_env = env; gdk_event_handler_set ((GdkEventFunc)awt_event_handler, NULL, NULL); if ((homedir = getenv ("HOME"))) { rcpath = (char *) malloc (strlen (homedir) + strlen (RC_FILE) + 2); sprintf (rcpath, "%s/%s", homedir, RC_FILE); } gtk_rc_parse ((rcpath) ? rcpath : RC_FILE); if (rcpath) free (rcpath); free (argv); /* setup cached IDs for posting GTK events to Java */ /* gtkgenericpeer = (*env)->FindClass (env, */ /* "gnu/java/awt/peer/gtk/GtkGenericPeer"); */ window = (*env)->FindClass (env, "java/awt/Window"); gtkcomponentpeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkComponentPeer"); gtkchoicepeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkChoicePeer"); gtkwindowpeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkWindowPeer"); gtkscrollbarpeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkScrollbarPeer"); gtklistpeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkListPeer"); gtkmenuitempeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkMenuItemPeer"); gtktextcomponentpeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkTextComponentPeer"); /* gdkColor = (*env)->FindClass (env, */ /* "gnu/java/awt/peer/gtk/GdkColor"); */ /* gdkColorID = (*env)->GetMethodID (env, gdkColor, "<init>", "(III)V"); */ /* postActionEventID = (*env)->GetMethodID (env, gtkgenericpeer, */ /* "postActionEvent", */ /* "(Ljava/lang/String;I)V"); */ setBoundsCallbackID = (*env)->GetMethodID (env, window, "setBoundsCallback", "(IIII)V"); postMenuActionEventID = (*env)->GetMethodID (env, gtkmenuitempeer, "postMenuActionEvent", "()V"); postMouseEventID = (*env)->GetMethodID (env, gtkcomponentpeer, "postMouseEvent", "(IJIIIIZ)V"); postConfigureEventID = (*env)->GetMethodID (env, gtkwindowpeer, "postConfigureEvent", "(IIII)V"); postWindowEventID = (*env)->GetMethodID (env, gtkwindowpeer, "postWindowEvent", "(ILjava/awt/Window;I)V"); postExposeEventID = (*env)->GetMethodID (env, gtkcomponentpeer, "postExposeEvent", "(IIII)V"); postKeyEventID = (*env)->GetMethodID (env, gtkcomponentpeer, "postKeyEvent", "(IJIICI)V"); postFocusEventID = (*env)->GetMethodID (env, gtkcomponentpeer, "postFocusEvent", "(IZ)V"); postAdjustmentEventID = (*env)->GetMethodID (env, gtkscrollbarpeer, "postAdjustmentEvent", "(II)V"); postItemEventID = (*env)->GetMethodID (env, gtkcomponentpeer, "postItemEvent", "(Ljava/lang/Object;I)V"); choicePostItemEventID = (*env)->GetMethodID (env, gtkchoicepeer, "choicePostItemEvent", "(Ljava/lang/String;I)V"); postListItemEventID = (*env)->GetMethodID (env, gtklistpeer, "postItemEvent", "(II)V"); postTextEventID = (*env)->GetMethodID (env, gtktextcomponentpeer, "postTextEvent", "()V"); global_gtk_window_group = gtk_window_group_new (); }
/***************************************************************************** * Initialize and launch the interface *****************************************************************************/ static void *Thread( void *obj ) { intf_thread_t *p_intf = (intf_thread_t *)obj; const char *p_args[] = { "vlc" }; int i_args = sizeof(p_args)/sizeof(char *); char **pp_args = (char **)p_args; HildonProgram *program; HildonWindow *window; GtkWidget *main_vbox, *bottom_hbox; GtkWidget *video, *seekbar; GtkWidget *play_button, *prev_button, *next_button; GtkWidget *stop_button, *playlist_button; gtk_init( &i_args, &pp_args ); program = HILDON_PROGRAM( hildon_program_get_instance() ); g_set_application_name( "VLC Media Player" ); window = HILDON_WINDOW( hildon_window_new() ); hildon_program_add_window( program, window ); gtk_object_set_data( GTK_OBJECT( window ), "p_intf", p_intf ); p_intf->p_sys->p_main_window = window; g_signal_connect( GTK_WIDGET(window), "key-press-event", G_CALLBACK( key_cb ), p_intf ); g_signal_connect (GTK_WIDGET(window), "delete_event", GTK_SIGNAL_FUNC( quit_event), p_intf ); // A little theming char *psz_rc_file = NULL; char *psz_data = config_GetDataDir( p_intf ); if( asprintf( &psz_rc_file, "%s/maemo/vlc_intf.rc", psz_data ) != -1 ) { gtk_rc_parse( psz_rc_file ); free( psz_rc_file ); } free( psz_data ); // We create the main vertical box main_vbox = gtk_vbox_new( FALSE, 0 ); gtk_container_add( GTK_CONTAINER( window ), main_vbox ); // Menubar GtkWidget *main_menu = create_menu( p_intf ); #ifdef HAVE_MAEMO hildon_window_set_menu( HILDON_WINDOW( p_intf->p_sys->p_main_window ), GTK_MENU( main_menu ) ); #else GtkWidget *menu_bar = gtk_menu_bar_new (); GtkWidget *item = gtk_menu_item_new_with_label ("Menu"); gtk_menu_bar_append(menu_bar, item); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), main_menu); gtk_widget_show_all (menu_bar); gtk_box_pack_start(GTK_BOX(main_vbox), menu_bar, FALSE, FALSE, 0); #endif // We put first the embedded video video = gtk_event_box_new(); GdkColor black = {0,0,0,0}; gtk_widget_modify_bg(video, GTK_STATE_NORMAL, &black); p_intf->p_sys->p_video_window = video; gtk_box_pack_start( GTK_BOX( main_vbox ), video, TRUE, TRUE, 0 ); create_playlist( p_intf ); gtk_box_pack_start( GTK_BOX( main_vbox ), p_intf->p_sys->p_playlist_window, TRUE, TRUE, 0 ); // We put the horizontal box which contains all the buttons p_intf->p_sys->p_control_window = bottom_hbox = gtk_hbox_new( FALSE, 0 ); // We create the buttons play_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( play_button ), gtk_image_new_from_stock( "vlc-play", GTK_ICON_SIZE_BUTTON ) ); p_intf->p_sys->p_play_button = play_button; stop_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( stop_button ), gtk_image_new_from_stock( "vlc-stop", GTK_ICON_SIZE_BUTTON ) ); prev_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( prev_button ), gtk_image_new_from_stock( "vlc-previous", GTK_ICON_SIZE_BUTTON ) ); next_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( next_button ), gtk_image_new_from_stock( "vlc-next", GTK_ICON_SIZE_BUTTON ) ); playlist_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( playlist_button ), gtk_image_new_from_stock( "vlc-playlist", GTK_ICON_SIZE_BUTTON ) ); seekbar = hildon_seekbar_new(); p_intf->p_sys->p_seekbar = HILDON_SEEKBAR( seekbar ); // We add them to the hbox gtk_box_pack_start( GTK_BOX( bottom_hbox ), play_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), stop_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), prev_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), next_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), playlist_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), seekbar , TRUE , TRUE , 5 ); // We add the hbox to the main vbox gtk_box_pack_start( GTK_BOX( main_vbox ), bottom_hbox, FALSE, FALSE, 0 ); g_signal_connect( play_button, "clicked", G_CALLBACK( play_cb ), NULL ); g_signal_connect( stop_button, "clicked", G_CALLBACK( stop_cb ), NULL ); g_signal_connect( prev_button, "clicked", G_CALLBACK( prev_cb ), NULL ); g_signal_connect( next_button, "clicked", G_CALLBACK( next_cb ), NULL ); g_signal_connect( playlist_button, "clicked", G_CALLBACK( playlist_cb ), NULL ); g_signal_connect( seekbar, "change-value", G_CALLBACK( seekbar_changed_cb ), NULL ); gtk_widget_show_all( GTK_WIDGET( window ) ); gtk_widget_hide_all( p_intf->p_sys->p_playlist_window ); #if 1 /* HACK: Only one X11 client can subscribe to mouse button press events. * VLC currently handles those in the video display. * Force GTK to unsubscribe from mouse press and release events. */ Display *dpy = GDK_WINDOW_XDISPLAY( gtk_widget_get_window(p_intf->p_sys->p_video_window) ); Window w = GDK_WINDOW_XID( gtk_widget_get_window(p_intf->p_sys->p_video_window) ); XWindowAttributes attr; XGetWindowAttributes( dpy, w, &attr ); attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask); XSelectInput( dpy, w, attr.your_event_mask ); #endif // The embedded video is only ready after gtk_main and windows are shown g_idle_add( interface_ready, p_intf ); gtk_main(); delete_input( p_intf ); delete_playlist( p_intf ); gtk_object_destroy( GTK_OBJECT( main_menu ) ); gtk_object_destroy( GTK_OBJECT( window ) ); return NULL; }
//main takes arguments from the commandline int main(int argc,char*argv[]) { GtkWidget*window; GtkWidget*button1,*button3,*button4,*button5,*button6,*button7,*button8,*button9,*handle; GtkWidget*picture1,*picture2,*label3,*label4,*label5,*label6,*label7,*label8,*label9,*label10,*label11,*label1,*label2; GtkWidget*box1,*box2,*box3,*box4,*box5,*box6,*box7,*box8,*box9,*picture; GtkWidget*image1,*image2,*image3,*image4,*image5,*image6,*image7,*image8,*image9,*lab1,*lab2,*lab3,*lab4; GtkWidget*hbox1,*hbox2,*hbox3,*hbox4,*hbox5,*hbox6,*hbox7,*hbox8,*hbox9,*hbox11; GtkWidget*vbox,*vbox1,*notebook,*fbox1,*fbox2,*fbox3,*fbox4,*pict1,*pict2,*pict3,*pict4; GdkColor color1,color2,color3; GtkWidget*but1,*but2,*but3,*but4; GtkWidget*img1,*img2,*img3,*img4; gtk_init(&argc,&argv); if(!gtk_init_check(&argc,&argv)) { handle_err("FAILED TO INITIALIZE THE GTK LIBRARIES"); } //the following creats a window window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable(GTK_WINDOW(window),TRUE); gtk_window_set_title(GTK_WINDOW(window),"GOSPEL BROWSER"); gtk_window_maximize(GTK_WINDOW(window)); gtk_window_present(GTK_WINDOW(window)); gtk_container_set_border_width(GTK_CONTAINER(window),0); gtk_window_set_icon_from_file(GTK_WINDOW(window),"icon.jpg",NULL); g_signal_connect(GTK_OBJECT(window),"destroy",G_CALLBACK(Close_Window),NULL); //the following creats entry boxes entry1=gtk_entry_new(); entry2=gtk_entry_new(); entry3=gtk_entry_new(); //reading a picture from the desktop picture1=gtk_image_new_from_file("picture.jpg"); picture2=gtk_image_new_from_file("ogo.jpg"); gtk_widget_set_size_request(picture1,300,100); //creating entry boxes gtk_entry_set_text(GTK_ENTRY(entry1),"http//:"); gtk_entry_set_text(GTK_ENTRY(entry2),"search"); gtk_entry_set_text(GTK_ENTRY(entry3),"www.emmanuelTV.com"); //the lines of code below creats images from stock image1=gtk_image_new_from_stock(GTK_STOCK_ADD,GTK_ICON_SIZE_MENU); image2=gtk_image_new_from_stock(GTK_STOCK_CLOSE,GTK_ICON_SIZE_MENU); image3=gtk_image_new_from_stock(GTK_STOCK_GO_BACK,GTK_ICON_SIZE_BUTTON); image4=gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_BUTTON); image5=gtk_image_new_from_stock(GTK_STOCK_FIND,GTK_ICON_SIZE_BUTTON); image6=gtk_image_new_from_stock(GTK_STOCK_HOME,GTK_ICON_SIZE_BUTTON); image7=gtk_image_new_from_file("search.jpg"); image8=gtk_image_new_from_stock(GTK_STOCK_GO_DOWN,GTK_ICON_SIZE_BUTTON); image9=gtk_image_new_from_stock(GTK_STOCK_EXECUTE,GTK_ICON_SIZE_BUTTON); //creates buttons button1=gtk_button_new(); button2=gtk_button_new(); button3=gtk_button_new(); button4=gtk_button_new(); button5=gtk_button_new(); button6=gtk_button_new(); button7=gtk_button_new(); button8=gtk_button_new(); button9=gtk_button_new(); but1=gtk_button_new(); but2=gtk_button_new(); but3=gtk_button_new(); but4=gtk_button_new(); //box creation box1=gtk_hbox_new(TRUE,0); box2=gtk_hbox_new(TRUE,0); box3=gtk_hbox_new(TRUE,0); box4=gtk_hbox_new(TRUE,0); box5=gtk_hbox_new(TRUE,0); box6=gtk_hbox_new(TRUE,0); box7=gtk_hbox_new(TRUE,0); box8=gtk_hbox_new(TRUE,0); box9=gtk_hbox_new(TRUE,0); //the next lines adds the images to the buttons gtk_box_pack_start_defaults(GTK_BOX(box1),image1); gtk_container_add(GTK_CONTAINER(button1),box1); gtk_widget_show_all(button1); gtk_box_pack_start_defaults(GTK_BOX(box2),image2); gtk_widget_set_size_request(box2,10,10); gtk_container_add(GTK_CONTAINER(button2),box2); gtk_widget_show_all(button2); gtk_box_pack_start_defaults(GTK_BOX(box3),image3); gtk_widget_set_size_request(box3,5,5); gtk_container_add(GTK_CONTAINER(button3),box3); gtk_widget_show_all(button3); gtk_box_pack_start_defaults(GTK_BOX(box4),image4); gtk_widget_set_size_request(box4,5,5); gtk_container_add(GTK_CONTAINER(button4),box4); gtk_widget_show_all(button4); gtk_box_pack_start_defaults(GTK_BOX(box5),image5); gtk_widget_set_size_request(box5,5,5); gtk_container_add(GTK_CONTAINER(button5),box5); gtk_widget_show_all(button5); gtk_box_pack_start_defaults(GTK_BOX(box6),image6); gtk_widget_set_size_request(box6,5,5); gtk_container_add(GTK_CONTAINER(button6),box6); gtk_widget_show_all(button6); gtk_box_pack_start_defaults(GTK_BOX(box7),image7); gtk_widget_set_size_request(box7,5,2); gtk_container_add(GTK_CONTAINER(button7),box7); gtk_widget_show_all(button7); gtk_box_pack_start_defaults(GTK_BOX(box8),image8); gtk_widget_set_size_request(box8,5,5); gtk_container_add(GTK_CONTAINER(button8),box8); gtk_widget_show_all(button8); gtk_box_pack_start_defaults(GTK_BOX(box9),image9); gtk_widget_set_size_request(box9,5,5); gtk_container_add(GTK_CONTAINER(button9),box9); gtk_widget_show_all(button9); //this creats labels to be added in to the hboxes label1=gtk_label_new(" "); label2=gtk_label_new(" "); label3=gtk_label_new("Gospel"); label4=gtk_label_new(""); label5=gtk_label_new(" "); label6=gtk_label_new(""); label7=gtk_label_new(" "); label8=gtk_label_new(" "); label9=gtk_label_new(" "); label10=gtk_label_new(" "); label11=gtk_label_new(" "); lab1=gtk_label_new(" "); lab2=gtk_label_new(" "); lab3=gtk_label_new(" "); lab4=gtk_label_new(" "); //color addiotion gdk_color_parse("#CA29EF",&color1); gdk_color_parse("#29EF2F",&color2); gdk_color_parse("#2951EF",&color3); //the function below changes the color of the labels specified gtk_widget_modify_fg(label3,GTK_STATE_NORMAL,&color3); /*creats hboxes abd vboxes to be added to the window*/ hbox1=gtk_hbox_new(FALSE,0); hbox2=gtk_hbox_new(FALSE,0); hbox3=gtk_hbox_new(FALSE,0); hbox4=gtk_hbox_new(FALSE,3); hbox5=gtk_hbox_new(TRUE,0); hbox6=gtk_hbox_new(TRUE,0); hbox7=gtk_hbox_new(TRUE,0); hbox8=gtk_hbox_new(TRUE,0); hbox9=gtk_hbox_new(TRUE,0); hbox10=gtk_hbox_new(FALSE,0); hbox11=gtk_hbox_new(TRUE,0); //vertical boxes vbox=gtk_vbox_new(FALSE,0); vbox1=gtk_vbox_new(TRUE,0); //creating event boxes fbox1=gtk_hbox_new(TRUE,0); fbox2=gtk_hbox_new(TRUE,0); fbox3=gtk_hbox_new(TRUE,0); fbox4=gtk_hbox_new(TRUE,0); //crating picutres pict1=gtk_image_new_from_file("joshua.jpg"); pict2=gtk_image_new_from_file("johnson.jpg"); pict3=gtk_image_new_from_file("chris.jpg"); pict4=gtk_image_new_from_file("Duncan.jpg"); //packing the images into the the event boxes gtk_box_pack_start_defaults(GTK_BOX(fbox1),pict1); gtk_widget_set_size_request(fbox1,65,30); gtk_container_add(GTK_CONTAINER(but1),fbox1); gtk_widget_show_all(but1); gtk_box_pack_start_defaults(GTK_BOX(fbox2),pict2); gtk_widget_set_size_request(fbox2,65,30); gtk_container_add(GTK_CONTAINER(but2),fbox2); gtk_widget_show_all(but2); gtk_box_pack_start_defaults(GTK_BOX(fbox3),pict3); gtk_widget_set_size_request(fbox3,100,30); gtk_container_add(GTK_CONTAINER(but3),fbox3); gtk_widget_show_all(but3); gtk_box_pack_start_defaults(GTK_BOX(fbox4),pict4); gtk_widget_set_size_request(fbox4,100,30); gtk_container_add(GTK_CONTAINER(but4),fbox4); gtk_widget_show_all(but4); //the following uses box pack function to add buttons to the hboxes gtk_box_pack_start_defaults(GTK_BOX(hbox1),button3); g_object_set(button3,"relief",GTK_RELIEF_NONE,NULL); gtk_box_pack_start_defaults(GTK_BOX(hbox1),button4); g_object_set(button4,"relief",GTK_RELIEF_NONE,NULL); gtk_box_pack_start_defaults(GTK_BOX(hbox1),entry1); gtk_box_pack_start_defaults(GTK_BOX(hbox1),button5); g_object_set(button5,"relief",GTK_RELIEF_NONE,NULL); g_signal_connect(GTK_OBJECT(button5),"clicked",G_CALLBACK(button_clicked),"button5"); gtk_box_pack_start_defaults(GTK_BOX(hbox1),entry2); gtk_box_pack_start_defaults(GTK_BOX(hbox1),button6); g_object_set(button6,"relief",GTK_RELIEF_NONE,NULL); gtk_box_pack_start_defaults(GTK_BOX(hbox1),button9); g_object_set(button9,"relief",GTK_RELIEF_NONE,NULL); g_signal_connect(GTK_OBJECT(button9),"clicked",GTK_SIGNAL_FUNC(upload_logo),"men_of_God"); gtk_box_pack_start_defaults(GTK_BOX(hbox1),button8); g_object_set(button8,"relief",GTK_RELIEF_NONE,NULL); g_signal_connect(GTK_OBJECT(button8),"clicked",GTK_SIGNAL_FUNC(file_chooser),"download"); gtk_widget_set_size_request(hbox1,800,1); gtk_box_pack_start_defaults(GTK_BOX(vbox),hbox1); gtk_box_pack_start_defaults(GTK_BOX(hbox9),label11); gtk_box_pack_start_defaults(GTK_BOX(vbox),hbox9); gtk_box_pack_start_defaults(GTK_BOX(hbox2),label4); gtk_box_pack_start_defaults(GTK_BOX(hbox2),picture1); gtk_box_pack_start_defaults(GTK_BOX(hbox2),label5); gtk_box_pack_start_defaults(GTK_BOX(vbox),hbox2); gtk_box_pack_start_defaults(GTK_BOX(hbox3),label1); gtk_box_pack_start_defaults(GTK_BOX(hbox3),picture2); gtk_box_pack_start_defaults(GTK_BOX(hbox3),entry3); gtk_box_pack_start_defaults(GTK_BOX(hbox3),button7); gtk_box_pack_start_defaults(GTK_BOX(hbox3),label2); gtk_box_pack_start_defaults(GTK_BOX(hbox3),label8); gtk_widget_set_size_request(button7,10,3); gtk_widget_set_size_request(hbox3,100,20); g_object_set(button7,"relief",GTK_RELIEF_NONE,NULL); g_signal_connect(GTK_OBJECT(button7),"clicked",GTK_SIGNAL_FUNC(button_clicked),"button7"); gtk_widget_set_size_request(hbox4,100,10); gtk_box_pack_start_defaults(GTK_BOX(vbox),hbox3); gtk_box_pack_start_defaults(GTK_BOX(hbox4),lab1); gtk_box_pack_start_defaults(GTK_BOX(hbox4),lab3); gtk_box_pack_start_defaults(GTK_BOX(hbox4),but1); g_object_set(but1,"relief",GTK_RELIEF_NONE,NULL); g_signal_connect(GTK_OBJECT(but1),"clicked",G_CALLBACK(generals_func),"Joshua"); gtk_box_pack_start_defaults(GTK_BOX(hbox4),but2); g_object_set(but2,"relief",GTK_RELIEF_NONE,NULL); g_signal_connect(GTK_OBJECT(but2),"clicked",G_CALLBACK(generals_func),"Johnson"); gtk_box_pack_start_defaults(GTK_BOX(hbox4),but3); g_object_set(but3,"relief",GTK_RELIEF_NONE,NULL); g_signal_connect(GTK_OBJECT(but3),"clicked",G_CALLBACK(generals_func),"Chris"); gtk_box_pack_start_defaults(GTK_BOX(hbox4),but4); g_object_set(but4,"relief",GTK_RELIEF_NONE,NULL); g_signal_connect(GTK_OBJECT(but4),"clicked",G_CALLBACK(generals_func),"Duncan"); gtk_box_pack_start_defaults(GTK_BOX(hbox4),lab2); gtk_box_pack_start_defaults(GTK_BOX(hbox4),lab4); gtk_widget_set_size_request(hbox4,100,150); gtk_box_pack_start_defaults(GTK_BOX(vbox),hbox4); //the following creats a notebook notebook=gtk_notebook_new(); gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook),TRUE); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook),GTK_POS_TOP); gtk_box_pack_start_defaults(GTK_BOX(hbox10),button2); g_object_set(button2,"relief",GTK_RELIEF_NONE,NULL); gtk_box_pack_start_defaults(GTK_BOX(hbox10),label3); gtk_box_pack_start_defaults(GTK_BOX(hbox10),button1); g_object_set(button1,"relief",GTK_RELIEF_NONE,NULL); gtk_widget_show_all(hbox10); gtk_widget_set_size_request(hbox10,150,35); gtk_notebook_append_page(GTK_NOTEBOOK(notebook),vbox,hbox10); g_signal_connect(GTK_OBJECT(button1),"clicked",G_CALLBACK(switch_page),(gpointer)notebook); g_signal_connect(GTK_OBJECT(button2),"clicked",G_CALLBACK(CloseApp),(gpointer)notebook); gtk_rc_parse("gosple.gtkrc"); //changes the sizes of some widgets gtk_widget_set_size_request(entry1,750,27); gtk_widget_set_size_request(button3,20,10); gtk_widget_set_size_request(button4,20,10); gtk_widget_set_size_request(button5,20,10); gtk_widget_set_size_request(button6,20,10); gtk_widget_set_size_request(button8,20,10); gtk_widget_set_size_request(entry3,400,27); gtk_widget_set_size_request(entry2,200,27); //adds the notebook to a contiainer gtk_container_add(GTK_CONTAINER(window),notebook); gtk_widget_show_all(window); gtk_main(); return 0; }
int dt_gui_gtk_init(dt_gui_gtk_t *gui, int argc, char *argv[]) { // unset gtk rc from kde: char gtkrc[PATH_MAX], path[PATH_MAX], datadir[PATH_MAX], configdir[PATH_MAX]; dt_loc_get_datadir(datadir, PATH_MAX); dt_loc_get_user_config_dir(configdir, PATH_MAX); g_snprintf(gtkrc, PATH_MAX, "%s/darktable.gtkrc", configdir); if (!g_file_test(gtkrc, G_FILE_TEST_EXISTS)) g_snprintf(gtkrc, PATH_MAX, "%s/darktable.gtkrc", datadir); if (g_file_test(gtkrc, G_FILE_TEST_EXISTS)) (void)setenv("GTK2_RC_FILES", gtkrc, 1); else fprintf(stderr, "[gtk_init] could not found darktable.gtkrc"); /* lets zero mem */ memset(gui,0,sizeof(dt_gui_gtk_t)); #if GLIB_MAJOR_VERSION <= 2 #if GLIB_MINOR_VERSION < 31 if (!g_thread_supported ()) g_thread_init(NULL); #endif #endif gdk_threads_init(); gdk_threads_enter(); gtk_init (&argc, &argv); GtkWidget *widget; gui->ui = dt_ui_initialize(argc,argv); gui->pixmap = NULL; gui->center_tooltip = 0; gui->presets_popup_menu = NULL; if(g_file_test(gtkrc, G_FILE_TEST_EXISTS)) gtk_rc_parse (gtkrc); // Initializing the shortcut groups darktable.control->accelerators = gtk_accel_group_new(); darktable.control->accelerator_list = NULL; // Connecting the callback to update keyboard accels for key_pressed g_signal_connect(G_OBJECT(gtk_accel_map_get()), "changed", G_CALLBACK(key_accel_changed), NULL); // Initializing widgets init_widgets(); // Adding the global shortcut group to the main window gtk_window_add_accel_group(GTK_WINDOW(dt_ui_main_window(darktable.gui->ui)), darktable.control->accelerators); // get the screen resolution gui->dpi = gdk_screen_get_resolution(gtk_widget_get_screen(GTK_WIDGET(dt_ui_main_window(darktable.gui->ui)))); // set constant width from conf key int panel_width = dt_conf_get_int("panel_width"); if(panel_width < 20 || panel_width > 500) { // fix for unset/insane values. panel_width = 300; dt_conf_set_int("panel_width", panel_width); } // dt_gui_background_jobs_init(); /* Have the delete event (window close) end the program */ dt_loc_get_datadir(datadir, PATH_MAX); snprintf(path, PATH_MAX, "%s/icons", datadir); gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), path); widget = dt_ui_center(darktable.gui->ui); g_signal_connect (G_OBJECT (widget), "key-press-event", G_CALLBACK (key_pressed), NULL); g_signal_connect (G_OBJECT (widget), "configure-event", G_CALLBACK (configure), NULL); g_signal_connect (G_OBJECT (widget), "expose-event", G_CALLBACK (expose), NULL); g_signal_connect (G_OBJECT (widget), "motion-notify-event", G_CALLBACK (mouse_moved), NULL); g_signal_connect (G_OBJECT (widget), "leave-notify-event", G_CALLBACK (center_leave), NULL); g_signal_connect (G_OBJECT (widget), "enter-notify-event", G_CALLBACK (center_enter), NULL); g_signal_connect (G_OBJECT (widget), "button-press-event", G_CALLBACK (button_pressed), NULL); g_signal_connect (G_OBJECT (widget), "button-release-event", G_CALLBACK (button_released), NULL); g_signal_connect (G_OBJECT (widget), "scroll-event", G_CALLBACK (scrolled), NULL); // TODO: left, right, top, bottom: //leave-notify-event widget = darktable.gui->widgets.left_border; g_signal_connect (G_OBJECT (widget), "expose-event", G_CALLBACK (expose_borders), (gpointer)0); g_signal_connect (G_OBJECT (widget), "button-press-event", G_CALLBACK (borders_button_pressed), darktable.gui->ui); g_signal_connect (G_OBJECT (widget), "scroll-event", G_CALLBACK (borders_scrolled), (gpointer)0); g_object_set_data(G_OBJECT (widget), "border", (gpointer)0); widget = darktable.gui->widgets.right_border; g_signal_connect (G_OBJECT (widget), "expose-event", G_CALLBACK (expose_borders), (gpointer)1); g_signal_connect (G_OBJECT (widget), "button-press-event", G_CALLBACK (borders_button_pressed), darktable.gui->ui); g_signal_connect (G_OBJECT (widget), "scroll-event", G_CALLBACK (borders_scrolled), (gpointer)1); g_object_set_data(G_OBJECT (widget), "border", (gpointer)1); widget = darktable.gui->widgets.top_border; g_signal_connect (G_OBJECT (widget), "expose-event", G_CALLBACK (expose_borders), (gpointer)2); g_signal_connect (G_OBJECT (widget), "button-press-event", G_CALLBACK (borders_button_pressed), darktable.gui->ui); g_signal_connect (G_OBJECT (widget), "scroll-event", G_CALLBACK (borders_scrolled), (gpointer)2); g_object_set_data(G_OBJECT (widget), "border", (gpointer)2); widget = darktable.gui->widgets.bottom_border; g_signal_connect (G_OBJECT (widget), "expose-event", G_CALLBACK (expose_borders), (gpointer)3); g_signal_connect (G_OBJECT (widget), "button-press-event", G_CALLBACK (borders_button_pressed), darktable.gui->ui); g_signal_connect (G_OBJECT (widget), "scroll-event", G_CALLBACK (borders_scrolled), (gpointer)3); g_object_set_data(G_OBJECT (widget), "border", (gpointer)3); dt_gui_presets_init(); widget = dt_ui_center(darktable.gui->ui); GTK_WIDGET_UNSET_FLAGS (widget, GTK_DOUBLE_BUFFERED); // GTK_WIDGET_SET_FLAGS (widget, GTK_DOUBLE_BUFFERED); GTK_WIDGET_SET_FLAGS (widget, GTK_APP_PAINTABLE); // TODO: make this work as: libgnomeui testgnome.c /* GtkContainer *box = GTK_CONTAINER(darktable.gui->widgets.plugins_vbox); GtkScrolledWindow *swin = GTK_SCROLLED_WINDOW(darktable.gui-> widgets.right_scrolled_window); gtk_container_set_focus_vadjustment (box, gtk_scrolled_window_get_vadjustment (swin)); */ dt_ctl_get_display_profile(widget, &darktable.control->xprofile_data, &darktable.control->xprofile_size); // register keys for view switching dt_accel_register_global(NC_("accel", "capture view"), GDK_t, 0); dt_accel_register_global(NC_("accel", "lighttable view"), GDK_l, 0); dt_accel_register_global(NC_("accel", "darkroom view"), GDK_d, 0); dt_accel_connect_global( "capture view", g_cclosure_new(G_CALLBACK(_gui_switch_view_key_accel_callback), (gpointer)DT_GUI_VIEW_SWITCH_TO_TETHERING, NULL)); dt_accel_connect_global( "lighttable view", g_cclosure_new(G_CALLBACK(_gui_switch_view_key_accel_callback), (gpointer)DT_GUI_VIEW_SWITCH_TO_LIBRARY, NULL)); dt_accel_connect_global( "darkroom view", g_cclosure_new(G_CALLBACK(_gui_switch_view_key_accel_callback), (gpointer)DT_GUI_VIEW_SWITCH_TO_DARKROOM, NULL)); // register_keys for applying styles init_styles_key_accels(); connect_styles_key_accels(); // register ctrl-q to quit: dt_accel_register_global(NC_("accel", "quit"), GDK_q, GDK_CONTROL_MASK); dt_accel_connect_global( "quit", g_cclosure_new(G_CALLBACK(quit_callback), NULL, NULL)); // Contrast and brightness accelerators dt_accel_register_global(NC_("accel", "increase brightness"), GDK_F10, 0); dt_accel_register_global(NC_("accel", "decrease brightness"), GDK_F9, 0); dt_accel_register_global(NC_("accel", "increase contrast"), GDK_F8, 0); dt_accel_register_global(NC_("accel", "decrease contrast"), GDK_F7, 0); dt_accel_connect_global( "increase brightness", g_cclosure_new(G_CALLBACK(brightness_key_accel_callback), (gpointer)1, NULL)); dt_accel_connect_global( "decrease brightness", g_cclosure_new(G_CALLBACK(brightness_key_accel_callback), (gpointer)0, NULL)); dt_accel_connect_global( "increase contrast", g_cclosure_new(G_CALLBACK(contrast_key_accel_callback), (gpointer)1, NULL)); dt_accel_connect_global( "decrease contrast", g_cclosure_new(G_CALLBACK(contrast_key_accel_callback), (gpointer)0, NULL)); // Full-screen accelerators dt_accel_register_global(NC_("accel", "toggle fullscreen"), GDK_F11, 0); dt_accel_register_global(NC_("accel", "leave fullscreen"), GDK_Escape, 0); dt_accel_connect_global( "toggle fullscreen", g_cclosure_new(G_CALLBACK(fullscreen_key_accel_callback), (gpointer)1, NULL)); dt_accel_connect_global( "leave fullscreen", g_cclosure_new(G_CALLBACK(fullscreen_key_accel_callback), (gpointer)0, NULL)); // Side-border hide/show dt_accel_register_global(NC_("accel", "toggle side borders"), GDK_Tab, 0); // toggle view of header dt_accel_register_global(NC_("accel", "toggle header"), GDK_h, GDK_CONTROL_MASK); // View-switch dt_accel_register_global(NC_("accel", "switch view"), GDK_period, 0); dt_accel_connect_global( "switch view", g_cclosure_new(G_CALLBACK(view_switch_key_accel_callback), NULL, NULL)); darktable.gui->reset = 0; for(int i=0; i<3; i++) darktable.gui->bgcolor[i] = 0.1333; /* apply contrast to theme */ dt_gui_contrast_init (); return 0; }
int GTK_system_init(void) { struct stat st; command_symbol_table *gtkcommands = command_symbol_table_new(_("GTK Options"), _("These commands control the GTK interface"), command_symbol_new("GTKDebuggerUpdateRate", _("Set the number of times per second " "that the debugger refreshes in 'Run' mode"), c_STATIC, gtk_debugger_set_update_rate /* action */ , RET_FIRST_ARG, command_arg_new_num (_("rate"), _("update rate in hertz"), NULL /* action */ , ARG_NUM(gtk_run_event_rate), NULL /* next */ ) , command_symbol_new("GTKCommandCentralFont", _("Set the font used for the 'Command Central' window"), c_STATIC, gtk_command_central_set_font /* action */ , RET_FIRST_ARG, command_arg_new_string (_("font"), _("font string in X11 format, i.e., " "'-adobe-utopia-regular-r-normal-*-*-120-*-*-p-*-iso8859-1'"), NULL /* action */ , NEW_ARG_STRBUF(>k_command_central_font), NULL /* next */ ) , NULL /* next */ )), NULL /* sub */ , NULL /* next */ ); #if 0 && defined ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, v9t9_argc, v9t9_argv, GNOME_PARAM_APP_DATADIR, ".", //PACKAGE_DATA_DIR, NULL); // gtk_set_locale(); // gtk_init(&v9t9_argc, &v9t9_argv); /* if (stat(SHAREDIR "/pixmaps", &st) == 0) add_pixmap_directory(SHAREDIR "/pixmaps"); else add_pixmap_directory(TOPSRCDIR "/pixmaps"); */ #if UNDER_WIN32 if (stat(SHAREDIR "/v9t9.win32.gtkrc", &st) == 0) gtk_rc_parse(SHAREDIR "/v9t9.win32.gtkrc"); else gtk_rc_parse(TOPSRCDIR "/v9t9.win32.gtkrc"); #else if (stat(SHAREDIR "/v9t9.gtkrc", &st) == 0) gtk_rc_parse(SHAREDIR "/v9t9.gtkrc"); else gtk_rc_parse(TOPSRCDIR "/v9t9.gtkrc"); #endif command_center = create_command_dialog(); gtk_widget_show(command_center); GTK_get_initial_size(); command_symbol_table_add_subtable(universe, gtkcommands); return 1; }
gint main (gint argc, gchar ** argv) { GOptionContext *ctx; GError *err = NULL; gint w, h; gchar *str; gint ret = 0; setlocale (LC_ALL, ""); #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif #if !GLIB_CHECK_VERSION(2,36,0) g_type_init (); #endif read_settings (); gtk_init (&argc, &argv); g_set_application_name ("YAD"); yad_options_init (); ctx = yad_create_context (); /* parse YAD_OPTIONS */ if (g_getenv ("YAD_OPTIONS")) { gchar *cmd, **args = NULL; gint cnt; cmd = g_strdup_printf ("yad %s", g_getenv ("YAD_OPTIONS")); if (g_shell_parse_argv (cmd, &cnt, &args, &err)) { g_option_context_parse (ctx, &cnt, &args, &err); if (err) { g_printerr (_("Unable to parse YAD_OPTIONS: %s\n"), err->message); g_error_free (err); err = NULL; } } else { g_printerr (_("Unable to parse YAD_OPTIONS: %s\n"), err->message); g_error_free (err); err = NULL; } g_free (cmd); } /* parse command line */ g_option_context_parse (ctx, &argc, &argv, &err); if (err) { g_printerr (_("Unable to parse command line: %s\n"), err->message); return -1; } yad_set_mode (); /* parse custom gtkrc */ if (options.gtkrc_file) gtk_rc_parse (options.gtkrc_file); /* set default icons and icon theme */ if (options.data.icon_theme) { settings.icon_theme = gtk_icon_theme_new (); gtk_icon_theme_set_custom_theme (settings.icon_theme, options.data.icon_theme); } else settings.icon_theme = gtk_icon_theme_get_default (); gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &w, &h); settings.big_fallback_image = gtk_icon_theme_load_icon (settings.icon_theme, "yad", MIN (w, h), GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h); settings.small_fallback_image = gtk_icon_theme_load_icon (settings.icon_theme, "yad", MIN (w, h), GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); /* correct separators */ str = g_strcompress (options.common_data.separator); options.common_data.separator = str; str = g_strcompress (options.common_data.item_separator); options.common_data.item_separator = str; /* loads an extra arguments, if specified */ if (options.rest_file) { GIOChannel *ioc; gchar *buf; guint len, line = 0; g_strfreev (options.extra_data); options.extra_data = NULL; ioc = g_io_channel_new_file (options.rest_file, "r", NULL); while (TRUE) { gint status = g_io_channel_read_line (ioc, &buf, NULL, NULL, NULL); if (status != G_IO_STATUS_NORMAL) break; /* remove \n at the end of string */ len = strlen (buf); if (buf[len - 1] == '\n') buf[len - 1] = '\0'; /* add line to arguments array */ options.extra_data = g_realloc (options.extra_data, (line + 2) * sizeof (gchar *)); options.extra_data[line] = g_strcompress (buf); options.extra_data[line + 1] = NULL; g_free (buf); line++; } g_io_channel_shutdown (ioc, FALSE, NULL); } #ifndef G_OS_WIN32 /* add YAD_PID variable */ str = g_strdup_printf ("%d", getpid ()); g_setenv ("YAD_PID", str, TRUE); /* set signal handlers */ signal (SIGUSR1, sa_usr1); signal (SIGUSR2, sa_usr2); #endif /* plug mode */ if (options.plug != -1) { create_plug (); gtk_main (); shmdt (tabs); return ret; } switch (options.mode) { case YAD_MODE_ABOUT: ret = yad_about (); break; case YAD_MODE_VERSION: g_print ("%s (GTK+ %d.%d.%d)\n", VERSION, gtk_major_version, gtk_minor_version, gtk_micro_version); break; case YAD_MODE_NOTIFICATION: ret = yad_notification_run (); break; case YAD_MODE_PRINT: ret = yad_print_run (); break; #ifdef HAVE_HTML case YAD_MODE_HTML: /* Webkit doesn't handle focus for child dialogs when gtk_dialog_run() is used */ /* FIXME: maybe this solution must be expanded to all dialogs */ dialog = create_dialog (); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (html_response_cb), &ret); gtk_widget_show_all (dialog); gtk_main (); break; #endif default: dialog = create_dialog (); #ifndef G_OS_WIN32 /* add YAD_XID variable */ str = g_strdup_printf ("0x%X", GDK_WINDOW_XID (gtk_widget_get_window (dialog))); g_setenv ("YAD_XID", str, TRUE); #endif if (options.mode == YAD_MODE_FILE) { /* show custom confirmation dialog */ g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (confirm_overwrite_cb), NULL); } else if (options.mode == YAD_MODE_NOTEBOOK) notebook_swallow_childs (); else if (options.mode == YAD_MODE_PANED) paned_swallow_childs (); ret = gtk_dialog_run (GTK_DIALOG (dialog)); if (options.data.always_print) print_result (); else if (ret != YAD_RESPONSE_TIMEOUT && ret != YAD_RESPONSE_ESC) { /* standard OK button pressed */ if (ret == YAD_RESPONSE_OK && options.data.buttons == NULL) print_result (); /* custom even button pressed */ else if (options.data.buttons && !(ret & 1)) print_result (); } #ifndef G_OS_WIN32 if (options.mode == YAD_MODE_NOTEBOOK) notebook_close_childs (); else if (options.mode == YAD_MODE_PANED) paned_close_childs (); /* autokill option for progress dialog */ if (!options.kill_parent) { if ((options.mode == YAD_MODE_PROGRESS || options.mode == YAD_MODE_MULTI_PROGRESS) && options.progress_data.autokill && ret != YAD_RESPONSE_OK) kill (getppid (), SIGHUP); } #endif } #ifndef G_OS_WIN32 /* NSIG defined in signal.h */ if (options.kill_parent > 0 && options.kill_parent < NSIG) kill (getppid (), options.kill_parent); #endif return ret; }
int main( int argc, char *argv[] ) { #ifdef __HYPHYMPI__ int rank, size; MPI_Init (&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); _hy_mpi_node_rank = rank; setParameter (mpiNodeID, (_Parameter)rank); setParameter (mpiNodeCount, (_Parameter)size); if (rank == 0) #endif gtk_init (&argc, &argv); /* set up globals */ char curWd[4096]; getcwd (curWd,4096); _String baseDir (curWd); baseDir=baseDir&'/'; pathNames&& &baseDir; baseDirectory = baseDir; for (long i=1; i<argc;i++) { _String thisArg (argv[i]); if (thisArg.beginswith ("BASEPATH=")) { baseDirectory = thisArg.Cut(9,-1); if (baseDirectory.sLength) { if (baseDirectory.sData[baseDirectory.sLength-1]!='/') baseDirectory = baseDirectory&"/"; } } else if (thisArg.beginswith ("USEPATH=")) { _String baseArgDir (thisArg,8,-1); errorFileName = baseArgDir & errorFileName; messageFileName = baseArgDir & messageFileName; pathNames.Delete (0); pathNames&& &baseDir; } else if (thisArg.beginswith ("CPU=")) { #ifdef __MP__ _String cpus = thisArg.Cut(4,-1); systemCPUCount = cpus.toNum(); if (systemCPUCount<1) systemCPUCount = 1; #ifdef __MP2__ pthread_setconcurrency (systemCPUCount+1); #endif #endif } #ifdef __HYPHYMPI__ else if (thisArg == _String("MPIOPTIMIZER")) { mpiParallelOptimizer = true; setParameter (mpiNodeCount, 0.0); } else if (thisArg == _String("MPIPARTITIONS")) { mpiPartitionOptimizer = true; setParameter (mpiNodeCount, 0.0); } #endif } #ifdef __HYPHYMPI__ if (rank == 0) #endif { baseDir = baseDirectory & "GTKResources"; _List scanRes; ScanDirectoryForFileNames(baseDir,scanRes,false); if (scanRes.lLength == 0) { GtkWidget * noRez = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "HYPHY_GTK was unable to find a required GTKResources directory in %s. Please use BASEPATH= command line option to specify where the installation directory of HyPhy can be found.", baseDirectory.sData); gtk_dialog_run (GTK_DIALOG (noRez)); gtk_widget_destroy (noRez); return 1; } _String rcPath = baseDir & "/theme/theme.rc"; //printf ("Loading res files from %s\n", rcPath.sData); gtk_rc_parse (rcPath.sData); } GlobalStartup(); #ifdef __HYPHYMPI__ if (rank == 0) { #endif GdkDisplay * defDisplay = gdk_screen_get_display (gdk_screen_get_default()); hSizeCursor = gdk_cursor_new_for_display (defDisplay,GDK_SB_H_DOUBLE_ARROW); pickUpCursor = gdk_cursor_new_for_display (defDisplay,GDK_TARGET); dropOffCursor = gdk_cursor_new_for_display (defDisplay,GDK_TCROSS); screenPContext = gdk_pango_context_get_for_screen (gdk_screen_get_default()); tablePDMenuIcon = (GdkPixbuf*)ProcureIconResource(4020); /*{ GdkScreen * defD = gdk_screen_get_default(); fontConversionFactor = 72.27 / (gdk_screen_get_height (defD) *25.4 / gdk_screen_get_height_mm(defD)); printf ("Pango conversion factor computed at: %g\n", fontConversionFactor); }*/ ReadInTemplateFiles (); hyphyConsoleWindow = new _HYConsoleWindow ("HYPHY Console"); ReadPreferences (); SetStatusLine ("None","Idle","00:00:00"); while (gtk_events_pending()) gtk_main_iteration(); SetPreferences (); ReadGeneticCodes (); ReadModelTemplates (); ReadTreeProcessors (); MoveConsoleWindow (consolePositionRectangle); StringToConsole (hyphyCiteString); hyphyConsoleWindow->BringToFront(); #ifdef __HYPHYMPI__ { char statBuffer[1024]; sprintf (statBuffer,"MPI version of HyPhy running on %d nodes (a master and %d compute nodes) in %s mode\n", size, size-1, mpiPartitionOptimizer?"partition":(mpiParallelOptimizer?"rate heterogeneity":"normal")); BufferToConsole (statBuffer); } #endif g_timeout_add (100,GlobalQueueTimer,nil); g_timeout_add (1000,progressTimerFunction,nil); gtk_main (); WritePreferences(); #ifdef __HYPHYMPI__ } else // slave node { if (mpiParallelOptimizer || mpiPartitionOptimizer) mpiOptimizerLoop (rank, size); else mpiNormalLoop (rank, size, baseDir); } #endif GlobalShutdown(); return 0; }
void gwave_main(void *p, int argc, char **argv) { int c; int i; int nobacktrace = 0; /* In guile-1.5 and later, need to use scm_primitive_eval_x * in order to change modules so that our C primitives * registered below become globals, instead of hidden away * in the guile-user module */ { SCM exp = scm_c_read_string("(define-module (guile))"); scm_primitive_eval_x(exp); } init_scwm_guile(); init_gtkmisc(); init_gwave(); init_cmd(); init_wavewin(); init_wavelist(); init_wavepanel(); init_event(); init_draw(); gtk_init(&argc, &argv); prog_name = argv[0]; /* simple pre-processing of debugging options that we need to set up * before we get into guile. These options cannot be bundled. * Most of the general user options are handled in std-args.scm */ for(i = 1; i < argc; i++) { if(strcmp(argv[i], "-n") == 0) { nobacktrace = 1; } else if (strcmp(argv[i], "-v") == 0) { v_flag = 1; } else if (strcmp(argv[i], "-x") == 0) { x_flag = 1; SCM_SETCDR(scm_gwave_debug, SCM_BOOL_T); } } gtk_rc_parse_string(gwave_base_gtkrc); gtk_rc_parse("gwave.gtkrc"); // assert( SCM_CONSP(scm_gwave_tooltips) ); #ifdef GUILE_GTK_EXTRA_LOADPATH scm_c_eval_string("(set! %load-path (cons \"" GUILE_GTK_EXTRA_LOADPATH "\" %load-path))"); #endif /* the default for this seems to have changed between guile-1.3 and guile-1.3.2; only the first clause is needed when we drop support for guile-1.3.2 */ if (!nobacktrace) { scm_c_eval_string("(debug-enable 'debug)(debug-enable 'backtrace) (read-enable 'positions)"); } /* else { scm_c_eval_str("(debug-disable 'debug)(read-disable 'positions)"); }*/ /* the compiled-in initial scheme code comes from minimal.scm, built into init_scheme_string.c by the Makefile Among other things, it finds and loads system and user .gwaverc files. */ { /* scope */ extern char *init_scheme_string; SCM res; if(v_flag) {fprintf(stderr, "running init_scheme_string\n");} res = scwm_safe_eval_str(init_scheme_string); if(v_flag) { printf("result="); fflush(stdout); scm_display(res, scm_cur_outp); printf("\n"); fflush(stdout); } if(!SCM_NFALSEP(res)) { fprintf(stderr, "gwave: aborting due to errors.\n"); exit(1); } } /* end scope */ wtable = g_new0(WaveTable, 1); wtable->cursor[0] = g_new0(VBCursor, 1); wtable->cursor[1] = g_new0(VBCursor, 1); wtable->srange = g_new0(SelRange, 1); wtable->npanels = 0; wtable->panels = NULL; setup_colors(wtable); setup_waveform_window(); xg_init(NULL); /* X-server interprocess communication for Gtk+ */ gtk_main(); exit(0); }
int main (int argc, char **argv) { GOptionContext *context; CheeseDbus *dbus_server; GError *error = NULL; GOptionEntry options[] = { {"verbose", 'v', 0, G_OPTION_ARG_NONE, &CheeseOptions.verbose, _("Be verbose"), NULL}, {"wide", 'w', 0, G_OPTION_ARG_NONE, &CheeseOptions.wide_mode, _("Enable wide mode"), NULL}, {"version", 0, 0, G_OPTION_ARG_NONE, &CheeseOptions.version, _("output version information and exit"), NULL}, {NULL} }; bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gtk_rc_parse (APPNAME_DATA_DIR G_DIR_SEPARATOR_S "gtkrc"); g_thread_init (NULL); gdk_threads_init (); /* initialize rsvg */ /* needed to load the camera icon for the countdown widget */ rsvg_init (); g_set_application_name (_("Cheese")); context = g_option_context_new (N_("- Take photos and videos with your webcam, with fun graphical effects")); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_group (context, gst_init_get_option_group ()); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { gchar *help_text = g_option_context_get_help (context, TRUE, NULL); g_print ("%s\n\n%s", error->message, help_text); g_free (help_text); g_error_free (error); g_option_context_free (context); return -1; } g_option_context_free (context); if (CheeseOptions.version) { g_print ("Cheese " VERSION " \n"); return 0; } dbus_server = cheese_dbus_new (); if (dbus_server == NULL) { gdk_notify_startup_complete (); return -1; } g_set_print_handler ((GPrintFunc) cheese_print_handler); g_print ("Cheese " VERSION " \n"); gtk_window_set_default_icon_name ("cheese"); gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), APPNAME_DATA_DIR G_DIR_SEPARATOR_S "icons"); CheeseWindow *window = g_object_new (CHEESE_TYPE_WINDOW, "startup-wide", CheeseOptions.wide_mode, NULL); cheese_dbus_set_window (window); gtk_widget_show (GTK_WIDGET (window)); gdk_threads_enter (); gtk_main (); gdk_threads_leave (); /* cleanup rsvg */ /* Note: this function is bad with multithread applications as it * calls xmlCleanupParser() and should be only called right before * exit */ rsvg_term (); return 0; }
int main(int argc, char *argv[]) { GtkWidget* window; shareMgr_t* theShareMgr; int nRet; gboolean ok; // catch the SIGTERM signal struct sigaction on_term; memset(&on_term, 0x00, sizeof(on_term)); on_term.sa_handler = on_sigterm; sigaction(SIGTERM, &on_term, NULL); DL_WARNPRINTF(PACKAGE_STRING); parse_arguments(argc, argv); // minimum battery charge required for background mode if (g_background) { if (get_battery_charge() <= BATTERY_MINCHARGE_BACKGROUND) { DL_ERRORPRINTF("Insufficient battery [%d] for background PC connect -> quit", get_battery_charge()); return NO_ERROR; } } /* init threads */ g_thread_init(NULL); gdk_threads_init(); // open the RC file associated with this program (re-use the downloadMgr one) gtk_rc_parse(DATA_DIR "/downloadMgr.rc"); DL_LOGPRINTF("rc file %s", DATA_DIR "/downloadMgr.rc"); gtk_init(&argc, &argv); load_registry(); languagesInit(); // create/init the channel to communicate with the content lister nRet = erIpcStartClient(ER_CONTENTLISTER_CHANNEL, &contentListerChannel); if (nRet != 0) { DL_ERRORPRINTF("erIpcStartClient returned %d", nRet); contentListerChannel = NULL; } // create the main, top level, window window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), PACKAGE " " VERSION); gtk_window_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(window), 0); // gtk_widget_set_size_request(GTK_WIDGET(window), SCREEN_WIDTH, SCREEN_HEIGHT); gtk_window_set_modal(GTK_WINDOW(window), FALSE); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); gtk_window_fullscreen(GTK_WINDOW(window)); // Fullscreen overlap taskbars theShareMgr = ctrlInit(window); if (theShareMgr) { // Connect the destroy event of the window with our on_destroy function // When the window is about to be destroyed we get a notification and // stop the main GTK loop g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(on_destroy), NULL); // make sure that everything, window and label, are visible if ( !g_background ) { gtk_widget_show(window); } } // Start the download thread ok = shareThread_start((gpointer)theShareMgr); if (!ok) { printf("%s %s: ", __FILE__, __FUNCTION__); perror("Could not create thread\n"); } // run the GTK main loop DL_LOGPRINTF("Before gtk_main"); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); nRet = theShareMgr->returnVal; DL_LOGPRINTF("exitValue after gtk_main [%d]", nRet); // GTK done, abort any copying that might be running shareThread_stop(); shareThread_wait(15); DL_WARNPRINTF("PC Share Manager quitting with return value \"%d\"", nRet); ctrlDestroy(theShareMgr); release_registry(); return nRet; }
gint load_dialog(struct raw_data* img_data, gchar* check_button_label) { int i; GtkWidget* dlg; GtkWidget* wgt; gchar** argv = g_new(gchar*, 1); gint argc = 1; struct load_dlg_data dlg_data; static char *labs[] = {"Width", "Height"}; if (!img_data) return ERROR; dlg_data.img_data = img_data; argv[0] = g_strdup("load"); gtk_init (&argc, &argv); gtk_rc_parse(gimp_gtkrc()); gdk_set_use_xshm(TRUE); dlg_data.id = gtk_dialog_new(); dlg = dlg_data.id; gtk_window_set_title(GTK_WINDOW (dlg), "Load raw image"); gtk_window_position(GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE); gtk_signal_connect(GTK_OBJECT (dlg), "destroy", (GtkSignalFunc) load_on_close, NULL); /* OK button */ wgt = gtk_button_new_with_label("OK"); GTK_WIDGET_SET_FLAGS(wgt, GTK_CAN_DEFAULT); gtk_signal_connect(GTK_OBJECT (wgt), "clicked", (GtkSignalFunc) load_on_ok, &dlg_data); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg)->action_area), wgt, TRUE, TRUE, 0); gtk_widget_grab_default(wgt); gtk_widget_show(wgt); /* Cancel button */ wgt = gtk_button_new_with_label("Cancel"); GTK_WIDGET_SET_FLAGS(wgt, GTK_CAN_DEFAULT); gtk_signal_connect(GTK_OBJECT (wgt), "clicked", (GtkSignalFunc) load_on_cancel, &dlg_data); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg)->action_area), wgt, TRUE, TRUE, 0); gtk_widget_grab_default(wgt); gtk_widget_show(wgt); /* Width and Height */ wgt = gtk_table_new(3, SIZE_DIM, FALSE); gtk_table_set_row_spacings(GTK_TABLE(wgt), 3); gtk_table_set_col_spacings(GTK_TABLE(wgt), 3); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg)->vbox), wgt, TRUE, TRUE, 0); gtk_widget_show(wgt); for (i = 0; i < SIZE_DIM; i++) { char init_size[16]; GtkWidget *label = gtk_label_new(labs[i]); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(wgt), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show(label); dlg_data.size[i] = gtk_entry_new(); gtk_widget_set_usize(dlg_data.size[i], 35, 0); sprintf(init_size, "%d", (int) dlg_data.img_data->size[i]); gtk_entry_set_text(GTK_ENTRY(dlg_data.size[i]), init_size); gtk_table_attach(GTK_TABLE(wgt), dlg_data.size[i], 1, 2, i, i+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show(dlg_data.size[i]); } if (check_button_label) { dlg_data.checked = gtk_check_button_new_with_mnemonic( check_button_label); gtk_table_attach(GTK_TABLE(wgt), dlg_data.checked, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show(dlg_data.checked); } else { dlg_data.checked = NULL; } gtk_widget_show(dlg); gtk_main(); gdk_flush(); return dlg_data.result_ok; }
/* * public: */ void gui_start(Config *config, Cache *cache) { gboolean start_app = FALSE; gboolean database_is_valid = FALSE; gboolean account_is_initialized = FALSE; GtkWidget *dialog = NULL; GError *err = NULL; g_assert(config != NULL); g_assert(cache != NULL); g_debug("Starting GUI..."); #ifdef G_OS_WIN32 gchar *path; /* load windows theme */ g_debug("Parsing MS-Windows theme file"); path = g_build_filename(pathbuilder_get_share_directory(), G_DIR_SEPARATOR_S, "themes", G_DIR_SEPARATOR_S, "MS-Windows", G_DIR_SEPARATOR_S, "gtk-2.0", G_DIR_SEPARATOR_S, "gtkrc", NULL); g_debug("filename: %s", path); gtk_rc_parse(path); g_free(path); #endif /* check if configuration is empty */ if(!(start_app = settings_config_has_account(config))) { /* configuration is empty => start wizard */ g_debug("Configuration doesn't contain at least one account, starting wizard"); if((start_app = wizard_start(config))) { _gui_save_config(config); } } if(start_app) { /* initialize database */ g_debug("Initializing database..."); switch(database_init(&err)) { case DATABASE_INIT_FAILURE: dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Couldn't initialize %s, database seems to be damaged."), APPLICATION_NAME); break; case DATABASE_INIT_APPLICATION_OUTDATED: dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Couldn't initialize database, please upgrade %s."), APPLICATION_NAME); break; case DATABASE_INIT_FIRST_INITIALIZATION: case DATABASE_INIT_SUCCESS: case DATABASE_INIT_DATABASE_UPGRADED: database_is_valid = TRUE; break; default: g_warning("Invalid database result code."); break; } /* display failure messages */ if(err) { g_warning("%s", err->message); g_error_free(err); err = NULL; } if(database_is_valid) { /* initialize first account (if neccessary) */ g_debug("Testing account initialization status..."); if(!(account_is_initialized = _gui_check_account_initialization(config))) { g_debug("Starting account initialization"); if((account_is_initialized = _gui_initialize_account(config))) { g_debug("account has been initialized successfully => updating configuration"); _gui_enable_account_initialization(config); _gui_save_config(config); } else { dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Account initialization failed, please try again later.")); } } /* open mainwindow */ if(account_is_initialized) { g_debug("Opening mainwindow"); mainwindow_start(config, cache); } } /* show warning dialog */ if(dialog) { gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } } }
int main( int argc, char *argv[] ) { glob_t globdata; int i, j, l, file_arg_start, new_empty = TRUE, get_screenshot = FALSE; if (argc > 1) { if ( strcmp(argv[1], "--version") == 0 ) { printf("%s\n\n", MT_VERSION); exit(0); } if ( strcmp(argv[1], "--help") == 0 ) { printf("%s\n\n" "Usage: mtpaint [option] [imagefile ... ]\n\n" "Options:\n" " --help Output this help\n" " --version Output version information\n" " -s Grab screenshot\n" " -v Start in viewer mode\n\n" , MT_VERSION); exit(0); } } putenv( "G_BROKEN_FILENAMES=1" ); // Needed to read non ASCII filenames in GTK+2 #if GTK2VERSION >= 4 /* Tablet handling in GTK+ 2.18+ is broken beyond repair if this mode * is set; so unset it, if g_unsetenv() is present */ g_unsetenv("GDK_NATIVE_WINDOWS"); #endif #ifdef U_THREADS /* Enable threading for GLib, but NOT for GTK+ (at least, not yet) */ g_thread_init(NULL); #endif inifile_init("/etc/mtpaint/mtpaintrc", "~/.mtpaint"); #ifdef U_NLS #if GTK_MAJOR_VERSION == 1 /* !!! GTK+1 needs locale set up before gtk_init(); GTK+2, *QUITE* * the opposite - WJ */ setup_language(); #endif #endif #ifdef U_THREADS /* !!! Uncomment to allow GTK+ calls from other threads */ /* gdk_threads_init(); */ #endif gtk_init( &argc, &argv ); gtk_init_bugfixes(); #if GTK_MAJOR_VERSION == 2 { char *theme = inifile_get(DEFAULT_THEME_INI, ""); if (theme[0]) gtk_rc_parse(theme); } #endif #ifdef U_NLS #if GTK_MAJOR_VERSION == 2 /* !!! GTK+2 starts acting up if this is before gtk_init() - WJ */ setup_language(); #endif bindtextdomain("mtpaint", MT_LANG_DEST); textdomain("mtpaint"); #if GTK_MAJOR_VERSION == 2 bind_textdomain_codeset("mtpaint", "UTF-8"); #endif #endif file_arg_start = 1; if (argc > 1) // Argument received, so assume user is trying to load a file { if ( strcmp(argv[1], "-g") == 0 ) // Loading GIF animation frames { file_arg_start+=2; sscanf(argv[2], "%i", &preserved_gif_delay); } if ( strcmp(argv[1], "-v") == 0 ) // Viewer mode { file_arg_start++; viewer_mode = TRUE; } if ( strcmp(argv[1], "-s") == 0 ) // Screenshot { file_arg_start++; get_screenshot = TRUE; } if ( strstr(argv[0], "mtv") != NULL ) viewer_mode = TRUE; } /* Something else got passed in */ l = argc - file_arg_start; while (l) { /* First, process wildcarded args */ memset(&globdata, 0, sizeof(globdata)); /* !!! I avoid GLOB_DOOFFS here, because glibc before version 2.2 mishandled it, * and quite a few copycats had cloned those buggy versions, some libc * implementors among them. So it is possible to encounter a broken function * in the wild, and playing it safe doesn't cost all that much - WJ */ for (i = file_arg_start , j = 0; i < argc; i++) { if (strcmp(argv[i], "-w")) continue; j++; if (++i >= argc) break; j++; // Ignore errors - be glad for whatever gets returned glob(argv[i], (j > 2 ? GLOB_APPEND : 0), NULL, &globdata); } files_passed = l - j + globdata.gl_pathc; /* If no wildcarded args */ file_args = argv + file_arg_start; if (!j) break; /* If no normal args */ file_args = globdata.gl_pathv; if (l <= j) break; /* Allocate space for both kinds of args together */ file_args = calloc(files_passed + 1, sizeof(char *)); // !!! Die by SIGSEGV if this allocation fails /* Copy normal args if any */ for (i = file_arg_start , j = 0; i < argc; i++) { if (!strcmp(argv[i], "-w")) i++; // Skip the pair else file_args[j++] = argv[i]; } /* Copy globbed args after them */ if (globdata.gl_pathc) memcpy(file_args + j, globdata.gl_pathv, globdata.gl_pathc * sizeof(char *)); break; } string_init(); // Translate static strings var_init(); // Load INI variables mem_init(); // Set up memory & back end layers_init(); init_cols(); if ( get_screenshot ) { if (load_image(NULL, FS_PNG_LOAD, FT_PIXMAP) == 1) new_empty = FALSE; // Successfully grabbed so no new empty else get_screenshot = FALSE; // Screenshot failed } main_init(); // Create main window if ( get_screenshot ) { do_new_chores(FALSE); notify_changed(); } else { if ((files_passed > 0) && !do_a_load(file_args[0], FALSE)) new_empty = FALSE; } if ( new_empty ) // If no file was loaded, start with a blank canvas { create_default_image(); } update_menus(); THREADS_ENTER(); gtk_main(); THREADS_LEAVE(); spawn_quit(); inifile_quit(); return 0; }