示例#1
0
static void
gpview_footprint_view_init(GTypeInstance *instance, gpointer g_class)
{
    GPViewFootprintViewPrivate *privat = GPVIEW_FOOTPRINT_VIEW_GET_PRIVATE(instance);

    if (privat != NULL)
    {
        privat->tree_view = (GtkTreeView*) gtk_tree_view_new();

        gtk_scrolled_window_set_policy(
            GTK_SCROLLED_WINDOW(instance),
            GTK_POLICY_AUTOMATIC,   /* hscrollbar_policy */
            GTK_POLICY_AUTOMATIC    /* vscrollbar_policy */
        );

        gtk_container_add(
            GTK_CONTAINER(instance),
            GTK_WIDGET(privat->tree_view)
        );

        privat->selection = gtk_tree_view_get_selection(privat->tree_view);

        gtk_tree_selection_set_mode(
            privat->selection,
            GTK_SELECTION_MULTIPLE
        );

        g_signal_connect(
            privat->selection,
            "changed",
            G_CALLBACK(gpview_footprint_view_changed_cb),
            instance
        );

        g_signal_connect(
            instance,
            "notify::database",
            G_CALLBACK(gpview_footprint_view_update_cb),
            instance
        );
    }
}
static GtkWidget *
create_view_and_model (LokBagPack * bag_pack)
{
  GtkTreeViewColumn *col;
  GtkCellRenderer *renderer;
  GtkWidget *view;
  GtkTreeModel *model;

  view = gtk_tree_view_new ();

  /* Column 1 */
  renderer = gtk_cell_renderer_text_new ();
  col = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (col, "name");
  gtk_tree_view_append_column(GTK_TREE_VIEW (view), col);
  gtk_tree_view_column_pack_start (col, renderer, TRUE);
  gtk_tree_view_column_add_attribute (col, renderer, "text", COL_NAME);

  /* Column 2 */
  renderer = gtk_cell_renderer_text_new ();
  col = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (col, "points of attack");
  gtk_tree_view_append_column(GTK_TREE_VIEW (view), col);
  gtk_tree_view_column_pack_start (col, renderer, TRUE);
  gtk_tree_view_column_add_attribute (col, renderer, "text", COL_ATTACK_POINTS);

  /* Column 3 */
  renderer = gtk_cell_renderer_text_new ();
  col = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (col, "weigth");
  gtk_tree_view_append_column(GTK_TREE_VIEW (view), col);
  gtk_tree_view_column_pack_start (col, renderer, TRUE);
  gtk_tree_view_column_add_attribute (col, renderer, "text", COL_WEIGHT);

  model = create_and_fill_model (bag_pack);
  gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);
  g_object_unref (model);
  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (
      GTK_TREE_VIEW (view)), GTK_SELECTION_NONE);

  return view;
}
示例#3
0
文件: gui.c 项目: oreoPanda/chatnut
/*create a GtkTreeView with one column that has a GtkCellRendererText*/
extern void create_list_view(void)
{
	GtkTreeViewColumn *column = NULL;
	GtkCellRenderer *renderer = NULL;

	list = gtk_tree_view_new();

	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);
	gtk_widget_set_hexpand(list, TRUE);
	gtk_widget_set_vexpand(list, TRUE);
	gtk_tree_view_set_activate_on_single_click(GTK_TREE_VIEW(list), TRUE);

	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes( "Name", renderer, "text", 0, NULL );//"text" is an attribute (property) of a GtkCellRendererText
	gtk_tree_view_append_column( GTK_TREE_VIEW(list), column );

	g_signal_connect(list, "row-activated", G_CALLBACK(contact_selection_cb), NULL);

	return;
}
//
// Create GtkTreeView that is similar to a CList
// ie single text column, with no header
GtkWidget* createFontTabTreeView() 
{
	GtkWidget* treeView;
	GtkListStore* listStore;
	GtkTreeViewColumn* column;
	GtkCellRenderer* renderer;

	treeView = gtk_tree_view_new();
	listStore = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING);
	gtk_tree_view_set_model(GTK_TREE_VIEW(treeView), GTK_TREE_MODEL(listStore));
	column = gtk_tree_view_column_new();
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_attributes(column, renderer, "text", TEXT_COLUMN, NULL);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(treeView), column);
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeView), FALSE);

	return treeView;
}
示例#5
0
// Helper function to create the TreeView
GtkWidget* ErrorCheckDialog::createTreeView ()
{
	_listView = gtk_tree_view_new();

	gtk_tree_view_append_column(GTK_TREE_VIEW(_listView), gtkutil::TextColumn(_("Entity"), CHECK_ENTITY));
	gtk_tree_view_append_column(GTK_TREE_VIEW(_listView), gtkutil::TextColumn(_("Brush"), CHECK_BRUSH));
	gtk_tree_view_append_column(GTK_TREE_VIEW(_listView), gtkutil::TextColumn(_("Message"), CHECK_MESSAGE));

	GtkTreeSelection* sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(_listView));
	g_signal_connect(G_OBJECT(sel), "changed", G_CALLBACK(callbackSelect), this);

	_listStore = gtk_list_store_new(CHECK_COLUMNS, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING);
	gtk_tree_view_set_model(GTK_TREE_VIEW(_listView), GTK_TREE_MODEL(_listStore));
	/* unreference the list so that is will be deleted along with the tree view */
	g_object_unref(_listStore);

	// Pack treeview into a scrolled window and frame, and return

	return gtkutil::ScrolledFrame(_listView);
}
示例#6
0
void gui_init(dt_lib_module_t *self)
{
  /* initialize ui widgets */
  dt_lib_modulelist_t *d = (dt_lib_modulelist_t *)g_malloc0(sizeof(dt_lib_modulelist_t));
  self->data = (void *)d;
  self->widget = gtk_scrolled_window_new(NULL, NULL); //GTK_ADJUSTMENT(gtk_adjustment_new(200, 100, 200, 10, 100, 100))
  gtk_widget_set_size_request(self->widget, -1, DT_PIXEL_APPLY_DPI(208));
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(self->widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
  d->tree = GTK_TREE_VIEW(gtk_tree_view_new());
  gtk_widget_set_size_request(GTK_WIDGET(d->tree), DT_PIXEL_APPLY_DPI(50), -1);
  gtk_container_add(GTK_CONTAINER(self->widget), GTK_WIDGET(d->tree));

  /* connect to signal for darktable.develop initialization */
  dt_control_signal_connect(darktable.signals,DT_SIGNAL_DEVELOP_INITIALIZE,G_CALLBACK(_lib_modulelist_populate_callback),self);
  g_signal_connect(GTK_WIDGET(d->tree), "style-set", G_CALLBACK(_lib_modulelist_style_set), self);
  g_signal_connect(GTK_WIDGET(d->tree), "cursor-changed", G_CALLBACK(_lib_modulelist_row_changed_callback), NULL);

  darktable.view_manager->proxy.more_module.module = self;
  darktable.view_manager->proxy.more_module.update = _lib_modulelist_gui_update;
}
示例#7
0
文件: temp.c 项目: cbelth/PurdueCS
static GtkWidget *create_list( char * title )
{

    GtkWidget *scrolled_window;
    GtkWidget *tree_view;
    GtkListStore *model;
    GtkTreeIter iter;
    GtkCellRenderer *cell;
    GtkTreeViewColumn *column;

    int i;

    /* Create a new scrolled window, with scrollbars only if needed */
    scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
            GTK_POLICY_AUTOMATIC,
            GTK_POLICY_AUTOMATIC);

    model = gtk_list_store_new (1, G_TYPE_STRING);
    tree_view = gtk_tree_view_new ();
    gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
    gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
    gtk_widget_show (tree_view);

    /* Add some messages to the window */
    //gtk_list_store_append(GTK_LIST_STORE (model), &iter);
    //gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, "1 test hello\r\n2 test hello\r\n3 test hello\r\n4 test hello\r\n", -1);
    for (i = 0; i < 10; i++) {
        //gchar *msg = g_strdup_printf ("Message #%d", i);
        gchar *msg = g_strdup_printf ("%s", messages[i]);
        gtk_list_store_append (GTK_LIST_STORE (model), &iter);
        gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, msg, -1);
        g_free (msg);
    }

    cell = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(title, cell, "text", 0, NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), GTK_TREE_VIEW_COLUMN (column));

    return scrolled_window;
}
示例#8
0
文件: tree-hello.c 项目: 10sr/junks
static GtkWidget *
create_view_and_model (void)
{
  GtkCellRenderer     *renderer;
  GtkTreeModel        *model;
  GtkWidget           *view;

  view = gtk_tree_view_new ();

  /* --- Column #1 --- */

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
                                               -1,
                                               "Name",
                                               renderer,
                                               "text", COL_NAME,
                                               NULL);

  /* --- Column #2 --- */

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
                                               -1,
                                               "Age",
                                               renderer,
                                               "text", COL_AGE,
                                               NULL);

  model = create_and_fill_model ();

  gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);

  /* The tree view has acquired its own reference to the
   *  model, so we can drop ours. That way the model will
   *  be freed automatically when the tree view is destroyed */

  g_object_unref (model);

  return view;
}
示例#9
0
void create_sidebar(void)
{
	GtkWidget *scrollwin, *toolbar;

	file_view_vbox = gtk_vbox_new(FALSE, 0);
	toolbar = make_toolbar();
	gtk_box_pack_start(GTK_BOX(file_view_vbox), toolbar, FALSE, FALSE, 0);

	file_view = gtk_tree_view_new();
	prepare_file_view();

	scrollwin = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
				       GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(scrollwin), file_view);
	gtk_container_add(GTK_CONTAINER(file_view_vbox), scrollwin);

	gtk_widget_show_all(file_view_vbox);
	gtk_notebook_append_page(GTK_NOTEBOOK(geany->main_widgets->sidebar_notebook),
				 file_view_vbox, gtk_label_new(_("Project")));
}
示例#10
0
CListBox::CListBox()
        : CWidget()
{

	m_Widget = gtk_tree_view_new();
	PostCreate();
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(m_Widget), false);

	GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
	GtkTreeViewColumn *col = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL);
	gtk_tree_view_insert_column( (GtkTreeView*)m_Widget, col, -1);

	m_Store = gtk_list_store_new(1, G_TYPE_STRING );

	gtk_tree_view_set_model(GTK_TREE_VIEW(m_Widget), GTK_TREE_MODEL(m_Store));
	g_object_unref(m_Store); // destroy model automatically with view

	gtk_tree_selection_set_mode( gtk_tree_view_get_selection(GTK_TREE_VIEW(m_Widget)), GTK_SELECTION_BROWSE);

	Show();
}
/**
 * 
 * Helper function used to create the tests, it creates a treeview and
 * a treemodel, it returns the treeview with the treemodel associated.
 * 
 */
static GtkWidget *
create_view_and_model (void)
{
  GtkTreeViewColumn   *col;
  GtkCellRenderer     *renderer;
  GtkTreeModel        *model;
  GtkWidget           *view;

  view = gtk_tree_view_new ();

  /* --- Column #1 --- */

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
                                               -1,      
                                               "Name",  
                                               renderer,
                                               "text", COL_NAME,
                                               NULL);

  /* --- Column #2 --- */

  col = gtk_tree_view_column_new();

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
                                               -1,      
                                               "Age",  
                                               renderer,
                                               "text", COL_AGE,
                                               NULL);

  model = create_and_fill_model ();

  gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);

  g_object_unref (model); /* destroy model automatically with view */

  return view;
}
示例#12
0
static void
gtk_app_chooser_widget_init (GtkAppChooserWidget *self)
{
  GtkWidget *scrolled_window;
  GtkTreeSelection *selection;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_WIDGET,
                                            GtkAppChooserWidgetPrivate);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_set_size_request (scrolled_window, 400, 300);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
                                       GTK_SHADOW_IN);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                  GTK_POLICY_NEVER,
                                  GTK_POLICY_AUTOMATIC);
  gtk_widget_show (scrolled_window);

  self->priv->program_list = gtk_tree_view_new ();
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (self->priv->program_list),
                                     FALSE);
  gtk_container_add (GTK_CONTAINER (scrolled_window), self->priv->program_list);
  gtk_box_pack_start (GTK_BOX (self), scrolled_window, TRUE, TRUE, 0);
  gtk_widget_show (self->priv->program_list);

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->program_list));
  gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
  gtk_tree_selection_set_select_function (selection, gtk_app_chooser_selection_func,
                                          self, NULL);
  g_signal_connect_swapped (selection, "changed",
                            G_CALLBACK (refresh_and_emit_app_selected),
                            self);
  g_signal_connect (self->priv->program_list, "row-activated",
                    G_CALLBACK (program_list_selection_activated),
                    self);
  g_signal_connect (self->priv->program_list, "button-press-event",
                    G_CALLBACK (widget_button_press_event_cb),
                    self);
}
示例#13
0
static void tree_prepare(GigoloBookmarkPanel *panel)
{
	GtkCellRenderer *text_renderer;
	GtkTreeViewColumn *column;
	GtkTreeSelection *selection;
	GtkWidget *tree;
	GtkListStore *store;
	GigoloBookmarkPanelPrivate *priv = gigolo_bookmark_panel_get_instance_private(panel);

	tree = gtk_tree_view_new();
	store = gtk_list_store_new(GIGOLO_BOOKMARK_PANEL_N_COLUMNS,
		G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);

    column = gtk_tree_view_column_new();

	text_renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), FALSE);
	gtk_tree_view_column_pack_start(column, text_renderer, TRUE);
	gtk_tree_view_column_set_attributes(column, text_renderer,
		"text", GIGOLO_BOOKMARK_PANEL_COL_NAME,
		"cell-background", GIGOLO_BOOKMARK_PANEL_COL_COLOR, NULL);

	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);

	gtk_tree_view_set_model(GTK_TREE_VIEW(tree), GTK_TREE_MODEL(store));
	g_object_unref(store);

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);

	g_signal_connect(tree, "row-activated", G_CALLBACK(tree_row_activated_cb), panel);
	g_signal_connect(selection, "changed", G_CALLBACK(tree_selection_changed_cb), panel);

	priv->tree = tree;
	priv->store = store;

	tree_selection_changed_cb(NULL, panel);
}
示例#14
0
文件: treeview.c 项目: Airr/Claro
void cgraphics_treeview_widget_create( widget_t *widget )
{
	GtkTreeSelection *select;
	GtkTreeViewColumn *tvc;
	GtkCellRenderer *irenderer, *trenderer;
	GtkTreeModel *model;
	
	widget->native = gtk_scrolled_window_new( NULL, NULL );
	gtk_scrolled_window_set_policy( widget->native, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
	gtk_scrolled_window_set_shadow_type( widget->native, GTK_SHADOW_IN );
	widget->container = gtk_tree_view_new( );
	gtk_container_add( widget->native, widget->container );
	gtk_widget_show( GTK_WIDGET( widget->container ) );
	
	cgraphics_widget_create( widget );
	gtk_tree_view_set_headers_visible( widget->container, FALSE );
	
	select = gtk_tree_view_get_selection( GTK_TREE_VIEW(widget->container) );
	gtk_tree_selection_set_mode( select, GTK_SELECTION_SINGLE );
	
	g_signal_connect( G_OBJECT(select), "changed", G_CALLBACK(cgraphics_treeview_selected_handler), widget );
	g_signal_connect( G_OBJECT(widget->container), "button-press-event", G_CALLBACK(cgraphics_treeview_rightclick_handler), widget );
	
	model = (GtkTreeModel *)gtk_tree_store_new( 3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER );
	gtk_tree_view_set_model( GTK_TREE_VIEW(widget->container), model );
	g_object_unref( model );
	
	irenderer = gtk_cell_renderer_pixbuf_new( );
	trenderer = gtk_cell_renderer_text_new( );
	
	tvc = gtk_tree_view_column_new( );
	gtk_tree_view_column_set_title( tvc, "Column" );
	gtk_tree_view_column_pack_start( tvc, irenderer, FALSE );
	gtk_tree_view_column_pack_end( tvc, trenderer, TRUE );
	gtk_tree_view_column_add_attribute( tvc, irenderer, "pixbuf", 0 );
	gtk_tree_view_column_add_attribute( tvc, trenderer, "text", 1 );
	
	gtk_tree_view_append_column( GTK_TREE_VIEW(widget->container), tvc );
}
示例#15
0
文件: UgSelector.c 项目: Endz0/uget
static GtkTreeView*	ug_selector_view_new (const gchar* title, gboolean active_toggled)
{
	GtkTreeView*		view;
	GtkCellRenderer*	renderer;
	GtkTreeViewColumn*	column;

	view = (GtkTreeView*) gtk_tree_view_new ();
//	gtk_tree_view_set_fixed_height_mode (view, TRUE);
	// UgSelectorItem.mark
	renderer = gtk_cell_renderer_toggle_new ();
	column = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title (column, "M");
	gtk_tree_view_column_pack_start (column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func (column, renderer,
			col_set_toggle, NULL, NULL);
	gtk_tree_view_column_set_resizable (column, FALSE);
	gtk_tree_view_column_set_alignment (column, 0.5);
	gtk_tree_view_column_set_min_width (column, 15);
//	gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_append_column (view, column);
	if (active_toggled) {
		g_signal_connect (renderer, "toggled",
				G_CALLBACK (on_cell_toggled), view);
	}
	// UgSelectorItem.uri
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title (column, title);
	gtk_tree_view_column_pack_start (column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func (column, renderer,
			col_set_uri, NULL, NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
//	gtk_tree_view_column_set_expand (column, TRUE);
//	gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_append_column (view, column);

	gtk_widget_show (GTK_WIDGET (view));
	return view;
}
示例#16
0
/* This function is used both for creating the "Display" and
 * "Screen" frames, since they have a similar structure. The
 * caller hooks up the right context for the value returned
 * in tree_view, and packs any relevant buttons into button_vbox.
 */
static void
create_frame (ChangeDisplayInfo *info,
	      const char        *title,
	      GtkWidget        **frame,
	      GtkWidget        **tree_view,
	      GtkWidget        **button_vbox)
{
  GtkTreeSelection *selection;
  GtkWidget *scrollwin;
  GtkWidget *hbox;

  *frame = gtk_frame_new (title);

  hbox = gtk_hbox_new (FALSE, 8);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
  gtk_container_add (GTK_CONTAINER (*frame), hbox);

  scrollwin = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
				  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin),
				       GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (hbox), scrollwin, TRUE, TRUE, 0);

  *tree_view = gtk_tree_view_new ();
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (*tree_view), FALSE);
  gtk_container_add (GTK_CONTAINER (scrollwin), *tree_view);

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (*tree_view));
  gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);

  *button_vbox = gtk_vbox_new (FALSE, 5);
  gtk_box_pack_start (GTK_BOX (hbox), *button_vbox, FALSE, FALSE, 0);

  if (!info->size_group)
    info->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

  gtk_size_group_add_widget (GTK_SIZE_GROUP (info->size_group), *button_vbox);
}
示例#17
0
文件: codecsbox.cpp 项目: GNOME/ekiga
GtkWidget *
codecs_box_new_with_type (GmApplication *app,
                          Ekiga::Call::StreamType type)
{
  CodecsBox *self = CODECS_BOX (g_object_new (CODECS_BOX_TYPE, NULL));

  Ekiga::ServiceCore& core = gm_application_get_core (app);

  self->priv = new _CodecsBoxPrivate ();
  self->priv->app = app;
  self->priv->call_core = core.get<Ekiga::CallCore> ("call-core");
  self->priv->type = type;
  self->priv->audio_settings = boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (AUDIO_CODECS_SCHEMA));
  self->priv->video_settings = boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (VIDEO_CODECS_SCHEMA));
  self->priv->codecs_list = gtk_tree_view_new ();

  codecs_box_build (self);

  codecs_box_set_codecs (self, self->priv->call_core->get_codecs ());

  return GTK_WIDGET (self);
}
示例#18
0
static void
treeview_download_files_init(void)
{
	GtkTreeView *tv;
	unsigned i;

	STATIC_ASSERT(FILEINFO_VISIBLE_COLUMNS == c_fi_num);

	tv = GTK_TREE_VIEW(gtk_tree_view_new());
	treeview_download_files = tv;

	for (i = 0; i < c_fi_num; i++) {
		GtkTreeViewColumn *column;

		column = add_column(tv, i,
			fi_gui_files_column_title(i),
			fi_gui_files_column_justify_right(i) ? 1.0 : 0.0,
			c_fi_progress == i ? gtk_cell_renderer_progress_new() : NULL,
			render_files);

		column_sort_tristate_register(column,
			on_fileinfo_treeview_column_clicked, NULL);
	}

	gtk_tree_selection_set_mode(gtk_tree_view_get_selection(tv),
		GTK_SELECTION_MULTIPLE);
	gtk_tree_view_set_headers_visible(tv, TRUE);
	gtk_tree_view_set_headers_clickable(tv, TRUE);
	gtk_tree_view_set_enable_search(tv, FALSE);
	gtk_tree_view_set_rules_hint(tv, TRUE);
	tree_view_set_fixed_height_mode(tv, TRUE);

	gtk_tree_view_set_model(tv, GTK_TREE_MODEL(store_files));
	tree_view_restore_visibility(tv, PROP_FILE_INFO_COL_VISIBLE);
	tree_view_restore_widths(tv, PROP_FILE_INFO_COL_WIDTHS);

	gui_signal_connect(tv,
		"cursor-changed", on_treeview_download_files_cursor_changed, NULL);
}
示例#19
0
void EntityList::populateWindow() {
	// Create the treeview
	_treeView = GTK_TREE_VIEW(gtk_tree_view_new());
	gtk_tree_view_set_headers_visible(_treeView, FALSE);
	
	gtk_tree_view_set_model(_treeView, _treeModel);
	
	GtkTreeViewColumn* column = gtkutil::TextColumn(_("Name"), GraphTreeModel::COL_NAME);
	gtk_tree_view_column_pack_start(column, gtk_cell_renderer_text_new(), TRUE);
	
	_selection = gtk_tree_view_get_selection(_treeView);
	gtk_tree_selection_set_mode(_selection, GTK_SELECTION_MULTIPLE);
	gtk_tree_selection_set_select_function(_selection, onSelection, this, 0);
	
	g_signal_connect(G_OBJECT(_treeView), "row-expanded", G_CALLBACK(onRowExpand), this);
	
	gtk_tree_view_append_column (_treeView, column);
	gtk_tree_view_column_set_sort_column_id(column, GraphTreeModel::COL_NAME);
	gtk_tree_view_column_clicked(column);

	// Create the toggle item
	_focusOnSelectedEntityToggle = gtk_check_button_new_with_label(_("Focus camera on selected entity."));

	// Update the toggle item status according to the registry
	bool isActive = GlobalRegistry().get(RKEY_ENTITYLIST_FOCUS_SELECTION) == "1";
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_focusOnSelectedEntityToggle), isActive);

	// Connect the toggle button's "toggled" signal
	g_signal_connect(G_OBJECT(_focusOnSelectedEntityToggle), "toggled", G_CALLBACK(onFocusSelectionToggle), this);
	
	// Create a VBOX
	GtkWidget* vbox = gtk_vbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(vbox), gtkutil::ScrolledFrame(GTK_WIDGET(_treeView)), TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), _focusOnSelectedEntityToggle, FALSE, FALSE, 0);

	// Pack the VBOX into the window
	gtk_container_add(GTK_CONTAINER(getWindow()), vbox);	
}
示例#20
0
GtkWidget *create_config_tab_content(const char *column_label,
                                      GtkListStore *store)
{
    GtkWidget *main_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
                                    GTK_POLICY_NEVER,
                                    GTK_POLICY_AUTOMATIC);
    /* workflow list treeview */
    GtkWidget *tv = gtk_tree_view_new();
    /* column with workflow name and description */
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;

    /* add column to tree view */
    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(column_label,
                                                 renderer,
                                                 "markup",
                                                 COLUMN_UINAME,
                                                 NULL);
    gtk_tree_view_column_set_resizable(column, TRUE);
    g_object_set(G_OBJECT(renderer), "wrap-mode", PANGO_WRAP_WORD, NULL);
    g_object_set(G_OBJECT(renderer), "wrap-width", 440, NULL);
    gtk_tree_view_column_set_sort_column_id(column, COLUMN_NAME);
    gtk_tree_view_append_column(GTK_TREE_VIEW(tv), column);
    /* "Please draw rows in alternating colors": */
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tv), TRUE);
    // TODO: gtk_tree_view_set_headers_visible(FALSE)? We have only one column anyway...
    GtkTreeModel *model = gtk_tree_model_filter_new(GTK_TREE_MODEL(store), NULL);
    gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(model), config_filter_func, NULL, NULL);

    gtk_tree_view_set_model(GTK_TREE_VIEW(tv), GTK_TREE_MODEL(model));
    gtk_container_add(GTK_CONTAINER(scroll), tv);

    gtk_box_pack_start(GTK_BOX(main_vbox), scroll, true, true, 10);
    return main_vbox;
}
示例#21
0
GtkWidget * CreateView()
{
    GtkTreeViewColumn *col;
    GtkCellRenderer *renderer;
    GtkTreeModel *model;
    GtkWidget *view;

    view = gtk_tree_view_new ();

    col = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title (col,"Detected Devices");
    gtk_tree_view_append_column (GTK_TREE_VIEW(view),col);

    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (col,renderer,TRUE);
    gtk_tree_view_column_add_attribute (col,renderer,"text",COLUMN);

    model = CreateModel();
    gtk_tree_view_set_model(GTK_TREE_VIEW(view),model);
    g_object_unref(model);

    return view;
}
示例#22
0
文件: gui.c 项目: iamscottmoyers/gsim
static GtkWidget *create_view_and_model (void)
{
	GtkTreeViewColumn *col;
	GtkCellRenderer *renderer;
	GtkWidget *view;
	GtkTreeModel *model;

	view = gtk_tree_view_new();

	col = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(col, "UML Elements");
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);

	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(col, renderer, TRUE);
	gtk_tree_view_column_add_attribute(col, renderer, "text", COLUMN);

	model = create_and_fill_model();
	gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
	g_object_unref(model);

	return view;
}
示例#23
0
文件: dialog.cpp 项目: adi6190/pcsx2
		void init()
		{
			show_pad = 0;
			has_columns = false;
			for (int i = 0; i < 2; i++)
				show_keyboard_key[i] = show_joy_key[i] = true;

			treestore = gtk_tree_store_new(NUM_COLS,
					G_TYPE_STRING,
					G_TYPE_STRING,
					G_TYPE_STRING,
					G_TYPE_UINT,
					G_TYPE_UINT,
					G_TYPE_UINT);

			model = GTK_TREE_MODEL(treestore);

			for (int i = 0; i < 2; i++) {
				view[i] = GTK_TREE_VIEW(gtk_tree_view_new());
				gtk_tree_view_set_model(view[i], model);
				gtk_tree_selection_set_mode(gtk_tree_view_get_selection(view[i]), GTK_SELECTION_SINGLE);
			}
			g_object_unref(model); /* destroy model automatically with view */
		}
示例#24
0
static void
gtk_syntax_check_window_init (GtkSyntaxCheckWindow *win)
{
  GtkSyntaxCheckWindowPrivate *priv;
  
  priv = GTK_SYNTAX_CHECK_WINDOW_GET_PRIVATE (win);

  win->priv = priv;

  priv->scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
  priv->lint_view = gtk_tree_view_new ();
  gtk_container_add (GTK_CONTAINER (priv->scrolledwindow), priv->lint_view);
  priv->lint_renderer = gtk_cell_renderer_text_new ();
  priv->lint_column = gtk_tree_view_column_new_with_attributes (_("Syntax Check Output"),
  priv->lint_renderer, "text", 0, NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->lint_view), priv->lint_column);
  gtk_widget_set_size_request (priv->lint_view, 80,80);
  priv->lint_select = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->lint_view));
  gtk_tree_selection_set_mode (priv->lint_select, GTK_SELECTION_SINGLE);
  g_signal_connect (G_OBJECT (priv->lint_select), "changed", G_CALLBACK (lint_row_activated), NULL);
  gtk_box_pack_start(GTK_BOX(win), GTK_WIDGET(priv->scrolledwindow), TRUE, TRUE, 2);
  gtk_widget_show(priv->scrolledwindow);
  gtk_widget_show(priv->lint_view);
}
示例#25
0
void
gui_init (dt_lib_module_t *self)
{
    dt_lib_collect_t *d = (dt_lib_collect_t *)malloc(sizeof(dt_lib_collect_t));

    self->data = (void *)d;
    self->widget = gtk_vbox_new(FALSE, 5);
    gtk_widget_set_size_request(self->widget, 100, -1);
    d->active_rule = 0;
    d->params = (dt_lib_collect_params_t*)malloc(sizeof(dt_lib_collect_params_t));

    dt_control_signal_connect(darktable.signals,
                              DT_SIGNAL_COLLECTION_CHANGED,
                              G_CALLBACK(collection_updated),
                              self);

    GtkBox *box;
    GtkWidget *w;
    GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL);
    GtkTreeView *view = GTK_TREE_VIEW(gtk_tree_view_new());
    d->view = view;
    GtkListStore *liststore;

    for(int i=0; i<MAX_RULES; i++)
    {
        d->rule[i].num = i;
        box = GTK_BOX(gtk_hbox_new(FALSE, 5));
        d->rule[i].hbox = GTK_WIDGET(box);
        gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(box), TRUE, TRUE, 0);
        w = gtk_combo_box_new_text();
        d->rule[i].combo = GTK_COMBO_BOX(w);
        for(int k=0; k<dt_lib_collect_string_cnt; k++)
            gtk_combo_box_append_text(GTK_COMBO_BOX(w), _(dt_lib_collect_string[k]));
        g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(combo_changed), d->rule + i);
        gtk_box_pack_start(box, w, FALSE, FALSE, 0);
        w = gtk_entry_new();
        dt_gui_key_accel_block_on_focus(w);
        d->rule[i].text = w;
        gtk_widget_add_events(w, GDK_FOCUS_CHANGE_MASK);
        g_signal_connect(G_OBJECT(w), "focus-in-event", G_CALLBACK(entry_focus_in_callback), d->rule + i);

        /* xgettext:no-c-format */
        g_object_set(G_OBJECT(w), "tooltip-text", _("type your query, use `%' as wildcard"), (char *)NULL);
        gtk_widget_add_events(w, GDK_KEY_PRESS_MASK);
        g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(changed_callback), d->rule + i);
        g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(entry_activated), d->rule + i);
        gtk_box_pack_start(box, w, TRUE, TRUE, 0);
        w = dtgtk_button_new(dtgtk_cairo_paint_presets, CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER);
        d->rule[i].button = w;
        gtk_widget_set_events(w, GDK_BUTTON_PRESS_MASK);
        g_signal_connect(G_OBJECT(w), "button-press-event", G_CALLBACK(popup_button_callback), d->rule + i);
        gtk_box_pack_start(box, w, FALSE, FALSE, 0);
        gtk_widget_set_size_request(w, 13, 13);
    }

    d->scrolledwindow = GTK_SCROLLED_WINDOW(sw);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(view));
    gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(sw), TRUE, TRUE, 0);
    gtk_tree_view_set_headers_visible(view, FALSE);
    liststore = gtk_list_store_new(DT_LIB_COLLECT_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
    GtkTreeViewColumn *col = gtk_tree_view_column_new();
    gtk_tree_view_append_column(view, col);
    gtk_widget_set_size_request(GTK_WIDGET(view), -1, 300);
    GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start(col, renderer, TRUE);
    gtk_tree_view_column_add_attribute(col, renderer, "text", DT_LIB_COLLECT_COL_TEXT);
    gtk_tree_selection_set_mode(gtk_tree_view_get_selection(view), GTK_SELECTION_SINGLE);
    gtk_tree_view_set_model(view, GTK_TREE_MODEL(liststore));
    g_signal_connect(G_OBJECT (view), "row-activated", G_CALLBACK (row_activated), d);

    /* setup proxy */
    darktable.view_manager->proxy.module_collect.module = self;
    darktable.view_manager->proxy.module_collect.update = _lib_collect_gui_update;

    _lib_collect_gui_update(self);
}
示例#26
0
void l_zarzvan_create_list (class l_zarzvan_data *data)
{
iceb_clock sss(data->window);
GtkListStore *model=NULL;
GtkTreeIter iter;
SQLCURSOR cur;
char strsql[512];
int  kolstr=0;
SQL_str row;
//GdkColor color;

data->kl_shift=0; //0-отжата 1-нажата  


if(data->treeview != NULL)
  gtk_widget_destroy(data->treeview);

data->treeview = gtk_tree_view_new();


gtk_container_add (GTK_CONTAINER (data->sw), data->treeview);

g_signal_connect(data->treeview,"row_activated",G_CALLBACK(l_zarzvan_v_row),data);

GtkTreeSelection *selection=gtk_tree_view_get_selection(GTK_TREE_VIEW(data->treeview));
gtk_tree_selection_set_mode(selection,GTK_SELECTION_SINGLE);
g_signal_connect(selection,"changed",G_CALLBACK(l_zarzvan_vibor),data);

gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (data->treeview), TRUE); //Устанавливаются полоски при отображении списка
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (data->treeview)),GTK_SELECTION_SINGLE);




model = gtk_list_store_new (NUM_COLUMNS+1, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_INT);


sprintf(strsql,"select * from Zvan order by kod asc");

if((kolstr=cur.make_cursor(&bd,strsql)) < 0)
 {
  iceb_msql_error(&bd,gettext("Ошибка создания курсора !"),strsql,data->window);
  return;
 }
//gtk_list_store_clear(model);

iceb_u_str ss[NUM_COLUMNS];

data->kolzap=0;

while(cur.read_cursor(&row) != 0)
 {
//  printf("%s %s %s %s\n",row[0],row[1],row[2],row[3]);
  
  if(l_zarzvan_prov_row(row,data) != 0)
    continue;


  if(iceb_u_SRAV(data->kod_zvan_tv.ravno(),row[0],0) == 0)
    data->snanomer=data->kolzap;

  //Код
  ss[COL_KOD].new_plus(iceb_u_toutf(row[0]));
  
  //Наименование
  ss[COL_NAIM].new_plus(iceb_u_toutf(row[1]));

  //Дата и время записи
  ss[COL_DATA_VREM].new_plus(iceb_u_toutf(iceb_u_vremzap(row[3])));

  //Кто записал
  ss[COL_KTO].new_plus(iceb_kszap(row[2],0,data->window));

  
  gtk_list_store_append (model, &iter);

  gtk_list_store_set (model, &iter,
  COL_KOD,ss[COL_KOD].ravno(),
  COL_NAIM,ss[COL_NAIM].ravno(),
  COL_DATA_VREM,ss[COL_DATA_VREM].ravno(),
  COL_KTO,ss[COL_KTO].ravno(),
  NUM_COLUMNS,data->kolzap,
  -1);

  data->kolzap++;
 }
data->kod_zvan_tv.new_plus("");

gtk_tree_view_set_model (GTK_TREE_VIEW(data-> treeview),GTK_TREE_MODEL (model));

g_object_unref (GTK_TREE_MODEL (model));

l_zarzvan_add_columns (GTK_TREE_VIEW (data->treeview));


if(data->kolzap == 0)
 {
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK3]),FALSE);//Недоступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK5]),FALSE);//Недоступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK2]),FALSE);//Недоступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK3]),FALSE);//Недоступна
 }
else
 {
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK3]),TRUE);//Доступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK5]),TRUE);//Доступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK2]),TRUE);//Доступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK3]),TRUE);//Доступна
 }

gtk_widget_show (data->treeview);
gtk_widget_show (data->sw);

//Стать подсветкой стороки на нужный номер строки
iceb_snanomer(data->kolzap,&data->snanomer,data->treeview);


iceb_u_str stroka;
iceb_u_str zagolov;
zagolov.plus(gettext("Список званий"));

sprintf(strsql," %s:%d",gettext("Количество записей"),data->kolzap);
zagolov.plus(strsql);

gtk_label_set_text(GTK_LABEL(data->label_kolstr),zagolov.ravno_toutf());

if(data->metka_poi == 1)
 {
  
  zagolov.new_plus(gettext("Поиск"));
  zagolov.plus(" !!!");

  iceb_str_poisk(&zagolov,data->poisk.kod.ravno(),gettext("Код"));
  iceb_str_poisk(&zagolov,data->poisk.naim.ravno(),gettext("Наименование"));
  

  gtk_label_set_text(GTK_LABEL(data->label_poisk),zagolov.ravno_toutf());
  gtk_widget_show(data->label_poisk);
 }
else
 gtk_widget_hide(data->label_poisk); 

gtk_widget_show(data->label_kolstr);

}
示例#27
0
static PanelAddtoDialog *
panel_addto_dialog_new (PanelWidget *panel_widget)
{
	PanelAddtoDialog *dialog;
	GtkWidget *dialog_vbox;
	GtkWidget *inner_vbox;
	GtkWidget *find_hbox;
	GtkWidget *sw;
	GtkCellRenderer *renderer;
	GtkTreeSelection *selection;
	GtkTreeViewColumn *column;

	dialog = g_new0 (PanelAddtoDialog, 1);

	g_object_set_qdata_full (G_OBJECT (panel_widget->toplevel),
				 panel_addto_dialog_quark,
				 dialog,
				 (GDestroyNotify) panel_addto_dialog_free);

	dialog->panel_widget = panel_widget;
	dialog->name_notify =
		panel_profile_toplevel_notify_add (
			dialog->panel_widget->toplevel,
			"name",
			(MateConfClientNotifyFunc) panel_addto_name_notify,
			dialog);


	dialog->addto_dialog = gtk_dialog_new ();
	gtk_dialog_add_button (GTK_DIALOG (dialog->addto_dialog),
			       GTK_STOCK_HELP, GTK_RESPONSE_HELP);
	dialog->back_button = gtk_dialog_add_button (GTK_DIALOG (dialog->addto_dialog),
						     GTK_STOCK_GO_BACK,
						     PANEL_ADDTO_RESPONSE_BACK);
	dialog->add_button = gtk_dialog_add_button (GTK_DIALOG (dialog->addto_dialog),
						     GTK_STOCK_ADD,
						     PANEL_ADDTO_RESPONSE_ADD);
	gtk_dialog_add_button (GTK_DIALOG (dialog->addto_dialog),
			       GTK_STOCK_CLOSE,
			       GTK_RESPONSE_CLOSE);
	gtk_widget_set_sensitive (GTK_WIDGET (dialog->add_button), FALSE);
	gtk_dialog_set_has_separator (GTK_DIALOG (dialog->addto_dialog),
				      FALSE);
	gtk_dialog_set_default_response (GTK_DIALOG (dialog->addto_dialog),
					 PANEL_ADDTO_RESPONSE_ADD);

	gtk_container_set_border_width (GTK_CONTAINER (dialog->addto_dialog), 5);

	dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog->addto_dialog));
	gtk_box_set_spacing (GTK_BOX (dialog_vbox), 12);
	gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);

	g_signal_connect (G_OBJECT (dialog->addto_dialog), "response",
			  G_CALLBACK (panel_addto_dialog_response), dialog);
	g_signal_connect (dialog->addto_dialog, "destroy",
			  G_CALLBACK (panel_addto_dialog_destroy), dialog);

	inner_vbox = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (dialog_vbox), inner_vbox, TRUE, TRUE, 0);

	find_hbox = gtk_hbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (inner_vbox), find_hbox, FALSE, FALSE, 0);

	dialog->label = gtk_label_new_with_mnemonic ("");
	gtk_misc_set_alignment (GTK_MISC (dialog->label), 0.0, 0.5);
	gtk_label_set_use_markup (GTK_LABEL (dialog->label), TRUE);

	gtk_box_pack_start (GTK_BOX (find_hbox), dialog->label,
			    FALSE, FALSE, 0);

	dialog->search_entry = gtk_entry_new ();
	g_signal_connect (G_OBJECT (dialog->search_entry), "changed",
			  G_CALLBACK (panel_addto_search_entry_changed), dialog);
	g_signal_connect (G_OBJECT (dialog->search_entry), "activate",
			  G_CALLBACK (panel_addto_search_entry_activated), dialog);

	gtk_box_pack_end (GTK_BOX (find_hbox), dialog->search_entry,
			  TRUE, TRUE, 0);

	gtk_label_set_mnemonic_widget (GTK_LABEL (dialog->label),
				       dialog->search_entry);

	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
					     GTK_SHADOW_IN);
	gtk_box_pack_start (GTK_BOX (inner_vbox), sw, TRUE, TRUE, 0);

	dialog->tree_view = gtk_tree_view_new ();
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->tree_view),
					   FALSE);
	gtk_tree_view_expand_all (GTK_TREE_VIEW (dialog->tree_view));

	renderer = g_object_new (GTK_TYPE_CELL_RENDERER_PIXBUF,
				 "xpad", 4,
				 "ypad", 4,
				 NULL);

	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (dialog->tree_view),
						     -1, NULL,
						     renderer,
						     "pixbuf", COLUMN_ICON,
						     NULL);
	renderer = gtk_cell_renderer_text_new ();
	g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (dialog->tree_view),
						     -1, NULL,
						     renderer,
						     "markup", COLUMN_TEXT,
						     NULL);

	//FIXME use the same search than the one for the search entry?
	gtk_tree_view_set_search_column (GTK_TREE_VIEW (dialog->tree_view),
					 COLUMN_SEARCH);

	gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (dialog->tree_view),
					      panel_addto_separator_func,
					      GINT_TO_POINTER (COLUMN_TEXT),
					      NULL);


	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

	column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->tree_view),
					   COLUMN_TEXT);
	gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);

	g_signal_connect (selection, "changed",
			  G_CALLBACK (panel_addto_selection_changed),
			  dialog);

	g_signal_connect (dialog->tree_view, "row-activated",
			  G_CALLBACK (panel_addto_selection_activated),
			  dialog);

	gtk_container_add (GTK_CONTAINER (sw), dialog->tree_view);

	gtk_widget_show_all (dialog_vbox);

	panel_toplevel_push_autohide_disabler (dialog->panel_widget->toplevel);
	panel_widget_register_open_dialog (panel_widget,
					   dialog->addto_dialog);

	panel_addto_name_change (dialog,
				 panel_toplevel_get_name (dialog->panel_widget->toplevel));

	return dialog;
}
示例#28
0
static void
add_tree_view (NautilusColumnChooser *chooser)
{
	GtkWidget *scrolled;
	GtkWidget *view;
	GtkListStore *store;
	GtkCellRenderer *cell;
	GtkTreeSelection *selection;
	
	view = gtk_tree_view_new ();
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
	
	store = gtk_list_store_new (NUM_COLUMNS,
				    G_TYPE_BOOLEAN,
				    G_TYPE_STRING,
				    G_TYPE_STRING,
				    G_TYPE_BOOLEAN);

	gtk_tree_view_set_model (GTK_TREE_VIEW (view), 
				 GTK_TREE_MODEL (store));
	g_object_unref (store);

	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (view), TRUE);

	g_signal_connect (view, "row-activated",
	                  G_CALLBACK (view_row_activated_callback), chooser);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
	g_signal_connect (selection, "changed", 
			  G_CALLBACK (selection_changed_callback), chooser);

	cell = gtk_cell_renderer_toggle_new ();
	
	g_signal_connect (G_OBJECT (cell), "toggled",
			  G_CALLBACK (visible_toggled_callback), chooser);

	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
						     -1, NULL,
						     cell,
						     "active", COLUMN_VISIBLE,
						     "sensitive", COLUMN_SENSITIVE,
						     NULL);

	cell = gtk_cell_renderer_text_new ();

	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
						     -1, NULL,
						     cell,
						     "text", COLUMN_LABEL,
						     "sensitive", COLUMN_SENSITIVE,
						     NULL);

	chooser->details->view = GTK_TREE_VIEW (view);
	chooser->details->store = store;

	gtk_widget_show (view);

	scrolled = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
					     GTK_SHADOW_IN);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	gtk_widget_show (GTK_WIDGET (scrolled));
	
	gtk_container_add (GTK_CONTAINER (scrolled), view);
	gtk_box_pack_start (GTK_BOX (chooser), scrolled, TRUE, TRUE, 0);
}
示例#29
0
static GList *select_from_list (GtkWindow *parent, GList *list, const gchar *title, const gchar *msg )
{
    GtkTreeIter iter;
    GtkCellRenderer *renderer;
    GtkWidget *view;
    gchar *latlon_string;
    int column_runner;

    GtkWidget *dialog = gtk_dialog_new_with_buttons (title,
                        parent,
                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                        GTK_STOCK_CANCEL,
                        GTK_RESPONSE_REJECT,
                        GTK_STOCK_OK,
                        GTK_RESPONSE_ACCEPT,
                        NULL);
    /* When something is selected then OK */
    gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
    GtkWidget *response_w = NULL;
#if GTK_CHECK_VERSION (2, 20, 0)
    /* Default to not apply - as initially nothing is selected! */
    response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(dialog), GTK_RESPONSE_REJECT );
#endif
    GtkWidget *label = gtk_label_new ( msg );
    GtkTreeStore *store = gtk_tree_store_new ( 6, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN );
    GList *list_runner = list;
    while (list_runner) {
        gpx_meta_data_t *gpx_meta_data = (gpx_meta_data_t *)list_runner->data;
        // To keep display compact three digits of precision for lat/lon should be plenty
        latlon_string = g_strdup_printf("(%.3f,%.3f)", gpx_meta_data->ll.lat, gpx_meta_data->ll.lon);
        gtk_tree_store_append(store, &iter, NULL);
        gtk_tree_store_set ( store, &iter,
                             0, gpx_meta_data->name,
                             1, gpx_meta_data->desc,
                             2, gpx_meta_data->timestamp,
                             3, latlon_string,
                             4, gpx_meta_data->vis,
                             5, gpx_meta_data->in_current_view,
                             -1 );
        list_runner = g_list_next ( list_runner );
        g_free ( latlon_string );
    }

    view = gtk_tree_view_new();
    renderer = gtk_cell_renderer_text_new();
    column_runner = 0;
    GtkTreeViewColumn *column;

    column = gtk_tree_view_column_new_with_attributes ( _("Name"), renderer, "text", column_runner, NULL);
    gtk_tree_view_column_set_sort_column_id (column, column_runner);
    gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);

    column_runner++;
    column = gtk_tree_view_column_new_with_attributes ( _("Description"), renderer, "text", column_runner, NULL);
    gtk_tree_view_column_set_sort_column_id (column, column_runner);
    gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);

    column_runner++;
    column = gtk_tree_view_column_new_with_attributes ( _("Time"), renderer, "text", column_runner, NULL);
    gtk_tree_view_column_set_sort_column_id (column, column_runner);
    gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);

    column_runner++;
    column = gtk_tree_view_column_new_with_attributes ( _("Lat/Lon"), renderer, "text", column_runner, NULL);
    gtk_tree_view_column_set_sort_column_id (column, column_runner);
    gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);

    column_runner++;
    column = gtk_tree_view_column_new_with_attributes ( _("Privacy"), renderer, "text", column_runner, NULL); // AKA Visibility
    gtk_tree_view_column_set_sort_column_id (column, column_runner);
    gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);

    GtkCellRenderer *renderer_toggle = gtk_cell_renderer_toggle_new ();
    g_object_set (G_OBJECT (renderer_toggle), "activatable", FALSE, NULL); // No user action - value is just for display
    column_runner++;
    column = gtk_tree_view_column_new_with_attributes ( _("Within Current View"), renderer_toggle, "active", column_runner, NULL);
    gtk_tree_view_column_set_sort_column_id (column, column_runner);
    gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);

    gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
    gtk_tree_selection_set_mode( gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), GTK_SELECTION_MULTIPLE );
    g_object_unref(store);

    GtkWidget *scrolledwindow = gtk_scrolled_window_new ( NULL, NULL );
    gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
    gtk_container_add ( GTK_CONTAINER(scrolledwindow), view );

    gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), label, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), scrolledwindow, TRUE, TRUE, 0);

    // Ensure a reasonable number of items are shown, but let the width be automatically sized
    gtk_widget_set_size_request ( dialog, -1, 400) ;
    gtk_widget_show_all ( dialog );

    if ( response_w )
        gtk_widget_grab_focus ( response_w );

    while ( gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT ) {

        // Possibily not the fastest method but we don't have thousands of entries to process...
        GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
        GList *selected = NULL;

        //  because we don't store the full data in the gtk model, we have to scan & look it up
        if ( gtk_tree_model_get_iter_first( GTK_TREE_MODEL(store), &iter) ) {
            do {
                if ( gtk_tree_selection_iter_is_selected ( selection, &iter ) ) {
                    // For every selected item,
                    // compare the name from the displayed view to every gpx entry to find the gpx this selection represents
                    gchar* name;
                    gtk_tree_model_get (GTK_TREE_MODEL(store), &iter, 0, &name, -1 );
                    // I believe the name of these items to be always unique
                    list_runner = list;
                    while (list_runner) {
                        if ( !strcmp ( ((gpx_meta_data_t*)list_runner->data)->name, name ) ) {
                            gpx_meta_data_t *copied = copy_gpx_meta_data_t (list_runner->data);
                            selected = g_list_prepend (selected, copied);
                            break;
                        }
                        list_runner = g_list_next ( list_runner );
                    }
                }
            }
            while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL(store), &iter ) );
        }

        if ( selected ) {
            gtk_widget_destroy ( dialog );
            return selected;
        }
        a_dialog_error_msg(parent, _("Nothing was selected"));
    }
    gtk_widget_destroy ( dialog );
    return NULL;
}
示例#30
0
void
gui_init (dt_lib_module_t *self)
{
  dt_lib_styles_t *d = (dt_lib_styles_t *)malloc (sizeof (dt_lib_styles_t));
  self->data = (void *)d;
  d->edit_button = NULL;
  self->widget = gtk_vbox_new (FALSE, 5);
  GtkWidget *w;

  /* list */
  d->list = GTK_TREE_VIEW (gtk_tree_view_new ());
  gtk_tree_view_set_headers_visible(d->list,FALSE);
  GtkListStore *liststore = gtk_list_store_new (DT_STYLES_NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
  GtkTreeViewColumn *col = gtk_tree_view_column_new ();
  gtk_tree_view_append_column (GTK_TREE_VIEW (d->list), col);
  GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (col, renderer, TRUE);
  gtk_tree_view_column_add_attribute (col, renderer, "text", DT_STYLES_COL_NAME);

  int ht = get_font_height( GTK_WIDGET (d->list), "Dreggn");
  gtk_widget_set_size_request (GTK_WIDGET (d->list), -1, 5*ht);

  gtk_tree_selection_set_mode (gtk_tree_view_get_selection(GTK_TREE_VIEW(d->list)), GTK_SELECTION_SINGLE);
  gtk_tree_view_set_model (GTK_TREE_VIEW(d->list), GTK_TREE_MODEL(liststore));
  g_object_unref (liststore);

  g_object_set(G_OBJECT(d->list), "tooltip-text", _("available styles,\ndoubleclick to apply"), (char *)NULL);
  g_signal_connect (d->list, "row-activated", G_CALLBACK(_styles_row_activated_callback), d);

  /* filter entry */
  w = gtk_entry_new();
  d->entry=GTK_ENTRY(w);
  g_object_set(G_OBJECT(w), "tooltip-text", _("enter style name"), (char *)NULL);
  g_signal_connect (d->entry, "changed", G_CALLBACK(entry_callback),d);
  g_signal_connect (d->entry, "activate", G_CALLBACK(entry_activated),d);

  dt_gui_key_accel_block_on_focus ( GTK_WIDGET (d->entry));

  gtk_box_pack_start(GTK_BOX (self->widget),GTK_WIDGET (d->entry),TRUE,FALSE,0);
  gtk_box_pack_start(GTK_BOX (self->widget),GTK_WIDGET (d->list),TRUE,FALSE,0);

  GtkWidget *hbox=gtk_hbox_new (FALSE,5);

  GtkWidget *widget;

  d->duplicate = gtk_check_button_new_with_label(_("create duplicate"));
  gtk_box_pack_start(GTK_BOX (self->widget),GTK_WIDGET (d->duplicate),TRUE,FALSE,0);
  g_signal_connect (d->duplicate, "toggled", G_CALLBACK(duplicate_callback),d);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (d->duplicate), dt_conf_get_bool("ui_last/styles_create_duplicate"));
  g_object_set (d->duplicate, "tooltip-text", _("creates a duplicate of the image before applying style"), (char *)NULL);

#if 0
  // TODO: Unfinished stuff
  GtkWidget *widget=gtk_button_new_with_label(_("edit"));
  d->edit_button = widget;
  also add to the init function
  g_signal_connect (widget, "clicked", G_CALLBACK(edit_clicked),d);
  gtk_box_pack_start(GTK_BOX (hbox),widget,TRUE,TRUE,0);
#endif

  widget=gtk_button_new_with_label(_("delete"));
  d->delete_button = widget;
  g_signal_connect (widget, "clicked", G_CALLBACK(delete_clicked),d);
  g_object_set (widget, "tooltip-text", _("deletes the selected style in list above"), (char *)NULL);
  gtk_box_pack_start(GTK_BOX (hbox),widget,TRUE,TRUE,0);
  gtk_box_pack_start(GTK_BOX (self->widget),hbox,TRUE,FALSE,0);
  // Export Button
  GtkWidget *exportButton = gtk_button_new_with_label(_("export"));
  d->export_button = exportButton;
  g_object_set (exportButton, "tooltip-text", _("export the selected style into a style file"), (char *)NULL);
  g_signal_connect (exportButton, "clicked", G_CALLBACK(export_clicked),d);
  gtk_box_pack_start(GTK_BOX (hbox),exportButton,TRUE,TRUE,0);
  // Import Button
  GtkWidget *importButton = gtk_button_new_with_label(C_("styles", "import"));
  d->import_button = importButton;
  g_object_set (importButton, "tooltip-text", _("import style from a style file"), (char *)NULL);
  g_signal_connect (importButton, "clicked", G_CALLBACK(import_clicked),d);
  gtk_box_pack_start(GTK_BOX (hbox),importButton,TRUE,TRUE,0);
  // add entry completion
  GtkEntryCompletion *completion = gtk_entry_completion_new();
  gtk_entry_completion_set_model(completion, gtk_tree_view_get_model(GTK_TREE_VIEW(d->list)));
  gtk_entry_completion_set_text_column(completion, 0);
  gtk_entry_completion_set_inline_completion(completion, TRUE);
  gtk_entry_set_completion(d->entry, completion);

  /* update filtered list */
  _gui_styles_update_view(d);

}