/*
  Process events in Emacsy then update the echo area at the bottom of the
  screen.
 */
static gboolean process_and_update_emacsy(void *user_data)
{
  // Process events and any background coroutines.
  int flags = emacsy_tick();

  // If there's been a request to quit, quit.
  if (flags & EY_QUIT_APPLICATION)
    gtk_main_quit();

  // Update the status line. 
  const char *modeline_string = emacsy_mode_line();
  const char *status = emacsy_message_or_echo_area();
  // Use markup to style the status line.
  char *markup = g_markup_printf_escaped ("<span foreground=\"white\" background=\"black\" underline=\"single\"><tt>%s </tt></span>", status);
  gtk_label_set_markup(GTK_LABEL(label), markup);
  g_free(markup);

  markup = g_markup_printf_escaped ("<span foreground=\"white\" background=\"black\" underline=\"none\"><tt>%s </tt></span>", modeline_string);
  gtk_label_set_markup(GTK_LABEL(modeline), markup);
  g_free(markup);

  // Show the cursor.  Exercise for the reader: Make it blink.
  char message[255];
  memset(message, ' ', 254);
  message[255] = NULL;
  message[emacsy_minibuffer_point() - 1] = '_';
  gtk_label_set_pattern(GTK_LABEL(label), message);

  return TRUE;                  
}
예제 #2
0
void GtkLabel_::set_pattern(Php::Parameters &parameters)
{
	std::string s_str = parameters[0];
	gchar *str = (gchar *)s_str.c_str();

	gtk_label_set_pattern (GTK_LABEL(instance), str);

}
예제 #3
0
파일: label.c 프로젝트: amery/clip-itk
/* The pattern of underlines you want under the existing text within the GtkLabel
 * widget. For example if the current text of the label says "FooBarBaz" passing
 * a pattern of "___ ___" will underline "Foo" and "Baz" but not "Bar".  */
int
clip_GTK_LABELSETPATTERN(ClipMachine * cm)
{
	C_widget *clbl = _fetch_cw_arg(cm);
	char  *pattern = _clip_parc(cm, 2);
	CHECKCWID(clbl,GTK_IS_LABEL);
	CHECKOPT(2,CHARACTER_t);
	gtk_label_set_pattern(GTK_LABEL(clbl->widget), pattern);
	return 0;
err:
	return 1;
}
예제 #4
0
파일: label.c 프로젝트: amery/clip-angelo
/* The pattern of underlines you want under the existing text within the GtkLabel
 * widget. For example if the current text of the label says "FooBarBaz" passing
 * a pattern of "___ ___" will underline "Foo" and "Baz" but not "Bar".  */
int
clip_GTK_LABELSETPATTERN(ClipMachine * ClipMachineMemory)
{
   C_widget *clbl = _fetch_cw_arg(ClipMachineMemory);

   char     *pattern = _clip_parc(ClipMachineMemory, 2);

   CHECKCWID(clbl, GTK_IS_LABEL);
   CHECKOPT(2, CHARACTER_type_of_ClipVarType);
   gtk_label_set_pattern(GTK_LABEL(clbl->widget), pattern);
   return 0;
 err:
   return 1;
}
예제 #5
0
파일: menu.c 프로젝트: MotoHoss/mate-panel
void
setup_menuitem (GtkWidget   *menuitem,
		GtkIconSize  icon_size,
		GtkWidget   *image,
		const char  *title)

{
	GtkWidget *label;
	char      *_title;

	/* this creates a label with an invisible mnemonic */
	label = g_object_new (GTK_TYPE_ACCEL_LABEL, NULL);
	_title = menu_escape_underscores_and_prepend (title);
	gtk_label_set_text_with_mnemonic (GTK_LABEL (label), _title);
	g_free (_title);

	gtk_label_set_pattern (GTK_LABEL (label), "");

	gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuitem);

	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_widget_show (label);

	gtk_container_add (GTK_CONTAINER (menuitem), label);

	if (image) {
		g_object_set_data_full (G_OBJECT (menuitem),
					"Panel:Image",
					g_object_ref (image),
					(GDestroyNotify) g_object_unref);
		gtk_widget_show (image);
		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
					       image);
	} else if (icon_size != GTK_ICON_SIZE_INVALID)
#if GTK_CHECK_VERSION (3, 0, 0)
		image_menuitem_set_size_request (menuitem, icon_size);
#else
		g_signal_connect (menuitem, "size_request",
				  G_CALLBACK (image_menuitem_size_request),
				  GINT_TO_POINTER (icon_size));
#endif

	gtk_widget_show (menuitem);
}
예제 #6
0
void
setup_menuitem (GtkWidget   *menuitem,
		GtkIconSize  icon_size,
		GtkWidget   *image,
		const char  *title)

{
	GtkWidget *label;
	char      *_title;

	/* this creates a label with an invisible mnemonic */
	label = g_object_new (GTK_TYPE_ACCEL_LABEL, NULL);
	_title = menu_escape_underscores_and_prepend (title);
	gtk_label_set_text_with_mnemonic (GTK_LABEL (label), _title);
	g_free (_title);

	gtk_label_set_pattern (GTK_LABEL (label), "");

	gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuitem);

#if GTK_CHECK_VERSION (3, 16, 0)
	gtk_label_set_xalign (GTK_LABEL (label), 0.0);
	gtk_label_set_yalign (GTK_LABEL (label), 0.5);
#else
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
#endif
	gtk_widget_show (label);

	gtk_container_add (GTK_CONTAINER (menuitem), label);

	if (image) {
		gint icon_height = PANEL_DEFAULT_MENU_ICON_SIZE;

		gtk_icon_size_lookup (icon_size, NULL, &icon_height);
		gtk_widget_show (image);
		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
					       image);
		gtk_image_set_pixel_size (GTK_IMAGE(image), icon_height);
	}

	gtk_widget_show (menuitem);
}
예제 #7
0
wxSize wxStaticText::DoGetBestSize() const
{
    // Do not return any arbitrary default value...
    wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") );

    // This resets the internal GTK1 size calculation, which
    // otherwise would be cashed (incorrectly)
    gtk_label_set_pattern( GTK_LABEL(m_widget), NULL );

    // GetBestSize is supposed to return unwrapped size
    gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );

    GtkRequisition req;
    req.width = -1;
    req.height = -1;
    (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
        (m_widget, &req );

    gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );

    return wxSize (req.width, req.height);
}
예제 #8
0
void
setup_menuitem (GtkWidget   *menuitem,
		GtkIconSize  icon_size,
		GtkWidget   *image,
		const char  *title)
			       
{
	GtkWidget *label;
	char      *_title;

	/* this creates a label with an invisible mnemonic */
	label = g_object_new (GTK_TYPE_ACCEL_LABEL, NULL);
	_title = menu_escape_underscores_and_prepend (title);
	gtk_label_set_text_with_mnemonic (GTK_LABEL (label), _title);
	g_free (_title);

	gtk_label_set_pattern (GTK_LABEL (label), "");

	gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuitem);

	gtk_label_set_xalign (GTK_LABEL (label), 0);
	gtk_widget_show (label);
       
	gtk_container_add (GTK_CONTAINER (menuitem), label);

	if (image) {
		g_object_set_data_full (G_OBJECT (menuitem),
					"Panel:Image",
					g_object_ref (image),
					(GDestroyNotify) g_object_unref);
		gtk_widget_show (image);
		panel_image_menu_item_set_image (PANEL_IMAGE_MENU_ITEM (menuitem), image);
	} else if (icon_size != GTK_ICON_SIZE_INVALID)
                image_menuitem_set_size_request (menuitem, icon_size);

	gtk_widget_show (menuitem);
}
예제 #9
0
int main( int   argc,
          char *argv[] )
{
  static GtkWidget *window = NULL;
  GtkWidget *hbox;
  GtkWidget *vbox;
  GtkWidget *frame;
  GtkWidget *label;

  /* Initialise GTK */
  gtk_init (&argc,&argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit),
                    NULL);

  gtk_window_set_title (GTK_WINDOW (window), "Label");
  vbox = gtk_vbox_new (FALSE, 5);
  hbox = gtk_hbox_new (FALSE, 5);
  gtk_container_add (GTK_CONTAINER (window), hbox);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (window), 5);
  
  frame = gtk_frame_new ("Normal Label");
  label = gtk_label_new ("This is a Normal label");
  gtk_container_add (GTK_CONTAINER (frame), label);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  
  frame = gtk_frame_new ("Multi-line Label");
  label = gtk_label_new ("This is a Multi-line label.\nSecond line\n" \
                         "Third line");
  gtk_container_add (GTK_CONTAINER (frame), label);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  
  frame = gtk_frame_new ("Left Justified Label");
  label = gtk_label_new ("This is a Left-Justified\n" \
                         "Multi-line label.\nThird      line");
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
  gtk_container_add (GTK_CONTAINER (frame), label);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  
  frame = gtk_frame_new ("Right Justified Label");
  label = gtk_label_new ("This is a Right-Justified\nMulti-line label.\n" \
                         "Fourth line, (j/k)");
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
  gtk_container_add (GTK_CONTAINER (frame), label);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

  vbox = gtk_vbox_new (FALSE, 5);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
  frame = gtk_frame_new ("Line wrapped label");
  label = gtk_label_new ("This is an example of a line-wrapped label.  It " \
                         "should not be taking up the entire             " /* big space to test spacing */\
                         "width allocated to it, but automatically " \
                         "wraps the words to fit.  " \
                         "The time has come, for all good men, to come to " \
                         "the aid of their party.  " \
                         "The sixth sheik's six sheep's sick.\n" \
                         "     It supports multiple paragraphs correctly, " \
                         "and  correctly   adds "\
                         "many          extra  spaces. ");
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_container_add (GTK_CONTAINER (frame), label);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  
  frame = gtk_frame_new ("Filled, wrapped label");
  label = gtk_label_new ("This is an example of a line-wrapped, filled label.  " \
                         "It should be taking "\
                         "up the entire              width allocated to it.  " \
                         "Here is a sentence to prove "\
                         "my point.  Here is another sentence. "\
                         "Here comes the sun, do de do de do.\n"\
                         "    This is a new paragraph.\n"\
                         "    This is another newer, longer, better " \
                         "paragraph.  It is coming to an end, "\
                         "unfortunately.");
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_FILL);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_container_add (GTK_CONTAINER (frame), label);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  
  frame = gtk_frame_new ("Underlined label");
  label = gtk_label_new ("This label is underlined!\n"
                         "This one is underlined in quite a funky fashion");
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
  gtk_label_set_pattern (GTK_LABEL (label),
                         "_________________________ _ _________ _ ______     __ _______ ___");
  gtk_container_add (GTK_CONTAINER (frame), label);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  
  gtk_widget_show_all (window);

  gtk_main ();
  
  return 0;
}
예제 #10
0
int music_build_element_widgets () {
	int i = 0;
	for (i = 0; i < 9; i++) {
		label_music_info[i] = gtk_label_new(NULL);
		gtk_label_set_width_chars(GTK_LABEL(label_music_info[i]), 15);
		gtk_label_set_max_width_chars(GTK_LABEL(label_music_info[i]), 150);
		gtk_label_set_line_wrap(GTK_LABEL(label_music_info[i]), TRUE);
	}
	separator_music_info = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
	
	for (i = 0; i < 9; i++) {
		label_music_lyric[i] = gtk_label_new(NULL);
		gtk_label_set_max_width_chars(GTK_LABEL(label_music_lyric[i]), 305);
// 		gtk_label_set_line_wrap(GTK_LABEL(label_music_lyric[i]), TRUE);
	}
	gtk_label_set_selectable(GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_use_underline (GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_use_markup (GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_pattern (GTK_LABEL(label_music_lyric[4]), "________");
	separator_music_lyric1 =  gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	separator_music_lyric2 =  gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);

	button_music_start_server = gtk_button_new_with_label("启动服务器");
// 	set_button_music_start_server(button_music_start_server);
	
	button_music_exit_server = gtk_button_new_with_label("关闭服务器");
// 	set_button_music_exit_server(button_music_exit_server);
	
	
	button_music_play = gtk_button_new();
// 	box_music_play = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png");
// 	box_music_pause = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png");
	image_music_play = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png");
	image_music_play_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play_light.png");
	image_music_pause = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png");
	image_music_pause_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause_light.png");
	gtk_button_set_relief(GTK_BUTTON(button_music_play), GTK_RELIEF_NONE);
	set_button_music_play(button_music_play);
	
	button_music_pause = gtk_button_new_with_label("暂停");
// 	set_button_music_pause(button_music_pause);
	
	button_music_unpause = gtk_button_new_with_label("取消暂停");
// 	set_button_music_unpause(button_music_unpause);
	
// 	button_music_stop = gtk_button_new_with_label("停止");
	button_music_stop = gtk_button_new();
	image_music_stop = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop.png");
	image_music_stop_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop_light.png");
	gtk_button_set_image(GTK_BUTTON(button_music_stop), image_music_stop);
	gtk_button_set_relief(GTK_BUTTON(button_music_stop), GTK_RELIEF_NONE);
	set_button_music_stop(button_music_stop);
	
// 	button_music_next = gtk_button_new_with_label("下一首");
	button_music_next = gtk_button_new();
	image_music_next = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next.png");
	image_music_next_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next_light.png");
	gtk_button_set_image(GTK_BUTTON(button_music_next), image_music_next);
	gtk_button_set_relief(GTK_BUTTON(button_music_next), GTK_RELIEF_NONE);
	set_button_music_next(button_music_next);
	
// 	button_music_pre = gtk_button_new_with_label("上一首");
	button_music_pre = gtk_button_new();
	image_music_pre = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre.png");
	image_music_pre_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre_light.png");
	gtk_button_set_image (GTK_BUTTON(button_music_pre), image_music_pre);
	gtk_button_set_relief(GTK_BUTTON(button_music_pre), GTK_RELIEF_NONE);
	set_button_music_pre(button_music_pre);
	

	
	
// 	button_music_volume_up = gtk_button_new_with_label("音量+");
// 	set_button_music_volume_up(button_music_volume_up);
	
// 	button_music_volume_silence = gtk_button_new_with_label("静音");
	button_music_silence = gtk_button_new();
	image_music_silence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence.png");
	image_music_silence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence_light.png");
	image_music_unsilence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence.png");
	image_music_unsilence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence_light.png");
	gtk_button_set_image (GTK_BUTTON(button_music_silence), image_music_silence);
	gtk_button_set_relief(GTK_BUTTON(button_music_silence), GTK_RELIEF_NONE);
	set_button_music_silence(button_music_silence);
	
	button_music_volume = gtk_volume_button_new();
	set_button_music_volume( button_music_volume);
	
	button_music_reset_list = gtk_button_new_with_label("重设列表");
	set_button_music_reset_list(button_music_reset_list);
	
// 	button_music_choose_path = gtk_button_new_with_label("添加路径");
// 	set_button_music_choose_path(button_music_choose_path);
// 	music_path_dialog = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
	music_path_dialog = gtk_file_chooser_dialog_new ("test_title", NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "test_button_text", NULL);
	button_music_choose_path = gtk_file_chooser_button_new_with_dialog (music_path_dialog);
	gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON(button_music_choose_path), "添加路径");
// 	gtk_file_chooser_set_select_multiple (music_path_dialog, TRUE);
	
	
	button_music_delete_path = gtk_button_new_with_label("删除当前路径");
	set_button_music_delete_path(button_music_delete_path);
	
	scale_music_process = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
	set_scale_music_process(scale_music_process);
	
	label_music_cur_time = gtk_label_new ("--:--:--");
	label_music_total_time = gtk_label_new ("--:--:--");
	
	switch_music_autonext = gtk_switch_new ();
	set_switch_music_autonext ();
	label_music_autonext = gtk_label_new ("AutoNext: ");
	
	switch_music_repeat = gtk_switch_new ();
	set_switch_music_repeat ();
	label_music_repeat = gtk_label_new ("Repeat: ");
	
	switch_music_shuffle = gtk_switch_new ();
	set_switch_music_shuffle ();
	label_music_shuffle = gtk_label_new ("Shuffle: ");
	
	radio_button_music_mode_shuffle = gtk_radio_button_new (NULL);
	label_music_mode_shuffle = gtk_label_new ("随机:");
	radio_button_music_mode_loop_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_loop_list = gtk_label_new ("列表循环:");
	radio_button_music_mode_play_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_play_list = gtk_label_new ("播放列表:");
	radio_button_music_mode_loop_one = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_loop_one = gtk_label_new ("单曲:");
	spinner_music_mode_changing = gtk_spinner_new ();
	
	set_radio_button_music_mode ();
	
	
	store_music_dir_list = gtk_tree_store_new(dir_n_columns, G_TYPE_STRING);
	tree_view_music_dir_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_dir_list));
	text_renderer_music_dir_list = gtk_cell_renderer_text_new ();
	column_music_dir_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_dir_list, "text", dir_name, NULL);
	gtk_tree_view_column_set_fixed_width(column_music_dir_list, 100);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_dir_list), column_music_dir_list);
	music_dir_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50);
	music_dir_list_sw = gtk_scrolled_window_new(NULL, music_dir_list_sw_adj_h);
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_dir_list_sw), 330);
	gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_dir_list_sw), 100);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_SHADOW_NONE);
// 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(music_dir_list_sw), tree_view_music_dir_list);
	
	selection_music_dir_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_dir_list));
	set_tree_view_music_dir_list ();
	

	store_music_list = gtk_tree_store_new(list_n_columns, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
// 	char file_index[BUFSIZ];
// 	printf("music_list_num is: %s\n", music_list_num);
// 	while (i < music_list_num) {
// // 		printf("%d: %s\n", i, music_list[i]);
// 		sprintf(file_index, "%d", i + 1);
// 		gtk_tree_store_append(store_music_list, &iter_music_list, NULL);
// 		gtk_tree_store_set (store_music_list, &iter_music_list, list_index, file_index, list_title, music_list[i], list_total_sec, "03:00", -1);
// 		i++;
// 	}
// 	
	tree_view_music_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_list));
	
	text_renderer_music_list = gtk_cell_renderer_text_new ();
	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_index, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
	gtk_tree_view_column_set_title(column_music_list, "序号");
	
	text_renderer_music_list = gtk_cell_renderer_text_new ();
	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_title, NULL);
	gtk_tree_view_column_set_fixed_width(column_music_list, 100);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
// 	text_renderer_music_list = gtk_cell_renderer_text_new ();
// 	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_total_sec, NULL);
// 	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
	
	
	music_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50);
	music_list_sw = gtk_scrolled_window_new(NULL, music_list_sw_adj_h);
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_list_sw), 370);
	gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_list_sw), 200);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_list_sw), GTK_SHADOW_NONE);
// 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(music_list_sw), tree_view_music_list);
	
	selection_music_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_list));
	set_tree_view_music_list ();
	return 1;
}
예제 #11
0
int main(int argc, char *argv[]) {
	gtk_init(&argc, &argv);

	GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
	gtk_window_set_title(GTK_WINDOW(window), "Label Demo");

	GtkWidget *hbox = gtk_hbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(window), hbox);
	gtk_widget_show(hbox);

	GtkWidget *vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
	gtk_widget_show(vbox);

	GtkWidget *frame;
	GtkWidget *label;

	frame = gtk_frame_new("Normal Label");
	label = gtk_label_new("This is a normal label.");
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
	
	frame = gtk_frame_new("Multi-line Label");
	label = gtk_label_new("This is a Multi-line \n label.");
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
	
	frame = gtk_frame_new("Left Justed Label");
	label = gtk_label_new("Left?.\nThis is the second line.");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
	
	frame = gtk_frame_new("Right Justed Label");
	label = gtk_label_new("Right?.\nThis is the second line.");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
	
	vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);

	frame = gtk_frame_new("Line wrapped label");
	label = gtk_label_new("This is an example of a line-warpped label. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit.");
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);

	frame = gtk_frame_new("Filled, wrapped label");
	label = gtk_label_new("This is an example of a line-warpped label. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit.");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_FILL);
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);

	frame = gtk_frame_new("Filled, wrapped label");
	label = gtk_label_new("This is an example of a line-warpped \nlabel. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit.");
	gtk_label_set_pattern(GTK_LABEL(label), "_ _ ");
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);

	gtk_widget_show_all(window);
	gtk_main();
	return 0;
}