int
main                                            (int argc, 
                                                 char **args)
{
    gtk_init (&argc, &args);
    
    HildonProgram *program = hildon_program_get_instance ();

    GtkWidget *window = hildon_window_new ();
    hildon_program_add_window (program, HILDON_WINDOW (window));

    gtk_init (&argc, &args);
    
    HildonSeekbar *bar = HILDON_SEEKBAR (hildon_seekbar_new ());
    gtk_widget_set_size_request (GTK_WIDGET (bar), 400, -1);

    hildon_seekbar_set_total_time (bar, 100);
    hildon_seekbar_set_position (bar, 50);

    GtkToolbar *toolbar = gtk_toolbar_new ();
    GtkToolItem *item = gtk_tool_item_new ();
    gtk_container_add (GTK_CONTAINER (item), GTK_WIDGET (bar));
    gtk_toolbar_insert (toolbar, item , 0);

    hildon_window_add_toolbar (window, toolbar);

    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
    gtk_widget_show_all (GTK_WIDGET (window));
    
    gtk_main ();

    return 0;
}
int
main                                            (int argc,
                                                 char **argv)
{
    hildon_gtk_init (&argc, &argv);

    HildonProgram *program = hildon_program_get_instance ();
    GtkDrawingArea *area = GTK_DRAWING_AREA (gtk_drawing_area_new ());
    gtk_widget_set_size_request (GTK_WIDGET (area), 320, 240);

    gtk_widget_set_events (GTK_WIDGET (area), 
                           GDK_BUTTON_PRESS_MASK);

    gtk_widget_set_extension_events (GTK_WIDGET (area), GDK_EXTENSION_EVENTS_ALL);
 
    GtkWidget *window = hildon_window_new ();
    hildon_program_add_window (program, HILDON_WINDOW (window));    

    gtk_window_set_title (GTK_WINDOW (window), "world");
    g_set_application_name ("hello");

    gtk_container_set_border_width (GTK_CONTAINER (window), 6);
    
    g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
    g_signal_connect (G_OBJECT (area), "button-press-event", G_CALLBACK (on_button_press), NULL);
    gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (area));
    gtk_widget_show_all (GTK_WIDGET (window));
    
    gtk_main ();
    return 0;
}
Beispiel #3
0
int main(int argc, char *argv[]) {
	pthread_t 		thread;

	/* init threads */
    g_thread_init (NULL);
    gdk_threads_init ();
    gdk_threads_enter ();

    gtk_init(&argc, &argv);

    initApp();

    appdata->program = HILDON_PROGRAM(hildon_program_get_instance());
    g_set_application_name("Webview");

    appdata->window = HILDON_WINDOW(hildon_window_new());
    hildon_program_add_window(appdata->program, appdata->window);


    create_menu(appdata->window);
    build_interface(appdata->window);

    /* Connect signal to X in the upper corner */
    g_signal_connect(G_OBJECT(appdata->window), "delete_event", G_CALLBACK(destroy), NULL);

	update_image();
	load_settings();

	gtk_widget_show_all(GTK_WIDGET(appdata->window));

	if(! start_camera(appdata->window))
	{
		g_warning("Unable to start camera\n");

		GtkWidget *failDialog = gtk_message_dialog_new(NULL,
	     		GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
	     		GTK_BUTTONS_OK,
	     		"Unable to start camera\n");
		gtk_dialog_run (GTK_DIALOG (failDialog));
		gtk_widget_destroy (failDialog);
	}

	if(! start_webserver())
	{
		GtkWidget *failDialog = gtk_message_dialog_new(NULL,
	     		GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
	     		GTK_BUTTONS_OK,
	     		"Unable to start web server.\nCheck server port is not already in use.\n");
		gtk_dialog_run (GTK_DIALOG (failDialog));
		gtk_widget_destroy (failDialog);
	}
	sleep(1);

	pthread_create(&thread, NULL, count_down_thread, NULL);

	gtk_main();

	gdk_threads_leave ();
	return( 0 );
}
int
main                                            (int argc, 
                                                 char **args)
{
    gtk_init (&argc, &args);
    
    HildonProgram *program = hildon_program_get_instance ();

    GtkWidget *window = hildon_window_new ();
    hildon_program_add_window (program, HILDON_WINDOW (window));    

    gtk_window_set_title (GTK_WINDOW (window), "world");
    g_set_application_name ("hello");

    gtk_container_set_border_width (GTK_CONTAINER (window), 6);
    
    GtkWidget *label = GTK_WIDGET (gtk_label_new ("Hello world!"));

    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
    gtk_container_add (GTK_CONTAINER (window), label);
    gtk_widget_show_all (GTK_WIDGET (window));
    
    gtk_main ();
    return 0;
}
Beispiel #5
0
void prefs_found(motorway *mway, int *res, gpointer *data)
{
  struct prefs_found_args *args = (struct prefs_found_args*)data;
  
  gdk_threads_enter();
  if (mway == NULL)
  {
    moflow_error_dialog(*res, NULL, GTK_BUTTONS_OK);
    main_exit(1);
  }
  client->activereq = args->request;
  
  GtkWidget *window = GTK_WIDGET(hildon_window_new());
  gtk_signal_connect(GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (wizard_delete_event), NULL);
  gtk_window_set_title(GTK_WINDOW(window), mway->roadName);

  GtkWidget *vbox = GTK_WIDGET(gtk_vbox_new(FALSE, 20));
  
  gtk_box_pack_start(GTK_BOX (vbox), direction_widget_new(args->table, mway, MF_DIRECTION_LEFT), TRUE, TRUE, 10);
  gtk_box_pack_start(GTK_BOX (vbox), direction_widget_new(args->table, mway, MF_DIRECTION_RIGHT), TRUE, TRUE, 10);
  
  gtk_container_add(GTK_CONTAINER(window), vbox);
  gtk_widget_show_all(window);
  gdk_threads_leave();
  g_free(args);
}
ZLGtkApplicationWindow::ZLGtkApplicationWindow(ZLApplication *application) :
	ZLApplicationWindow(application),
	KeyActionOnReleaseNotOnPressOption(ZLCategoryKey::CONFIG, "KeyAction", "OnRelease", false),
	myFullScreen(false) {
	myProgram = HILDON_PROGRAM(hildon_program_get_instance());
	g_set_application_name("");

	myWindow = HILDON_WINDOW(hildon_window_new());

	((ZLMaemoCommunicationManager&)ZLCommunicationManager::Instance()).init();

	myToolbar = GTK_TOOLBAR(gtk_toolbar_new());
	gtk_toolbar_set_show_arrow(myToolbar, false);
	gtk_toolbar_set_orientation(myToolbar, GTK_ORIENTATION_HORIZONTAL);
	gtk_toolbar_set_style(myToolbar, GTK_TOOLBAR_ICONS);

	myMenu = GTK_MENU(gtk_menu_new());
	hildon_window_set_menu(myWindow, myMenu);
	gtk_widget_show_all(GTK_WIDGET(myMenu));

	hildon_window_add_toolbar(myWindow, myToolbar);
	hildon_program_add_window(myProgram, myWindow);
	gtk_widget_show_all(GTK_WIDGET(myWindow));

	myViewWidget = 0;

	ZLGtkSignalUtil::connectSignal(GTK_OBJECT(myWindow), "delete_event", GTK_SIGNAL_FUNC(applicationQuit), this);
	ZLGtkSignalUtil::connectSignal(GTK_OBJECT(myWindow), "key_press_event", GTK_SIGNAL_FUNC(handleKeyPress), this);
	ZLGtkSignalUtil::connectSignal(GTK_OBJECT(myWindow), "key_release_event", GTK_SIGNAL_FUNC(handleKeyRelease), this);
}
Beispiel #7
0
static GtkWidget *
create_main_window (void)
{
  GtkWidget *window;

  window = hildon_window_new ();

  return window;
}
Beispiel #8
0
/**
 * Creates a window of a fixed, well known size
 */
GtkWidget *
create_test_window ()
{
  GtkWidget *window = NULL;

  window = hildon_window_new ();
  /*  gtk_window_resize (GTK_WINDOW (window), TEST_WINDOW_WIDTH, TEST_WINDOW_HEIGHT);  */

  return window;
}
static void
fx_setup_default_note ()
{
    int argc = 0;

    gtk_init(&argc, NULL);

    n_window = GTK_WINDOW(hildon_window_new());
    /* Check window object has been created properly */
    fail_if(!HILDON_IS_WINDOW(n_window),
            "hildon-note: Window creation failed.");
}
Beispiel #10
0
void motorway_list_handler(GHashTable *table, int *res, gpointer *data)
{
  if (*res != NO_ASYNC)
   gdk_threads_enter();
  
  GtkWidget *window = GTK_WIDGET( hildon_window_new() );
  gtk_signal_connect(GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (wizard_delete_event), NULL);
  gtk_window_set_title(GTK_WINDOW(window), "Pick a motorway");

  if (table == NULL)
  {
    moflow_error_dialog(*res, NULL, GTK_BUTTONS_OK);
    main_exit(1);
  }
  
  GtkWidget *hbox = gtk_hbox_new(FALSE, 2);
  GtkWidget *vbox = gtk_vbox_new(FALSE, 2);
  GtkWidget *selector = hildon_touch_selector_new_text();
  
  GList *sortedList = g_list_sort(g_hash_table_get_keys(table), (GCompareFunc)motorwaycmp);
  for (GList *li = sortedList; li != NULL; li = g_list_next(li))
  {
    gchar *key = (gchar*)li->data;
    hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(selector), key);
  }
  g_list_free(sortedList);
  gtk_box_pack_start(GTK_BOX(vbox), selector, TRUE, TRUE, 2);

  GtkWidget *button = hildon_button_new_with_text(HILDON_SIZE_AUTO_WIDTH, HILDON_BUTTON_ARRANGEMENT_VERTICAL, "Go!", NULL);
  gtk_widget_set_sensitive(button, FALSE);
  g_signal_connect(G_OBJECT(selector), "changed", G_CALLBACK(selection_changed), button);
  g_object_set_data(G_OBJECT(button), "motorwayTable", table);
  g_object_set_data(G_OBJECT(button), "motorwaySelector", selector);
  gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(motorway_select_cb), NULL);
  gtk_widget_set_size_request(button, -1, 70);
  gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 2);
  
  GtkWidget *logo = gtk_image_new_from_file("/usr/share/pixmaps/moflow/motorway.png");
  gtk_box_pack_end(GTK_BOX(hbox), logo, FALSE, FALSE, 20);
  
  gtk_container_add(GTK_CONTAINER(window), hbox);
  gtk_widget_show_all(window);

  if (*res != NO_ASYNC)
    gdk_threads_leave();
}
int
main                                            (int argc, 
                                                 char **args)
{
    gtk_init (&argc, &args);
    
    HildonWindow *window = HILDON_WINDOW (hildon_window_new ());
    GtkWidget *button = gtk_button_new_with_label ("Click me");

    hildon_helper_set_insensitive_message (button, "Do not poke me!");
    gtk_widget_set_sensitive (button, FALSE);
       
    gtk_container_add (GTK_CONTAINER (window), button);

    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);

    gtk_widget_show_all (GTK_WIDGET (window));
    gtk_main ();
    
    return 0;
}
static void
fx_setup_default_time_picker ()
{
  int argc = 0;
  gtk_init(&argc, NULL);

  tp_window = HILDON_WINDOW(hildon_window_new());
 /* Check window object has been created properly */
  fail_if(!HILDON_IS_WINDOW(tp_window),
          "hildon-time-picker: Window creation failed.");

  time_picker = HILDON_TIME_PICKER(hildon_time_picker_new(GTK_WINDOW(tp_window)));

  /* Check time_picker object has been created properly */
  fail_if(!HILDON_IS_TIME_PICKER(time_picker),
          "hildon-time-picker: Creation failed.");

  /* Displays the widget and the window */
  show_all_test_window (GTK_WIDGET (tp_window));
  show_all_test_window (GTK_WIDGET (time_picker));

}
Beispiel #13
0
// ***************************************************
a_window *create_window( char *title )
{
  HildonProgram *program;
  GtkWidget *window;

  // Allocate memory for our window structure from heap
  a_window *tmp = malloc( sizeof( a_window ) );

  if( tmp == NULL )
    malloc_failed();

  /* Create new hildon program */
  program = HILDON_PROGRAM( hildon_program_get_instance() );

  /* Set title of our program */
  g_set_application_name( title );

  /* Create new window */
  window = hildon_window_new();

  /* Add window to program */
  hildon_program_add_window( program, HILDON_WINDOW( window ) );

  /* Save values to structure a_window. */
  tmp->window = window;
  tmp->window_state = WS_NORMAL;
  tmp->width = 796;
  tmp->height = 396;

  /* When user closes this window, we must quit. */
  g_signal_connect( G_OBJECT( tmp->window ), "delete_event",
      G_CALLBACK( destroy_window ), NULL );
  /*
  g_signal_connect( G_OBJECT( tmp->window ), "key_press_event",
      G_CALLBACK( key_pressed ), tmp );
  */
  /* Return our structure. */
  return tmp;
}
int
main                                            (int argc,
                                                 char **argv)
{
    hildon_gtk_init (&argc, &argv);

    HildonProgram *program = hildon_program_get_instance ();

    GtkWidget *window = hildon_window_new ();
    hildon_program_add_window (program, HILDON_WINDOW (window));    

    gtk_container_set_border_width (GTK_CONTAINER (window), 6);

    GtkVBox *vbox = GTK_VBOX (gtk_vbox_new (6, FALSE));
    GtkButton *button1 = GTK_BUTTON (gtk_button_new_with_label ("Information note"));
    g_signal_connect (G_OBJECT (button1), "clicked", G_CALLBACK (on_information_clicked), window);

    GtkButton *button2 = GTK_BUTTON (gtk_button_new_with_label ("Confirmation note"));
    g_signal_connect (G_OBJECT (button2), "clicked", G_CALLBACK (on_confirmation_clicked), window);

    GtkButton *button3 = GTK_BUTTON (gtk_button_new_with_label ("Progress note"));
    g_signal_connect (G_OBJECT (button3), "clicked", G_CALLBACK (on_progress_clicked), window);

    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);

    gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (button1), TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (button2), TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (button3), TRUE, TRUE, 0);

    gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (vbox));

    gtk_widget_show_all (GTK_WIDGET (window));
    
    gtk_main ();

    return 0;
}
int
main                                            (int argc,
                                                 char **argv)
{
    hildon_gtk_init (&argc, &argv);

    HildonProgram *program = hildon_program_get_instance ();

    GtkWidget *window = hildon_window_new ();
    hildon_program_add_window (program, HILDON_WINDOW (window));    

    gtk_container_set_border_width (GTK_CONTAINER (window), 6);
    
    GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
    gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
    hildon_helper_set_thumb_scrollbar (scrolled, TRUE);

    GtkVBox *vbox = GTK_VBOX (gtk_vbox_new (6, FALSE));
    int i;

    for (i = 0; i < 30; i++) {
            GtkLabel *label = GTK_LABEL (gtk_label_new (""));
            gchar *content = g_strdup_printf ("<big><big><big>Content %d</big></big></big>", i);
            gtk_label_set_markup (label, content);
            g_free (content);
            gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (label), TRUE, TRUE, 0);
    }

    gtk_scrolled_window_add_with_viewport (scrolled, GTK_WIDGET (vbox));

    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
    gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (scrolled));
    gtk_widget_show_all (GTK_WIDGET (window));
    
    gtk_main ();
    return 0;
}
Beispiel #16
0
/*---------------------------------------------------------------------*/
HildonWindow *
make_hop_gui() {
   /* Create the Hildon program and setup the title */
   program = HILDON_PROGRAM( hildon_program_get_instance() );
   g_set_application_name( "Hop launcher" );

   /* Create HildonWindow and set it to HildonProgram */
   win = HILDON_WINDOW( hildon_window_new() );
   hildon_program_add_window( program, win );

   /* Add vbox to hildon window */
   make_main_gui();
   
   /* The Hop logo and version */
   make_hop_logo();
   
   /* The console */
   make_hop_console();

   /* The restart HOP area */
   make_hop_restart();

   return win;
}
int
main                                            (int argc,
        char **argv)
{
    hildon_gtk_init (&argc, &argv);

    HildonProgram *program = hildon_program_get_instance ();

    GtkWidget *window = hildon_window_new ();
    hildon_program_add_window (program, HILDON_WINDOW (window));

    GtkMenu *menu = GTK_MENU (gtk_menu_new ());
    GtkWidget *menu_item = gtk_menu_item_new_with_label ("Test common item");
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);

    hildon_program_set_common_menu (program, menu);

    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
    gtk_widget_show_all (GTK_WIDGET (window));

    gtk_main ();

    return 0;
}
int main (int argc, char **argv)
{
#if 1
  HildonProgram *program;
#endif
  GtkListStore *store;
  GtkWidget *window, *scrolled_window, *vbox, *bct, *button;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;

  gtk_init (&argc, &argv);

  /* Main window */
#if 1
  program = hildon_program_get_instance ();
  window = hildon_window_new ();
  hildon_program_add_window (program, HILDON_WINDOW (window));
#else
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
#endif
  gtk_container_set_border_width (GTK_CONTAINER (window), 2);
  gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
  g_signal_connect (window, "delete-event", gtk_main_quit, NULL);

  vbox = gtk_vbox_new (FALSE, 3);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  current_root = g_strdup ("/");

  bct = hildon_bread_crumb_trail_new ();
  g_signal_connect (bct, "crumb-clicked", G_CALLBACK (crumb_clicked_cb), NULL);
  gtk_box_pack_start (GTK_BOX (vbox), bct, FALSE, FALSE, 0);
  gtk_widget_show (bct);

  hildon_bread_crumb_trail_push_text (HILDON_BREAD_CRUMB_TRAIL (bct), "/",
				      g_strdup ("/"), (GDestroyNotify)free_id);

  /* Treeview */
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);
  store = gtk_list_store_new (N_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN);
  gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
                                   SORTID_DIRALPHA,
                                   sort_iter_compare_func,
                                   GINT_TO_POINTER (SORTID_DIRALPHA),
                                   NULL);
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
                                        SORTID_DIRALPHA,
                                        GTK_SORT_ASCENDING);

  populate_store (store, "/");
  treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
  g_signal_connect (treeview, "row-activated", G_CALLBACK (row_activated_cb), bct);

  renderer = gtk_cell_renderer_pixbuf_new ();
  column = gtk_tree_view_column_new_with_attributes ("Icon",
						     renderer,
						     "pixbuf", ICON_COL,
						     NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("Name",
						     renderer,
						     "text", STRING_COL,
						     NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

  gtk_container_add (GTK_CONTAINER (scrolled_window), treeview);
  gtk_widget_show (treeview);
  gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
  gtk_widget_show (scrolled_window);

  button = gtk_button_new_with_label ("Clear!");
  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (clear_cb), bct);
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
Beispiel #19
0
int
main (int argc, char *argv[])
{
  char *dbfilename;
  int console=FALSE;

#ifdef USING_HILDON
  HildonProgram *program;
  GtkWidget *container;
  GtkWidget *main_menu;
  GtkWidget *item;

  if(!g_thread_supported()) {
    //g_thread_init(NULL);
  }
  setlocale(LC_ALL, "");
  //bind_textdomain_codeset(PACKAGE, "UTF-8"); 
#endif
  
  if (argc < 2) {
    fprintf(stderr, "Usage: sqlpilot <filename>\n");
    exit(0);
  }

  if (*argv[1] == '-') {
    if (argc < 3) {
	fprintf(stderr, "duh\n");
	exit(1);
    }
    dbfilename = argv[2];
    console = TRUE;
  } else {
    dbfilename = argv[1];
  }

  if (console) {
    
  } else {
    gtk_init (&argc, &argv);
    if ((logbook = logbook_new(dbfilename)) == NULL) exit(1);

#ifdef USING_HILDON
    /*  */
    program = HILDON_PROGRAM(hildon_program_get_instance());
    container = logbook->window;
    logbook->window = hildon_window_new();
    gtk_widget_reparent(container, logbook->window);

    hildon_program_add_window(program, HILDON_WINDOW(logbook->window));
    g_set_application_name(_("SqlPilot"));
    /* Hildon Menu */
    main_menu = gtk_menu_new();

    item = gtk_menu_item_new_with_label(_("New"));
    //g_signal_connect_swapped( item,"activate",GTK_SIGNAL_FUNC(new_1_player_game),ui_main);
    gtk_menu_append(main_menu, item);

    item = gtk_menu_item_new_with_label(_("Yay"));
    gtk_menu_append(main_menu, item);

    item = gtk_menu_item_new_with_label(_("Hello"));
    gtk_menu_append(main_menu, item);

    item = gtk_menu_item_new_with_label(_("Quit"));
    gtk_menu_append(main_menu, item);

    hildon_window_set_menu(HILDON_WINDOW(logbook->window), GTK_MENU(main_menu));

    gtk_widget_show_all(GTK_WIDGET(main_menu));
#endif
    g_signal_connect_swapped(logbook->window ,"destroy", GTK_SIGNAL_FUNC(logbook_save_options), logbook);
    gtk_widget_show (logbook->window);

    gtk_main ();
    logbook_finalize (logbook);    
  }

  return 0;
}
Beispiel #20
0
/* Registering the hildon application */
static GtkWidget* gtkbuilder_hildon_window_new (GtkBuilder *builder, GType type, GladeWidgetInfo *info)
{
    return hildon_window_new();
}
Beispiel #21
0
bool wxTopLevelWindowGTK::Create( wxWindow *parent,
                                  wxWindowID id,
                                  const wxString& title,
                                  const wxPoint& pos,
                                  const wxSize& sizeOrig,
                                  long style,
                                  const wxString &name )
{
    // always create a frame of some reasonable, even if arbitrary, size (at
    // least for MSW compatibility)
    wxSize size = sizeOrig;
    size.x = WidthDefault(size.x);
    size.y = HeightDefault(size.y);

    wxTopLevelWindows.Append( this );

    if (!PreCreation( parent, pos, size ) ||
        !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
    {
        wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
        return false;
    }

    m_title = title;

    // NB: m_widget may be !=NULL if it was created by derived class' Create,
    //     e.g. in wxTaskBarIconAreaGTK
    if (m_widget == NULL)
    {
#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
        // we must create HildonWindow and not a normal GtkWindow as the latter
        // doesn't look correctly in Maemo environment and it must also be
        // registered with the main program object
        m_widget = hildon_window_new();
        hildon_program_add_window(wxTheApp->GetHildonProgram(),
                                  HILDON_WINDOW(m_widget));
#else // !wxUSE_LIBHILDON || !wxUSE_LIBHILDON2
        m_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
        {
            // Tell WM that this is a dialog window and make it center
            // on parent by default (this is what GtkDialog ctor does):
            gtk_window_set_type_hint(GTK_WINDOW(m_widget),
                                     GDK_WINDOW_TYPE_HINT_DIALOG);
            gtk_window_set_position(GTK_WINDOW(m_widget),
                                    GTK_WIN_POS_CENTER_ON_PARENT);
        }
        else
        {
            if (style & wxFRAME_TOOL_WINDOW)
            {
                gtk_window_set_type_hint(GTK_WINDOW(m_widget),
                                         GDK_WINDOW_TYPE_HINT_UTILITY);

                // On some WMs, like KDE, a TOOL_WINDOW will still show
                // on the taskbar, but on Gnome a TOOL_WINDOW will not.
                // For consistency between WMs and with Windows, we
                // should set the NO_TASKBAR flag which will apply
                // the set_skip_taskbar_hint if it is available,
                // ensuring no taskbar entry will appear.
                style |= wxFRAME_NO_TASKBAR;
            }
        }
#endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2/!wxUSE_LIBHILDON || !wxUSE_LIBHILDON2

        g_object_ref(m_widget);
    }

    wxWindow *topParent = wxGetTopLevelParent(m_parent);
    if (topParent && (((GTK_IS_WINDOW(topParent->m_widget)) &&
                       (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)) ||
                       (style & wxFRAME_FLOAT_ON_PARENT)))
    {
        gtk_window_set_transient_for( GTK_WINDOW(m_widget),
                                      GTK_WINDOW(topParent->m_widget) );
    }

    if (style & wxFRAME_NO_TASKBAR)
    {
        gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), TRUE);
    }

    if (style & wxSTAY_ON_TOP)
    {
        gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE);
    }
    if (style & wxMAXIMIZE)
        gtk_window_maximize(GTK_WINDOW(m_widget));

#if 0
    if (!name.empty())
        gtk_window_set_role( GTK_WINDOW(m_widget), wxGTK_CONV( name ) );
#endif

    gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) );
    gtk_widget_set_can_focus(m_widget, false);

    g_signal_connect (m_widget, "delete_event",
                      G_CALLBACK (gtk_frame_delete_callback), this);

    // m_mainWidget is a GtkVBox, holding the bars and client area (m_wxwindow)
    m_mainWidget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    gtk_widget_show( m_mainWidget );
    gtk_widget_set_can_focus(m_mainWidget, false);
    gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );

    // m_wxwindow is the client area
    m_wxwindow = wxPizza::New();
    gtk_widget_show( m_wxwindow );
    gtk_box_pack_start(GTK_BOX(m_mainWidget), m_wxwindow, true, true, 0);

    // we donm't allow the frame to get the focus as otherwise
    // the frame will grab it at arbitrary focus changes
    gtk_widget_set_can_focus(m_wxwindow, false);

    if (m_parent) m_parent->AddChild( this );

    g_signal_connect(m_wxwindow, "size_allocate",
        G_CALLBACK(size_allocate), this);

    PostCreation();

#ifndef __WXGTK3__
    if ((m_x != -1) || (m_y != -1))
        gtk_widget_set_uposition( m_widget, m_x, m_y );
#endif

    // for some reported size corrections
    g_signal_connect (m_widget, "map_event",
                      G_CALLBACK (gtk_frame_map_callback), this);

    // for iconized state
    g_signal_connect (m_widget, "window_state_event",
                      G_CALLBACK (gtk_frame_window_state_callback), this);


    // for wxMoveEvent
    g_signal_connect (m_widget, "configure_event",
                      G_CALLBACK (gtk_frame_configure_callback), this);

    // activation
    g_signal_connect_after (m_widget, "focus_in_event",
                      G_CALLBACK (gtk_frame_focus_in_callback), this);
    g_signal_connect_after (m_widget, "focus_out_event",
                      G_CALLBACK (gtk_frame_focus_out_callback), this);

    // GTK processes key events at the top level first, which handles for
    // menu accelerators and shortcuts before passing the event on to the
    // focus child window to begin propagation. We want to propagate
    // first, so we connect gtk_window_propagate_key_event to
    // key_press_event.
    g_signal_connect (m_widget, "key_press_event",
                      G_CALLBACK (gtk_window_propagate_key_event), NULL);

#ifdef GDK_WINDOWING_X11
#ifdef __WXGTK3__
    if (GDK_IS_X11_SCREEN(gtk_window_get_screen(GTK_WINDOW(m_widget))))
#endif
    {
        gtk_widget_add_events(m_widget, GDK_PROPERTY_CHANGE_MASK);
        g_signal_connect(m_widget, "property_notify_event",
            G_CALLBACK(property_notify_event), this);
    }
#endif // GDK_WINDOWING_X11

    // translate wx decorations styles into Motif WM hints (they are recognized
    // by other WMs as well)

    // always enable moving the window as we have no separate flag for enabling
    // it
    m_gdkFunc = GDK_FUNC_MOVE;

    if ( style & wxCLOSE_BOX )
        m_gdkFunc |= GDK_FUNC_CLOSE;

    if ( style & wxMINIMIZE_BOX )
        m_gdkFunc |= GDK_FUNC_MINIMIZE;

    if ( style & wxMAXIMIZE_BOX )
        m_gdkFunc |= GDK_FUNC_MAXIMIZE;

    if ( (style & wxSIMPLE_BORDER) || (style & wxNO_BORDER) )
    {
        m_gdkDecor = 0;
    }
    else // have border
    {
        m_gdkDecor = GDK_DECOR_BORDER;

        if ( style & wxCAPTION )
            m_gdkDecor |= GDK_DECOR_TITLE;

        if ( style & wxSYSTEM_MENU )
            m_gdkDecor |= GDK_DECOR_MENU;

        if ( style & wxMINIMIZE_BOX )
            m_gdkDecor |= GDK_DECOR_MINIMIZE;

        if ( style & wxMAXIMIZE_BOX )
            m_gdkDecor |= GDK_DECOR_MAXIMIZE;

        if ( style & wxRESIZE_BORDER )
        {
           m_gdkFunc |= GDK_FUNC_RESIZE;
           m_gdkDecor |= GDK_DECOR_RESIZEH;
        }
    }

    // GTK sometimes chooses very small size if max size hint is not explicitly set
    DoSetSizeHints(m_minWidth, m_minHeight, m_maxWidth, m_maxHeight, m_incWidth, m_incHeight);

    m_decorSize = GetCachedDecorSize();
    int w, h;
    GTKDoGetSize(&w, &h);
    gtk_window_set_default_size(GTK_WINDOW(m_widget), w, h);

    return true;
}
Beispiel #22
0
/*****************************************************************************
* 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;
}
Beispiel #23
0
static int gtkDialogMapMethod(Ihandle* ih)
{
  int decorations = 0;
  int functions = 0;
  InativeHandle* parent;
  GtkWidget* fixed;
  int has_titlebar = 0;

#ifdef HILDON
  if (iupAttribGetBoolean(ih, "HILDONWINDOW")) 
  {
    HildonProgram *program = HILDON_PROGRAM(hildon_program_get_instance());
    ih->handle = hildon_window_new();
    if (ih->handle)
      hildon_program_add_window(program, HILDON_WINDOW(ih->handle)); 
  } 
  else 
  {
    iupAttribSetStr(ih, "DIALOGHINT", "YES");  /* otherwise not displayed correctly */ 
    ih->handle = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  }
#else
  ih->handle = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#endif
  if (!ih->handle)
    return IUP_ERROR;

  parent = iupDialogGetNativeParent(ih);
  if (parent)
  {
    gtk_window_set_transient_for((GtkWindow*)ih->handle, (GtkWindow*)parent);

    /* manually remove child windows when parent is destroyed */
    g_signal_connect(G_OBJECT(parent), "destroy", G_CALLBACK(gtkDialogChildDestroyEvent), ih);
  }

  g_signal_connect(G_OBJECT(ih->handle), "focus-in-event",     G_CALLBACK(iupgtkFocusInOutEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "focus-out-event",    G_CALLBACK(iupgtkFocusInOutEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "enter-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "leave-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "show-help",          G_CALLBACK(iupgtkShowHelp), ih);

  /* The iupgtkKeyPressEvent of the control with the focus will propagate the key up to the dialog. */
  /* Inside iupgtkKeyPressEvent we test this to avoid duplicate calls. */
  g_signal_connect(G_OBJECT(ih->handle), "key-press-event",    G_CALLBACK(iupgtkKeyPressEvent), ih);

  g_signal_connect(G_OBJECT(ih->handle), "configure-event",    G_CALLBACK(gtkDialogConfigureEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "window-state-event", G_CALLBACK(gtkDialogWindowStateEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "delete-event",       G_CALLBACK(iupgtkDialogDeleteEvent), ih);
                                    
  gtk_window_set_default_size((GtkWindow*)ih->handle, 100, 100); /* set this to avoid size calculation problems  */

  if (iupAttribGetBoolean(ih, "DIALOGHINT")) 
    gtk_window_set_type_hint(GTK_WINDOW(ih->handle), GDK_WINDOW_TYPE_HINT_DIALOG);

  /* the container that will receive the child element. */
  fixed = gtk_fixed_new();
  gtk_container_add((GtkContainer*)ih->handle, fixed);
  gtk_widget_show(fixed);

  /* initialize the widget */
  gtk_widget_realize(ih->handle);

  if (iupAttribGet(ih, "TITLE"))
    has_titlebar = 1;
  if (iupAttribGetBoolean(ih, "RESIZE")) 
  {
    functions   |= GDK_FUNC_RESIZE;
    decorations |= GDK_DECOR_RESIZEH;

    decorations |= GDK_DECOR_BORDER;  /* has_border */
  }
  else
    iupAttribSetStr(ih, "MAXBOX", "NO");
  if (iupAttribGetBoolean(ih, "MENUBOX")) 
  {
    functions   |= GDK_FUNC_CLOSE;
    decorations |= GDK_DECOR_MENU;
    has_titlebar = 1;
  }
  if (iupAttribGetBoolean(ih, "MAXBOX")) 
  {
    functions   |= GDK_FUNC_MAXIMIZE;
    decorations |= GDK_DECOR_MAXIMIZE;
    has_titlebar = 1;
  }
  if (iupAttribGetBoolean(ih, "MINBOX")) 
  {
    functions   |= GDK_FUNC_MINIMIZE;
    decorations |= GDK_DECOR_MINIMIZE;
    has_titlebar = 1;
  }
  if (has_titlebar)
  {
    functions   |= GDK_FUNC_MOVE;
    decorations |= GDK_DECOR_TITLE;
    gtk_window_set_title((GtkWindow*)ih->handle, "");
  }
  if (iupAttribGetBoolean(ih, "BORDER") || has_titlebar)
    decorations |= GDK_DECOR_BORDER;  /* has_border */

  if (decorations == 0)
    gtk_window_set_decorated((GtkWindow*)ih->handle, FALSE);
  else
  {
    GdkWindow* window = iupgtkGetWindow(ih->handle);
    if (window)
    {
      gdk_window_set_decorations(window, (GdkWMDecoration)decorations);
      gdk_window_set_functions(window, (GdkWMFunction)functions);
    }
  }

  /* configure for DRAG&DROP */
  if (IupGetCallback(ih, "DROPFILES_CB"))
    iupAttribSetStr(ih, "DROPFILESTARGET", "YES");

  {
    /* Reset the DLGBGCOLOR global attribute 
       if it is the first time a dialog is created. 
       The value returned by gtk_style_new is not accurate. */
    GtkStyle* style = gtk_widget_get_style(ih->handle);
    if (style && IupGetGlobal("_IUP_RESET_GLOBALCOLORS"))
    {
      iupgtkUpdateGlobalColors(style);
      IupSetGlobal("_IUP_RESET_GLOBALCOLORS", NULL);
    }
  }

  /* configure the size range */
  gtkDialogSetMinMax(ih, 1, 1, 65535, 65535);  /* MINSIZE and MAXSIZE default values */

  /* Ignore VISIBLE before mapping */
  iupAttribSetStr(ih, "VISIBLE", NULL);

  if (iupStrBoolean(IupGetGlobal("INPUTCALLBACKS")))
    gtk_widget_add_events(ih->handle, GDK_POINTER_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_MOTION_MASK);

  return IUP_NOERROR;
}
Beispiel #24
0
int main(int argc, char *argv[])
{
    if (argc < 3) {
        printf("Usage: %s <username> <password>\n", argv[0]);
        return 1;
    }

    GtkWidget *vbox;
    GtkWidget *swin;
    GtkTreeSelection *selection;


    /* Create needed variables - not anymore, use appdata instead
    HildonProgram *program;
    HildonWindow *window; */

    /* Create AppData */
    AppData *appdata=g_malloc( sizeof( *appdata ) );

    /* Initialize the GTK. */
    gtk_init(&argc, &argv);

    /* Create the Hildon program and setup the title */
    g_set_application_name("Maemify");
#ifdef MAEMO4
    appdata->program = HILDON_PROGRAM(hildon_program_get_instance());

    /* Create HildonWindow and set it to HildonProgram */
    appdata->window = HILDON_WINDOW(hildon_window_new());
    hildon_program_add_window(appdata->program, appdata->window);
#else
    appdata->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (appdata->window), "Maemify");
    gtk_widget_set_usize( GTK_WIDGET ( appdata->window ) , 600 , 300 );
    /* create our table */
    appdata->table = gtk_table_new(3, 3, FALSE); //three rows, three columns, not homogenous
    gtk_container_add(GTK_CONTAINER(appdata->window),appdata->table);
#endif


    /* Create find toolbar, but keep it hidden */
    create_find_toolbar(appdata);

#ifdef MAEMO4
    gtk_widget_show_all(GTK_WIDGET(appdata->find_toolbar));
    /* Create menu for the Window */
    create_menu(appdata->window);
#else
    gtk_table_attach_defaults(GTK_TABLE(appdata->table), GTK_WIDGET(appdata->entry), 1, 2, 2, 3);
    gtk_widget_show_all(GTK_WIDGET(appdata->table));
#endif

    /* Begin the main application */
    gtk_widget_show_all(GTK_WIDGET(appdata->window));

    /* Connect signal to X in the upper corner */
    g_signal_connect(G_OBJECT(appdata->window), "delete_event",
    G_CALLBACK(gtk_main_quit), NULL);
    if (!despotify_init())
    {
        printf("despotify_init() failed\n");
        return 1;
    }

    appdata->ds = despotify_init_client(callback, NULL, false);
    if (!appdata->ds) {
        printf("despotify_init_client() failed\n");
        return 1;
    }
    if (!despotify_authenticate(appdata->ds, argv[1], argv[2])) {
        printf( "Authentication failed: %s\n", despotify_get_error(appdata->ds));
        despotify_exit(appdata->ds);
        return 1;
    }

  /* Create a tree view and place it in a scrolled window */
  appdata->list = gtk_tree_view_new();
  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(appdata->list), TRUE);
  swin = gtk_scrolled_window_new(NULL, NULL);
  
  vbox = gtk_vbox_new(FALSE, 0);

  /* add labels to the fields */
  appdata->label = gtk_label_new("Search hits");
  gtk_label_set_justify(GTK_LABEL(appdata->label), GTK_JUSTIFY_CENTER);
  gtk_box_pack_start(GTK_BOX(vbox), appdata->label, FALSE, FALSE, 5);

  gtk_container_add(GTK_CONTAINER(swin), appdata->list);
#ifdef MAEMO4
  gtk_container_add(GTK_CONTAINER(appdata->window), swin);
#else
  gtk_table_attach_defaults(GTK_TABLE(appdata->table), swin, 1, 2, 1, 2);
#endif

  /* initialize a list to hold search hits */
  init_list(appdata->list);

  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->list));

  g_signal_connect(selection, "changed", 
      G_CALLBACK(on_changed), appdata);

    gtk_widget_show_all(GTK_WIDGET(appdata->window));

    gtk_main();

    despotify_deinit(appdata);

    /* Exit */
    return 0;
}
MedSLTDocWindow::MedSLTDocWindow(MedSLTDocWindowObserver& observer)
	: 	m_observer(observer),
		m_list_index(0),
		m_list_items(0),
		m_is_fullscreen(FALSE),
		m_back_translation(""),
		m_ui_state(UI_STATE_DISCONNECTED),
		m_wrap_position(5)
{
	ACE_TRACE("[MedSLTDocWindow::MedSLTDocWindow()]");

	GtkBox*					hbox;
	GtkBox* 				coverbox;
	GtkBox* 				textbox;
	GtkBox* 				buthbox;
	GtkWidget* 				menu;
	GtkWidget* 				appimage;	
	GtkWidget*				scroll1;
	GtkWidget* 				scroll2;
	GtkWidget*				scroll3;
	PangoFontDescription*	font1;
	PangoFontDescription*	font2;
	//GtkStyle*				style;
	GtkAccelGroup*			accel = gtk_accel_group_new();

	// Window
#ifdef _MAEMO
	m_window = GTK_WINDOW(hildon_window_new());	
#else
	m_window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
	gtk_window_set_default_size(m_window, 450, -1);
#endif
	
	gtk_window_add_accel_group(m_window, accel);	
	gtk_window_set_icon_from_file(m_window, app_icon, NULL);	
	gtk_container_set_border_width(GTK_CONTAINER(m_window), 5);
	
	// Boxes
	coverbox = GTK_BOX(gtk_vbox_new(False, 5));	
	hbox = GTK_BOX(gtk_hbox_new(False, 5));	
	textbox = GTK_BOX(gtk_vbox_new(False, 5));
	buthbox = GTK_BOX(gtk_vbox_new(False, 5));
			
	// Image
	appimage = gtk_image_new_from_file(app_icon_big);
	
	// Fonts	
	font1 = pango_font_description_from_string("Monospace Bold 21");
	font2 = pango_font_description_from_string("Monospace Bold 16");
	
	// Lists
	m_list = gtk_clist_new(1);
		 
	gtk_widget_set_size_request(GTK_WIDGET(m_list), 550, 180);
	
	gtk_clist_set_row_height((GtkCList*)m_list, 65);

	gtk_widget_modify_font(m_list, font1);
	
	gchar* text[3][1] = {	{"where is the pain?"},
								{"do you have fever?"},
								{"do you have headaches in\nthe morning?"}};
	
	gtk_clist_append((GtkCList*)m_list, text[0]);
	gtk_clist_append((GtkCList*)m_list, text[1]);
	gtk_clist_append((GtkCList*)m_list, text[2]);
	
	m_list_items = 3;
	
	GdkColormap *colormap;
	GdkColor color;
		
	colormap = gtk_widget_get_colormap(m_list);
	color.red = color_map[0][0];
	color.green = color_map[0][1];
	color.blue = color_map[0][2];
	gdk_color_alloc(colormap, &color);
	gtk_clist_set_background(GTK_CLIST(m_list), 0, &color);

	color.red = color_map[1][0];
	color.green = color_map[1][1];
	color.blue = color_map[1][2];
	gdk_color_alloc(colormap, &color);
	gtk_clist_set_background(GTK_CLIST(m_list), 1, &color);
	
	color.red = color_map[2][0];
	color.green = color_map[2][1];
	color.blue = color_map[2][2];
	gdk_color_alloc(colormap, &color);
	gtk_clist_set_background(GTK_CLIST(m_list), 2, &color);
		
	gtk_clist_select_row((GtkCList*)m_list, 0, 0);
	
	// Styles
	//style = gtk_style_new();
	//style->font_desc = font2;
	//gdk_color_parse("red", &(style->bg[GTK_STATE_NORMAL]));
	//gdk_color_parse ("green", &(style->bg[GTK_STATE_PRELIGHT]));
	//gdk_color_parse ("green", &(style->bg[GTK_STATE_ACTIVE]));
		
	// Text Boxes
	m_txtbox1 = gtk_text_view_new();
			
	gtk_widget_modify_font(m_txtbox1, font1);
		
	gtk_widget_set_size_request(GTK_WIDGET(m_txtbox1), 550, 20);
		
	gtk_text_view_set_editable(GTK_TEXT_VIEW(m_txtbox1), false);
		
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(m_txtbox1), GTK_WRAP_WORD_CHAR);
	
	color.red = color_map[3][0];
	color.green = color_map[3][1];
	color.blue = color_map[3][2];
	
	gtk_widget_modify_base(GTK_WIDGET(m_txtbox1), GTK_STATE_NORMAL, &color);
	//gtk_widget_modify_fg(GTK_WIDGET(m_txtbox1), GTK_STATE_NORMAL, &color);
	
 	//gtk_widget_set_style(GTK_WIDGET(m_txtbox1), style);
	
	m_txtbox2 = gtk_text_view_new();
				
	gtk_widget_modify_font(m_txtbox2, font1);
			
	gtk_widget_set_size_request(GTK_WIDGET(m_txtbox2), 550, 20);
			
	gtk_text_view_set_editable(GTK_TEXT_VIEW(m_txtbox2), false);
			
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(m_txtbox2), GTK_WRAP_WORD_CHAR);
		
	// Scroll bars
	scroll1 = gtk_scrolled_window_new(NULL, NULL);
	scroll2 = gtk_scrolled_window_new(NULL, NULL);
	scroll3 = gtk_scrolled_window_new(NULL, NULL);
	
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll1), GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll2), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll3), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
	
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll1), GTK_SHADOW_IN);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll2), GTK_SHADOW_IN);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll3), GTK_SHADOW_IN);
	
	gtk_container_add(GTK_CONTAINER(scroll1), GTK_WIDGET(m_list));
	gtk_container_add(GTK_CONTAINER(scroll2), GTK_WIDGET(m_txtbox1));
	gtk_container_add(GTK_CONTAINER(scroll3), GTK_WIDGET(m_txtbox2));
			
	// Text labels
	m_understood = gtk_label_new("Understood");
	m_response = gtk_label_new("Response");
	m_translation = gtk_label_new("Translation");

	gtk_widget_modify_font(m_understood, font2);
	gtk_widget_modify_font(m_response, font2);
	gtk_widget_modify_font(m_translation, font2);
	
	gtk_label_set_justify(GTK_LABEL(m_understood), GTK_JUSTIFY_LEFT);
	gtk_label_set_justify(GTK_LABEL(m_response), GTK_JUSTIFY_LEFT);
	gtk_label_set_justify(GTK_LABEL(m_translation), GTK_JUSTIFY_LEFT);
		
	gtk_label_set_ellipsize(GTK_LABEL(m_understood), PANGO_ELLIPSIZE_END);	
	gtk_label_set_ellipsize(GTK_LABEL(m_response), PANGO_ELLIPSIZE_END);
	gtk_label_set_ellipsize(GTK_LABEL(m_translation), PANGO_ELLIPSIZE_END);
		
	// Buttons
	m_rec = gtk_button_new();
	m_speech = gtk_button_new();
	m_abort = gtk_button_new();
	m_up = gtk_button_new();
	m_select = gtk_button_new();
	m_down = gtk_button_new();
	
	gtk_button_set_image(GTK_BUTTON(m_rec),
							gtk_image_new_from_file(record_icon));
	gtk_button_set_image(GTK_BUTTON(m_speech),
									gtk_image_new_from_file(speech_icon));
	gtk_button_set_image(GTK_BUTTON(m_abort),
							gtk_image_new_from_file(stop_icon));
	gtk_button_set_image(GTK_BUTTON(m_up),
							gtk_image_new_from_file(up_icon));
	gtk_button_set_image(GTK_BUTTON(m_select),
							gtk_image_new_from_file(select_icon));
	gtk_button_set_image(GTK_BUTTON(m_down),
							gtk_image_new_from_file(down_icon));

	// Menu
	// Recheck: Is it destroyed somewhere
	menu = CreateMenu(accel);
	
	// Progress bar
	m_progressbar = gtk_progress_bar_new();
	gtk_progress_set_text_alignment(GTK_PROGRESS(m_progressbar),
									0.5, 0.5);
	gtk_widget_set_size_request(GTK_WIDGET(m_progressbar), 150, 50);	
	//gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(vbox));	
		
	gtk_box_pack_start(textbox, m_understood, TRUE, TRUE, 0);
	gtk_box_pack_start(textbox, scroll1, TRUE, TRUE, 0);
	gtk_box_pack_start(textbox, m_response, TRUE, TRUE, 0);
	gtk_box_pack_start(textbox, scroll2, TRUE, TRUE, 0);
	gtk_box_pack_start(textbox, m_translation, TRUE, TRUE, 0);
	gtk_box_pack_start(textbox, scroll3, TRUE, TRUE, 0);
	
	gtk_box_pack_start(buthbox, m_rec, TRUE, TRUE, 0);
	gtk_box_pack_start(buthbox, m_speech, TRUE, TRUE, 0);
	gtk_box_pack_start(buthbox, m_abort, TRUE, TRUE, 0);
	gtk_box_pack_start(buthbox, m_up, TRUE, TRUE, 0);
	gtk_box_pack_start(buthbox, m_select, TRUE, TRUE, 0);
	gtk_box_pack_start(buthbox, m_down, TRUE, TRUE, 0);
	
	gtk_box_pack_start(hbox, GTK_WIDGET(textbox), TRUE, TRUE, 0);
	gtk_box_pack_start(hbox, GTK_WIDGET(buthbox), TRUE, TRUE, 0);
	
	gtk_box_pack_start(coverbox, GTK_WIDGET(hbox), TRUE, TRUE, 0);
	//gtk_box_pack_start(coverbox, m_progressbar, TRUE, TRUE, 0);
		
	gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(coverbox));
	
#ifdef _MAEMO
	hildon_window_set_menu(HILDON_WINDOW(m_window), GTK_MENU(menu));	
#else
	gtk_box_pack_start(vbox, menu, FALSE, FALSE, 0);
#endif

	// Signals
	g_signal_connect(G_OBJECT(m_rec), "clicked", 
						G_CALLBACK(RecognizeClicked), this);
	g_signal_connect(G_OBJECT(m_speech), "clicked",
							G_CALLBACK(AbortClicked), this);
	g_signal_connect(G_OBJECT(m_abort), "clicked",
						G_CALLBACK(AbortClicked), this);
	g_signal_connect(G_OBJECT(m_up), "clicked",
						G_CALLBACK(UpClicked), this);
	g_signal_connect(G_OBJECT(m_select), "clicked",
						G_CALLBACK(SelectClicked), this);
	g_signal_connect(G_OBJECT(m_down), "clicked",
						G_CALLBACK(DownClicked), this);
	g_signal_connect(G_OBJECT(m_list), "select_row",
						G_CALLBACK(ListRowSelected), this);
	g_signal_connect(G_OBJECT(m_window), "destroy",
						G_CALLBACK(CloseApp), this);
	g_signal_connect(G_OBJECT(m_window), "delete_event",
						G_CALLBACK(CloseApp), this);

	// Shortcuts
#ifndef _MAEMO
	gtk_widget_add_accelerator(m_rec, "clicked", accel, GDK_space,
								0, 0);
	gtk_widget_add_accelerator(m_speech, "clicked", accel, GDK_space,
									0, 0);
	gtk_widget_add_accelerator(m_abort, "clicked", accel, GDK_space,
								0, 0);
	gtk_widget_add_accelerator(m_next, "clicked", accel, GDK_Right,
								GDK_CONTROL_MASK, 0);
#endif

	// Initial state
	SetUiState(UI_STATE_DISCONNECTED);
	
	return;
}