Beispiel #1
0
static void create_menu()
{
    /* Create needed variables */
    GtkWidget *main_menu;
    GtkWidget *item_settings;
    GtkWidget *item_about;
    GtkWidget *item_separator;
    GtkWidget *item_close;

    /* Create new main menu */
    main_menu = gtk_menu_new();

    /* Create menu items */
    item_settings = gtk_menu_item_new_with_label("Settings");
    item_about = gtk_menu_item_new_with_label("About");
    item_separator = gtk_separator_menu_item_new();
    item_close = gtk_menu_item_new_with_label("Close");

    /* Add menu items to right menus*/
    gtk_menu_append(main_menu, item_settings);
    gtk_menu_append(main_menu, item_about);
    gtk_menu_append(main_menu, item_separator);
    gtk_menu_append(main_menu, item_close);

    hildon_window_set_menu(appdata->window, GTK_MENU(main_menu));

    /* Attach the callback functions to the activate signal */
    g_signal_connect(G_OBJECT(item_settings), "activate", GTK_SIGNAL_FUNC(menu_settings_clicked), NULL);
    g_signal_connect(G_OBJECT(item_about), "activate", GTK_SIGNAL_FUNC(menu_about_clicked), NULL);
    g_signal_connect(G_OBJECT(item_close), "activate", GTK_SIGNAL_FUNC(menu_exit_clicked), NULL);

    /* Make all menu widgets visible*/
    gtk_widget_show_all(GTK_WIDGET(main_menu));

}
Beispiel #2
0
void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
{
    wxFrameBase::AttachMenuBar(menuBar);

    if (m_frameMenuBar)
    {
#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
        hildon_window_set_menu(HILDON_WINDOW(m_widget),
                               GTK_MENU(m_frameMenuBar->m_widget));
#else // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
        m_frameMenuBar->SetParent(this);

        // menubar goes into top of vbox (m_mainWidget)
        gtk_box_pack_start(
            GTK_BOX(m_mainWidget), menuBar->m_widget, false, false, 0);
        gtk_box_reorder_child(GTK_BOX(m_mainWidget), menuBar->m_widget, 0);

        // reset size request to allow native sizing to work
        gtk_widget_set_size_request(menuBar->m_widget, -1, -1);

        gtk_widget_show( m_frameMenuBar->m_widget );
#endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2/!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
    }
    // make sure next size_allocate causes a wxSizeEvent
    m_useCachedClientSize = false;
    m_clientWidth = 0;
}
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 #4
0
static int gtkMenuMapMethod(Ihandle* ih)
{
  if (iupMenuIsMenuBar(ih))
  {
    /* top level menu used for MENU attribute in IupDialog (a menu bar) */
#ifdef HILDON
    Ihandle *pih;
    ih->handle = gtk_menu_new();
    if (!ih->handle)
      return IUP_ERROR;

    pih = iupChildTreeGetNativeParent(ih);
    hildon_window_set_menu(HILDON_WINDOW(pih->handle), GTK_MENU(ih->handle));
#else
    ih->handle = gtk_menu_bar_new();
    if (!ih->handle)
      return IUP_ERROR;

    iupgtkBaseAddToParent(ih);
#endif
  }
  else
  {
    ih->handle = gtk_menu_new();
    if (!ih->handle)
      return IUP_ERROR;

    if (ih->parent)
    {
      /* parent is a submenu */
      gtk_menu_item_set_submenu((GtkMenuItem*)ih->parent->handle, ih->handle);

      g_signal_connect(G_OBJECT(ih->handle), "map", G_CALLBACK(gtkMenuMap), ih);
      g_signal_connect(G_OBJECT(ih->handle), "unmap", G_CALLBACK(gtkMenuUnMap), ih);
    }
    else
    {
      /* top level menu used for IupPopup */
      iupAttribSetStr(ih, "_IUPGTK_POPUP_MENU", "1");

      g_signal_connect(G_OBJECT(ih->handle), "map", G_CALLBACK(gtkMenuMap), ih);
      g_signal_connect(G_OBJECT(ih->handle), "unmap", G_CALLBACK(gtkPopupMenuUnMap), ih);
    }
  }

  gtk_widget_add_events(ih->handle, GDK_KEY_PRESS_MASK);
  g_signal_connect(G_OBJECT(ih->handle), "key-press-event", G_CALLBACK(gtkMenuKeyPressEvent), ih);

  ih->serial = iupMenuGetChildId(ih); 
  gtk_widget_show(ih->handle);

  return IUP_NOERROR;
}
Beispiel #5
0
/* 
 * Create the menu items needed for the main view.
 * This needs to be implemented properly.
*/
static void create_menu(HildonWindow * main_window) 
{
    /* Create needed variables */
    GtkWidget *main_menu;
    GtkWidget *menu_others;
    GtkWidget *item_others;
    GtkWidget *item_radio1;
    GtkWidget *item_radio2;
    GtkWidget *item_check;
    GtkWidget *item_close;
    GtkWidget *item_separator;

    /* Create new main menu */
    main_menu = gtk_menu_new();

    /* Create new submenu for "Others" */
    menu_others = gtk_menu_new();

    /* Create menu items */
    item_others = gtk_menu_item_new_with_label("Others");
    item_radio1 = gtk_radio_menu_item_new_with_label(NULL, "Radio1");
    item_radio2 =
        gtk_radio_menu_item_new_with_label_from_widget(GTK_RADIO_MENU_ITEM
                                                       (item_radio1),
                                                       "Radio2");
    item_check = gtk_check_menu_item_new_with_label("Check");
    item_close = gtk_menu_item_new_with_label("Close");
    item_separator = gtk_separator_menu_item_new();

    /* Add menu items to right menus */
    gtk_menu_append(main_menu, item_others);
    gtk_menu_append(menu_others, item_radio1);
    gtk_menu_append(menu_others, item_radio2);
    gtk_menu_append(menu_others, item_separator);
    gtk_menu_append(menu_others, item_check);
    gtk_menu_append(main_menu, item_close);

    /* Add others submenu to the "Others" item */
    hildon_window_set_menu(HILDON_WINDOW(main_window), GTK_MENU(main_menu));
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item_others), menu_others);

    /* Attach the callback functions to the activate signal */
    g_signal_connect(G_OBJECT(item_close), "activate",
                     GTK_SIGNAL_FUNC(item_close_cb), NULL);

    /* Make all menu widgets visible */
    gtk_widget_show_all(GTK_WIDGET(main_menu));
}
Beispiel #6
0
void wxFrame::DetachMenuBar()
{
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
    wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );

    if ( m_frameMenuBar )
    {
#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
        hildon_window_set_menu(HILDON_WINDOW(m_widget), NULL);
#else // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
        g_object_ref( m_frameMenuBar->m_widget );

        gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget );
#endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
    }

    wxFrameBase::DetachMenuBar();

    // make sure next size_allocate causes a wxSizeEvent
    m_oldClientWidth = 0;
}
Beispiel #7
0
void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
{
    wxFrameBase::AttachMenuBar(menuBar);

    if (m_frameMenuBar)
    {
#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
        hildon_window_set_menu(HILDON_WINDOW(m_widget),
                               GTK_MENU(m_frameMenuBar->m_menubar));
#else // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
        m_frameMenuBar->SetParent(this);

        // menubar goes into top of vbox (m_mainWidget)
        gtk_box_pack_start(
            GTK_BOX(m_mainWidget), menuBar->m_widget, false, false, 0);
        gtk_box_reorder_child(GTK_BOX(m_mainWidget), menuBar->m_widget, 0);

        // disconnect wxWindowGTK "size_request" handler,
        // it interferes with sizing of detached GtkHandleBox
        gulong handler_id = g_signal_handler_find(
            menuBar->m_widget,
            GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
            g_signal_lookup("size_request", GTK_TYPE_WIDGET),
            0, NULL, NULL, menuBar);
        if (handler_id != 0)
            g_signal_handler_disconnect(menuBar->m_widget, handler_id);

        // reset size request to allow native sizing to work
        gtk_widget_set_size_request(menuBar->m_widget, -1, -1);

        gtk_widget_show( m_frameMenuBar->m_widget );
#endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2/!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
    }
    // make sure next size_allocate causes a wxSizeEvent
    m_oldClientWidth = 0;
}
Beispiel #8
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;
}
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;
}
Beispiel #10
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;
}