static void
add_columns(GevoAddBuddyDialog *dialog)
{
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;

	/* Name column */
	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Name"));
	gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1);
	gtk_tree_view_column_set_sort_column_id(column, COLUMN_NAME);

	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_add_attribute(column, renderer,
									   "text", COLUMN_NAME);

	/* Account column */
	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Instant Messaging"));
	gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1);
	gtk_tree_view_column_set_sort_column_id(column, COLUMN_USERNAME);

	/* Protocol icon */
	renderer = gtk_cell_renderer_pixbuf_new();
	gtk_tree_view_column_pack_start(column, renderer, FALSE);
	gtk_tree_view_column_add_attribute(column, renderer,
									   "pixbuf", COLUMN_PRPL_ICON);

	/* Account name */
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_add_attribute(column, renderer,
									   "text", COLUMN_USERNAME);
}
Exemple #2
0
static void
move_to_right (GtkTreeIter  *src_iter,
	       GtkTreeModel *dest,
	       GtkTreeIter  *dest_iter)
{
  gchar *label;
  GtkTreeViewColumn *column;
  gint before = -1;

  gtk_tree_model_get (GTK_TREE_MODEL (left_tree_model),
		      src_iter, 0, &label, 1, &column, -1);
  gtk_list_store_remove (GTK_LIST_STORE (left_tree_model), src_iter);

  if (dest_iter)
    {
      GtkTreePath *path = gtk_tree_model_get_path (dest, dest_iter);
      before = (gtk_tree_path_get_indices (path))[0];
      gtk_tree_path_free (path);
    }
  
  if (dest == top_right_tree_model)
    gtk_tree_view_insert_column (GTK_TREE_VIEW (sample_tree_view_top), column, before);
  else
    gtk_tree_view_insert_column (GTK_TREE_VIEW (sample_tree_view_bottom), column, before);

  g_free (label);
}
Exemple #3
0
static void
move_up_or_down (GtkTreeModel *src,
		 GtkTreeIter  *src_iter,
		 GtkTreeModel *dest,
		 GtkTreeIter  *dest_iter)
{
  GtkTreeViewColumn *column;
  gchar *label;
  gint before = -1;
  
  gtk_tree_model_get (src, src_iter, 0, &label, 1, &column, -1);

  if (dest_iter)
    {
      GtkTreePath *path = gtk_tree_model_get_path (dest, dest_iter);
      before = (gtk_tree_path_get_indices (path))[0];
      gtk_tree_path_free (path);
    }
  
  if (src == top_right_tree_model)
    gtk_tree_view_remove_column (GTK_TREE_VIEW (sample_tree_view_top), column);
  else
    gtk_tree_view_remove_column (GTK_TREE_VIEW (sample_tree_view_bottom), column);

  if (dest == top_right_tree_model)
    gtk_tree_view_insert_column (GTK_TREE_VIEW (sample_tree_view_top), column, before);
  else
    gtk_tree_view_insert_column (GTK_TREE_VIEW (sample_tree_view_bottom), column, before);

  g_free (label);
}
static GtkWidget *
_gtk_user_list_dialog_create_tree(GtkWidget *widget)
{
	GtkWidget *tree;
	GtkListStore *store;
	GtkTreeModel *model;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;

	/* create treeview & model */
	tree = gtk_tree_view_new();
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE);
	gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), FALSE);

	store = gtk_list_store_new(3, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_STRING);
	model = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(store));
	gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), GTK_USER_LIST_TREEVIEW_COLUMN_USERNAME, GTK_SORT_ASCENDING);
	gtk_tree_view_set_model(GTK_TREE_VIEW(tree), model);

	/* insert column to display checkbox */
	column = gtk_tree_view_column_new();

	renderer = gtk_cell_renderer_toggle_new();
	gtk_cell_renderer_toggle_set_activatable(GTK_CELL_RENDERER_TOGGLE(renderer), TRUE);
	g_signal_connect(G_OBJECT(renderer), "toggled", (GCallback)_gtk_user_list_dialog_tree_checkbox_toggled, widget);
	gtk_tree_view_column_pack_start(column, renderer, FALSE);
	gtk_tree_view_column_add_attribute(column, renderer, "active", GTK_USER_LIST_TREEVIEW_COLUMN_CHECKBOX);

	gtk_tree_view_insert_column(GTK_TREE_VIEW(tree), column, -1);

	/* insert column to display icon & text */
	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, "User");

	renderer = gtk_cell_renderer_pixbuf_new();
	gtk_tree_view_column_pack_start(column, renderer, FALSE);
	gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", GTK_USER_LIST_TREEVIEW_COLUMN_PIXBUF);

	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_add_attribute(column, renderer, "text", GTK_USER_LIST_TREEVIEW_COLUMN_USERNAME);

	gtk_tree_view_insert_column(GTK_TREE_VIEW(tree), column, -1);

	/* free data */
	g_object_unref(store);
	g_object_unref(model);

	return tree;
}
static void
add_columns(GtkWidget *treeview, AccountsWindow *dialog)
{
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;

  /* Screen Name column */
  column = gtk_tree_view_column_new();
  gtk_tree_view_column_set_title(column, _("Screen Name"));
  gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
  gtk_tree_view_column_set_resizable(column, TRUE);

  /* Icon */
  renderer = gtk_cell_renderer_pixbuf_new();
  gtk_tree_view_column_pack_start(column, renderer, FALSE);
  gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", COLUMN_ICON);

  /* Screen Name */
  renderer = gtk_cell_renderer_text_new();
  gtk_tree_view_column_pack_start(column, renderer, TRUE);
  gtk_tree_view_column_add_attribute(column, renderer,
    "text", COLUMN_SCREENNAME);
  dialog->screenname_col = column;

  /* Enabled */
  renderer = gtk_cell_renderer_toggle_new();

  g_signal_connect(G_OBJECT(renderer), "toggled",
    G_CALLBACK(enabled_cb), dialog);

  column = 
    gtk_tree_view_column_new_with_attributes(_("AutoProfile sets user info"),
    renderer, "active", COLUMN_ENABLED, NULL);

  gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
  gtk_tree_view_column_set_resizable(column, TRUE);

  /* Protocol name */
  column = gtk_tree_view_column_new();
  gtk_tree_view_column_set_title(column, _("Protocol"));
  gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
  gtk_tree_view_column_set_resizable(column, TRUE);

  renderer = gtk_cell_renderer_text_new();
  gtk_tree_view_column_pack_start(column, renderer, TRUE);
  gtk_tree_view_column_add_attribute(column, renderer,
    "text", COLUMN_PROTOCOL);
}
Exemple #6
0
void
setup_treeview (GtkWidget    *treeview,
                GtkTreeModel *model,
                char         *headers[],
                int           render_index)
{
        GtkTreeSelection *selection;
        int i;

        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
        g_assert (selection != NULL);

        for (i = 0; headers[i] != NULL; i++) {
                GtkCellRenderer   *renderer;
                GtkTreeViewColumn *column;

                column = gtk_tree_view_column_new ();
                renderer = gtk_cell_renderer_text_new ();
                gtk_tree_view_column_pack_end (column, renderer, FALSE);
                gtk_tree_view_column_set_title (column, headers[i]);
                gtk_tree_view_column_add_attribute (column,
                                                    renderer,
                                                    "text", i + render_index);
                gtk_tree_view_column_set_sizing(column,
                                                GTK_TREE_VIEW_COLUMN_AUTOSIZE);

                gtk_tree_view_insert_column (GTK_TREE_VIEW (treeview),
                                             column,
                                             -1);
        }

        gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
                                 model);
        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
}
Exemple #7
0
void
glade_gtk_treeview_replace_child (GladeWidgetAdaptor * adaptor,
                                  GObject * container,
                                  GObject * current, GObject * new_column)
{
  GtkTreeView *view = GTK_TREE_VIEW (container);
  GList *columns;
  GtkTreeViewColumn *column;
  GladeWidget *gcolumn;
  gint index;

  if (!GTK_IS_TREE_VIEW_COLUMN (current))
    return;

  column = GTK_TREE_VIEW_COLUMN (current);

  columns = gtk_tree_view_get_columns (view);
  index = g_list_index (columns, column);
  g_list_free (columns);

  gtk_tree_view_remove_column (view, column);
  column = GTK_TREE_VIEW_COLUMN (new_column);

  gtk_tree_view_insert_column (view, column, index);

  if (gtk_tree_view_get_fixed_height_mode (view))
    {
      gcolumn = glade_widget_get_from_gobject (column);
      glade_widget_property_set (gcolumn, "sizing", GTK_TREE_VIEW_COLUMN_FIXED);
      glade_widget_property_set_sensitive (gcolumn, "sizing", FALSE,
                                           INSENSITIVE_COLUMN_SIZING_MSG);
    }

  glade_gtk_cell_layout_sync_attributes (G_OBJECT (column));
}
Exemple #8
0
static void list_set_columns(GtkTreeView *view, const std::vector<list_view_column> &columns) {
  for(unsigned int key = 0; key < columns.size(); key++) {
    const char *name = columns[key].name;
    int hlkey = columns[key].hlkey;
    int flags = columns[key].flags;

    GtkTreeViewColumn *column;

    if(flags & LIST_FLAG_STOCK_ICON) {
      GtkCellRenderer *pixbuf_renderer = gtk_cell_renderer_pixbuf_new();
      column = gtk_tree_view_column_new_with_attributes(name, pixbuf_renderer,
                                                        "stock_id", key, nullptr);
    } else {
      GtkCellRenderer *renderer = gtk_cell_renderer_text_new();

      if(flags & LIST_FLAG_CAN_HIGHLIGHT)
        g_object_set(renderer, "background", "red", nullptr );

      if(flags & LIST_FLAG_ELLIPSIZE)
        g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, nullptr);

      // if LIST_FLAG_CAN_HIGHLIGHT is not set this will be nullptr, so the function
      // will ignore the following int attribute anyway
      const char *hlattr = (flags & LIST_FLAG_CAN_HIGHLIGHT) ? "background-set" : nullptr;
      column = gtk_tree_view_column_new_with_attributes(name, renderer, "text", key,
                                                        hlattr, hlkey, nullptr);

      gtk_tree_view_column_set_expand(column,
                                      (flags & (LIST_FLAG_EXPAND | LIST_FLAG_ELLIPSIZE)) ? TRUE : FALSE);
    }

    gtk_tree_view_column_set_sort_column_id(column, key);
    gtk_tree_view_insert_column(view, column, -1);
  }
}
ZLGtkSelectionDialog::ZLGtkSelectionDialog(const char *caption, ZLTreeHandler &handler) : ZLSelectionDialog(handler) {
	myExitFlag = false;
	myNodeSelected = false;

	myDialog = createGtkDialog(caption);

	std::string okString = gtkButtonName(ZLDialogManager::OK_BUTTON);
	std::string cancelString = gtkButtonName(ZLDialogManager::CANCEL_BUTTON);
	gtk_dialog_add_button(myDialog, okString.c_str(), GTK_RESPONSE_ACCEPT);
	gtk_dialog_add_button(myDialog, cancelString.c_str(), GTK_RESPONSE_REJECT);

	myStateLine = GTK_ENTRY(gtk_entry_new());

	gtk_editable_set_editable(GTK_EDITABLE(myStateLine), !this->handler().isOpenHandler());
	gtk_widget_set_sensitive(GTK_WIDGET(myStateLine), !this->handler().isOpenHandler());

	gtk_box_pack_start(GTK_BOX(myDialog->vbox), GTK_WIDGET(myStateLine), false, false, 2);

	gtk_widget_show(GTK_WIDGET(myStateLine));

	myStore = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
	myView = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(myStore)));

	gtk_object_set_user_data(GTK_OBJECT(myView), this);
	gtk_tree_view_set_headers_visible(myView, false);

	GtkTreeSelection *selection = gtk_tree_view_get_selection(myView);

	gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);

	// MSS: in case we do not want single click navigation, comment out the line below
	g_signal_connect(myView, "button-press-event", G_CALLBACK(clickHandler), this);

	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;

	column = gtk_tree_view_column_new();
	gtk_tree_view_insert_column(myView, column, -1);
	gtk_tree_view_column_set_resizable(column, true);

	renderer = gtk_cell_renderer_pixbuf_new();
	gtk_tree_view_column_pack_start(column, renderer, false);
	gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", 0);

	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, renderer, true);
	gtk_tree_view_column_add_attribute(column, renderer, "text", 1);

	g_signal_connect(myView, "row-activated", G_CALLBACK(activatedHandler), 0);

	GtkWidget *scrolledWindow = gtk_scrolled_window_new(0, 0);
	gtk_container_add(GTK_CONTAINER(scrolledWindow), GTK_WIDGET(myView));
	gtk_box_pack_start(GTK_BOX(myDialog->vbox), scrolledWindow, true, true, 2);
	gtk_widget_show_all(scrolledWindow);

	gtk_widget_grab_focus(GTK_WIDGET(myView));
	gtk_window_resize(GTK_WINDOW(myDialog), 1000, 1000);

	update();
}
static void
tabu_playlist_init (TabuPlaylist *self)
{
  self->tree_view = gtk_tree_view_new ( );

	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (self->tree_view), FALSE);
	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (self->tree_view), TRUE);

	gtk_tree_selection_set_mode ( 
    GTK_TREE_SELECTION ( 
      gtk_tree_view_get_selection (GTK_TREE_VIEW (self->tree_view))), 
      GTK_SELECTION_SINGLE);

  self->cell_renderer = gtk_cell_renderer_text_new ();

  self->tree_view_column = gtk_tree_view_column_new_with_attributes(
    "",
    self->cell_renderer,
    "markup", 0,
    NULL );

  gtk_tree_view_insert_column (
    GTK_TREE_VIEW (self->tree_view), 
    self->tree_view_column, 
    -1);

  self->list_store = gtk_list_store_new ( 
    2, 
    G_TYPE_STRING, 
    G_TYPE_STRING );

  gtk_tree_view_set_model (
    GTK_TREE_VIEW (self->tree_view), 
    GTK_TREE_MODEL (self->list_store));  
/*
  g_signal_connect (
    G_OBJECT (self->tree_view), 
    "row-activated", 
    G_CALLBACK (playlist_row_activated_callback), 
    NULL);

  g_signal_connect ( 
    G_OBJECT (self->tree_view), 
    "key-press-event", 
    G_CALLBACK (playlist_key_press_callback), 
    NULL);
*/

	gtk_scrolled_window_set_policy (
    GTK_SCROLLED_WINDOW (self), 
    GTK_POLICY_AUTOMATIC, 
    GTK_POLICY_AUTOMATIC);

	gtk_container_add ( 
    GTK_CONTAINER ( GTK_SCROLLED_WINDOW (self)), 
    GTK_WIDGET (self->tree_view));

}
/** Hide expanders in the given GtkTreeView.
 *
 * @todo
 * This should be replaced by a gtk_tree_view_set_show_expanders when
 * we switch to GTK+ 2.12.
 *
 * @param view the given GtkTreeView
 */
static void hide_expanders(GtkTreeView * view)
{
    GtkTreeViewColumn * column;

    column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_visible(column, FALSE);
    gtk_tree_view_insert_column(view, column, -1 /* at the end */);
    gtk_tree_view_set_expander_column(view, column);
}
GtkTreeViewColumn *add_vector_to_dialog (vector_table_options_D *dialog, VectorTable *pvt, int idx)
  {
  GList *llItr = NULL, *llCols = NULL ;
  GtkTreeViewColumn *col = NULL ;
  GtkCellRenderer *cr = NULL ;
  int idxCol = (-1 == idx ? idx : idx + 2) ;
  int idxVector = (-1 == idx ? pvt->vectors->icUsed - 1 : idx) ;
  char *psz = NULL ;
  int Nix, new_idx = -1 ;

  if (idx >= 0)
    {
    // Move to the first vector column
    if (NULL != (llCols = llItr = gtk_tree_view_get_columns (GTK_TREE_VIEW (dialog->tv))))
      {
      if (NULL != (llItr = llItr->next))
        llItr = llItr->next ;
      // Increment the indices for all vector columns following the new one.
      for (Nix = 0 ; llItr != NULL ; llItr = llItr->next, Nix++)
        if (Nix >= idx)
          if (NULL != (cr = g_object_get_data (G_OBJECT (llItr->data), "cr")))
            {
            g_object_set_data (G_OBJECT (cr), "idxVector",
              (gpointer)(new_idx = (int)g_object_get_data (G_OBJECT (cr), "idxVector") + 1)) ;
            gtk_tree_view_column_set_title (GTK_TREE_VIEW_COLUMN (llItr->data), psz = g_strdup_printf ("%d", new_idx)) ;
            g_free (psz) ;
            }
      g_list_free (llCols) ;
      }
    }

  gtk_tree_view_insert_column (GTK_TREE_VIEW (dialog->tv), col = gtk_tree_view_column_new (), idxCol) ;
  gtk_tree_view_column_set_title (col, psz = g_strdup_printf ("%d", idxVector)) ;
  g_free (psz) ;
  gtk_tree_view_column_pack_start (col, cr = qcad_cell_renderer_vt_new (), FALSE) ;
  g_object_set (G_OBJECT (cr), 
    "cell-background-gdk", &((gtk_widget_get_style (dialog->tv))->base[3]),
    "cell-background-set", FALSE, 
    "editable", TRUE, NULL) ;
  gtk_tree_view_column_add_attribute (col, cr, "row-type", BUS_LAYOUT_MODEL_COLUMN_TYPE) ;
  gtk_tree_view_column_add_attribute (col, cr, "sensitive", VECTOR_TABLE_MODEL_COLUMN_ACTIVE) ;
  gtk_tree_view_column_set_clickable (col, TRUE) ;
  g_object_set_data (G_OBJECT (cr), "idxVector", (gpointer)idxVector) ;
  g_object_set_data (G_OBJECT (cr), "pvt", pvt) ;
  gtk_tree_view_column_set_cell_data_func (col, cr, vector_data_func, pvt, NULL) ;
  g_object_set_data (G_OBJECT (col), "cr", cr) ;
  g_object_set_data (G_OBJECT (cr), "col", col) ;

  g_signal_connect (G_OBJECT (col), "clicked", (GCallback)vector_column_clicked, dialog) ;
  g_signal_connect (G_OBJECT (cr), "clicked", (GCallback)vector_column_clicked, dialog) ;
  g_signal_connect (G_OBJECT (cr), "edited",  (GCallback)vector_value_edited, dialog->tv) ;
  g_signal_connect (G_OBJECT (cr), "editing-started", (GCallback)vector_value_editing_started, dialog) ;

  return col ;
  }
void gtk_assert_dialog_append_text_column (GtkWidget *treeview, const gchar *name, int index)
{
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;

    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes (name, renderer,
                                                       "text", index, NULL);
    gtk_tree_view_insert_column (GTK_TREE_VIEW (treeview), column, index);
    gtk_tree_view_column_set_resizable (column, TRUE);
    gtk_tree_view_column_set_reorderable (column, TRUE);
}
Exemple #14
0
static GtkWidget *create_blocks_list(void)
{
        GtkWidget *view, *scrolled;
        GtkTreeIter iter;
        GtkTreeViewColumn *column;
        GtkListStore *blocks_store;
        GtkCellRenderer *renderer;
        UnicodeBlock *block;

        /* Tree view */
        blocks_store = gtk_list_store_new(2, G_TYPE_BOOLEAN, G_TYPE_STRING);
        view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(blocks_store));
        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
        gtk_tooltips_set_tip(tooltips, view,
                             "Controls which blocks are enabled for "
                             "recognition and appear in the training mode "
                             "combo box.", NULL);

        /* Column */
        column = gtk_tree_view_column_new();
        gtk_tree_view_insert_column(GTK_TREE_VIEW(view), column, 0);
        renderer = gtk_cell_renderer_toggle_new();
        g_signal_connect(G_OBJECT(renderer), "toggled",
                         G_CALLBACK(unicode_block_toggled), blocks_store);
        gtk_tree_view_column_pack_start(column, renderer, FALSE);
        gtk_tree_view_column_add_attribute(column, renderer, "active", 0);
        renderer = gtk_cell_renderer_text_new();
        gtk_tree_view_column_pack_start(column, renderer, TRUE);
        gtk_tree_view_column_add_attribute(column, renderer, "text", 1);

        /* Fill blocks list */
        block = unicode_blocks;
        while (block->name) {
                gtk_list_store_append(blocks_store, &iter);
                gtk_list_store_set(blocks_store, &iter, 0, block->enabled,
                                   1, block->name, -1);
                block++;
        }

        /* Scrolled window */
        scrolled = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
                                            GTK_SHADOW_ETCHED_IN);
        gtk_container_add(GTK_CONTAINER(scrolled), view);

        return scrolled;
}
void
create_user_privileges_table (void)
{
	GtkWidget *list;
	GtkTreeModel *model, *filter_model;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeIter iter;

	list = gst_dialog_get_widget (tool->main_dialog, "user_privileges");

	model = GTK_TREE_MODEL (gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_OBJECT));
	filter_model = gtk_tree_model_filter_new (model, NULL);
	gtk_tree_view_set_model (GTK_TREE_VIEW (list), filter_model);
	g_object_unref (filter_model);
	g_object_unref (model);

	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), COL_DESCRIPTION, GTK_SORT_ASCENDING);
	gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter_model),
						privileges_table_visible_func,
						NULL, NULL);

	column = gtk_tree_view_column_new ();

	renderer = gtk_cell_renderer_toggle_new ();
	gtk_tree_view_column_pack_start (column, renderer, FALSE);
	gtk_tree_view_column_set_attributes (column,
					     renderer,
					     "active", COL_MEMBER,
					     NULL);
	g_signal_connect (G_OBJECT (renderer), "toggled",
			  G_CALLBACK (on_user_privilege_toggled), filter_model);

	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_end (column, renderer, TRUE);
	gtk_tree_view_column_set_attributes (column,
					     renderer,
					     "text", COL_DESCRIPTION,
					     NULL);

	gtk_tree_view_column_set_sort_column_id (column, 1);
	gtk_tree_view_insert_column (GTK_TREE_VIEW (list), column, 0);
}
Exemple #16
0
static int add_playlist_page(struct playlist *playlist, const char *title)
{
	struct playlist_ui_ctx *ctx = get_playlist_ui_ctx(playlist);

	struct playlist_page *page = NEW(struct playlist_page);
	if (page == NULL)
		return -1;
	page->playlist = playlist;

	page->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ctx->store));
	gtk_tree_selection_set_mode(
		gtk_tree_view_get_selection(GTK_TREE_VIEW(page->view)),
		GTK_SELECTION_MULTIPLE);
	g_signal_connect(G_OBJECT(page->view), "row-activated", G_CALLBACK(playlist_clicked), NULL);

	/* song name column */
	GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
	g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(
		"Name", renderer, "text", COL_NAME,
		"foreground", COL_COLOR, NULL);
	gtk_tree_view_column_set_expand(column, true);
	gtk_tree_view_insert_column(GTK_TREE_VIEW(page->view), column, -1);

	/* song length column */
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(page->view),
		-1, "Length", renderer, "text", COL_LENGTH,
		"foreground", COL_COLOR, NULL);

	page->page = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(page->page),
		GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(page->page), page->view);

	gtk_widget_show_all(page->page);

	int idx = gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page->page,
					   gtk_label_new(title));
	pages[idx] = page;
	return idx;
}
static void
add_columns (GtkTreeView *treeview)
{
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;

	column = gtk_tree_view_column_new ();

	/* Checkbox */
	renderer = gtk_cell_renderer_toggle_new ();

	g_signal_connect (G_OBJECT (renderer), "toggled",
			  G_CALLBACK (on_service_toggled), tool);

	g_object_set (G_OBJECT (renderer), "xpad", 12, NULL);

	gtk_tree_view_insert_column_with_attributes (treeview,
						     -1, "",
						     renderer,
						     "active", COL_ACTIVE,
						     NULL);
	/* Image */
	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_tree_view_column_pack_start (column, renderer, FALSE);
	gtk_tree_view_column_set_attributes (column, renderer,
					     "pixbuf", COL_IMAGE,
					     NULL);

	/* Text */
	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, renderer, TRUE);
	gtk_tree_view_column_set_attributes (column, renderer,
					     "markup", COL_DESC,
					     NULL);

	g_object_set (G_OBJECT (renderer), "yalign", 0, NULL);
	gtk_tree_view_insert_column (treeview, column, -1);

	gtk_tree_view_column_set_sort_column_id (column, 1);
	gtk_tree_view_column_clicked (column);
}
Exemple #18
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();
}
Exemple #19
0
static void apply_window_insert_check_column(GtkWidget *list_view)
{
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;

	renderer = gtk_cell_renderer_toggle_new();
	g_object_set(renderer,
		     "radio", FALSE,
		     "activatable", TRUE,
		     NULL);
	column = gtk_tree_view_column_new_with_attributes
		("",
		 renderer,
		 "active", TAG_SELECTED,
		 "inconsistent", TAG_SELECTED_INCONSISTENT,
		 NULL);
	gtk_tree_view_column_set_alignment (column, 0.5);
	gtk_tree_view_insert_column(GTK_TREE_VIEW(list_view), column, 0);		
	g_signal_connect(G_OBJECT(renderer), "toggled",
			 G_CALLBACK(tag_apply_selected_toggled),
			 list_view);
}
Exemple #20
0
void
glade_gtk_treeview_set_child_property (GladeWidgetAdaptor * adaptor,
                                       GObject * container,
                                       GObject * child,
                                       const gchar * property_name,
                                       const GValue * value)
{
  if (strcmp (property_name, "position") == 0)
    {

      gtk_tree_view_remove_column (GTK_TREE_VIEW (container),
                                   GTK_TREE_VIEW_COLUMN (child));
      gtk_tree_view_insert_column (GTK_TREE_VIEW (container),
                                   GTK_TREE_VIEW_COLUMN (child),
                                   g_value_get_int (value));
    }
  else
    /* Chain Up */
    GWA_GET_CLASS
        (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
                                                  container, child,
                                                  property_name, value);
}
static void
set_up (EmpathyIndividualLinker *self)
{
  EmpathyIndividualLinkerPriv *priv;
  EmpathyIndividualManager *individual_manager;
  GtkWidget *top_vbox;
  GtkPaned *paned;
  GtkWidget *label, *scrolled_window;
  GtkBox *vbox;
  EmpathyPersonaView *persona_view;
  gchar *tmp;
  GtkWidget *alignment;

  priv = GET_PRIV (self);

  top_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);

  /* Layout panes */

  paned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL));

  /* Left column heading */
  alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 0, 6);
  gtk_widget_show (alignment);

  vbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 6));
  label = gtk_label_new (NULL);
  tmp = g_strdup_printf ("<b>%s</b>", _("Select contacts to link"));
  gtk_label_set_markup (GTK_LABEL (label), tmp);
  g_free (tmp);
  gtk_box_pack_start (vbox, label, FALSE, TRUE, 0);
  gtk_widget_show (label);

  /* Individual selector */
  individual_manager = empathy_individual_manager_dup_singleton ();
  priv->individual_store = EMPATHY_INDIVIDUAL_STORE (
      empathy_individual_store_manager_new (individual_manager));
  g_object_unref (individual_manager);

  empathy_individual_store_set_show_protocols (priv->individual_store, FALSE);

  priv->individual_view = empathy_individual_view_new (priv->individual_store,
      EMPATHY_INDIVIDUAL_VIEW_FEATURE_INDIVIDUAL_DRAG |
      EMPATHY_INDIVIDUAL_VIEW_FEATURE_INDIVIDUAL_DROP |
      EMPATHY_INDIVIDUAL_VIEW_FEATURE_PERSONA_DROP,
      EMPATHY_INDIVIDUAL_FEATURE_NONE);
  empathy_individual_view_set_show_offline (priv->individual_view, TRUE);
  empathy_individual_view_set_show_untrusted (priv->individual_view, FALSE);

  g_signal_connect (priv->individual_view, "row-activated",
      (GCallback) row_activated_cb, self);
  g_signal_connect (priv->individual_view, "drag-motion",
      (GCallback) individual_view_drag_motion_cb, self);
  g_signal_connect (priv->individual_view, "drag-persona-received",
      (GCallback) individual_view_drag_persona_received_cb, self);

  /* Add a checkbox column to the selector */
  priv->toggle_renderer = gtk_cell_renderer_toggle_new ();
  g_signal_connect (priv->toggle_renderer, "toggled",
      (GCallback) row_toggled_cb, self);

  priv->toggle_column = gtk_tree_view_column_new ();
  gtk_tree_view_column_pack_start (priv->toggle_column, priv->toggle_renderer,
      FALSE);
  gtk_tree_view_column_set_cell_data_func (priv->toggle_column,
      priv->toggle_renderer,
      (GtkTreeCellDataFunc) contact_toggle_cell_data_func, self, NULL);

  gtk_tree_view_insert_column (GTK_TREE_VIEW (priv->individual_view),
      priv->toggle_column, 0);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
      GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
      GTK_SHADOW_IN);
  gtk_container_add (GTK_CONTAINER (scrolled_window),
      GTK_WIDGET (priv->individual_view));
  gtk_widget_show (GTK_WIDGET (priv->individual_view));

  gtk_box_pack_start (vbox, scrolled_window, TRUE, TRUE, 0);
  gtk_widget_show (scrolled_window);

  /* Live search */
  priv->search_widget = empathy_live_search_new (
      GTK_WIDGET (priv->individual_view));
  empathy_individual_view_set_live_search (priv->individual_view,
      EMPATHY_LIVE_SEARCH (priv->search_widget));

  gtk_box_pack_end (vbox, priv->search_widget, FALSE, TRUE, 0);

  gtk_container_add (GTK_CONTAINER (alignment), GTK_WIDGET (vbox));
  gtk_paned_pack1 (paned, alignment, TRUE, FALSE);
  gtk_widget_show (GTK_WIDGET (vbox));

  /* Right column heading */
  alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 6, 0);
  gtk_widget_show (alignment);

  vbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 6));
  label = gtk_label_new (NULL);
  tmp = g_strdup_printf ("<b>%s</b>", _("New contact preview"));
  gtk_label_set_markup (GTK_LABEL (label), tmp);
  g_free (tmp);
  gtk_box_pack_start (vbox, label, FALSE, TRUE, 0);
  gtk_widget_show (label);

  /* New individual preview */
  priv->preview_widget = empathy_individual_widget_new (priv->new_individual,
      EMPATHY_INDIVIDUAL_WIDGET_SHOW_DETAILS);
  gtk_box_pack_start (vbox, priv->preview_widget, FALSE, TRUE, 0);
  gtk_widget_show (priv->preview_widget);

  /* Persona list */
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
      GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
      GTK_SHADOW_IN);

  priv->persona_store = empathy_persona_store_new (priv->new_individual);
  empathy_persona_store_set_show_protocols (priv->persona_store, TRUE);
  persona_view = empathy_persona_view_new (priv->persona_store,
      EMPATHY_PERSONA_VIEW_FEATURE_ALL);
  empathy_persona_view_set_show_offline (persona_view, TRUE);

  g_signal_connect (persona_view, "drag-individual-received",
      (GCallback) persona_view_drag_individual_received_cb, self);

  gtk_container_add (GTK_CONTAINER (scrolled_window),
      GTK_WIDGET (persona_view));
  gtk_widget_show (GTK_WIDGET (persona_view));

  gtk_box_pack_start (vbox, scrolled_window, TRUE, TRUE, 0);
  gtk_widget_show (scrolled_window);

  gtk_container_add (GTK_CONTAINER (alignment), GTK_WIDGET (vbox));
  gtk_paned_pack2 (paned, alignment, TRUE, FALSE);
  gtk_widget_show (GTK_WIDGET (vbox));

  gtk_widget_show (GTK_WIDGET (paned));

  /* Footer label */
  label = gtk_label_new (NULL);
  tmp = g_strdup_printf ("<i>%s</i>",
      _("Contacts selected in the list on the left will be linked together."));
  gtk_label_set_markup (GTK_LABEL (label), tmp);
  g_free (tmp);
  gtk_widget_show (label);

  gtk_box_pack_start (GTK_BOX (top_vbox), GTK_WIDGET (paned), TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (top_vbox), label, FALSE, TRUE, 0);

  /* Add the main vbox to the bin */
  gtk_box_pack_start (GTK_BOX (self), GTK_WIDGET (top_vbox), TRUE, TRUE, 0);
  gtk_widget_show (GTK_WIDGET (top_vbox));
}
Exemple #22
0
static void
ft_manager_build_ui (EmpathyFTManager *manager)
{
  GtkBuilder *gui;
  GtkTreeView *view;
  GtkListStore *liststore;
  GtkTreeViewColumn *column;
  GtkCellRenderer *renderer;
  GtkTreeSelection *selection;
  gchar *filename;
  EmpathyFTManagerPriv *priv = GET_PRIV (manager);

  filename = empathy_file_lookup ("empathy-ft-manager.ui", "src");
  gui = tpaw_builder_get_file (filename,
      "ft_manager_dialog", &priv->window,
      "ft_list", &priv->treeview,
      "clear_button", &priv->clear_button,
      "open_button", &priv->open_button,
      "abort_button", &priv->abort_button,
      NULL);
  g_free (filename);

  tpaw_builder_connect (gui, manager,
      "ft_manager_dialog", "destroy", ft_manager_destroy_cb,
      "ft_manager_dialog", "response", ft_manager_response_cb,
      "ft_manager_dialog", "delete-event", ft_manager_delete_event_cb,
      "ft_manager_dialog", "key-press-event", ft_manager_key_press_event_cb,
      NULL);

  tpaw_builder_unref_and_keep_widget (gui, priv->window);

  /* Window geometry. */
  empathy_geometry_bind (GTK_WINDOW (priv->window), "ft-manager");

  /* Setup the tree view */
  view = GTK_TREE_VIEW (priv->treeview);
  selection = gtk_tree_view_get_selection (view);
  gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
  g_signal_connect (selection, "changed",
      G_CALLBACK (ft_manager_selection_changed), manager);
  g_signal_connect (view, "button-press-event",
                    G_CALLBACK (ft_view_button_press_event_cb),
                    manager);
  gtk_tree_view_set_headers_visible (view, TRUE);
  gtk_tree_view_set_enable_search (view, FALSE);

  /* Setup the model */
  liststore = gtk_list_store_new (5,
      G_TYPE_INT,     /* percent */
      G_TYPE_ICON,    /* icon */
      G_TYPE_STRING,  /* message */
      G_TYPE_STRING,  /* remaining */
      G_TYPE_OBJECT); /* ft_handler */
  gtk_tree_view_set_model (view, GTK_TREE_MODEL (liststore));
  priv->model = GTK_TREE_MODEL (liststore);
  g_object_unref (liststore);

  /* Progress column */
  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("%"));
  gtk_tree_view_column_set_sort_column_id (column, COL_PERCENT);
  gtk_tree_view_insert_column (view, column, -1);

  renderer = gtk_cell_renderer_progress_new ();
  g_object_set (renderer, "xalign", 0.5, NULL);
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_cell_data_func (column, renderer,
      ft_manager_progress_cell_data_func, NULL, NULL);

  /* Icon and filename column*/
  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("File"));
  gtk_tree_view_column_set_expand (column, TRUE);
  gtk_tree_view_column_set_resizable (column, TRUE);
  gtk_tree_view_column_set_sort_column_id (column, COL_MESSAGE);
  gtk_tree_view_column_set_spacing (column, 3);
  gtk_tree_view_insert_column (view, column, -1);

  renderer = gtk_cell_renderer_pixbuf_new ();
  g_object_set (renderer, "xpad", 3,
      "stock-size", GTK_ICON_SIZE_DND, NULL);
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_attributes (column, renderer,
      "gicon", COL_ICON, NULL);

  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
  gtk_tree_view_column_pack_start (column, renderer, TRUE);
  gtk_tree_view_column_set_attributes (column, renderer,
      "text", COL_MESSAGE, NULL);

  /* Remaining time column */
  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("Remaining"));
  gtk_tree_view_column_set_sort_column_id (column, COL_REMAINING);
  gtk_tree_view_insert_column (view, column, -1);

  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer, "xalign", 0.5, NULL);
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_attributes (column, renderer,
      "text", COL_REMAINING, NULL);

  /* clear button should be sensitive only if there are completed/cancelled
   * handlers in the store.
   */
  gtk_widget_set_sensitive (priv->clear_button, FALSE);
}
Exemple #23
0
GtkWidget *
gimp_tool_view_new (GimpViewType     view_type,
                    GimpContainer   *container,
                    GimpContext     *context,
                    gint             view_size,
                    gint             view_border_width,
                    GimpMenuFactory *menu_factory)
{
  GimpToolView        *tool_view;
  GimpContainerEditor *editor;

  tool_view = g_object_new (GIMP_TYPE_TOOL_VIEW, NULL);

  if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (tool_view),
                                         view_type,
                                         container, context,
                                         view_size, view_border_width,
                                         menu_factory, "<Tools>",
                                         "/tools-popup"))
    {
      g_object_unref (tool_view);
      return NULL;
    }

  editor = GIMP_CONTAINER_EDITOR (tool_view);

  tool_view->raise_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools",
                                   "tools-raise",
                                   "tools-raise-to-top", GDK_SHIFT_MASK,
                                   NULL);

  tool_view->lower_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools",
                                   "tools-lower",
                                   "tools-lower-to-bottom", GDK_SHIFT_MASK,
                                    NULL);

  tool_view->reset_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools",
                                   "tools-reset", NULL);

  if (view_type == GIMP_VIEW_TYPE_LIST)
    {
      GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (editor->view);
      GtkWidget             *tree_widget = GTK_WIDGET (tree_view);
      GtkTreeViewColumn     *column;
      GtkCellRenderer       *eye_cell;
      GtkIconSize            icon_size;

      column = gtk_tree_view_column_new ();
      gtk_tree_view_insert_column (tree_view->view, column, 0);

      eye_cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_VISIBLE);

      icon_size = gimp_get_icon_size (GTK_WIDGET (tree_view),
                                      GIMP_STOCK_VISIBLE,
                                      GTK_ICON_SIZE_BUTTON,
                                      view_size -
                                      2 * tree_widget->style->xthickness,
                                      view_size -
                                      2 * tree_widget->style->ythickness);
      g_object_set (eye_cell, "stock-size", icon_size, NULL);

      gtk_tree_view_column_pack_start (column, eye_cell, FALSE);
      gtk_tree_view_column_set_cell_data_func  (column, eye_cell,
                                                gimp_tool_view_eye_data_func,
                                                tree_view,
                                                NULL);

      tree_view->toggle_cells = g_list_prepend (tree_view->toggle_cells,
                                                eye_cell);

      g_signal_connect (eye_cell, "clicked",
                        G_CALLBACK (gimp_tool_view_eye_clicked),
                        tree_view);

      tool_view->visible_handler_id =
        gimp_container_add_handler (container, "notify::visible",
                                    G_CALLBACK (gimp_tool_view_visible_notify),
                                    tree_view);
    }

  gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor);

  return GTK_WIDGET (tool_view);
}
Exemple #24
0
static void setup_view(GtkWidget* view)
{
    GtkListStore* store = gtk_list_store_new (23,
    G_TYPE_STRING,   /* 0 Country */
    G_TYPE_STRING,   /* 1 Good Name */
    GDK_TYPE_PIXBUF, /* 2 NULL for Status handle / empty */
    G_TYPE_STRING,   /* 3 User Comments */
    G_TYPE_STRING,   /* 4 File Name */
    G_TYPE_STRING,   /* 5 MD5 Hash */
    G_TYPE_STRING,   /* 6 CRC1 */
    G_TYPE_STRING,   /* 7 CRC2 */
    G_TYPE_STRING,   /* 8 Internal Name */
    G_TYPE_STRING,   /* 9 Save Type */
    G_TYPE_STRING,   /* 10 Players */
    G_TYPE_STRING,   /* 11 Size */
    G_TYPE_STRING,   /* 12 Compression */
    G_TYPE_STRING,   /* 13 Image Type */
    G_TYPE_STRING,   /* 14 CIC Chip */
    G_TYPE_STRING,   /* 15 Rumble */
    GDK_TYPE_PIXBUF, /* 16-20 Pixbufs for Status stars. */
    GDK_TYPE_PIXBUF,
    GDK_TYPE_PIXBUF,
    GDK_TYPE_PIXBUF,
    GDK_TYPE_PIXBUF,
    GDK_TYPE_PIXBUF, /* 21 Flag */
    G_TYPE_POINTER,  /* 22 RCS Entry */
    -1);

    GtkCellRenderer* renderer;
    GtkTreeViewColumn* column;
    GtkWidget* item;
    char buffer[128];
    int i;
    unsigned char visible;

    /* Create country flag / string dual rendered cell. */
    renderer = gtk_cell_renderer_pixbuf_new();
    g_MainWindow.column[0] = gtk_tree_view_column_new();
    column = g_MainWindow.column[0];
    gtk_tree_view_column_set_title(column, g_MainWindow.column_names[0][0]); 
    gtk_tree_view_column_pack_start(column, renderer, FALSE);
    gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", 21);
    g_object_set(renderer, "xpad", 5, NULL);
    renderer = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start(column, renderer, TRUE);
    gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_reorderable(column, TRUE);
    gtk_tree_view_column_set_sort_column_id(column, 0);
    gtk_tree_view_insert_column(GTK_TREE_VIEW (view), column, 0);
    g_signal_connect(column->button, "button-press-event", G_CALLBACK(callback_header_clicked), column);

    renderer = gtk_cell_renderer_text_new();
    g_MainWindow.column[1] = gtk_tree_view_column_new_with_attributes(g_MainWindow.column_names[1][0], renderer, "text", 1, NULL);
    column = g_MainWindow.column[1];
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_reorderable(column, TRUE);
    gtk_tree_view_column_set_sort_column_id(column, 1);
    gtk_tree_view_insert_column(GTK_TREE_VIEW (view), column, 1);
    g_signal_connect(column->button, "button-press-event", G_CALLBACK(callback_header_clicked), column);

    /* Status stars. */
    g_MainWindow.column[2] = gtk_tree_view_column_new();
    column = g_MainWindow.column[2];
    gtk_tree_view_column_set_title(column, g_MainWindow.column_names[2][0]); 
    renderer = gtk_cell_renderer_pixbuf_new();
    g_object_set(renderer, "xpad", 2, NULL);
    gtk_tree_view_column_pack_start(column, renderer, FALSE);
    gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", 2);
    for(i = 0; i < 5; ++i)
        {
        renderer = gtk_cell_renderer_pixbuf_new();
        gtk_tree_view_column_pack_start(column, renderer, FALSE);
        gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", 16+i);
        }
    renderer = gtk_cell_renderer_pixbuf_new();
    g_object_set(renderer, "xpad", 2, NULL);
    gtk_tree_view_column_pack_start(column, renderer, FALSE);
    gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", 2);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_reorderable(column, TRUE);
    gtk_tree_view_column_set_sort_column_id(column, 2);
    gtk_tree_view_insert_column(GTK_TREE_VIEW (view), column, 2);
    g_signal_connect(column->button, "button-press-event", G_CALLBACK(callback_header_clicked), column);

    for(i = 3; i < 16; ++i)
        {
        renderer = gtk_cell_renderer_text_new();
        g_MainWindow.column[i] = gtk_tree_view_column_new_with_attributes(g_MainWindow.column_names[i][0], renderer, "text", i, NULL);
        column = g_MainWindow.column[i];
        gtk_tree_view_column_set_resizable(column, TRUE);
        gtk_tree_view_column_set_reorderable(column, TRUE);
        gtk_tree_view_column_set_sort_column_id(column, i);
        gtk_tree_view_insert_column(GTK_TREE_VIEW (view), column, i);
        g_signal_connect(column->button, "button-press-event", G_CALLBACK(callback_header_clicked), column);
        }

    renderer = gtk_cell_renderer_text_new ();
    g_MainWindow.column[16] = gtk_tree_view_column_new();
    column = g_MainWindow.column[16];
    gtk_tree_view_column_set_visible(column, FALSE);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(view), column, 2);
    g_signal_connect(column->button, "button-press-event", G_CALLBACK(callback_header_clicked), column);

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

    g_MainWindow.romHeaderMenu = gtk_menu_new();

    /* Toggle column visibility from config file, make menu. */
    for(i = 0; i < 16; ++i)
        {
        snprintf(buffer, sizeof(buffer), " %s", g_MainWindow.column_names[i][0]);
        item = gtk_check_menu_item_new_with_mnemonic(buffer); 
        if((visible=config_get_bool(g_MainWindow.column_names[i][1], 2))==2)
             {
             visible = (i<5) ? TRUE: FALSE;
             config_put_bool(g_MainWindow.column_names[i][1], visible);
             }
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), visible); 
        gtk_tree_view_column_set_visible(g_MainWindow.column[i], visible);
        gtk_menu_shell_append(GTK_MENU_SHELL(g_MainWindow.romHeaderMenu), item);
        g_signal_connect(item, "activate", G_CALLBACK(callback_column_visible), GUINT_TO_POINTER(i));
        }

    gtk_tree_view_column_set_visible(g_MainWindow.column[16], FALSE);
    for(i = 0; i < 16; ++i)
        {
        if(gtk_tree_view_column_get_visible(GTK_TREE_VIEW_COLUMN(g_MainWindow.column[i])))
            return;
        }
    gtk_tree_view_column_set_visible(g_MainWindow.column[16], TRUE);
}
static void
bt_settings_page_interaction_controller_init_ui (const
    BtSettingsPageInteractionController * self, GtkWidget * pages)
{
  GtkWidget *label, *widget, *scrolled_window;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *tree_col;
  GtkTreeSelection *tree_sel;
  BtIcRegistry *ic_registry;
  gchar *str;

  gtk_widget_set_name (GTK_WIDGET (self), "interaction controller settings");

  // create the widget already so that we can set the initial text
  self->priv->message = GTK_LABEL (gtk_label_new (NULL));
  g_object_set (GTK_WIDGET (self->priv->message), "hexpand", TRUE, NULL);

  // add setting widgets
  label = gtk_label_new (NULL);
  str = g_strdup_printf ("<big><b>%s</b></big>", _("Interaction Controller"));
  gtk_label_set_markup (GTK_LABEL (label), str);
  g_free (str);
  g_object_set (label, "xalign", 0.0, NULL);
  gtk_grid_attach (GTK_GRID (self), label, 0, 0, 3, 1);
  gtk_grid_attach (GTK_GRID (self), gtk_label_new ("    "), 0, 1, 1, 3);

  label = gtk_label_new (_("Device"));
  g_object_set (label, "xalign", 1.0, NULL);
  gtk_grid_attach (GTK_GRID (self), label, 1, 1, 1, 1);

  widget = gtk_combo_box_new ();
  self->priv->device_menu = GTK_COMBO_BOX (widget);
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_renderer_set_fixed_size (renderer, 1, -1);
  gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT
      (renderer), 1);
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self->priv->device_menu),
      renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self->priv->device_menu),
      renderer, "text", DEVICE_MENU_LABEL, NULL);

  // get list of devices from libbtic and listen to changes
  g_object_get (self->priv->app, "ic-registry", &ic_registry, NULL);
  g_signal_connect_object (ic_registry, "notify::devices",
      G_CALLBACK (on_ic_registry_devices_changed), (gpointer) self, 0);
  g_object_unref (ic_registry);
  g_object_set (widget, "hexpand", TRUE, "margin-left", LABEL_PADDING, NULL);
  gtk_grid_attach (GTK_GRID (self), widget, 2, 1, 1, 1);
  g_signal_connect (widget, "changed",
      G_CALLBACK (on_device_menu_changed), (gpointer) self);

  // add list of controllers (updated when selecting a device)
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
      GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
      GTK_SHADOW_ETCHED_IN);
  self->priv->controller_list = GTK_TREE_VIEW (gtk_tree_view_new ());
  g_object_set (self->priv->controller_list,
      "enable-search", FALSE, "rules-hint", TRUE, NULL);

  // have this first as the last column gets the remaining space (always :/)
  renderer = gtk_cell_renderer_toggle_new ();
  gtk_tree_view_insert_column_with_attributes (self->priv->controller_list, -1,
      _("In use"), renderer, "active", CONTROLLER_LIST_USED, NULL);

  self->priv->id_renderer = renderer = gtk_cell_renderer_text_new ();
  //gtk_cell_renderer_set_fixed_size (renderer, 1, -1);
  gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT
      (renderer), 1);
  g_signal_connect (renderer, "edited", G_CALLBACK (on_control_name_edited),
      (gpointer) self);
  if ((tree_col =
          gtk_tree_view_column_new_with_attributes (_("Controller"), renderer,
              "text", CONTROLLER_LIST_LABEL, NULL))
      ) {
    g_object_set (tree_col, "expand", TRUE, NULL);
    gtk_tree_view_insert_column (self->priv->controller_list, tree_col, -1);
  } else
    GST_WARNING ("can't create treeview column");

  tree_sel = gtk_tree_view_get_selection (self->priv->controller_list);
  gtk_tree_selection_set_mode (tree_sel, GTK_SELECTION_BROWSE);
  g_signal_connect (tree_sel, "changed", G_CALLBACK (on_control_selected),
      (gpointer) self);

  gtk_container_add (GTK_CONTAINER (scrolled_window),
      GTK_WIDGET (self->priv->controller_list));
  g_object_set (GTK_WIDGET (scrolled_window), "hexpand", TRUE, "vexpand", TRUE,
      "margin-left", LABEL_PADDING, NULL);
  gtk_grid_attach (GTK_GRID (self), GTK_WIDGET (scrolled_window), 1, 2, 2, 1);

  // add a message pane
#if ! defined(USE_GUDEV) && ! defined(USE_ALSA)
  gtk_label_set_text (self->priv->message,
      _("This package has been built without GUdev and Alsa support and thus "
          "supports no interaction controllers."));
#endif
  gtk_grid_attach (GTK_GRID (self), GTK_WIDGET (self->priv->message), 0, 3, 3,
      1);

  // listen to page changes
  g_signal_connect ((gpointer) pages, "notify::page",
      G_CALLBACK (on_page_switched), (gpointer) self);

  // initial refresh
  on_ic_registry_devices_changed (ic_registry, NULL, (gpointer) self);
}
Exemple #26
0
static gchar   *select_module()
{
    GtkWidget      *dialog;     /* the dialog window */
    GtkWidget      *modlist;    /* the treeview widget */
    GtkListStore   *liststore;  /* the list store data structure */
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;
    GtkTreeIter     item;       /* new item added to the list store */
    GtkTreeSelection *selection;
    GtkTreeModel   *selmod;
    GtkTreeModel   *listtreemodel;
    GtkWidget      *swin;
    GDir           *dir = NULL; /* directory handle */
    GError         *error = NULL;       /* error flag and info */
    gchar          *dirname;    /* directory name */
    const gchar    *filename;   /* file name */
    gchar         **buffv;
    guint           count = 0;

    /* create and fill data model */
    liststore = gtk_list_store_new(1, G_TYPE_STRING);

    /* scan for .mod files in the user config directory and
       add the contents of each .mod file to the list store
     */
    dirname = get_modules_dir();
    dir = g_dir_open(dirname, 0, &error);

    if (dir)
    {
        sat_log_log(SAT_LOG_LEVEL_DEBUG,
                    _("%s:%s: Scanning directory %s for modules."),
                    __FILE__, __func__, dirname);

        while ((filename = g_dir_read_name(dir)))
        {
            if (g_str_has_suffix(filename, ".mod"))
            {
                /* strip extension and add to list */
                buffv = g_strsplit(filename, ".mod", 0);

                gtk_list_store_append(liststore, &item);
                gtk_list_store_set(liststore, &item, 0, buffv[0], -1);

                g_strfreev(buffv);

                count++;
            }
        }
    }
    else
    {
        sat_log_log(SAT_LOG_LEVEL_ERROR,
                    _("%s:%d: Failed to open module dir %s (%s)"),
                    __FILE__, __LINE__, dirname, error->message);
        g_clear_error(&error);
    }

    g_free(dirname);
    g_dir_close(dir);

    if (count < 1)
    {
        /* tell user that there are no modules, try "New" instead */
        dialog = gtk_message_dialog_new(GTK_WINDOW(app),
                                        GTK_DIALOG_MODAL |
                                        GTK_DIALOG_DESTROY_WITH_PARENT,
                                        GTK_MESSAGE_INFO,
                                        GTK_BUTTONS_OK,
                                        _("You do not have any modules "
                                          "set up yet. Please use File->New "
                                          "in order to create a module."));

        gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_destroy(dialog);

        return NULL;
    }

    /* create tree view */
    modlist = gtk_tree_view_new();
    listtreemodel = GTK_TREE_MODEL(liststore);
    gtk_tree_view_set_model(GTK_TREE_VIEW(modlist), listtreemodel);
    g_object_unref(liststore);
    /* connecting row activated signal postponed so that we can attach dialog window */

    swin = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    /* sort the tree by name */
    gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(listtreemodel), 0,
                                    compare_func, NULL, NULL);
    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(listtreemodel),
                                         0, GTK_SORT_ASCENDING);

    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("Module"), renderer,
                                                      "text", 0, NULL);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(modlist), column, -1);
    gtk_widget_show(modlist);

    /* create dialog */
    dialog = gtk_dialog_new_with_buttons(_("Select a module"),
                                         GTK_WINDOW(app),
                                         GTK_DIALOG_MODAL |
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
                                         "_Cancel", GTK_RESPONSE_CANCEL,
                                         "_OK", GTK_RESPONSE_OK, NULL);

    gtk_window_set_default_size(GTK_WINDOW(dialog), -1, 200);
    gtk_container_add(GTK_CONTAINER(swin), modlist);
    gtk_widget_show(swin);
    gtk_box_pack_start(GTK_BOX
                       (gtk_dialog_get_content_area(GTK_DIALOG(dialog))), swin,
                       TRUE, TRUE, 0);

    /* double clicking in list will open clicked module */
    g_signal_connect(modlist, "row-activated",
                     G_CALLBACK(select_module_row_activated_cb), dialog);

    switch (gtk_dialog_run(GTK_DIALOG(dialog)))
    {
        /* user pressed OK */
    case GTK_RESPONSE_OK:
        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(modlist));

        if (gtk_tree_selection_get_selected(selection, &selmod, &item))
        {
            gtk_tree_model_get(selmod, &item, 0, &dirname, -1);
            sat_log_log(SAT_LOG_LEVEL_DEBUG,
                        _("%s:%s: Selected module is: %s"),
                        __FILE__, __func__, dirname);
        }
        else
        {
            sat_log_log(SAT_LOG_LEVEL_ERROR,
                        _("%s:%s: No selection is list of modules."),
                        __FILE__, __func__);
            dirname = NULL;
        }
        break;

        /* everything else is regarded as CANCEL */
    default:
        dirname = NULL;
        break;
    }

    gtk_widget_destroy(dialog);

    return dirname;
}
GtkWidget *
CChoosebook::create_tree()
{
	GtkWidget *sw;
	GtkTreeStore *model;
	GtkTreeIter iter;
	gchar *filename;
	
	model = gtk_tree_store_new (3,GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_STRING);
	
	filename = g_build_filename(g_pReciteWord->userpath, "hardbooks", NULL);	
	gtk_tree_store_append (model, &iter, NULL);
	gtk_tree_store_set (model, &iter, 0,Skin->choosebook.dir.p[0],1, _("hardbooks"),2,filename, -1);
	create_tree_model(filename,model, &iter);
	g_free(filename);

	filename = g_build_filename(g_pReciteWord->userpath, "books", NULL);
	gtk_tree_store_append (model, &iter, NULL);
	gtk_tree_store_set (model, &iter, 0,Skin->choosebook.dir.p[0],1, _("my books"),2,filename, -1);
	create_tree_model(filename,model, &iter);
	g_free(filename);
	
	gtk_tree_store_append (model, &iter, NULL);
	filename = g_build_filename(reciteword_data_dir, "books", NULL);
	gtk_tree_store_set (model, &iter,
			  0,Skin->choosebook.dir.p[0],1, _("books"),2, filename,
			  -1);
	create_tree_model(filename,model, &iter);
	g_free(filename);

	
	tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
	g_object_unref (model);
	
	
	/*GtkTreeViewColumn *column;
	GtkCellRenderer *cell_renderer;
	     column = gtk_tree_view_column_new ();

      cell_renderer = gtk_cell_renderer_pixbuf_new ();
      gtk_tree_view_column_pack_start (column,
				       cell_renderer,
				       FALSE);
      cell_renderer = gtk_cell_renderer_text_new ();
      gtk_tree_view_column_pack_start (column,
				       cell_renderer,
				       TRUE);
      gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
				   column);*/
				   
	GtkCellRenderer *renderer_image;
	GtkCellRenderer *renderer_text;
	GtkTreeViewColumn *column;
	renderer_image = gtk_cell_renderer_pixbuf_new();
	renderer_text = gtk_cell_renderer_text_new ();
	//g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column,_("Directories"));
	gtk_tree_view_column_pack_start(column,renderer_image,FALSE);
	gtk_tree_view_column_add_attribute(column,
                                     renderer_image,
                                     "pixbuf",0);
	gtk_tree_view_column_pack_end(column,renderer_text,TRUE);
	gtk_tree_view_column_add_attribute(column,
                                     renderer_text,
                                     "text",1);
	gtk_tree_view_insert_column(GTK_TREE_VIEW(tree_view),column,-1);
/*	col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
							    -1, "Folder",
							    renderer, "text",
							    0,
							    NULL);
	  column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);*/
	  //gtk_tree_view_column_set_visible(GTK_TREE_VIEW_COLUMN (column), FALSE);
	  gtk_tree_view_column_set_clickable (column, TRUE);
	      
	GtkTreeSelection *selection;
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	gtk_tree_view_expand_all(GTK_TREE_VIEW(tree_view));
	//gtk_tree_selection_set_select_function(selection,tree_selection_func,this,NULL);
	g_signal_connect (G_OBJECT (selection),
			"changed",
			G_CALLBACK (on_choosebook_tree_selection_changed),
			this);

	/*g_signal_connect (G_OBJECT (tree_view),
			"button_press_event",
			G_CALLBACK (on_choosebook_tree_button_press),
			this);*/
	
	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_set_size_request(sw,Skin->choosebook.book_tree.w,Skin->choosebook.book_tree.h);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),GTK_SHADOW_ETCHED_IN);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);	
	gtk_container_add (GTK_CONTAINER (sw), tree_view);
	gtk_widget_show(tree_view);
	
	return sw;
}
Exemple #28
0
static void
tabu_playlist_init (TabuPlaylist *self)
{ 
  gtk_scrolled_window_set_shadow_type (
    GTK_SCROLLED_WINDOW (self),
    GTK_SHADOW_IN);

  gtk_scrolled_window_set_hadjustment (
    GTK_SCROLLED_WINDOW (self),
    NULL);

  gtk_scrolled_window_set_vadjustment (
    GTK_SCROLLED_WINDOW (self),
    NULL);

  gtk_scrolled_window_set_policy (
    GTK_SCROLLED_WINDOW (self), 
    GTK_POLICY_NEVER, 
    GTK_POLICY_AUTOMATIC);
  
  self->tree_view = gtk_tree_view_new ( );

  gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (self->tree_view), TRUE);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (self->tree_view), FALSE);
	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (self->tree_view), TRUE);
  gtk_tree_view_set_reorderable (GTK_TREE_VIEW (self->tree_view), TRUE);

	gtk_tree_selection_set_mode ( 
    GTK_TREE_SELECTION ( 
      gtk_tree_view_get_selection (GTK_TREE_VIEW (self->tree_view))), 
      GTK_SELECTION_MULTIPLE);

  self->cell_renderer = gtk_cell_renderer_text_new ();
  g_object_set (self->cell_renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);

  GtkTreeViewColumn *pointercol = gtk_tree_view_column_new_with_attributes(
    "Pointer",
    GTK_CELL_RENDERER (self->cell_renderer),
    "markup", 0,
    NULL );

  self->tree_view_column = gtk_tree_view_column_new_with_attributes(
    "Cancion",
    GTK_CELL_RENDERER (self->cell_renderer),
    "markup", 1,
    NULL );

  gtk_tree_view_column_set_sizing (self->tree_view_column, GTK_TREE_VIEW_COLUMN_FIXED);
  gtk_tree_view_column_set_sizing (pointercol, GTK_TREE_VIEW_COLUMN_FIXED);  
//  gtk_tree_view_column_set_fixed_width (pointercol, 15 );;
	gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (self->tree_view_column), TRUE);

  gtk_tree_view_insert_column (
    GTK_TREE_VIEW (self->tree_view), 
    pointercol, 
    -1);

  gtk_tree_view_insert_column (
    GTK_TREE_VIEW (self->tree_view), 
    self->tree_view_column, 
    -1);

  self->list_store = gtk_list_store_new ( 
    3, 
    G_TYPE_STRING, 
    G_TYPE_STRING,
    G_TYPE_STRING);

  gtk_tree_view_set_model (
    GTK_TREE_VIEW (self->tree_view), 
    GTK_TREE_MODEL (self->list_store));  

  g_signal_connect (
    G_OBJECT (self->tree_view), 
    "row-activated", 
    G_CALLBACK (on_tabu_playlist_row_activated_event), 
    NULL);

  g_signal_connect ( 
    G_OBJECT (self->tree_view), 
    "key-press-event", 
    G_CALLBACK (on_tabu_playlist_key_press_event), 
    NULL);
  
	gtk_container_add ( 
    GTK_CONTAINER ( GTK_SCROLLED_WINDOW (self)), 
    GTK_WIDGET (self->tree_view));
}
Exemple #29
0
/** Create QTH list widgets. */
static GtkWidget *create_qth_list()
{
    GtkTreeModel   *model;
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;

    qthlist = gtk_tree_view_new();

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

    /* name column */
    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer,
                                                      "text",
                                                      QTH_LIST_COL_NAME, NULL);
    gtk_tree_view_column_set_expand(column, TRUE);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(qthlist), column, -1);

    /* location column */
    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("Location"), renderer,
                                                      "text", QTH_LIST_COL_LOC,
                                                      NULL);
    gtk_tree_view_column_set_expand(column, TRUE);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(qthlist), column, -1);

    /* lat column */
    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("Lat"), renderer,
                                                      "text", QTH_LIST_COL_LAT,
                                                      NULL);
    gtk_tree_view_column_set_alignment(column, 0.5);
    gtk_tree_view_column_set_cell_data_func(column,
                                            renderer,
                                            float_cell_data_function,
                                            GUINT_TO_POINTER(QTH_LIST_COL_LAT),
                                            NULL);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(qthlist), column, -1);

    /* lon column */
    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("Lon"), renderer,
                                                      "text", QTH_LIST_COL_LON,
                                                      NULL);
    gtk_tree_view_column_set_alignment(column, 0.5);
    gtk_tree_view_column_set_cell_data_func(column,
                                            renderer,
                                            float_cell_data_function,
                                            GUINT_TO_POINTER(QTH_LIST_COL_LON),
                                            NULL);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(qthlist), column, -1);

    /* alt column */
    renderer = gtk_cell_renderer_text_new();
    if (sat_cfg_get_bool(SAT_CFG_BOOL_USE_IMPERIAL))
    {
        column = gtk_tree_view_column_new_with_attributes(_("Alt\n(ft)"),
                                                          renderer,
                                                          "text",
                                                          QTH_LIST_COL_ALT,
                                                          NULL);
    }
    else
    {
        column =
            gtk_tree_view_column_new_with_attributes(_("Alt\n(m)"), renderer,
                                                     "text", QTH_LIST_COL_ALT,
                                                     NULL);
    }
    gtk_tree_view_insert_column(GTK_TREE_VIEW(qthlist), column, -1);
    gtk_tree_view_column_set_alignment(column, 0.5);

    /* locator */
    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("QRA"), renderer,
                                                      "text", QTH_LIST_COL_QRA,
                                                      NULL);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(qthlist), column, -1);
    gtk_tree_view_column_set_alignment(column, 0.5);

    /* weather station */
    /*      renderer = gtk_cell_renderer_text_new (); */
    /*      column = gtk_tree_view_column_new_with_attributes (_("WX"), renderer, */
    /*                                       "text", QTH_LIST_COL_WX, */
    /*                                       NULL); */
    /*      gtk_tree_view_insert_column (GTK_TREE_VIEW (qthlist), column, -1); */
    /*      gtk_tree_view_column_set_alignment (column, 0.5); */

    /* default */
    renderer = gtk_cell_renderer_toggle_new();
    handler_id = g_signal_connect(renderer, "toggled",
                                  G_CALLBACK(default_toggled), model);

    column = gtk_tree_view_column_new_with_attributes(_("Default"), renderer,
                                                      "active",
                                                      QTH_LIST_COL_DEF, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(qthlist), column);
    gtk_tree_view_column_set_alignment(column, 0.5);

    g_signal_connect(qthlist, "row-activated", G_CALLBACK(row_activated_cb),
                     NULL);

#ifdef HAS_LIBGPS
    /* GPSD enabled */
    /*server */
    renderer = gtk_cell_renderer_text_new();
    column =
        gtk_tree_view_column_new_with_attributes(_("GPSD\nServer"), renderer,
                                                 "text",
                                                 QTH_LIST_COL_GPSD_SERVER,
                                                 NULL);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(qthlist), column, -1);
    gtk_tree_view_column_set_alignment(column, 0.5);
    /*port */
    renderer = gtk_cell_renderer_text_new();
    column =
        gtk_tree_view_column_new_with_attributes(_("GPSD\nPort"), renderer,
                                                 "text",
                                                 QTH_LIST_COL_GPSD_PORT, NULL);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(qthlist), column, -1);
    gtk_tree_view_column_set_alignment(column, 0.5);

    /*type */
    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("QTH\nType"), renderer,
                                                      "text",
                                                      QTH_LIST_COL_TYPE, NULL);
    gtk_tree_view_insert_column(GTK_TREE_VIEW(qthlist), column, -1);
    gtk_tree_view_column_set_alignment(column, 0.5);
#endif

    return qthlist;
}
void
ghid_netlist_window_create (GHidPort * out)
{
  GtkWidget *vbox, *hbox, *button, *label, *sep;
  GtkTreeView *treeview;
  GtkTreeModel *model;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;

  if (netlist_window)
    return;

  netlist_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (G_OBJECT (netlist_window), "destroy",
		    G_CALLBACK (netlist_destroy_cb), out);
  gtk_window_set_title (GTK_WINDOW (netlist_window), _("PCB Netlist"));
  gtk_window_set_wmclass (GTK_WINDOW (netlist_window), "PCB_Netlist", "PCB");
  g_signal_connect (G_OBJECT (netlist_window), "configure_event",
		    G_CALLBACK (netlist_window_configure_event_cb), NULL);
  gtk_window_set_default_size (GTK_WINDOW (netlist_window),
			       -1, ghidgui->netlist_window_height);

  gtk_container_set_border_width (GTK_CONTAINER (netlist_window), 2);

  vbox = gtk_vbox_new (FALSE, 4);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
  gtk_container_add (GTK_CONTAINER (netlist_window), vbox);
  hbox = gtk_hbox_new (FALSE, 8);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 4);


  model = net_model_create ();
  treeview = GTK_TREE_VIEW (gtk_tree_view_new_with_model (model));
  net_model = model;
  net_treeview = treeview;
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (net_model),
					NET_NAME_COLUMN, GTK_SORT_ASCENDING);

  gtk_tree_view_set_rules_hint (treeview, FALSE);
  g_object_set (treeview, "enable-tree-lines", TRUE, NULL);

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (treeview, -1, _(" "),
					       renderer,
					       "text", NET_ENABLED_COLUMN,
					       NULL);

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes (_("Net Name"),
						     renderer,
						     "text", NET_NAME_COLUMN, NULL);
  gtk_tree_view_insert_column (treeview, column, -1);
  gtk_tree_view_set_expander_column (treeview, column);

  /* TODO: dont expand all, but record expanded states when window is
     |  destroyed and restore state here.
   */
  gtk_tree_view_expand_all (treeview);

  ghid_scrolled_selection (treeview, hbox,
                           GTK_SELECTION_SINGLE,
                           GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC,
                           net_selection_changed_cb, NULL);

  /* Connect to the double click event.
   */
  g_signal_connect (G_OBJECT (treeview), "row-activated",
		    G_CALLBACK (net_selection_double_click_cb), NULL);



  /* Create the elements treeview and wait for a callback to populate it.
   */
  treeview = GTK_TREE_VIEW (gtk_tree_view_new ());
  node_treeview = treeview;

  gtk_tree_view_set_rules_hint (treeview, FALSE);

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (treeview, -1, _("Nodes"),
					       renderer,
					       "text", NODE_NAME_COLUMN,
					       NULL);

  ghid_scrolled_selection (treeview, hbox,
                           GTK_SELECTION_SINGLE,
                           GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC,
                           node_selection_changed_cb, NULL);

  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  label = gtk_label_new (_("Operations on selected 'Net Name':"));
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);

  button = gtk_button_new_with_label (_("Select"));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_select_cb), GINT_TO_POINTER (1));

  button = gtk_button_new_with_label (_("Unselect"));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_select_cb), GINT_TO_POINTER (0));

  button = gtk_button_new_with_label (_("Find"));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_find_cb), GINT_TO_POINTER (0));

  button = gtk_button_new_with_label (_("Rip Up"));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_rip_up_cb), GINT_TO_POINTER (0));
  
  ghid_check_button_connected (vbox, &disable_all_button, FALSE, TRUE, FALSE,
			       FALSE, 0, netlist_disable_all_cb, NULL,
			       _("Disable all nets for adding rats"));

  sep = gtk_hseparator_new ();
  gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 3);

  hbox = gtk_hbutton_box_new ();
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
  button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_close_cb), NULL);
  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);


  gtk_widget_realize (netlist_window);
  if (Settings.AutoPlace)
    gtk_window_move (GTK_WINDOW (netlist_window), 10, 10);

}