Exemplo n.º 1
0
void
create_windows(const char *host_tag, int instance_count)
{
    char tag[64];

    /* build a nice identifier string for the window titles */
    if (strlen(host_tag) == 0) {
        strcpy(tag, host_name_default);
    } else if (strstr(host_tag, host_name_default)) {
        if (strlen(host_tag) > 63) {
            snprintf(tag, 64, "...%s", host_tag + strlen(host_tag) - 60); /* hope the unique info is at the end */
        } else {
            strcpy(tag, host_tag);
        }
    } else {
        if (strlen(host_name_default) + strlen(host_tag) > 62) {
            snprintf(tag, 64, "%s ...%s", host_name_default, host_tag + strlen(host_tag) + strlen(host_name_default) - 59);
        } else {
            snprintf(tag, 64, "%s %s", host_name_default, host_tag);
        }
    }

    create_main_window(tag, instance_count);
    create_ui_context_menu(main_window);
    create_file_selection(tag);
    create_about_window(tag);
    create_notice_window(tag);
}
Exemplo n.º 2
0
static void
activate (GtkApplication *app)
{
	GList *list;
	GSList* actions;
	gboolean hidden = FALSE;

	list = gtk_application_get_windows (app);

	AppShellData* app_data = appshelldata_new("matecc.menu", GTK_ICON_SIZE_DND, FALSE, TRUE, 0);

	generate_categories(app_data);

	actions = get_actions_list();
	layout_shell(app_data, _("Filter"), _("Groups"), _("Common Tasks"), actions, handle_static_action_clicked);

	if (list)
	{
		gtk_window_present (GTK_WINDOW (list->data));
	}
	else
	{
		create_main_window(app_data, "MyControlCenter", _("Control Center"), "preferences-desktop", 975, 600, hidden);
		gtk_application_add_window (app, GTK_WINDOW(app_data->main_app));
	}
}
Exemplo n.º 3
0
void 
init_ASWallpaper()
{
	memset( &WallpaperState, 0x00, sizeof(ASWallpaperState));
	
	create_main_window(); 
	create_backs_list();
	create_list_preview();
	
	WallpaperState.sel_apply_button = asgtk_add_button_to_box( NULL, GTK_STOCK_APPLY, NULL, G_CALLBACK(on_list_apply_clicked), WallpaperState.backs_list );
	WallpaperState.make_xml_button = asgtk_add_button_to_box( NULL, GTK_STOCK_PROPERTIES, "Make XML", G_CALLBACK(on_make_xml_clicked), WallpaperState.backs_list );
	WallpaperState.edit_xml_button = asgtk_add_button_to_box( NULL, GTK_STOCK_PROPERTIES, "Edit XML", G_CALLBACK(on_edit_xml_clicked), WallpaperState.backs_list );
	WallpaperState.make_mini_button = asgtk_add_button_to_box( NULL, GTK_STOCK_PROPERTIES, "Make mini", G_CALLBACK(on_make_mini_clicked), WallpaperState.backs_list );
	
	WallpaperState.sel_del_button = asgtk_add_button_to_box( NULL, GTK_STOCK_DELETE, NULL, G_CALLBACK(on_list_del_clicked), WallpaperState.backs_list );

	gtk_widget_hide(WallpaperState.edit_xml_button);

	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.sel_apply_button, 0 );
	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.make_mini_button, 5 );
	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.make_xml_button, 5 );
	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.edit_xml_button, 5 );
	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.sel_del_button, 5 );
	
	asgtk_image_dir_set_sel_handler( ASGTK_IMAGE_DIR(WallpaperState.backs_list), backs_list_sel_handler, WallpaperState.list_preview);

	reload_private_backs_list();

	g_signal_connect (G_OBJECT (WallpaperState.main_window), "destroy", G_CALLBACK (on_destroy), NULL);
  	gtk_widget_show (WallpaperState.main_window);
}	 
Exemplo n.º 4
0
int
main (int argc, char *argv[])
{
  GtkWidget *window, *scroll, *image;

  gtk_init (&argc, &argv);

  window = create_main_window ();
  scroll = create_scroll_widget ();
  image = gtk_image_new_from_file ("./img.jpg");

  gtk_container_add (GTK_CONTAINER (window), scroll);
  
#ifdef HAVE_HILDON
  hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (scroll), image);
#else
  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), image);
#endif

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
Exemplo n.º 5
0
int main()
{
  GUI* g=NULL;
  WIDGET* pic=NULL;

  g=init_gui();
  create_main_window(g,"Example GUI");
  set_main_size(g,500,500);
  
  build_labs(g);
  build_buts(g);
  build_check(g);
  build_radio(g);
  build_text(g);
  build_misc(g);

  
  pic=create_picture(g,"pic.xpm",10,300);
  add_to_main(g,pic);
  
  show_main(g);
  while(gui_running(g)){
    usleep(250000);
  }

  destroy_gui(g);
  return 0;
}
Exemplo n.º 6
0
int
main (int    argc,
      char **argv)
{
    GOptionContext *option_context;
    GError *error = NULL;
    gchar *plugin_dir;
    PeasEngine *engine;

    option_context = g_option_context_new (_("- libpeas demo application"));
    g_option_context_add_main_entries (option_context, demo_args, GETTEXT_PACKAGE);
    g_option_context_add_group (option_context, gtk_get_option_group (TRUE));

    if (!g_option_context_parse (option_context, &argc, &argv, &error))
    {
        g_warning ("Error while parsing arguments: %s", error->message);
        g_error_free (error);
        return -1;
    }

    g_option_context_free (option_context);

    /* Ensure we pick the uninstalled plugin loaders if we're running from build dir */
    if (run_from_build_dir)
    {
        g_debug ("Running from build dir.");
        g_irepository_prepend_search_path ("../libpeas");
        g_irepository_prepend_search_path ("../libpeas-gtk");
        g_setenv ("PEAS_PLUGIN_LOADERS_DIR", "../loaders", TRUE);
    }

    engine = peas_engine_get_default ();
    plugin_dir = g_build_filename (g_get_user_config_dir (), "peas-demo/plugins", NULL);
    peas_engine_add_search_path (engine, plugin_dir, plugin_dir);
    g_free (plugin_dir);

    peas_engine_enable_loader (engine, "gjs");
    peas_engine_enable_loader (engine, "python3");
    peas_engine_enable_loader (engine, "seed");

    if (run_from_build_dir)
        peas_engine_add_search_path (engine, "./plugins", NULL);
    else
        peas_engine_add_search_path (engine,
                                     PEAS_LIBDIR "/peas-demo/plugins/",
                                     PEAS_PREFIX "/share/peas-demo/plugins");

    n_windows = 0;
    main_window = create_main_window ();
    gtk_widget_show_all (main_window);

    gtk_main ();

    gtk_widget_destroy (main_window);

    g_object_unref (engine);

    return 0;
}
Exemplo n.º 7
0
static void init(void) {
  app_message_init();

  bitmaps_init();

  create_main_window();
  show_main_window(true);
}
Exemplo n.º 8
0
OutputVisualizer::OutputVisualizer(utils::GeneralOptions general_options) {
  // Initialize console window
  initscr();

  // Disable character echoing
  noecho();

  // Hide cursor
  this->original_cursor_state_ = curs_set(0);

  // Activate special keyboard keys
  keypad(stdscr, TRUE);

  // Disable input line buffering
  cbreak();

  // Make input calls non-blocking
  nodelay(stdscr, true);

  // Initialize colors
  if (has_colors()) {
    start_color();

    // Define color pair 1 as white on blue
    init_pair(1, COLOR_WHITE, COLOR_BLUE);

    // Define color pair 2 as blue on white
    init_pair(2, COLOR_BLUE, COLOR_WHITE);

    /*
     * Redefine colors if terminal supports it
     * (We only have 8 colors available, so the names might be a bit unfitting)
    */
    init_color(COLOR_RED, 933, 461, 0);  // Dark Orange
    init_color(COLOR_YELLOW, 1000, 645, 0);  // Light Orange

    // Define color pair 3 and 4 for use in the diagram
    init_pair(3, COLOR_WHITE, COLOR_RED);
    init_pair(4, COLOR_WHITE, COLOR_YELLOW);

    int rows, cols;

    // retrieve window size
    getmaxyx(stdscr, rows, cols);

    this->rows_ = rows;
    this->cols_ = cols;

    refresh();
    create_top_window();
    create_main_window();

  } else {
    failed_ = true;
  }
}
Exemplo n.º 9
0
int main(int argc, char *argv[]) {
  GtkWidget *main_window;

  gtk_set_locale();
  gtk_init(&argc, &argv);

  main_window = create_main_window();

#ifdef USE_HILDON
  HildonProgram *app = HILDON_PROGRAM(hildon_program_get_instance());
  g_set_application_name("SmallBASIC");
  output.osso = osso_initialize(PACKAGE, VERSION, TRUE, NULL);
  hildon_program_add_window(app, HILDON_WINDOW(main_window));
#endif

  drawing_area_init(main_window);
  gtk_widget_show_all(GTK_WIDGET(main_window));
  g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(destroy_event), NULL);

  // prepare runtime flags
  opt_graphics = 1;
  opt_quiet = 1;
  opt_interactive = 0;
  opt_nosave = 1;
  opt_ide = IDE_NONE;           // for sberr.c
  opt_command[0] = 0;
  opt_pref_width = 0;
  opt_pref_height = 0;
  opt_pref_bpp = 0;

  if (argc == 2 && access(argv[1], R_OK) == 0) {
    sbasic_main(argv[1]);
  }

  GtkWidget *dialog = create_opendialog();
  while (1) {
    gtk_widget_show(dialog);
    gtk_window_set_title(GTK_WINDOW(dialog), "Open BAS File");
    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
      char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
      const char *p = strrchr(filename, '/');
      gtk_window_set_title(GTK_WINDOW(main_window), p ? p + 1 : filename);
      gtk_widget_hide(dialog);
      sbasic_main(filename);
      g_free(filename);
    } else {
      break;
    }
  }
  gtk_widget_destroy(dialog);
  om_cleanup();
  return 0;
}
Exemplo n.º 10
0
gint main(gint argc, gchar* argv[]) {
    GtkWidget* login_dialog;
    const char* user_const;
    const char* pass_const;
    gchar username[100];
    gchar password[100];
    gint result;
    gnome_program_init("CdDatabase", "0.1", LIBGNOMEUI_MODULE,
                       argc, argv,
                       GNOME_PARAM_APP_DATADIR, "",
                       NULL);
    GtkWidget* main_window = create_main_window();
    gtk_widget_show_all(main_window);
    /* Must login to database before we start, so create dialog to
       input username and password */
    login_dialog = create_login_dialog();

    while (1) {
        result = gtk_dialog_run(GTK_DIALOG(login_dialog));

        /* If we click cancel, then confirm exit */
        if (result != GTK_RESPONSE_ACCEPT) {
            if (confirm_exit()) {
                return 0;
            } else {
                continue;
            }
        }

        /* Retrieve username and password */
        user_const = gtk_entry_get_text(GTK_ENTRY(username_entry));
        pass_const = gtk_entry_get_text(GTK_ENTRY(password_entry));
        strcpy(username, user_const);
        strcpy(password, pass_const);

        if (database_start(username, password) == TRUE) {
            break;
        }

        /* If we couldn't logon, then display error message and try again */
        GtkWidget* error_dialog = gtk_message_dialog_new(GTK_WINDOW(main_window),
                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                  GTK_MESSAGE_ERROR,
                                  GTK_BUTTONS_CLOSE,
                                  "Could not log on! - Check Username and Password");
        gtk_dialog_run(GTK_DIALOG(error_dialog));
        gtk_widget_destroy(error_dialog);
    }

    gtk_widget_destroy(login_dialog);
    gtk_main();
    return 0;
}
Exemplo n.º 11
0
static void handle_init(void) {
  create_main_window();
  create_leg_window();
  
   // Register callbacks
  app_message_register_inbox_received(inbox_received_callback);
  app_message_register_inbox_dropped(inbox_dropped_callback);
  app_message_register_outbox_failed(outbox_failed_callback);
  app_message_register_outbox_sent(outbox_sent_callback);
  
  // Open AppMessage
  app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); 
}
Exemplo n.º 12
0
int main (int argc, char *argv[])
{

  GtkWidget *MainWindow;
  gtk_set_locale ();
  gtk_init(&argc, &argv);
  /*create the main window*/
  MainWindow = create_main_window();
  gtk_widget_show(MainWindow);
   
  /*This is a loop*/
  gtk_main ();
  return 0;
}
Exemplo n.º 13
0
int main (int argc, char *argv[])
{
	osso_context_t* ctx = NULL;
	gtk_init (&argc, &argv);
	main_window = create_main_window ();
	ctx = osso_initialize("org.maemo.mpuzzle", "1.7", TRUE, NULL);
	if (ctx == NULL) {
		g_print("Failed to init LibOSSO\n");
		return 0;
	}
	g_print("LibOSSO Init done\n");
				
	gtk_widget_show_all (main_window);
	gtk_main ();
	return 0;
}
Exemplo n.º 14
0
int main()
{
  GUI* g = init_gui(NULL);
  create_main_window(g,"Test Window");
  set_main_size(g,300, 300);

  WIDGET* box = create_combobox(20,10,10,my_string);
  WIDGET* but = create_button("Hello",50,50);
  add_item_to_combobox(box,"Test 1");
  add_to_main(g,box);
  add_to_main(g,but);

  show_main(g);
  while(gui_running(g)){
    sleep(1);
  }

  destroy_gui(g);
  return 0;
}
Exemplo n.º 15
0
int
main(int argc, char *argv[])
{
	g_thread_init(NULL);
	gdk_threads_init();
	
	gtk_init(&argc, &argv);

	config_load();
	
	create_main_window();

	_debug = FALSE;

	window_printf(window_get_active(), "[%s-%s (%s)] : [%s] : [placeholderforquotes]\n", APP_NAME, APP_VERSION, APP_VERSION_NAME, APP_WEBSITE);

	gtk_main();

	return 0;
}
Exemplo n.º 16
0
int
main(int argc, char** argv)
{
    GError* error = NULL;
    GConfClient* client = NULL;
    GtkWidget* main_window;

    gtk_init(&argc, &argv);

    /* If you pass NULL for error, then gconf_init() will simply print
       to stderr and exit if an error occurs. */
    if (!gconf_init(argc, argv, &error))
    {
        g_assert(error != NULL);
        g_warning("GConf init failed:\n  %s", error->message);
        /* These next two lines would be important if we weren't going to
           exit immediately */
        g_error_free(error);
        error = NULL;
        return 1;
    }

    g_assert(error == NULL);

    client = gconf_client_get_default();

    gconf_client_add_dir(client, "/apps/basic-gconf-app", GCONF_CLIENT_PRELOAD_NONE, NULL);

    main_window = create_main_window(client);

    gtk_widget_show_all(main_window);

    gtk_main();

    /* This ensures we cleanly detach from the GConf server (assuming
     * we hold the last reference)
     */
    g_object_unref(G_OBJECT(client));

    return 0;
}
Exemplo n.º 17
0
int main(int argc, char *argv[])
{
	gchar *message;

	config_file = g_strdup_printf("%s/.gtktermrc", getenv("HOME"));

	bindtextdomain(PACKAGE, LOCALEDIR);
	bind_textdomain_codeset(PACKAGE, "UTF-8");
	textdomain(PACKAGE);

	gtk_init(&argc, &argv);

	create_buffer();

	create_main_window();

	if(read_command_line(argc, argv) < 0)
	{
		delete_buffer();
		exit(1);
	}

	Config_port();

	message = get_port_string();
	Set_window_title(message);
	Set_status_message(message);
	g_free(message);

	add_shortcuts();

	set_view(ASCII_VIEW);

	gtk_main();

	delete_buffer();

	Close_port();

	return 0;
}
int
main (int argc, char** argv)
{
  MateConfClient *client;
  GtkWidget *main_window;
  
  gtk_init (&argc, &argv);

  /* Get the default client */
  client = mateconf_client_get_default ();

  /* Tell MateConfClient that we're interested in the given directory.
   * This means MateConfClient will receive notification of changes
   * to this directory, and cache keys under this directory.
   * So _don't_ add "/" or something silly like that or you'll end
   * up with a copy of the whole MateConf database. ;-)
   *
   * We pass NULL for the error to use the default error handler;
   * and use PRELOAD_NONE to avoid loading all config keys on
   * startup. If your app pretty much reads all config keys
   * on startup, then preloading the cache may make sense.
   */
   
  mateconf_client_add_dir (client, "/apps/basic-mateconf-app",
                        MATECONF_CLIENT_PRELOAD_NONE, NULL);

  main_window = create_main_window (client);
  
  gtk_widget_show_all (main_window);
  
  gtk_main ();

  /* This ensures we cleanly detach from the MateConf server (assuming
   * we hold the last reference). It's purely a bit of cleanliness,
   * the server does survive fine if we crash.
   */
  g_object_unref (G_OBJECT (client));
  
  return 0;
}
Exemplo n.º 19
0
/**
 *程序入口
 */
int main(int argc,char *argv[]){
   GtkWidget *vBox = NULL;//主布局
   GtkWidget *hPanel = NULL; //操作主布局
   GtkWidget *rightMainVBox = NULL; //右边主布局
   
   gtk_init(&argc,&argv);
   
   g_print("检查目录%d\n",check_dir());
   
   
   window = create_main_window();//创建主窗口
   set_main_window(window);//同步ui.c的window
   hPanel = gtk_hpaned_new(); //创建操作主布局
   leftCatalogVBox = gtk_vbox_new(FALSE,0);  //新建竖向布局
   rightMainVBox = gtk_vbox_new(FALSE,0);  //新建竖向布局
   
   //设置主布局
   vBox = gtk_vbox_new(FALSE,0);  //新建竖向布局
   gtk_container_add(GTK_CONTAINER(window),vBox);//向窗口加入主布局--不可视
   
   gtk_box_pack_start(GTK_BOX(vBox),create_menus(),FALSE,FALSE,0);  //添加菜单
   gtk_box_pack_start(GTK_BOX(vBox),hPanel,TRUE,TRUE,10);  //添加面板
   
   gtk_paned_add1(GTK_PANED(hPanel),leftCatalogVBox);// 添加布局
   gtk_paned_add2(GTK_PANED(hPanel),rightMainVBox);// 添加布局
   
   gtk_widget_set_size_request(leftCatalogVBox,150,300); //设置左边大小
   
   init_tree_view_catalog();
   gtk_box_pack_start(GTK_BOX(rightMainVBox),init_right_main_view(),TRUE,TRUE,0); //显示左边主要内容
   
   
   gtk_widget_show_all(window);  //显示所有组件
   
   init_right_main_view_hide_all(NULL);
   gtk_main();
   return 0;
}
Exemplo n.º 20
0
void ncurses_thread()
{
  create_main_window();
}
Exemplo n.º 21
0
Arquivo: xsm.c Projeto: aosm/X11
/*
 * Main program
 */
int
main(int argc, char *argv[])
{
    char	*p;
    char 	errormsg[256];
    static	char environment_name[] = "SESSION_MANAGER";
    int		success, found_command_line_name, i;

    Argc = argc;
    Argv = argv;

    for (i = 1; i < argc; i++)
    {
	if (argv[i][0] == '-')
	{
	    switch (argv[i][1])
	    {
	    case 'd':					/* -display */
		if (++i >= argc) goto usage;
		cmd_line_display = (char *) XtNewString (argv[i]);
		continue;

	    case 's':					/* -session */
		if (++i >= argc) goto usage;
		session_name = XtNewString (argv[i]);
		continue;

	    case 'v':					/* -verbose */
		verbose = 1;
		continue;
	    }
	}

    usage:
	fprintf (stderr,
	 "usage: xsm [-display display] [-session session_name] [-verbose]\n");
	exit (1);
    }

    topLevel = XtVaAppInitialize (&appContext, "XSm", NULL, 0,
	&argc, argv, NULL,
	XtNmappedWhenManaged, False,
	XtNwindowRole, "xsm main window",
	NULL);
	
    wmStateAtom = XInternAtom (
	XtDisplay (topLevel), "WM_STATE", False);
    wmDeleteAtom = XInternAtom (
	XtDisplay (topLevel), "WM_DELETE_WINDOW", False);

    register_signals (appContext);


    /*
     * Install an IO error handler.  For an explanation,
     * see the comments for InstallIOErrorHandler().
     */

    InstallIOErrorHandler ();


    /*
     * Init SM lib
     */

    if (!SmsInitialize ("SAMPLE-SM", "1.0",
	NewClientProc, NULL,
	HostBasedAuthProc, 256, errormsg))
    {
	fprintf (stderr, "%s\n", errormsg);
	exit (1);
    }

    if (!IceListenForConnections (&numTransports, &listenObjs,
	256, errormsg))
    {
	fprintf (stderr, "%s\n", errormsg);
	exit (1);
    }

    atexit(CloseListeners);

    if (!SetAuthentication (numTransports, listenObjs, &authDataEntries))
    {
	fprintf (stderr, "Could not set authorization\n");
	exit (1);
    }

    InitWatchProcs (appContext);

    for (i = 0; i < numTransports; i++)
    {
	XtAppAddInput (appContext,
	    IceGetListenConnectionNumber (listenObjs[i]),
	    (XtPointer) XtInputReadMask,
	    NewConnectionXtProc, (XtPointer) listenObjs[i]);
    }

    /* the sizeof includes the \0, so we don't need to count the '=' */
    networkIds = IceComposeNetworkIdList (numTransports, listenObjs);
    p = (char *) XtMalloc((sizeof environment_name) + strlen(networkIds) + 1);
    if(!p) nomem();
    sprintf(p, "%s=%s", environment_name, networkIds);
    putenv(p);

    if (cmd_line_display)
    {
	/*
	 * If a display was passed on the command line, set the DISPLAY
	 * environment in this process so all applications started by
	 * the session manager will run on the specified display.
	 */

	p = (char *) XtMalloc(8 + strlen(cmd_line_display) + 1);
	sprintf(p, "DISPLAY=%s", cmd_line_display);
	putenv(p);
    }

    if (verbose)
	printf ("setenv %s %s\n", environment_name, networkIds);

    create_choose_session_popup ();
    create_main_window ();
    create_client_info_popup ();
    create_save_popup ();
    create_log_popup ();


    /*
     * Initalize all lists
     */

    RunningList = ListInit();
    if(!RunningList) nomem();

    PendingList = ListInit();
    if(!PendingList) nomem();

    RestartAnywayList = ListInit();
    if(!RestartAnywayList) nomem();

    RestartImmedList = ListInit();
    if(!RestartImmedList) nomem();

    WaitForSaveDoneList = ListInit();
    if (!WaitForSaveDoneList) nomem();

    InitialSaveList = ListInit();
    if (!InitialSaveList) nomem();

    FailedSaveList = ListInit();
    if (!FailedSaveList) nomem();

    WaitForInteractList = ListInit();
    if (!WaitForInteractList) nomem();

    WaitForPhase2List = ListInit();
    if (!WaitForPhase2List) nomem();


    /*
     * Get list of session names.  If a session name was found on the
     * command line, and it is in the list of session names we got, then
     * use that session name.  If there were no session names found, then
     * use the default session name.  Otherwise, present a list of session
     * names for the user to choose from.
     */

    success = GetSessionNames (&sessionNameCount,
	&sessionNamesShort, &sessionNamesLong, &sessionsLocked);

    found_command_line_name = 0;
    if (success && session_name)
    {
	for (i = 0; i < sessionNameCount; i++)
	    if (strcmp (session_name, sessionNamesShort[i]) == 0)
	    {
		found_command_line_name = 1;

		if (sessionsLocked[i])
		{
		    fprintf (stderr, "Session '%s' is locked\n", session_name);
		    exit (1);
		}

		break;
	    }
    }

    if (!success || found_command_line_name)
    {
	FreeSessionNames (sessionNameCount,
	    sessionNamesShort, sessionNamesLong, sessionsLocked);

	if (!found_command_line_name)
	    session_name = XtNewString (DEFAULT_SESSION_NAME);

    	if (!StartSession (session_name, !found_command_line_name))
	    UnableToLockSession (session_name);
    }
    else
    {
	ChooseSession ();
    }
    

    /*
     * Main loop
     */

    XtAppMainLoop (appContext);
    exit(0);
}
Exemplo n.º 22
0
gint main(gint argc, gchar **argv)
{
	Conf *conf;
	GtkItemFactory *ifactory;
	gchar *stdin_data = NULL;
	
	bindtextdomain(PACKAGE, LOCALEDIR);			//bindtextdomain ??
	bind_textdomain_codeset(PACKAGE, "UTF-8");		// ??
	textdomain(PACKAGE);					// ??
	
	pub = g_malloc(sizeof(PublicData));			
	pub->fi = g_malloc(sizeof(FileInfo));
	pub->fi->filename     = NULL;
	pub->fi->charset      = NULL;
	pub->fi->charset_flag = FALSE;
	pub->fi->lineend      = LF;
	
	parse_args(argc, argv, pub->fi);
	
	gtk_init(&argc, &argv);					//call before using any gtk fuction
	g_set_application_name(PACKAGE_NAME);
	g_print("%s\n", PACKAGE_NAME);
	
#if !GTK_CHECK_VERSION(2, 6, 0)
	add_about_stock();
#endif
	
	pub->mw = create_main_window();			//Find create_main_window
	
	conf = g_malloc(sizeof(Conf));				//sends default vlues to load and overwrites in the function
	conf->width       = 600;
	conf->height      = 400;
	conf->fontname    = g_strdup("Monospace 12");
	conf->wordwrap    = FALSE;
	conf->linenumbers = FALSE;
	conf->autoindent  = FALSE;
	
	load_config_file(conf);
	//gtk options for GUI
	gtk_window_set_default_size(
		GTK_WINDOW(pub->mw->window), conf->width, conf->height);
	set_text_font_by_name(pub->mw->view, conf->fontname);
	
	ifactory = gtk_item_factory_from_widget(pub->mw->menubar);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
		gtk_item_factory_get_widget(ifactory, "/Options/Word Wrap")),
		conf->wordwrap);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
		gtk_item_factory_get_widget(ifactory, "/Options/Line Numbers")),
		conf->linenumbers);
	indent_refresh_tab_width(pub->mw->view);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
		gtk_item_factory_get_widget(ifactory, "/Options/Auto Indent")),
		conf->autoindent);
	
	gtk_widget_show_all(pub->mw->window);
	g_free(conf->fontname);
	g_free(conf);
	
#ifdef ENABLE_EMACS
	check_emacs_key_theme(GTK_WINDOW(pub->mw->window), ifactory);
#endif
	
	hlight_init(pub->mw->buffer);
	undo_init(pub->mw->view,
		gtk_item_factory_get_widget(ifactory, "/Edit/Undo"),
		gtk_item_factory_get_widget(ifactory, "/Edit/Redo"));
//	hlight_init(pub->mw->buffer);
	dnd_init(pub->mw->view);
	
	if (pub->fi->filename)
		file_open_real(pub->mw->view, pub->fi);
#ifdef G_OS_UNIX
	else
		stdin_data = gedit_utils_get_stdin();
#endif
	if (stdin_data) {
		gchar *str;
		GtkTextIter iter;
		
		str = g_convert(stdin_data, -1, "UTF-8",
			get_default_charset(), NULL, NULL, NULL);
		g_free(stdin_data);
	
//		gtk_text_buffer_set_text(buffer, "", 0);
		gtk_text_buffer_get_start_iter(pub->mw->buffer, &iter);
		gtk_text_buffer_insert(pub->mw->buffer, &iter, str, strlen(str));
		gtk_text_buffer_get_start_iter(pub->mw->buffer, &iter);
		gtk_text_buffer_place_cursor(pub->mw->buffer, &iter);
		gtk_text_buffer_set_modified(pub->mw->buffer, FALSE);
		gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(pub->mw->view), &iter, 0, FALSE, 0, 0);
		g_free(str);
	}
	
	if (jump_linenum) {
		GtkTextIter iter;
		
		gtk_text_buffer_get_iter_at_line(pub->mw->buffer, &iter, jump_linenum - 1);
		gtk_text_buffer_place_cursor(pub->mw->buffer, &iter);
//		gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(textview), &iter, 0.1, FALSE, 0.5, 0.5);
		scroll_to_cursor(pub->mw->buffer, 0.25);
	}
	
	set_main_window_title();
//	hlight_apply_all(pub->mw->buffer);
	
	gtk_main();
	
	return 0;
}
Exemplo n.º 23
0
int main(int argc, char * argv[])
{
	int i;
	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-help") == 0
		    || strcmp(argv[i], "-h") == 0)
		{
			show_help(argc, argv);
			return 0;
		}
		else if (strcmp(argv[i], "-res") == 0) {
			show_resources();
			return 0;
		}
	}

	init_appres(argc, argv);
	the_bar.realized = 0;

	if (!get_display_info() ||
	    !init_resources() ||
	    !create_main_window())
		exit (1);

	set_signals();
	XMapWindow(gdi.display, gdi.mainw);

	set_keybindings();

	XEvent evt;
	while (1) {
		XNextEvent(gdi.display, &evt);
#ifdef DEBUG
		printf("wid %08X\t%s\n", (int)(evt.xany.window),
		       event_names[evt.type]);
		fflush(stdout);
#endif

		switch(evt.type){
		case KeyPress:
			handle_key_press(&evt);
			break;
		case ReparentNotify:
			handle_reparent(&evt);
			break;
		case MapRequest:
			/* add a new tab */
			handle_maprequest(&evt);
			break;
		case DestroyNotify:
			/* remove a tab */
			handle_destroy(&evt);
			break;
		case ConfigureNotify:
			handle_configure_notify(&evt);
			break;
		case ConfigureRequest:
			handle_configure_request(&evt);
			break;
		case Expose:
			if (evt.xexpose.window != gdi.mainw)
				bar_handle_expose(&(evt.xexpose));
			break;
		case ButtonPress:
			bar_handle_button(&(evt.xbutton));
			break;
		case PropertyNotify:
			bar_handle_prop(&evt);
			break;
		case MapNotify:
			if (evt.xmap.window == gdi.mainw) {
				if (init_stage == 0) {
					init_stage ++;
					spawn_xterm();
				}
			}
			break;
		case UnmapNotify:
			if (the_bar.tab_group.tab_count == 0)
				exit(0);
			break;
		case EnterNotify:
			set_focus();
			break;
		default:
			break;
		}
		XFlush(gdi.display);
	};
	return 0;
}
Exemplo n.º 24
0
Arquivo: main.c Projeto: gabri94/olsrd
int
main(int argc, char *argv[])
{
  struct hostent *hp;
  struct in_addr in;

#ifdef _WIN32
  WSADATA WsaData;
#endif /* _WIN32 */
  GtkWidget *main_window;

#ifdef _WIN32
  if (WSAStartup(0x0202, &WsaData)) {
    fprintf(stderr, "Could not initialize WinSock.\n");
    exit(EXIT_FAILURE);
  }
#endif /* _WIN32 */

  /* Get IP */
  if ((hp = gethostbyname(argc > 1 ? argv[1] : "localhost")) == 0) {
    fprintf(stderr, "Not a valid host \"%s\"\n", argv[1]);
    exit(EXIT_FAILURE);
  }

  in.s_addr = ((struct in_addr *)(void *)(hp->h_addr))->s_addr;
  printf("Address: %s\n", inet_ntoa(in));

  /* fill in the socket structure with host information */
  memset(&pin, 0, sizeof(pin));
  pin.sin_family = AF_INET;
  pin.sin_addr.s_addr = ((struct in_addr *)(void *)(hp->h_addr))->s_addr;
  pin.sin_port = htons(IPC_PORT);

  gtk_init(&argc, &argv);

  init_nodes();

  freeze_packets = 1;
  display_dec = 1;

  /* "Failsafe" values */
  ipversion = AF_INET;
  ipsize = sizeof(struct in_addr);

  main_window = create_main_window();
  gtk_widget_show(main_window);

  printf("Done building GUI\n");

  memset(&main_addr, 0, sizeof(union olsr_ip_addr));
  memset(&null_addr, 0, sizeof(union olsr_ip_addr));

  /* Terminate signal */
  signal(SIGINT, shutdown_);

  /* Init node timeout */
  nodes_timeout = NEIGHB_HOLD_TIME_NW;
  init_timer((olsr_u32_t) (nodes_timeout * 1000), &hold_time_nodes);

  ipc_connect(&pin);

  add_timeouts();

  gtk_main();
  return 0;
}
Exemplo n.º 25
0
Arquivo: main.c Projeto: rplnt/abrt
int main(int argc, char **argv)
{
    abrt_init(argv);

    /* I18n */
    setlocale(LC_ALL, "");
#if ENABLE_NLS
    bindtextdomain(PACKAGE, LOCALEDIR);
    textdomain(PACKAGE);
#endif

    /* without this the name is set to argv[0] which confuses
     * desktops which uses the name to find the corresponding .desktop file
     * trac#180
     */
    gtk_init(&argc, &argv);

    /* Can't keep these strings/structs static: _() doesn't support that */
    const char *program_usage_string = _(
                                           "\b [-vp] [DIR]...\n"
                                           "\n"
                                           "Shows list of ABRT dump directories in specified DIR(s)\n"
                                           "(default DIRs: "DEBUG_DUMPS_DIR" $HOME/.abrt/spool)"
                                       );
    enum {
        OPT_v = 1 << 0,
        OPT_p = 1 << 1,
    };
    /* Keep enum above and order of options below in sync! */
    struct options program_options[] = {
        OPT__VERBOSE(&g_verbose),
        OPT_BOOL(   'p', NULL, NULL      , _("Add program names to log")),
        OPT_END()
    };
    unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);

    export_abrt_envvars(opts & OPT_p);

    GtkWidget *main_window = create_main_window();

    const char *default_dirs[] = {
        "/var/spool/abrt",
        NULL,
        NULL,
    };
    argv += optind;
    if (!argv[0])
    {
        char *home = getenv("HOME");
        if (home)
            default_dirs[1] = concat_path_file(home, ".abrt/spool");
        argv = (char**)default_dirs;
    }
    s_dirs = argv;

    init_notify();

    scan_dirs_and_add_to_dirlist();

    gtk_widget_show_all(main_window);

    sanitize_cursor(NULL);

    /* Set up signal pipe */
    xpipe(s_signal_pipe);
    close_on_exec_on(s_signal_pipe[0]);
    close_on_exec_on(s_signal_pipe[1]);
    ndelay_on(s_signal_pipe[0]);
    ndelay_on(s_signal_pipe[1]);
    signal(SIGCHLD, handle_signal);
    g_io_add_watch(g_io_channel_unix_new(s_signal_pipe[0]),
                   G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
                   handle_signal_pipe,
                   NULL);

    /* Enter main loop */
    gtk_main();

    return 0;
}
Exemplo n.º 26
0
void
init_interface (int *argcp, char ***argvp)
{
printf("init_interface started\n");
  GL_realizer::gl_init (argcp, argvp);

  main_window = create_main_window ();
  Publisher::init (main_window);
  fill_toolbar_with_icons();
  
  Kit::external_widget =
    (GtkBox *) lookup_widget (main_window, "properties_vbox");
  g_signal_connect ((gpointer) main_window, "destroy",
		    G_CALLBACK (gtk_main_quit), NULL);

  window2 = create_window2 ();
  g_signal_connect ((gpointer) window2, "destroy", G_CALLBACK (gtk_main_quit),
		    NULL);
  gtk_window_set_transient_for (GTK_WINDOW (window2),
				GTK_WINDOW (main_window));
		    
  quit_dialog = create_quit_dialog();
  gtk_window_set_transient_for (GTK_WINDOW (quit_dialog),
				GTK_WINDOW (main_window));

  new_dialog = create_new_dialog();
  gtk_window_set_transient_for (GTK_WINDOW (new_dialog),
				GTK_WINDOW (main_window));

  GtkWidget *fcd = gtk_file_chooser_dialog_new (_("Choose a file"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, NULL);

printf("Wins created, not shown\n"); 


#ifdef EDITOR_FULL
  osg::ref_ptr < TopView > top =
    new TopView (lookup_widget (main_window, "main_drawingarea"));
  osg::ref_ptr < PerspectiveView > perspective =
    new PerspectiveView (lookup_widget (window2, "drawingarea2"));
  static Editor editor (top.get ());
  editor.addPerspectiveView (perspective.get ());
  perspective->
    unsetNodeMask (Editor::Masks::nm_Nodes | Editor::Masks::nm_Maps);
#else
  Publisher::set_status_msg (3, "Publisher::set_status_msg(...)");
  static foo realizer2 (lookup_widget (window2, "drawingarea2"));
  static foo realizer1 (lookup_widget (main_window, "main_drawingarea"));
  static Editor editor;
  // printf("foos created\n"); _sleep(4444);
#endif
printf("Win show attempt\n"); 
  gtk_widget_show (main_window);
  gtk_widget_show (window2);
printf("Wins shown\n"); 

#ifndef EDITOR_FULL

  Kit *kit = new Kit[3];
  
  kit[1].addIntEntry ("Malinowski", 0, 100, 1, 1);
  kit[1].addIntEntry ("Kowalski", 0, 1000, 1, 555);
  kit[1].addFileSel ("Majewski", "C:\\WINDOWS\\Desktop\\Editor\\src","(*.h$)|(*.o$)","Konarski");
  kit[0].addTextEntry ("Wisniewski", "");
  kit[0].addTextEntry ("Bednarski", "");
  kit[0].addTextEntry ("Jankowski", "");
  kit[0].addTextEntry ("Kozlowski", "");
  kit[0].addTextEntry ("Jaworski", "");
  kit[0].addTextEntry ("Janowski", "");
  kit[0].addTextEntry ("Zalewski", "");
  kit[0].addButton ("Borowski", 1, 0);
  // kit[0].addFileSel ("Majewski", "C:\\WINDOWS\\Desktop","*.*","Zielinski");
  std::vector<std::string> p, e;
  p.push_back(std::string("*.*"));
  /*
  e.push_back(std::string("emb #1"));
  e.push_back(std::string("emb #2"));
  e.push_back(std::string("emb #3"));
  */
  kit[0].addFileSel ("Majewski", "C:\\WINDOWS\\Desktop",p,"Zielinski",3,true,e);
  static Kit::Item gajewski_item = kit[0].addButton ("Gajewski", 1, 1);
  // gajewski_item.switching();

  // kit[1].activate();
  gtk_timeout_add (7000, to_handler, kit);
  //gtk_timeout_add (1000, gajewski_h, &kit[0]);

#endif

  Undo::init ( lookup_widget(main_window,"undo_toolbutton"),
             lookup_widget(main_window,"record_toolbutton") );
             
  g_timeout_add(AUTOSAVE_DELAY_SECONDS*1000,autosave_callback,NULL);
};
Exemplo n.º 27
0
/* entry point */
int main(int ac, char **av)
{
    int ret;

    memset(&ctx, 0, sizeof(ctx));

    /* instance handle of this module */
    {
        HMODULE module;

        module = GetModuleHandle(NULL);
        if(module == NULL) {
            error_message_le("GetModuleHandle() failed");
            return 1;
        }

        ctx.instance = (HINSTANCE)module;
    }

    /* initialize COM */
    {
        HRESULT hres;

        hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
        if(FAILED(hres)) {
            error_message_hr("CoInitializeEx() failed", hres);
            return 1;
        }

        hres = init_regexp();
        if(FAILED(hres)) {
            error_message_hr("init_regexp() failed", hres);
            return 1;
        }
    }

    /* create main message window */
    ctx.main_window = create_main_window();
    if(ctx.main_window == NULL) {
        error_message_le("create_main_window() failed");
        return 1;
    }

    /* logger */
    ret = create_logger();
    if(ret == 0) {
        error_message_le("create_logger() failed");
        return 1;
    }

    ctx.sprocs.hdr.api_ver = MP_OP_API_VERSION;
    ctx.sprocs.hdr.type = MP_OP_TYPE_SUPPORT;
    ctx.sprocs.log_printf = log_printf;
    ctx.sprocs.log_s_exp = log_print_s_exp;
    ctx.sprocs.log_lasterror = log_print_lasterror;
    ctx.sprocs.log_hresult = log_print_hresult;

    /* command line option */
    {
        LPWSTR *avw, file;
        int acw;

        avw = CommandLineToArgvW(GetCommandLineW(), &acw);
        if(avw != NULL && acw >= 2) {
            file = avw[1];
        } else {
            file = NULL;
        }

        /* load setting file */
        load_setting(file, TRUE);
    }

    /* start message */
    log_printf(LOG_LEVEL_NOTIFY, L"\nmouse-processor started\n");

    /* main message loop */
    ret = message_loop();

    /* uninitialize COM */
    CoUninitialize();

    /* end logger */
    destroy_logger();

    return ret;
}
Exemplo n.º 28
0
void
contacts_create_ui (ContactsData *data)
{
	create_main_window (data);
	create_chooser_dialog (data);
}
Exemplo n.º 29
0
int
main (int argc, char *argv[])
{
  int cnt;
  const char *p;
  char arg[128];
  
#ifdef __WIN32__
  HMODULE hModule;
  char *sBuffer;
  DWORD dWord;
  char *dirname;
  char *base_dir;
  char *pixmap_dir;
  char *locale_dir;
  
  // Init the path for the Windows version by getting the 
  // executable location.
  hModule = GetModuleHandle("skinedit.exe");
  sBuffer = (char *) malloc(4096 * sizeof(char));
  dWord = GetModuleFileName(hModule, sBuffer, 4096);
  dirname = g_dirname(sBuffer);
  base_dir = g_strconcat(dirname, "\\", NULL);
  g_free(dirname);
  free(sBuffer);
  
  pixmap_dir = g_strconcat(base_dir, "pixmaps\\", NULL);
  locale_dir = g_strconcat(base_dir, "locale\\", NULL);
#endif

#ifdef ENABLE_NLS
#ifndef __WIN32__
  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#else
  bindtextdomain(PACKAGE, locale_dir);
  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif
#endif

  gtk_set_locale ();
  gtk_init (&argc, &argv);

#ifndef __WIN32__
  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
#else
  add_pixmap_directory (pixmap_dir);
#endif

  signal(SIGINT, signal_handler);

  fprintf(stdout, _("SkinEdit v%s, (C) 2002-2003 Julien BLACHE <*****@*****.**>\n"), VERSION);
  fprintf(stdout, _("                  2004-2005 Romain Lievin <*****@*****.**>\n"));
  fprintf(stdout, "\n");
  fprintf(stdout, _("This program is free software; you can redistribute it and/or modify\n"));
  fprintf(stdout, _("it under the terms of the GNU General Public License as published by\n"));
  fprintf(stdout, _("the Free Software Foundation; version 2 of the License\n"));
  fprintf(stdout, _("This program is distributed in the hope that it will be useful,\n"));
  fprintf(stdout, _("but WITHOUT ANY WARRANTY; without even the implied warranty of\n"));
  fprintf(stdout, _("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"));
  fprintf(stdout, _("GNU General Public License for more details.\n"));

  gtk_widget_show (main_wnd = create_main_window());

  sbar_print(_("Skinedit v%s -- Supported formats : TiEmu v2.00 (R/W), VTiv2.1 (R/W), VTiv2.5 (R/W)"), VERSION);

    // scan command line
    for (cnt = 1; cnt < argc; cnt++) {
      
      // get argument
      p = argv[cnt];
      if (*p == '-') {
	// argument
	p++;
      } else {
	// filename
	if(load_skin(p) == 0)
	  skin_infos.changed = 1;
      }
      
      strcpy(arg, p);
      
      if (strexact(arg, "-help") || strexact(arg, "h"))
	help();
      if (strexact(arg, "-version") || strexact(arg, "v"))
	exit(0);
    }
    
    gtk_main ();
    return 0;
}
Exemplo n.º 30
0
int main(int argc, char* argv[])
{
	gboolean hidden = FALSE;
	UniqueApp* unique_app;
	AppShellData* app_data;
	GSList* actions;
	GError* error;
	GOptionEntry options[] = {
		{"hide", 0, 0, G_OPTION_ARG_NONE, &hidden, N_("Hide on start (useful to preload the shell)"), NULL},
		{NULL}
	};

	#ifdef ENABLE_NLS
		bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR);
		bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
		textdomain(GETTEXT_PACKAGE);
	#endif

	error = NULL;

	if (!gtk_init_with_args(&argc, &argv, NULL, options, GETTEXT_PACKAGE, &error))
	{
		g_printerr("%s\n", error->message);
		g_error_free(error);
		return 1;
	}

	unique_app = unique_app_new("org.mate.mate-control-center.shell", NULL);

	if (unique_app_is_running(unique_app))
	{
		int retval = 0;

		if (!hidden)
		{
			UniqueResponse response;
			response = unique_app_send_message(unique_app, UNIQUE_ACTIVATE, NULL);
			retval = (response != UNIQUE_RESPONSE_OK);
		}

		g_object_unref(unique_app);
		return retval;
	}

	app_data = appshelldata_new("matecc.menu", GTK_ICON_SIZE_DND, FALSE, TRUE, 0);
	generate_categories(app_data);

	actions = get_actions_list();
	layout_shell(app_data, _("Filter"), _("Groups"), _("Common Tasks"), actions, handle_static_action_clicked);

	create_main_window(app_data, "MyControlCenter", _("Control Center"), "preferences-desktop", 975, 600, hidden);

	unique_app_watch_window(unique_app, GTK_WINDOW(app_data->main_app));
	g_signal_connect(unique_app, "message-received", G_CALLBACK(message_received_cb), app_data);

	gtk_main();

	g_object_unref(unique_app);

	return 0;
}