コード例 #1
0
/**
 * create_bookmarks_window:
 * 
 * Create a new bookmark-editing window. 
 * @list: The NautilusBookmarkList that this window will edit.
 *
 * Return value: A pointer to the new window.
 **/
GtkWindow *
create_bookmarks_window (NautilusBookmarkList *list, GObject *undo_manager_source)
{
	GtkWidget         *window;
	GtkTreeViewColumn *col;
	GtkCellRenderer   *rend;
	GtkBuilder        *builder;

	bookmarks = list;

	builder = gtk_builder_new ();
	if (!gtk_builder_add_from_file (builder,
					UIDIR  "/nautilus-bookmarks-window.ui",
					NULL)) {
		return NULL;
	}

	window = (GtkWidget *)gtk_builder_get_object (builder, "bookmarks_dialog");
	bookmark_list_widget = (GtkTreeView *)gtk_builder_get_object (builder, "bookmark_tree_view");
	remove_button = (GtkWidget *)gtk_builder_get_object (builder, "bookmark_delete_button");
	jump_button = (GtkWidget *)gtk_builder_get_object (builder, "bookmark_jump_button");

	set_up_close_accelerator (window);
	nautilus_undo_share_undo_manager (G_OBJECT (window), undo_manager_source);

	gtk_window_set_wmclass (GTK_WINDOW (window), "bookmarks", "Nautilus");
	nautilus_bookmarks_window_restore_geometry (window);

	g_object_weak_ref (G_OBJECT (undo_manager_source), edit_bookmarks_dialog_reset_signals, 
			   undo_manager_source);
	
	bookmark_list_widget = GTK_TREE_VIEW (gtk_builder_get_object (builder, "bookmark_tree_view"));

	rend = gtk_cell_renderer_pixbuf_new ();
	col = gtk_tree_view_column_new_with_attributes ("Icon", 
							rend,
							"gicon", 
							BOOKMARK_LIST_COLUMN_ICON,
							NULL);
	gtk_tree_view_append_column (bookmark_list_widget,
				     GTK_TREE_VIEW_COLUMN (col));
	gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (col),
					      NAUTILUS_ICON_SIZE_SMALLER);

	rend = gtk_cell_renderer_text_new ();
	g_object_set (rend,
		      "ellipsize", PANGO_ELLIPSIZE_END,
		      "ellipsize-set", TRUE,
		      NULL);

	col = gtk_tree_view_column_new_with_attributes ("Icon", 
							rend,
							"text", 
							BOOKMARK_LIST_COLUMN_NAME,
							"style",
							BOOKMARK_LIST_COLUMN_STYLE,
							NULL);
	gtk_tree_view_append_column (bookmark_list_widget,
				     GTK_TREE_VIEW_COLUMN (col));
	
	bookmark_list_store = create_bookmark_store ();
	setup_empty_list ();
	gtk_tree_view_set_model (bookmark_list_widget,
				 GTK_TREE_MODEL (bookmark_empty_list_store));
	
	bookmark_selection =
		GTK_TREE_SELECTION (gtk_tree_view_get_selection (bookmark_list_widget));

	name_field = nautilus_entry_new ();
	
	gtk_widget_show (name_field);
	gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "bookmark_name_placeholder")),
			    name_field, TRUE, TRUE, 0);
	
	gtk_label_set_mnemonic_widget (
		GTK_LABEL (gtk_builder_get_object (builder, "bookmark_name_label")),
		name_field);

	uri_field = nautilus_entry_new ();
	gtk_widget_show (uri_field);
	gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "bookmark_location_placeholder")),
			    uri_field, TRUE, TRUE, 0);

	gtk_label_set_mnemonic_widget (
		GTK_LABEL (gtk_builder_get_object (builder, "bookmark_location_label")),
		uri_field);

	bookmark_list_changed_signal_id =
		g_signal_connect (bookmarks, "changed",
				  G_CALLBACK (on_bookmark_list_changed), NULL);
	row_changed_signal_id =
		g_signal_connect (bookmark_list_store, "row_changed",
				  G_CALLBACK (on_row_changed), NULL);
	row_deleted_signal_id =
		g_signal_connect (bookmark_list_store, "row_deleted",
				  G_CALLBACK (on_row_deleted), NULL);
        row_activated_signal_id =
                g_signal_connect (bookmark_list_widget, "row_activated",
                                  G_CALLBACK (on_row_activated), undo_manager_source);
        button_pressed_signal_id =
                g_signal_connect (bookmark_list_widget, "button_press_event",
                                  G_CALLBACK (on_button_pressed), NULL);
        key_pressed_signal_id =
                g_signal_connect (bookmark_list_widget, "key_press_event",
                                  G_CALLBACK (on_key_pressed), NULL);
	selection_changed_id =
		g_signal_connect (bookmark_selection, "changed",
				  G_CALLBACK (on_selection_changed), NULL);	

	g_signal_connect (window, "delete_event",
			  G_CALLBACK (on_window_delete_event), NULL);
	g_signal_connect (window, "hide",
			  G_CALLBACK (on_window_hide_event), NULL);                    	    
	g_signal_connect (window, "destroy",
			  G_CALLBACK (on_window_destroy_event), NULL);
	g_signal_connect (window, "response",
			  G_CALLBACK (nautilus_bookmarks_window_response_callback), NULL);

	name_field_changed_signal_id =
		g_signal_connect (name_field, "changed",
				  G_CALLBACK (on_name_field_changed), NULL);
                      		    
	g_signal_connect (name_field, "focus_out_event",
			  G_CALLBACK (on_text_field_focus_out_event), NULL);                            
	g_signal_connect (name_field, "activate",
			  G_CALLBACK (name_or_uri_field_activate), NULL);

	uri_field_changed_signal_id = 
		g_signal_connect (uri_field, "changed",
				  G_CALLBACK (on_uri_field_changed), NULL);
                      		    
	g_signal_connect (uri_field, "focus_out_event",
			  G_CALLBACK (on_text_field_focus_out_event), NULL);
	g_signal_connect (uri_field, "activate",
			  G_CALLBACK (name_or_uri_field_activate), NULL);
	g_signal_connect (remove_button, "clicked",
			  G_CALLBACK (on_remove_button_clicked), NULL);
	jump_button_signal_id = 
		g_signal_connect (jump_button, "clicked",
				  G_CALLBACK (on_jump_button_clicked), undo_manager_source);

	gtk_tree_selection_set_mode (bookmark_selection, GTK_SELECTION_BROWSE);
	
	/* Fill in list widget with bookmarks, must be after signals are wired up. */
	repopulate();

	g_object_unref (builder);
	
	return GTK_WINDOW (window);
}
コード例 #2
0
ファイル: modulelist.c プロジェクト: bluesceada/darktable
static void _lib_modulelist_populate_callback(gpointer instance, gpointer user_data)
{
    dt_lib_module_t *self = (dt_lib_module_t *)user_data;
    if(!self || !(self->data)) return;

    GtkListStore *store;
    GtkTreeIter iter;
    GtkWidget *view = GTK_WIDGET(((dt_lib_modulelist_t *)self->data)->tree);
    GtkCellRenderer *pix_renderer, *fav_renderer, *text_renderer;
    GdkRGBA color;
    GtkStyleContext *context = gtk_widget_get_style_context(view);
    gboolean color_found = gtk_style_context_lookup_color (context, "selected_bg_color", &color);
    if(!color_found)
    {
        color.red = 1.0;
        color.green = 0.0;
        color.blue = 0.0;
        color.alpha = 1.0;
    }

    store = gtk_list_store_new(NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
    gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
    g_object_unref(store);

    gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), COL_MODULE, _lib_modulelist_gui_sort, NULL, NULL);
    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), COL_MODULE, GTK_SORT_ASCENDING);

    pix_renderer = gtk_cell_renderer_pixbuf_new();
    g_object_set(pix_renderer, "cell-background-rgba", &color, NULL);

    fav_renderer = gtk_cell_renderer_pixbuf_new();
    cairo_surface_t *fav_cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ICON_SIZE, ICON_SIZE);
    cairo_t *fav_cr = cairo_create(fav_cst);
    cairo_set_source_rgb(fav_cr, 0.7, 0.7, 0.7);
    dtgtk_cairo_paint_modulegroup_favorites(fav_cr, 0, 0, ICON_SIZE, ICON_SIZE, 0);
    guchar *data = cairo_image_surface_get_data(fav_cst);
    dt_draw_cairo_to_gdk_pixbuf(data, ICON_SIZE, ICON_SIZE);
    ((dt_lib_modulelist_t *)self->data)->fav_pixbuf
        = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE, 8, ICON_SIZE, ICON_SIZE,
                                   cairo_image_surface_get_stride(fav_cst), NULL, NULL);
    g_object_set(fav_renderer, "cell-background-rgba", &color, NULL);
    g_object_set(fav_renderer, "width", gdk_pixbuf_get_width(((dt_lib_modulelist_t *)self->data)->fav_pixbuf),
                 NULL);

    text_renderer = gtk_cell_renderer_text_new();
    g_object_set(text_renderer, "cell-background-rgba", &color, NULL);

    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
    gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(view), FALSE);
    GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
    gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);

    GtkTreeViewColumn *col;
    col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 0);
    if(col) gtk_tree_view_remove_column(GTK_TREE_VIEW(view), col);
    gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), 0, "favorite", fav_renderer,
            favorite_renderer_function, NULL, NULL);
    col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 1);
    if(col) gtk_tree_view_remove_column(GTK_TREE_VIEW(view), col);
    gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), 1, "image", pix_renderer,
            image_renderer_function, NULL, NULL);
    col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 2);
    if(col) gtk_tree_view_remove_column(GTK_TREE_VIEW(view), col);
    gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), 2, "name", text_renderer,
            text_renderer_function, NULL, NULL);

    /* go thru list of iop modules and add them to the list */
    GList *modules = g_list_last(darktable.develop->iop);

    char datadir[PATH_MAX] = { 0 };
    dt_loc_get_datadir(datadir, sizeof(datadir));

    while(modules)
    {
        dt_iop_module_t *module = (dt_iop_module_t *)(modules->data);
        if(!dt_iop_is_hidden(module) && !(module->flags() & IOP_FLAGS_DEPRECATED) && module->multi_priority == 0)
        {
            GdkPixbuf *pixbuf;
            char filename[PATH_MAX] = { 0 };

            snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/%s.svg", datadir, module->op);
            pixbuf = load_image(filename);
            if(pixbuf) goto end;

            snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/%s.png", datadir, module->op);
            pixbuf = load_image(filename);
            if(pixbuf) goto end;

            snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/template.svg", datadir);
            pixbuf = load_image(filename);
            if(pixbuf) goto end;

            snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/template.png", datadir);
            pixbuf = load_image(filename);
            if(pixbuf) goto end;

            // wow, we could neither load the SVG nor the PNG files. something is fucked up.
            pixbuf = gdk_pixbuf_new_from_data(fallback_pixel, GDK_COLORSPACE_RGB, TRUE, 8, 1, 1, 4, NULL, NULL);

end:
            gtk_list_store_append(store, &iter);
            gtk_list_store_set(store, &iter, COL_IMAGE, pixbuf, COL_MODULE, module, -1);
            g_object_unref(pixbuf);
        }

        modules = g_list_previous(modules);
    }
}
コード例 #3
0
ファイル: testtreeedit.c プロジェクト: 3v1n0/gtk
gint
main (gint argc, gchar **argv)
{
  GtkWidget *window;
  GtkWidget *scrolled_window;
  GtkWidget *tree_view;
  GtkWidget *vbox, *hbox, *cntl_vbox;
  GtkTreeModel *tree_model;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;
  GtkCellArea *area;
  CallbackData callback[4];
  
  gtk_init (&argc, &argv);

  if (g_getenv ("RTL"))
    gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "GtkTreeView editing sample");
  g_signal_connect (window, "destroy", gtk_main_quit, NULL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_widget_show (vbox);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_ETCHED_IN);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), 
				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);

  tree_model = create_model ();
  tree_view = gtk_tree_view_new_with_model (tree_model);
  g_signal_connect (tree_view, "button_press_event", G_CALLBACK (button_press_event), NULL);
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), TRUE);

  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, "String");
  area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (column));

  renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_attributes (column, renderer,
				       "icon-name", ICON_NAME_COLUMN, 
				       "sensitive", IS_SENSITIVE_COLUMN,
				       NULL);
  callback[0].area = area;
  callback[0].renderer = renderer;

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_attributes (column, renderer,
				       "text", STRING_COLUMN,
				       "editable", IS_EDITABLE_COLUMN,
				       "sensitive", IS_SENSITIVE_COLUMN,
				       NULL);
  callback[1].area = area;
  callback[1].renderer = renderer;
  g_signal_connect (renderer, "edited",
		    G_CALLBACK (edited), tree_model);
  g_object_set (renderer,
                "placeholder-text", "Type here",
                NULL);

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_attributes (column, renderer,
		  		       "text", STRING_COLUMN,
				       "editable", IS_EDITABLE_COLUMN,
				       "sensitive", IS_SENSITIVE_COLUMN,
				       NULL);
  callback[2].area = area;
  callback[2].renderer = renderer;
  g_signal_connect (renderer, "edited",
		    G_CALLBACK (edited), tree_model);
  g_object_set (renderer,
                "placeholder-text", "Type here too",
                NULL);

  renderer = gtk_cell_renderer_pixbuf_new ();
  g_object_set (renderer,
		"xalign", 0.0,
		NULL);
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_attributes (column, renderer,
				       "icon-name", LAST_ICON_NAME_COLUMN, 
				       "sensitive", IS_SENSITIVE_COLUMN,
				       NULL);
  callback[3].area = area;
  callback[3].renderer = renderer;

  gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);

  renderer = gtk_cell_renderer_toggle_new ();
  g_signal_connect (renderer, "toggled",
		    G_CALLBACK (editable_toggled), tree_model);
  
  g_object_set (renderer,
		"xalign", 0.0,
		NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
					       -1, "Editable",
					       renderer,
					       "active", IS_EDITABLE_COLUMN,
					       NULL);

  renderer = gtk_cell_renderer_toggle_new ();
  g_signal_connect (renderer, "toggled",
		    G_CALLBACK (sensitive_toggled), tree_model);
  
  g_object_set (renderer,
		"xalign", 0.0,
		NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
					       -1, "Sensitive",
					       renderer,
					       "active", IS_SENSITIVE_COLUMN,
					       NULL);

  renderer = gtk_cell_renderer_progress_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
					       -1, "Progress",
					       renderer,
					       "value", PROGRESS_COLUMN,
					       NULL);

  gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
  
  gtk_window_set_default_size (GTK_WINDOW (window),
			       800, 250);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_widget_show (hbox);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  /* Alignment controls */
  cntl_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_widget_show (cntl_vbox);
  gtk_box_pack_start (GTK_BOX (hbox), cntl_vbox, FALSE, FALSE, 0);

  create_control (cntl_vbox, 1, CNTL_ALIGN, &callback[0]);
  create_control (cntl_vbox, 2, CNTL_ALIGN, &callback[1]);
  create_control (cntl_vbox, 3, CNTL_ALIGN, &callback[2]);
  create_control (cntl_vbox, 4, CNTL_ALIGN, &callback[3]);

  /* Expand controls */
  cntl_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_widget_show (cntl_vbox);
  gtk_box_pack_start (GTK_BOX (hbox), cntl_vbox, FALSE, FALSE, 0);

  create_control (cntl_vbox, 1, CNTL_EXPAND, &callback[0]);
  create_control (cntl_vbox, 2, CNTL_EXPAND, &callback[1]);
  create_control (cntl_vbox, 3, CNTL_EXPAND, &callback[2]);
  create_control (cntl_vbox, 4, CNTL_EXPAND, &callback[3]);

  /* Fixed controls */
  cntl_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_widget_show (cntl_vbox);
  gtk_box_pack_start (GTK_BOX (hbox), cntl_vbox, FALSE, FALSE, 0);

  create_control (cntl_vbox, 1, CNTL_FIXED, &callback[0]);
  create_control (cntl_vbox, 2, CNTL_FIXED, &callback[1]);
  create_control (cntl_vbox, 3, CNTL_FIXED, &callback[2]);
  create_control (cntl_vbox, 4, CNTL_FIXED, &callback[3]);

  gtk_widget_show_all (window);
  gtk_main ();

  return 0;
}
コード例 #4
0
ファイル: empathy-log-window.c プロジェクト: james-w/empathy
static void
log_window_find_setup (EmpathyLogWindow *window)
{
	GtkTreeView       *view;
	GtkTreeModel      *model;
	GtkTreeSelection  *selection;
	GtkTreeSortable   *sortable;
	GtkTreeViewColumn *column;
	GtkListStore      *store;
	GtkCellRenderer   *cell;
	gint               offset;

	view = GTK_TREE_VIEW (window->treeview_find);
	selection = gtk_tree_view_get_selection (view);

	/* New store */
	store = gtk_list_store_new (COL_FIND_COUNT,
				    G_TYPE_STRING,          /* account icon name */
				    G_TYPE_STRING,          /* account name */
				    EMPATHY_TYPE_ACCOUNT,   /* account */
				    G_TYPE_STRING,          /* chat name */
				    G_TYPE_STRING,          /* chat id */
				    G_TYPE_BOOLEAN,         /* is chatroom */
				    G_TYPE_STRING,          /* date */
				    G_TYPE_STRING);         /* date_readable */

	model = GTK_TREE_MODEL (store);
	sortable = GTK_TREE_SORTABLE (store);

	gtk_tree_view_set_model (view, model);

	/* New column */
	column = gtk_tree_view_column_new ();

	cell = gtk_cell_renderer_pixbuf_new ();
	gtk_tree_view_column_pack_start (column, cell, FALSE);
	gtk_tree_view_column_add_attribute (column, cell,
					    "icon-name",
					    COL_FIND_ACCOUNT_ICON);

	cell = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, cell, TRUE);
	gtk_tree_view_column_add_attribute (column, cell,
					    "text",
					    COL_FIND_ACCOUNT_NAME);

	gtk_tree_view_column_set_title (column, _("Account"));
	gtk_tree_view_append_column (view, column);

	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_column_set_clickable (column, TRUE);

	cell = gtk_cell_renderer_text_new ();
	offset = gtk_tree_view_insert_column_with_attributes (view, -1, _("Conversation"),
							      cell, "text", COL_FIND_CHAT_NAME,
							      NULL);

	column = gtk_tree_view_get_column (view, offset - 1);
	gtk_tree_view_column_set_sort_column_id (column, COL_FIND_CHAT_NAME);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_column_set_clickable (column, TRUE);

	cell = gtk_cell_renderer_text_new ();
	offset = gtk_tree_view_insert_column_with_attributes (view, -1, _("Date"),
							      cell, "text", COL_FIND_DATE_READABLE,
							      NULL);

	column = gtk_tree_view_get_column (view, offset - 1);
	gtk_tree_view_column_set_sort_column_id (column, COL_FIND_DATE);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_column_set_clickable (column, TRUE);

	/* Set up treeview properties */
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	gtk_tree_sortable_set_sort_column_id (sortable,
					      COL_FIND_DATE,
					      GTK_SORT_ASCENDING);

	/* Set up signals */
	g_signal_connect (selection, "changed",
			  G_CALLBACK (log_window_find_changed_cb),
			  window);

	g_object_unref (store);
}
コード例 #5
0
/**
 * pk_treeview_add_general_columns:
 **/
static void
pk_treeview_add_general_columns (GtkTreeView *treeview)
{
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;

	/* --- column for date --- */
	renderer = gtk_cell_renderer_text_new ();
	g_object_set (renderer, "yalign", 0.0, NULL);
	/* TRANSLATORS: column for the date */
	column = gtk_tree_view_column_new_with_attributes (_("Date"), renderer,
							   "markup", GPK_LOG_COLUMN_DATE_TEXT, NULL);
	gtk_tree_view_append_column (treeview, column);
	gtk_tree_view_column_set_expand (column, FALSE);
	gtk_tree_view_column_set_sort_column_id (column, GPK_LOG_COLUMN_DATE);

	/* --- column for image and text --- */
	column = gtk_tree_view_column_new ();
	/* TRANSLATORS: column for what was done, e.g. update-system */
	gtk_tree_view_column_set_title (column, _("Action"));

	/* image */
	renderer = gtk_cell_renderer_pixbuf_new ();
	g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
	g_object_set (renderer, "yalign", 0.0, NULL);
	gtk_tree_view_column_pack_start (column, renderer, FALSE);
	gtk_tree_view_column_add_attribute (column, renderer, "icon-name", GPK_LOG_COLUMN_ICON);

	renderer = gtk_cell_renderer_text_new ();
	g_object_set (renderer, "yalign", 0.0, NULL);

	/* text */
	gtk_tree_view_column_pack_start (column, renderer, TRUE);
	gtk_tree_view_column_add_attribute (column, renderer, "markup", GPK_LOG_COLUMN_ROLE);
	gtk_tree_view_column_set_expand (column, FALSE);
	gtk_tree_view_column_set_sort_column_id (column, GPK_LOG_COLUMN_ROLE);

	gtk_tree_view_append_column (treeview, GTK_TREE_VIEW_COLUMN(column));

	/* --- column for details --- */
	renderer = gtk_cell_renderer_text_new ();
	g_object_set (renderer, "yalign", 0.0, NULL);
	g_object_set (renderer, "wrap-mode", PANGO_WRAP_WORD, NULL);
	g_object_set (renderer, "wrap-width", 400, NULL);
	g_signal_connect (treeview, "size-allocate", G_CALLBACK (gpk_log_treeview_size_allocate_cb), renderer);
	/* TRANSLATORS: column for what packages were upgraded */
	column = gtk_tree_view_column_new_with_attributes (_("Details"), renderer,
							   "markup", GPK_LOG_COLUMN_DETAILS, NULL);
	gtk_tree_view_append_column (treeview, column);
	gtk_tree_view_column_set_expand (column, TRUE);

	/* TRANSLATORS: column for the username, e.g. Richard Hughes */
	column = gtk_tree_view_column_new_with_attributes (_("Username"), renderer,
							   "markup", GPK_LOG_COLUMN_USER, NULL);
	gtk_tree_view_append_column (treeview, column);
	gtk_tree_view_column_set_expand (column, FALSE);
	gtk_tree_view_column_set_sort_column_id (column, GPK_LOG_COLUMN_USER);

	/* TRANSLATORS: column for the application used for the install, e.g. Add/Remove Programs */
	column = gtk_tree_view_column_new_with_attributes (_("Application"), renderer,
							   "markup", GPK_LOG_COLUMN_TOOL, NULL);
	gtk_tree_view_append_column (treeview, column);
	gtk_tree_view_column_set_expand (column, FALSE);
	gtk_tree_view_column_set_sort_column_id (column, GPK_LOG_COLUMN_TOOL);
}
コード例 #6
0
ファイル: ui.c プロジェクト: binarycodes/gcolor3
GtkWidget* create_window (void) {
	GtkWidget *window, *box_all, *expander, *expander_box_all, *expander_box_buttons, *separator, *box_buttons, *button_quit, *button_about;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW (window), "Gcolor3");
	gtk_window_set_default_icon_name ("gcolor2");
	g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

	box_all = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	gtk_container_set_border_width (GTK_CONTAINER (box_all), 5);
	box_buttons = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	gtk_container_set_border_width (GTK_CONTAINER (box_buttons), 5);

	color_chooser = gtk_color_selection_new();
	expander = gtk_expander_new(_("Show saved colors"));
	expander_box_all = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	expander_box_buttons = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	button_save = gtk_button_new_from_stock ("gtk-save");
	button_delete = gtk_button_new_from_stock ("gtk-delete");
	gtk_widget_set_sensitive (button_delete, FALSE);

	/* setup the tree view widget */
	liststore = gtk_list_store_new (N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
	tree = gtk_tree_view_new();
	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree), TRUE);
	gtk_tree_view_set_model (GTK_TREE_VIEW (tree), GTK_TREE_MODEL (liststore));

	column = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title (column, _("Color"));

	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_tree_view_column_pack_start (column, renderer, FALSE);
	gtk_tree_view_column_set_attributes (column, renderer, "pixbuf", COLOR, NULL);

	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, renderer, TRUE);
	gtk_tree_view_column_set_attributes (column, renderer, "text", COLOR_VALUE, NULL);

	gtk_tree_view_column_set_sort_column_id (column, COLOR_VALUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (_("Name"), renderer, "text", COLOR_NAME, NULL);
	gtk_tree_view_column_set_sort_column_id (column, COLOR_NAME);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);

	/* enable searching on Name column */
	gtk_tree_view_set_search_column (GTK_TREE_VIEW (tree), COLOR_NAME);

	/* setup the selection handler */
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

	separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	button_quit = gtk_button_new_from_stock ("gtk-quit");
	button_about = gtk_button_new_from_stock ("gtk-about");

	gtk_box_pack_start (GTK_BOX (box_all), color_chooser, TRUE, TRUE, 0);
	gtk_box_pack_end (GTK_BOX (expander_box_buttons), button_save, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (expander_box_buttons), button_delete, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (expander_box_all), expander_box_buttons, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (expander_box_all), tree, TRUE, TRUE, 0);
	gtk_container_add (GTK_CONTAINER (expander), expander_box_all);
	gtk_box_pack_start (GTK_BOX (box_all), expander, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (box_all), separator, TRUE, TRUE, 0);
	gtk_box_pack_end (GTK_BOX (box_buttons), button_quit, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (box_buttons), button_about, FALSE, FALSE, 0);

	g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (on_list_selection_changed), NULL);
	g_signal_connect ((gpointer) color_chooser, "color_changed", G_CALLBACK (on_colorselection_color_changed), NULL);
	g_signal_connect (button_save, "clicked", G_CALLBACK (on_save_button_clicked), NULL);
	g_signal_connect (button_delete, "clicked", G_CALLBACK (on_delete_button_clicked), NULL);
	g_signal_connect (button_quit, "clicked", G_CALLBACK (gtk_main_quit), NULL);
	g_signal_connect (button_about, "clicked", G_CALLBACK (about_dialog_open), NULL);

	gtk_container_add (GTK_CONTAINER (box_all), box_buttons);
	gtk_container_add (GTK_CONTAINER (window), box_all);

	return window;
}
コード例 #7
0
ファイル: testcellrenderertext.c プロジェクト: BYC/gtk
static GtkWidget *
create_tree (gboolean rtl)
{
  GtkWidget *sw;
  GtkWidget *treeview;
  GtkListStore *list_store;
  GtkTreeViewColumn *column;
  GtkCellRenderer *renderer;
  GdkPixbuf *pixbuf;

  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
  gtk_widget_set_direction (sw, rtl ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);

  list_store = create_list_store ();

  treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
  gtk_widget_set_direction (treeview, rtl ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
  gtk_container_add (GTK_CONTAINER (sw), treeview);

  /* Line number */

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("#",
						     renderer,
						     "text", COL_LINE_NUM,
						     NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

  /* Description */

  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer,
		"font", "monospace",
		NULL);
  column = gtk_tree_view_column_new_with_attributes ("Description",
						     renderer,
						     "text", 0,
						     NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

  /* Test text */

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("Test",
						     renderer,
						     "text", 1,
						     "xpad", 2,
						     "ypad", 3,
						     "xalign", 4,
						     "yalign", 5,
						     "sensitive", 6,
						     "width", 7,
						     "height", 8,
						     "width_chars", 9,
						     "wrap_width", 10,
						     "wrap_mode", 11,
						     "single_paragraph_mode", 12,
						     "ellipsize", 13,
						     "alignment", 14,
						     "cell_background", 15,
						     NULL);
  gtk_tree_view_column_set_resizable (column, TRUE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

  /* Empty column */

  pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL);

  renderer = gtk_cell_renderer_pixbuf_new ();
  g_object_set (renderer,
		"pixbuf", pixbuf,
		"xpad", 10,
		"ypad", 10,
		NULL);
  column = gtk_tree_view_column_new_with_attributes ("Empty",
						     renderer,
						     NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

  return sw;
}
コード例 #8
0
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;
}
コード例 #9
0
static TBEditorWidget *tb_editor_create_dialog(MarlinViewWindow *mvw)
{
    GtkWidget *dialog, *vbox, *hbox, *vbox_buttons, *button_add, *button_remove;
    GtkWidget *swin_available, *swin_used, *tree_available, *tree_used, *label;
    GtkCellRenderer *text_renderer, *icon_renderer;
    GtkTreeViewColumn *column;
    TBEditorWidget *tbw = g_new(TBEditorWidget, 1);

    dialog = gtk_dialog_new_with_buttons(_("Customize Toolbar"),
                                         GTK_WINDOW (mvw),
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
                                         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
    vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
    gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
    gtk_widget_set_name(dialog, "GeanyDialog");
    gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 300);
    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);

    tbw->store_available = gtk_list_store_new(TB_EDITOR_COLS_MAX,
                                              G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF);
    tbw->store_used = gtk_list_store_new(TB_EDITOR_COLS_MAX,
                                         G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF);

    label = gtk_label_new(_("Select items to be displayed on the toolbar. Items can be reordered by drag and drop."));
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);

    tree_available = gtk_tree_view_new();
    gtk_tree_view_set_model(GTK_TREE_VIEW(tree_available), GTK_TREE_MODEL(tbw->store_available));
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree_available), TRUE);
    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(tbw->store_available), TB_EDITOR_COL_LABEL, GTK_SORT_ASCENDING);

    icon_renderer = gtk_cell_renderer_pixbuf_new();
    column = gtk_tree_view_column_new_with_attributes(NULL, icon_renderer, "pixbuf", TB_EDITOR_COL_ICON, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_available), column);

    text_renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("Available Items"), text_renderer, "text", TB_EDITOR_COL_LABEL, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_available), column);

    swin_available = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin_available),
                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin_available), GTK_SHADOW_ETCHED_IN);
    gtk_container_add(GTK_CONTAINER(swin_available), tree_available);

    tree_used = gtk_tree_view_new();
    gtk_tree_view_set_model(GTK_TREE_VIEW(tree_used), GTK_TREE_MODEL(tbw->store_used));
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree_used), TRUE);
    gtk_tree_view_set_reorderable(GTK_TREE_VIEW(tree_used), TRUE);

    icon_renderer = gtk_cell_renderer_pixbuf_new();
    column = gtk_tree_view_column_new_with_attributes(NULL, icon_renderer, "pixbuf", TB_EDITOR_COL_ICON, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_used), column);

    text_renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("Displayed Items"), text_renderer, "text", TB_EDITOR_COL_LABEL, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_used), column);

    swin_used = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin_used),
                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin_used), GTK_SHADOW_ETCHED_IN);
    gtk_container_add(GTK_CONTAINER(swin_used), tree_used);

    /* drag'n'drop */
    gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(tree_available), GDK_BUTTON1_MASK,
                                           tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
    gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(tree_available),
                                         tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
    g_signal_connect(tree_available, "drag-data-get",
                     G_CALLBACK(tb_editor_drag_data_get_cb), tbw);
    g_signal_connect(tree_available, "drag-data-received",
                     G_CALLBACK(tb_editor_drag_data_rcvd_cb), tbw);
    g_signal_connect(tree_available, "drag-motion",
                     G_CALLBACK(tb_editor_drag_motion_cb), tbw);

    gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(tree_used), GDK_BUTTON1_MASK,
                                           tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
    gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(tree_used),
                                         tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
    g_signal_connect(tree_used, "drag-data-get",
                     G_CALLBACK(tb_editor_drag_data_get_cb), tbw);
    g_signal_connect(tree_used, "drag-data-received",
                     G_CALLBACK(tb_editor_drag_data_rcvd_cb), tbw);
    g_signal_connect(tree_used, "drag-motion",
                     G_CALLBACK(tb_editor_drag_motion_cb), tbw);


    button_add = gtk_button_new();
    gtk_button_set_image(GTK_BUTTON(button_add),
                         gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON));
    button_remove = gtk_button_new();
    g_signal_connect(button_add, "clicked", G_CALLBACK(tb_editor_btn_add_clicked_cb), tbw);
    gtk_button_set_image(GTK_BUTTON(button_remove),
                         gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
    g_signal_connect(button_remove, "clicked", G_CALLBACK(tb_editor_btn_remove_clicked_cb), tbw);

    vbox_buttons = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
    /* FIXME this is a little hack'ish, any better ideas? */
    gtk_box_pack_start(GTK_BOX(vbox_buttons), gtk_label_new(""), TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox_buttons), button_add, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox_buttons), button_remove, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox_buttons), gtk_label_new(""), TRUE, TRUE, 0);

    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start(GTK_BOX(hbox), swin_available, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), vbox_buttons, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), swin_used, TRUE, TRUE, 0);

    g_object_set (label, "margin", 5, NULL);
    g_object_set (hbox, "margin", 5, NULL);

    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

    gtk_widget_show_all(vbox);

    g_object_unref(tbw->store_available);
    g_object_unref(tbw->store_used);

    tbw->dialog = dialog;
    tbw->tree_available = GTK_TREE_VIEW(tree_available);
    tbw->tree_used = GTK_TREE_VIEW(tree_used);

    tbw->last_drag_path = NULL;

    return tbw;
}
コード例 #10
0
ファイル: shell.c プロジェクト: BackupTheBerlios/hardinfo-svn
static ShellInfoTree *
info_tree_new(gboolean extra)
{
    ShellInfoTree	*info;
    GtkWidget		*treeview, *scroll;
    GtkTreeModel	*model;
    GtkTreeStore	*store;
    GtkTreeViewColumn	*column;
    GtkCellRenderer	*cr_text, *cr_pbuf;

    info = g_new0(ShellInfoTree, 1);

    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW
                                        (scroll), GTK_SHADOW_IN);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);

    store = gtk_tree_store_new(INFO_TREE_NCOL, G_TYPE_STRING, G_TYPE_STRING,
                               G_TYPE_STRING, GDK_TYPE_PIXBUF);
    model = GTK_TREE_MODEL(store);
    treeview = gtk_tree_view_new_with_model(model);
    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);

    column = gtk_tree_view_column_new();
    gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);

    cr_pbuf = gtk_cell_renderer_pixbuf_new();
    gtk_tree_view_column_pack_start(column, cr_pbuf, FALSE);
    gtk_tree_view_column_add_attribute(column, cr_pbuf, "pixbuf",
                                       INFO_TREE_COL_PBUF);

    cr_text = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start(column, cr_text, TRUE);
    gtk_tree_view_column_add_attribute(column, cr_text, "markup",
                                       INFO_TREE_COL_NAME);

    column = gtk_tree_view_column_new();
    gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);

    cr_text = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start(column, cr_text, TRUE);
    gtk_tree_view_column_add_attribute(column, cr_text, "markup",
                                       INFO_TREE_COL_VALUE);

    if (!extra) {
        GtkTreeSelection *sel;

        sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
        g_signal_connect(G_OBJECT(sel), "changed",
                         (GCallback) info_selected, info);
    }

    gtk_container_add(GTK_CONTAINER(scroll), treeview);

    info->scroll = scroll;
    info->view = treeview;
    info->model = model;

    gtk_widget_show_all(scroll);

    return info;
}
コード例 #11
0
ファイル: report_gui.c プロジェクト: testfarm/testfarm
static void report_gui_list_clicked(report_gui_t *rg)
{
  report_gui_list_t *rgl = &(rg->list);
  GtkTreeViewColumn *column;
  GtkCellRenderer *renderer;
  GtkTreeSelection *selection;
  int i;

  if ( rgl->window == NULL ) {
    rgl->window = create_report_list_window();

    /* Create list display widget */
    rgl->view = GTK_TREE_VIEW(lookup_widget(rgl->window, "report_list_view"));

    rgl->model = gtk_list_store_new(REPORT_LIST_NCOLS,
				    /* Node Name   */      G_TYPE_STRING,
				    /* Verdict     */      GDK_TYPE_PIXBUF,
				    /* Verdict Value */    G_TYPE_INT,
				    /* Def. Crit.  */      G_TYPE_STRING,
				    /* Def. Crit. Color */ G_TYPE_STRING,
				    /* Def. Crit. Value */ G_TYPE_INT,
				    /* Criticity   */      G_TYPE_STRING,
				    /* Crit. Color */      G_TYPE_STRING,
				    /* Criticity Value */  G_TYPE_INT,
				    /* Key         */      G_TYPE_ULONG);
    rgl->model_sort = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(rgl->model));
    gtk_tree_view_set_model(rgl->view, rgl->model_sort);

    /* Setup tree selection handler */
    report_gui_list_select_clear(rgl);
    selection = gtk_tree_view_get_selection(rgl->view);
    gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
    gtk_tree_selection_set_select_function(selection,
					   (GtkTreeSelectionFunc) report_gui_list_select, &(rg->list),
					   NULL);

    /* Column #0: Test Case name */
    renderer = gtk_cell_renderer_text_new();
    gtk_tree_view_insert_column_with_attributes(rgl->view, -1, "Test Case", renderer,
						"text", REPORT_LIST_COL_NAME,
						NULL);
    column = gtk_tree_view_get_column(rgl->view, 0);
    gtk_tree_view_column_set_clickable(column, TRUE);
    gtk_tree_view_column_set_sort_column_id(column, REPORT_LIST_SORT_NAME);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_expand(column, TRUE);

    /* Column #1: Default criticity */
    renderer = gtk_cell_renderer_text_new();
    gtk_object_set(GTK_OBJECT(renderer), "scale", 0.7, NULL);
    gtk_tree_view_insert_column_with_attributes(rgl->view, -1, "Def. Criticity", renderer,
						"text", REPORT_LIST_COL_CRITICITY_DEFAULT,
						"foreground", REPORT_LIST_COL_CRITICITY_DEFAULT_COLOR,
						NULL);
    column = gtk_tree_view_get_column(rgl->view, 1);
    gtk_tree_view_column_set_clickable(column, TRUE);
    gtk_tree_view_column_set_sort_column_id(column, REPORT_LIST_SORT_CRITICITY);
    gtk_tree_view_column_set_resizable(column, FALSE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);

    /* Column #2: Verdict and Criticity */
    column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title(column, "Verdict");

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

    renderer = gtk_cell_renderer_text_new();
    gtk_object_set(GTK_OBJECT(renderer), "scale", 0.7, NULL);
    gtk_tree_view_column_pack_start(column, renderer, TRUE);
    gtk_tree_view_column_add_attribute(column, renderer, "text", REPORT_LIST_COL_CRITICITY);
    gtk_tree_view_column_add_attribute(column, renderer, "foreground", REPORT_LIST_COL_CRITICITY_COLOR);

    gtk_tree_view_column_set_clickable(column, TRUE);
    gtk_tree_view_column_set_sort_column_id(column, REPORT_LIST_SORT_VERDICT);
    gtk_tree_view_column_set_resizable(column, FALSE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
    gtk_tree_view_append_column(rgl->view, column);

    /* Setup list sort functions */
    for (i = 0; i < REPORT_LIST_NSORTS; i++)
      gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(rgl->model_sort), i,
				      (GtkTreeIterCompareFunc) report_gui_list_sort, GINT_TO_POINTER(i),
				      NULL);

    /* Setup spot buttons */
    rgl->spot_tree = lookup_widget(rgl->window, "report_list_tree");
    gtk_widget_set_sensitive(rgl->spot_tree, 0);
    gtk_signal_connect_object(GTK_OBJECT(rgl->spot_tree),
			      "clicked", (GtkSignalFunc) report_gui_list_tree_clicked, rg);

    rgl->spot_log = lookup_widget(rgl->window, "report_list_log");
    gtk_widget_set_sensitive(rgl->spot_log, 0);
    gtk_signal_connect_object(GTK_OBJECT(rgl->spot_log),
			      "clicked", (GtkSignalFunc) report_gui_list_log_clicked, rg);


    /* Setup termination events */
    gtk_signal_connect_object(GTK_OBJECT(rgl->window), "destroy",
			      (GtkSignalFunc) report_gui_list_destroyed, rg);
    gtk_signal_connect_object(GTK_OBJECT(lookup_widget(rgl->window, "report_list_close")),
                              "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(rgl->window));

    /* Feed the list */
    report_gui_list_feed(rg);

    gtk_widget_show(rgl->window);
    gtk_tree_selection_unselect_all(selection);
  }
  else {
    gtk_window_present(GTK_WINDOW(rgl->window));
  }
}
コード例 #12
0
ファイル: tab-panel.c プロジェクト: elelay/midori-mz-sync
static void
tab_panel_app_add_browser_cb (MidoriApp*       app,
                              MidoriBrowser*   browser,
                              MidoriExtension* extension)
{
    GtkTreeStore* model;
    GtkWidget* treeview;
    GtkTreeViewColumn* column;
    GtkCellRenderer* renderer_pixbuf;
    GtkCellRenderer* renderer_text;
    GtkWidget* panel;
    GtkWidget* toolbar;
    gint i;
    /* GtkToolItem* toolitem; */

    g_object_set (browser, "show-tabs", FALSE, NULL);

    panel = katze_object_get_object (browser, "panel");

    model = gtk_tree_store_new (8, MIDORI_TYPE_VIEW,
        G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_STRING,
        G_TYPE_INT, GDK_TYPE_COLOR, GDK_TYPE_COLOR);
    g_object_set_data (G_OBJECT (browser), "tab-panel-ext-model", model);
    treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
    gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (treeview), FALSE);
    g_signal_connect (treeview, "query-tooltip",
        G_CALLBACK (tab_panel_treeview_query_tooltip_cb), NULL);
    gtk_widget_set_has_tooltip (treeview, TRUE);
    column = gtk_tree_view_column_new ();
    renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
        "pixbuf", 3, "cell-background-gdk", 6, NULL);
    renderer_text = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_text,
        "text", 4, "ellipsize", 5,
        "cell-background-gdk", 6, "foreground-gdk", 7, NULL);
    gtk_tree_view_column_set_expand (column, TRUE);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    column = gtk_tree_view_column_new ();
    renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
        "stock-id", 1, "follow-state", 2,
        "visible", 2, "cell-background-gdk", 6, NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    g_object_connect (treeview,
                      "signal::row-activated",
                      midori_extension_row_activated_cb, extension,
                      "signal::cursor-changed",
                      midori_extension_cursor_or_row_changed_cb, extension,
                      "signal::columns-changed",
                      midori_extension_cursor_or_row_changed_cb, extension,
                      "signal::button-release-event",
                      midori_extension_button_release_event_cb, extension,
                      "signal::key-release-event",
                      midori_extension_key_release_event_cb, extension,
                      "signal::popup-menu",
                      midori_extension_popup_menu_cb, extension,
                      NULL);
    gtk_widget_show (treeview);

    toolbar = gtk_toolbar_new ();
    g_object_set_data (G_OBJECT (browser), "tab-panel-ext-toolbar", toolbar);
    gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
    gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
    gtk_widget_show (toolbar);

    /*
    TODO: Implement optional thumbnail images
    toolitem = gtk_toggle_tool_button_new_from_stock (STOCK_IMAGE);
    gtk_tool_item_set_is_important (toolitem, TRUE);
    g_signal_connect (toolitem, "toggled",
            G_CALLBACK (tab_panel_button_thumbnail_toggled_cb), notebook);
    gtk_widget_show (GTK_WIDGET (toolitem));
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); */

    i = midori_panel_append_widget (MIDORI_PANEL (panel), treeview,
                                    STOCK_TAB_PANEL, _("Tab Panel"), toolbar);
    if (gtk_widget_get_visible (GTK_WIDGET (browser)))
        midori_panel_set_current_page (MIDORI_PANEL (panel), i);
    g_object_unref (panel);

    midori_browser_foreach (browser,
        (GtkCallback)tab_panel_browser_foreach_cb, treeview);

    g_signal_connect_after (browser, "add-tab",
        G_CALLBACK (tab_panel_browser_add_tab_cb), extension);
    g_signal_connect (browser, "remove-tab",
        G_CALLBACK (tab_panel_browser_remove_tab_cb), extension);
    g_signal_connect (browser, "notify::tab",
        G_CALLBACK (tab_panel_browser_notify_tab_cb), treeview);
    g_signal_connect (extension, "deactivate",
        G_CALLBACK (tab_panel_deactivate_cb), treeview);
    g_signal_connect (browser, "move-tab",
        G_CALLBACK (tab_panel_browser_move_tab_cb), NULL);
}
コード例 #13
0
void
dlg_export_to_picasaweb (GthBrowser *browser,
		         GList      *file_list)
{
	DialogData       *data;
	GtkTreeSelection *selection;
	GList            *scan;
	int               n_total;
	goffset           total_size;
	char             *total_size_formatted;
	char             *text;

	data = g_new0 (DialogData, 1);
	data->browser = browser;
	data->settings = g_settings_new (GTHUMB_PICASAWEB_SCHEMA);
	data->location = gth_file_data_dup (gth_browser_get_location_data (browser));
	data->builder = _gtk_builder_new_from_file ("export-to-picasaweb.ui", "picasaweb");
	data->dialog = _gtk_builder_get_widget (data->builder, "export_dialog");
	data->cancellable = g_cancellable_new ();

	{
		GtkCellLayout   *cell_layout;
		GtkCellRenderer *renderer;

		cell_layout = GTK_CELL_LAYOUT (GET_WIDGET ("name_treeviewcolumn"));

		renderer = gtk_cell_renderer_pixbuf_new ();
		gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
		gtk_cell_layout_set_attributes (cell_layout, renderer,
						"icon-name", ALBUM_ICON_COLUMN,
						NULL);

		renderer = gtk_cell_renderer_text_new ();
		gtk_cell_layout_pack_start (cell_layout, renderer, TRUE);
		gtk_cell_layout_set_attributes (cell_layout, renderer,
						"text", ALBUM_NAME_COLUMN,
						NULL);

		renderer = gtk_cell_renderer_pixbuf_new ();
		gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
		gtk_cell_layout_set_attributes (cell_layout, renderer,
						"icon-name", ALBUM_EMBLEM_COLUMN,
						NULL);
	}

	_gtk_window_resize_to_fit_screen_height (data->dialog, 500);

	data->file_list = NULL;
	n_total = 0;
	total_size = 0;
	for (scan = file_list; scan; scan = scan->next) {
		GthFileData *file_data = scan->data;
		const char  *mime_type;

		mime_type = gth_file_data_get_mime_type (file_data);
		if (g_content_type_equals (mime_type, "image/bmp")
		    || g_content_type_equals (mime_type, "image/gif")
		    || g_content_type_equals (mime_type, "image/jpeg")
		    || g_content_type_equals (mime_type, "image/png"))
		{
			total_size += g_file_info_get_size (file_data->info);
			n_total++;
			data->file_list = g_list_prepend (data->file_list, g_object_ref (file_data));
		}
	}
	data->file_list = g_list_reverse (data->file_list);

	if (data->file_list == NULL) {
		GError *error;

		gth_task_dialog (GTH_TASK (data->service), TRUE, NULL);

		error = g_error_new_literal (GTH_ERROR, GTH_ERROR_GENERIC, _("No valid file selected."));
		_gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), _("Could not export the files"), error);
		g_clear_error (&error);
		destroy_dialog (data);
		return;
	}

	total_size_formatted = g_format_size (total_size);
	text = g_strdup_printf (g_dngettext (NULL, "%d file (%s)", "%d files (%s)", n_total), n_total, total_size_formatted);
	gtk_label_set_text (GTK_LABEL (GET_WIDGET ("images_info_label")), text);
	g_free (text);
	g_free (total_size_formatted);

	/* Set the widget data */

	data->list_view = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_MODE_NO_SELECTION, FALSE);
	gth_file_list_set_thumb_size (GTH_FILE_LIST (data->list_view), 112);
	gth_file_list_enable_thumbs (GTH_FILE_LIST (data->list_view), TRUE);
	gth_file_list_set_ignore_hidden (GTH_FILE_LIST (data->list_view), TRUE);
	gth_file_list_set_caption (GTH_FILE_LIST (data->list_view), "none");
	gth_file_list_set_sort_func (GTH_FILE_LIST (data->list_view), gth_main_get_sort_type ("file::name")->cmp_func, FALSE);
	gtk_widget_show (data->list_view);
	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("images_box")), data->list_view, TRUE, TRUE, 0);
	gth_file_list_set_files (GTH_FILE_LIST (data->list_view), data->file_list);

	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GET_WIDGET ("album_liststore")), ALBUM_NAME_COLUMN, GTK_SORT_ASCENDING);

	gtk_widget_set_sensitive (GET_WIDGET ("upload_button"), FALSE);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("resize_checkbutton")),
				      g_settings_get_int (data->settings, PREF_PICASAWEB_RESIZE_WIDTH) != -1);

	_gtk_combo_box_add_image_sizes (GTK_COMBO_BOX (GET_WIDGET ("resize_combobox")),
					g_settings_get_int (data->settings, PREF_PICASAWEB_RESIZE_WIDTH),
					g_settings_get_int (data->settings, PREF_PICASAWEB_RESIZE_HEIGHT));

	/* Set the signals handlers. */

	g_signal_connect (data->dialog,
			  "delete-event",
			  G_CALLBACK (gtk_true),
			  NULL);
	g_signal_connect (data->dialog,
			  "response",
			  G_CALLBACK (export_dialog_response_cb),
			  data);
	g_signal_connect (GET_WIDGET ("add_album_button"),
			  "clicked",
			  G_CALLBACK (add_album_button_clicked_cb),
			  data);
	g_signal_connect (GET_WIDGET ("edit_accounts_button"),
			  "clicked",
			  G_CALLBACK (edit_accounts_button_clicked_cb),
			  data);
	g_signal_connect (GET_WIDGET ("account_combobox"),
			  "changed",
			  G_CALLBACK (account_combobox_changed_cb),
			  data);
	g_signal_connect (GET_WIDGET ("resize_checkbutton"),
			  "toggled",
			  G_CALLBACK (resize_checkbutton_toggled_cb),
			  data);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (GET_WIDGET ("albums_treeview")));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	g_signal_connect (selection,
			  "changed",
			  G_CALLBACK (albums_treeview_selection_changed_cb),
			  data);

	update_sensitivity (data);

	data->service = picasa_web_service_new (data->cancellable,
						GTK_WIDGET (data->browser),
						data->dialog);
	g_signal_connect (data->service,
			  "account-ready",
			  G_CALLBACK (service_account_ready_cb),
			  data);
	g_signal_connect (data->service,
			  "accounts-changed",
			  G_CALLBACK (service_accounts_changed_cb),
			  data);

	data->progress_dialog = gth_progress_dialog_new (GTK_WINDOW (data->browser));
	gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (data->progress_dialog), GTH_TASK (data->service));

	web_service_autoconnect (WEB_SERVICE (data->service));
}
コード例 #14
0
ファイル: dccgui.c プロジェクト: TingPing/conspire
int
fe_dcc_open_recv_win (int passive)
{
	GtkWidget *radio, *table, *vbox, *bbox, *view, *exp, *detailbox;
	GtkListStore *store;
	GSList *group;
	if (dccfwin.window)
	{
		if (!passive)
			mg_bring_tofront (dccfwin.window);
		return TRUE;
	}
	dccfwin.window = mg_create_generic_tab ("Transfers", _("conspire: Uploads and Downloads"),
														 FALSE, TRUE, close_dcc_file_window, NULL,
														 win_width, win_height, &vbox, 0);
	gtk_container_set_border_width (GTK_CONTAINER (dccfwin.window), 3);
	gtk_box_set_spacing (GTK_BOX (vbox), 3);

	store = gtk_list_store_new (N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING,
										 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
										 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
										 G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_COLOR);
	view = gtkutil_treeview_new (vbox, GTK_TREE_MODEL (store), NULL, -1);
	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE);
	/* Up/Down Icon column */
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), -1, NULL,
																gtk_cell_renderer_pixbuf_new (),
																"pixbuf", COL_TYPE, NULL);
	dcc_add_column (view, COL_STATUS, COL_COLOR, _("Status"), FALSE);
	dcc_add_column (view, COL_FILE,   COL_COLOR, _("File"), FALSE);
	dcc_add_column (view, COL_SIZE,   COL_COLOR, _("Size"), TRUE);
	dcc_add_column (view, COL_POS,    COL_COLOR, _("Position"), TRUE);
	dcc_add_column (view, COL_PERC,   COL_COLOR, "%", TRUE);
	dcc_add_column (view, COL_SPEED,  COL_COLOR, "KB/s", TRUE);
	dcc_add_column (view, COL_ETA,    COL_COLOR, _("ETA"), FALSE);
	dcc_add_column (view, COL_NICK,   COL_COLOR, _("Nick"), FALSE);

	dccfwin.list = view;
	dccfwin.store = store;
	dccfwin.sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
	view_mode = VIEW_BOTH;
	gtk_tree_selection_set_mode (dccfwin.sel, GTK_SELECTION_MULTIPLE);

	if (!prefs.windows_as_tabs)
		g_signal_connect (G_OBJECT (dccfwin.window), "configure_event",
								G_CALLBACK (dcc_configure_cb), 0);
	g_signal_connect (G_OBJECT (dccfwin.sel), "changed",
							G_CALLBACK (dcc_row_cb), NULL);
	/* double click */
	g_signal_connect (G_OBJECT (view), "row-activated",
							G_CALLBACK (dcc_dclick_cb), NULL);

	table = gtk_table_new (1, 3, FALSE);
	gtk_table_set_col_spacings (GTK_TABLE (table), 16);
	gtk_box_pack_start (GTK_BOX (vbox), table, 0, 0, 0);

	radio = gtk_radio_button_new_with_mnemonic (NULL, _("Both"));
	g_signal_connect (G_OBJECT (radio), "toggled",
							G_CALLBACK (dcc_toggle), GINT_TO_POINTER (VIEW_BOTH));
	gtk_table_attach (GTK_TABLE (table), radio, 3, 4, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));

	radio = gtk_radio_button_new_with_mnemonic (group, _("Uploads"));
	g_signal_connect (G_OBJECT (radio), "toggled",
							G_CALLBACK (dcc_toggle), GINT_TO_POINTER (VIEW_UPLOAD));
	gtk_table_attach (GTK_TABLE (table), radio, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));

	radio = gtk_radio_button_new_with_mnemonic (group, _("Downloads"));
	g_signal_connect (G_OBJECT (radio), "toggled",
							G_CALLBACK (dcc_toggle), GINT_TO_POINTER (VIEW_DOWNLOAD));
	gtk_table_attach (GTK_TABLE (table), radio, 2, 3, 0, 1, GTK_FILL, GTK_FILL, 0, 0);

	exp = gtk_expander_new (_("Details"));
	gtk_table_attach (GTK_TABLE (table), exp, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);

	detailbox = gtk_table_new (3, 3, FALSE);
	gtk_table_set_col_spacings (GTK_TABLE (detailbox), 6);
	gtk_table_set_row_spacings (GTK_TABLE (detailbox), 2);
	gtk_container_set_border_width (GTK_CONTAINER (detailbox), 6);
	g_signal_connect (G_OBJECT (exp), "activate",
							G_CALLBACK (dcc_exp_cb), detailbox);
	gtk_table_attach (GTK_TABLE (table), detailbox, 0, 4, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);

	dccfwin.file_label = dcc_detail_label (_("File:"), detailbox, 0);
	dccfwin.address_label = dcc_detail_label (_("Address:"), detailbox, 1);

	bbox = gtk_hbutton_box_new ();
	gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_SPREAD);
	gtk_box_pack_end (GTK_BOX (vbox), bbox, FALSE, FALSE, 2);

	dccfwin.abort_button = gtkutil_button (bbox, GTK_STOCK_CANCEL, 0, abort_clicked, 0, _("Abort"));
	dccfwin.accept_button = gtkutil_button (bbox, GTK_STOCK_APPLY, 0, accept_clicked, 0, _("Accept"));
	dccfwin.resume_button = gtkutil_button (bbox, GTK_STOCK_REFRESH, 0, resume_clicked, 0, _("Resume"));
	dccfwin.open_button = gtkutil_button (bbox, 0, 0, browse_dcc_folder, 0, _("Open Folder..."));
	gtk_widget_set_sensitive (dccfwin.accept_button, FALSE);
	gtk_widget_set_sensitive (dccfwin.resume_button, FALSE);
	gtk_widget_set_sensitive (dccfwin.abort_button, FALSE);

	dcc_fill_window (3);
	gtk_widget_show_all (dccfwin.window);
	gtk_widget_hide (detailbox);

	return FALSE;
}
コード例 #15
0
static void
xfburn_preferences_dialog_init (XfburnPreferencesDialog * obj)
{
  GtkBox *box = GTK_BOX (GTK_DIALOG (obj)->vbox);
  XfburnPreferencesDialogPrivate *priv = XFBURN_PREFERENCES_DIALOG_GET_PRIVATE (obj);
  
  GtkWidget *vbox, *vbox2, *vbox3, *hbox;
  GtkWidget *label;
  GtkWidget *frame;
  GtkWidget *scrolled_window;
  GtkListStore *icon_store, *store;
  gint x,y;
  GdkPixbuf *icon = NULL;
  GtkTreeIter iter;
  GtkTreeViewColumn *column_name;
  GtkCellRenderer *cell_icon, *cell_name;
  GtkWidget *button_close;
  gint idx;
  
  gtk_window_set_title (GTK_WINDOW (obj), _("Preferences"));
  xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (obj), _("Tune how Xfburn behaves"));
  gtk_window_set_default_size (GTK_WINDOW (obj), 775, 400);
  gtk_window_set_destroy_with_parent (GTK_WINDOW (obj), TRUE);
  gtk_window_set_icon_name (GTK_WINDOW (obj), GTK_STOCK_PREFERENCES);
  gtk_dialog_set_has_separator (GTK_DIALOG (obj), FALSE);
  
  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (box, hbox, TRUE, TRUE, 0);
  gtk_widget_show (hbox);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  g_object_set (G_OBJECT (scrolled_window),
                "hscrollbar-policy", GTK_POLICY_NEVER,
                "shadow-type", GTK_SHADOW_IN,
                "vscrollbar-policy", GTK_POLICY_NEVER,
                NULL);
  gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, FALSE, FALSE, 0);
  gtk_widget_show (scrolled_window);

  /* icon bar */
  icon_store = gtk_list_store_new (SETTINGS_LIST_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
  priv->icon_bar = exo_icon_bar_new_with_model (GTK_TREE_MODEL (icon_store));
  exo_icon_bar_set_pixbuf_column (EXO_ICON_BAR (priv->icon_bar), SETTINGS_LIST_PIXBUF_COLUMN);
  exo_icon_bar_set_text_column (EXO_ICON_BAR (priv->icon_bar), SETTINGS_LIST_TEXT_COLUMN);
  gtk_container_add (GTK_CONTAINER (scrolled_window), priv->icon_bar);
  gtk_widget_show (priv->icon_bar);
  
  /* notebook */
  priv->notebook = gtk_notebook_new ();
  gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), BORDER);
  g_object_set (G_OBJECT (priv->notebook),
                "show-border", FALSE,
                "show-tabs", FALSE,
                NULL);
  gtk_box_pack_start (GTK_BOX (hbox), priv->notebook, TRUE, TRUE, BORDER);
  gtk_widget_show (priv->notebook);

  /* general tab */
  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER);
  idx = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), vbox, NULL);
  gtk_widget_show (vbox);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox2);

  frame = xfce_gtk_frame_box_new_with_content (_("Temporary directory"), vbox2);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, BORDER);
  gtk_widget_show (frame);

  priv->chooser_button = gtk_file_chooser_button_new (_("Temporary directory"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
  gtk_box_pack_start (GTK_BOX (vbox2), priv->chooser_button, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->chooser_button);

  priv->check_clean_tmpdir = gtk_check_button_new_with_mnemonic (_("_Clean temporary directory on exit"));
  gtk_box_pack_start (GTK_BOX (vbox2), priv->check_clean_tmpdir, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->check_clean_tmpdir);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox2);

  frame = xfce_gtk_frame_box_new_with_content (_("File browser"), vbox2);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, BORDER);
  gtk_widget_show (frame);

  priv->check_show_hidden = gtk_check_button_new_with_mnemonic (_("Show _hidden files"));
  gtk_box_pack_start (GTK_BOX (vbox2), priv->check_show_hidden, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->check_show_hidden);
  g_signal_connect (G_OBJECT (priv->check_show_hidden), "clicked", G_CALLBACK (cb_show_hidden_clicked), NULL);

  priv->check_show_human_readable = gtk_check_button_new_with_mnemonic (_("Show human_readable filesizes"));
  gtk_box_pack_start (GTK_BOX (vbox2), priv->check_show_human_readable, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->check_show_human_readable);

  icon = gtk_widget_render_icon (GTK_WIDGET (priv->icon_bar),
                                 GTK_STOCK_PROPERTIES,
                                 GTK_ICON_SIZE_DIALOG,
                                 NULL);
  gtk_list_store_append (icon_store, &iter);
  gtk_list_store_set (icon_store, &iter,
                      SETTINGS_LIST_PIXBUF_COLUMN, icon,
                      SETTINGS_LIST_TEXT_COLUMN, _("General"),
                      SETTINGS_LIST_INDEX_COLUMN, idx,
                      -1);
  g_object_unref (G_OBJECT (icon));
  
  /* devices tab */
  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER);
  idx = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), vbox, NULL);
  gtk_widget_show (vbox);

  label = gtk_label_new (_("Devices"));
  gtk_widget_show (label);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (priv->notebook),
                              gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 1), label);
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox2);

  frame = xfce_gtk_frame_box_new_with_content (_("Detected devices"), vbox2);
  gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, BORDER);
  gtk_widget_show (frame);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
  gtk_widget_show (scrolled_window);
  gtk_box_pack_start (GTK_BOX (vbox2), scrolled_window, TRUE, TRUE, BORDER);

  store = gtk_list_store_new (DEVICE_LIST_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING,
                              G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
                              G_TYPE_BOOLEAN);
  priv->treeview_devices = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), DEVICE_LIST_COLUMN_NAME, GTK_SORT_ASCENDING);
  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->treeview_devices), TRUE);
  gtk_widget_show (priv->treeview_devices);
  gtk_container_add (GTK_CONTAINER (scrolled_window), priv->treeview_devices);
  g_object_unref (store);
  
  /* add columns */
  column_name = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column_name, _("Name"));
  gtk_tree_view_column_set_expand (column_name, TRUE);

  cell_icon = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column_name, cell_icon, FALSE);
  gtk_tree_view_column_set_attributes (column_name, cell_icon, "pixbuf", DEVICE_LIST_COLUMN_ICON, NULL);
  g_object_set (cell_icon, "xalign", 0.0, "ypad", 0, NULL);

  cell_name = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column_name, cell_name, TRUE);
  gtk_tree_view_column_set_attributes (column_name, cell_name, "text", DEVICE_LIST_COLUMN_NAME, NULL);

  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview_devices), column_name);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Node"),
                                               gtk_cell_renderer_text_new (), "text", DEVICE_LIST_COLUMN_NODE, NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write CD-R"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_CDR, NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write CD-RW"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_CDRW,
                                               NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write DVD-R"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_DVDR,
                                               NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write DVD-RAM"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_DVDRAM,
                                               NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write Blu-ray"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_BD,
                                               NULL);

  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, BORDER);
  gtk_widget_show (hbox);

  priv->button_scan = xfce_gtk_button_new_mixed (GTK_STOCK_CDROM, _("Sc_an for devices"));
  gtk_box_pack_end (GTK_BOX (hbox), priv->button_scan, FALSE, FALSE, BORDER);
  g_signal_connect (G_OBJECT (priv->button_scan), "clicked", G_CALLBACK (scan_button_clicked_cb), obj);
  gtk_widget_show (priv->button_scan);

  gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &x, &y);
  icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), "media-optical", x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);
  if (!icon)
    icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), "media-cdrom", x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);
  if (!icon)
    icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), GTK_STOCK_CDROM, x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);

  
  gtk_list_store_append (icon_store, &iter);
  gtk_list_store_set (icon_store, &iter,
                      SETTINGS_LIST_PIXBUF_COLUMN, icon,
                      SETTINGS_LIST_TEXT_COLUMN, _("Devices"),
                      SETTINGS_LIST_INDEX_COLUMN, idx,
                      -1);
  if (icon)
    g_object_unref (G_OBJECT (icon));
  
  exo_mutual_binding_new (G_OBJECT (priv->notebook), "page", G_OBJECT (priv->icon_bar), "active");


  /* below the device list */
#if 0
  priv->check_empty_speed_list = gtk_check_button_new_with_mnemonic (_("Show warning on _empty speed list"));
  gtk_box_pack_start (GTK_BOX (vbox2), priv->check_empty_speed_list, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->check_empty_speed_list);
#endif

  /* fifo */
  vbox3 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox3);

  frame = xfce_gtk_frame_box_new_with_content (_("FIFO buffer size (in kb)"), vbox3);
  gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, BORDER);
  gtk_widget_show (frame);

  priv->scale_fifo = gtk_hscale_new_with_range (0.0, FIFO_MAX_SIZE, 32.0);
  gtk_scale_set_value_pos (GTK_SCALE (priv->scale_fifo), GTK_POS_LEFT);
  gtk_range_set_value (GTK_RANGE (priv->scale_fifo), 0);
  gtk_box_pack_start (GTK_BOX (vbox3), priv->scale_fifo, FALSE, FALSE, BORDER/2);
  gtk_widget_show (priv->scale_fifo);

  
  /* action buttons */
  button_close = gtk_button_new_from_stock ("gtk-close");
  gtk_widget_show (button_close);
  gtk_dialog_add_action_widget (GTK_DIALOG (obj), button_close, GTK_RESPONSE_CLOSE);
  GTK_WIDGET_SET_FLAGS (button_close, GTK_CAN_DEFAULT);
  gtk_widget_grab_focus (button_close);
  gtk_widget_grab_default (button_close);

  g_signal_connect (G_OBJECT (obj), "response", G_CALLBACK (xfburn_preferences_dialog_response_cb), priv);
  
  refresh_devices_list (obj);
  
  g_object_unref (icon_store);
}
コード例 #16
0
ファイル: gimpgegltool.c プロジェクト: barmic/gimp
static void
gimp_gegl_tool_dialog (GimpImageMapTool *image_map_tool)
{
  GimpGeglTool      *tool   = GIMP_GEGL_TOOL (image_map_tool);
  GimpOperationTool *o_tool = GIMP_OPERATION_TOOL (image_map_tool);
  GtkListStore      *store;
  GtkCellRenderer   *cell;
  GtkWidget         *main_vbox;
  GtkWidget         *hbox;
  GtkWidget         *combo;
  GList             *opclasses;
  GList             *iter;

  GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->dialog (image_map_tool);

  main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);

  /*  The operation combo box  */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
  gtk_box_reorder_child (GTK_BOX (main_vbox), hbox, 0);
  gtk_widget_show (hbox);

  store = gtk_list_store_new (N_COLUMNS,
                              G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);

  opclasses = gimp_get_geglopclasses ();

  for (iter = opclasses; iter; iter = iter->next)
    {
      GeglOperationClass *opclass = GEGL_OPERATION_CLASS (iter->data);
      const gchar        *stock_id;
      const gchar        *label;

      if (g_str_has_prefix (opclass->name, "gegl:"))
        {
          label    = opclass->name + strlen ("gegl:");
          stock_id = GIMP_STOCK_GEGL;
        }
      else
        {
          label    = opclass->name;
          stock_id = NULL;
        }

      gtk_list_store_insert_with_values (store, NULL, -1,
                                         COLUMN_NAME,     opclass->name,
                                         COLUMN_LABEL,    label,
                                         COLUMN_STOCK_ID, stock_id,
                                         -1);
    }

  g_list_free (opclasses);

  combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
  g_object_unref (store);
  gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
  gtk_widget_show (combo);

  cell = gtk_cell_renderer_pixbuf_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, FALSE);
  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), cell,
                                 "stock-id", COLUMN_STOCK_ID);

  cell = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), cell,
                                 "text", COLUMN_LABEL);

  g_signal_connect (combo, "changed",
                    G_CALLBACK (gimp_gegl_tool_operation_changed),
                    tool);

  tool->operation_combo = combo;

  tool->description_label = gtk_label_new ("");
  gtk_label_set_line_wrap (GTK_LABEL (tool->description_label), TRUE);
  gtk_misc_set_alignment (GTK_MISC (tool->description_label), 0.0, 0.0);
  gtk_box_pack_start (GTK_BOX (main_vbox), tool->description_label,
                      FALSE, FALSE, 0);
  gtk_box_reorder_child (GTK_BOX (main_vbox), tool->description_label, 1);

  /*  The options vbox  */
  o_tool->options_table =
    gtk_label_new (_("Select an operation from the list above"));
  gimp_label_set_attributes (GTK_LABEL (o_tool->options_table),
                             PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
                             -1);
  gtk_misc_set_padding (GTK_MISC (o_tool->options_table), 0, 4);
  gtk_container_add (GTK_CONTAINER (o_tool->options_box),
                     o_tool->options_table);
  gtk_widget_show (o_tool->options_table);
}
コード例 #17
0
ファイル: greeter_item_ulist.c プロジェクト: echofourpapa/mdm
static void
greeter_generate_userlist (GtkWidget *tv, GreeterItemInfo *info)
{
	GtkTreeModel *tm;
	GtkTreeViewColumn *column_one, *column_two;
	GtkTreeSelection *selection;
	GList *list, *li;

	mdm_greeter_users_init ();

	check_for_displays ();

	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tv),
					   FALSE);
	gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tv),
					 FALSE);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	if (users != NULL) {
		g_signal_connect (selection, "changed",
				  G_CALLBACK (user_selected),
				  NULL);

		g_signal_connect (GTK_TREE_VIEW (tv), "button_release_event",
				  G_CALLBACK (browser_change_focus),
				  NULL);

		tm = (GtkTreeModel *)gtk_list_store_new (4,
							 GDK_TYPE_PIXBUF,
							 G_TYPE_STRING,
							 G_TYPE_STRING,
							 G_TYPE_BOOLEAN);
		gtk_tree_view_set_model (GTK_TREE_VIEW (tv), tm);
		column_one = gtk_tree_view_column_new_with_attributes (_("Icon"),
								       gtk_cell_renderer_pixbuf_new (),
								       "pixbuf", GREETER_ULIST_ICON_COLUMN,
								       NULL);
		gtk_tree_view_append_column (GTK_TREE_VIEW (tv), column_one);

		column_two = gtk_tree_view_column_new_with_attributes (_("Username"),
								       gtk_cell_renderer_text_new (),
								       "markup", GREETER_ULIST_LABEL_COLUMN,
								       NULL);
		gtk_tree_view_append_column (GTK_TREE_VIEW (tv), column_two);

		greeter_populate_user_list (tm);

		list = gtk_tree_view_column_get_cell_renderers (column_one);
		for (li = list; li != NULL; li = li->next) {
			GtkObject *cell = li->data;

			if (info->data.list.icon_color != NULL)
				g_object_set (cell, "cell-background",
					      info->data.list.icon_color, NULL);
		}

		list = gtk_tree_view_column_get_cell_renderers (column_two);
		for (li = list; li != NULL; li = li->next) {
			GtkObject *cell = li->data;

			if (info->data.list.label_color != NULL) 
				g_object_set (cell, "background",
					      info->data.list.label_color, NULL);
		}
	}

	/* we are done with the hash */
	g_hash_table_destroy (displays_hash);
	displays_hash = NULL;
}
コード例 #18
0
static void
pluma_documents_panel_init (PlumaDocumentsPanel *panel)
{
	GtkWidget 		*sw;
	GtkTreeViewColumn	*column;
	GtkCellRenderer 	*cell;
	GtkTreeSelection 	*selection;

	panel->priv = PLUMA_DOCUMENTS_PANEL_GET_PRIVATE (panel);
	
	panel->priv->adding_tab = FALSE;
	panel->priv->is_reodering = FALSE;

	gtk_orientable_set_orientation (GTK_ORIENTABLE (panel),
	                                GTK_ORIENTATION_VERTICAL);
	
	/* Create the scrolled window */
	sw = gtk_scrolled_window_new (NULL, NULL);
	g_return_if_fail (sw != 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_widget_show (sw);
	gtk_box_pack_start (GTK_BOX (panel), sw, TRUE, TRUE, 0);
	
	/* Create the empty model */
	panel->priv->model = GTK_TREE_MODEL (gtk_list_store_new (N_COLUMNS,
								 GDK_TYPE_PIXBUF,
								 G_TYPE_STRING,
								 G_TYPE_POINTER));

	/* Create the treeview */
	panel->priv->treeview = gtk_tree_view_new_with_model (panel->priv->model);
	g_object_unref (G_OBJECT (panel->priv->model));
	gtk_container_add (GTK_CONTAINER (sw), panel->priv->treeview);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (panel->priv->treeview), FALSE);
	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (panel->priv->treeview), TRUE);

	g_object_set (panel->priv->treeview, "has-tooltip", TRUE, NULL);

	gtk_widget_show (panel->priv->treeview);
	
	column = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title (column, _("Documents"));

	cell = gtk_cell_renderer_pixbuf_new ();
	gtk_tree_view_column_pack_start (column, cell, FALSE);
	gtk_tree_view_column_add_attribute (column, cell, "pixbuf", PIXBUF_COLUMN);
	cell = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, cell, TRUE);
	gtk_tree_view_column_add_attribute (column, cell, "markup", NAME_COLUMN);

	gtk_tree_view_append_column (GTK_TREE_VIEW (panel->priv->treeview),
				     column);
				     
	selection = gtk_tree_view_get_selection (
			GTK_TREE_VIEW (panel->priv->treeview));

	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	
	g_signal_connect (panel->priv->treeview,
			  "cursor_changed",
			  G_CALLBACK (treeview_cursor_changed),
			  panel);
	g_signal_connect (panel->priv->treeview,
			  "button-press-event",
			  G_CALLBACK (panel_button_press_event),
			  panel);
	g_signal_connect (panel->priv->treeview,
			  "popup-menu",
			  G_CALLBACK (panel_popup_menu),
			  panel);
	g_signal_connect (panel->priv->treeview,
			  "query-tooltip",
			  G_CALLBACK (treeview_query_tooltip),
			  NULL);

	g_signal_connect (panel->priv->model,
			  "row-inserted",
			  G_CALLBACK (treeview_row_inserted),
			  panel);
}
コード例 #19
0
ファイル: list_store.c プロジェクト: ahodesuka/gtk
static void
add_columns (GtkTreeView *treeview)
{
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;
  GtkTreeModel *model = gtk_tree_view_get_model (treeview);

  /* column for fixed toggles */
  renderer = gtk_cell_renderer_toggle_new ();
  g_signal_connect (renderer, "toggled",
                    G_CALLBACK (fixed_toggled), model);

  column = gtk_tree_view_column_new_with_attributes ("Fixed?",
                                                     renderer,
                                                     "active", COLUMN_FIXED,
                                                     NULL);

  /* set this column to a fixed sizing (of 50 pixels) */
  gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
                                   GTK_TREE_VIEW_COLUMN_FIXED);
  gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
  gtk_tree_view_append_column (treeview, column);

  /* column for bug numbers */
  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("Bug number",
                                                     renderer,
                                                     "text",
                                                     COLUMN_NUMBER,
                                                     NULL);
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_NUMBER);
  gtk_tree_view_append_column (treeview, column);

  /* column for severities */
  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("Severity",
                                                     renderer,
                                                     "text",
                                                     COLUMN_SEVERITY,
                                                     NULL);
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_SEVERITY);
  gtk_tree_view_append_column (treeview, column);

  /* column for description */
  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("Description",
                                                     renderer,
                                                     "text",
                                                     COLUMN_DESCRIPTION,
                                                     NULL);
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_DESCRIPTION);
  gtk_tree_view_append_column (treeview, column);

  /* column for spinner */
  renderer = gtk_cell_renderer_spinner_new ();
  column = gtk_tree_view_column_new_with_attributes ("Spinning",
                                                     renderer,
                                                     "pulse",
                                                     COLUMN_PULSE,
                                                     "active",
                                                     COLUMN_ACTIVE,
                                                     NULL);
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_PULSE);
  gtk_tree_view_append_column (treeview, column);

  /* column for symbolic icon */
  renderer = gtk_cell_renderer_pixbuf_new ();
  column = gtk_tree_view_column_new_with_attributes ("Symbolic icon",
                                                     renderer,
                                                     "icon-name",
                                                     COLUMN_ICON,
                                                     "sensitive",
                                                     COLUMN_SENSITIVE,
                                                     NULL);
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_ICON);
  gtk_tree_view_append_column (treeview, column);
}
コード例 #20
0
ファイル: gui_cardview.c プロジェクト: nuschpl/cardpeek
GtkWidget *gui_cardview_create_window(GtkAccelGroup *accel_group)
{
    GtkCellRenderer     *renderer;
    GtkWidget           *scrolled_window;
    GtkTreeViewColumn   *column;
    GtkWidget           *base_container;
    GtkWidget           *toolbar;
    GtkWidget	      *colheader;
    GtkWidget	      *colitem;

    /* Create base window container */

    base_container = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);

    /* Create the toolbar */

    TB_CARD_VIEW[0].callback_data = create_analyzer_menu(accel_group);

    toolbar = gui_toolbar_new(TB_CARD_VIEW);

    gtk_box_pack_start (GTK_BOX (base_container), toolbar, FALSE, FALSE, 0);

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

    gtk_box_pack_end (GTK_BOX (base_container), scrolled_window, TRUE, TRUE, 0);

    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);


    CARDVIEW = gtk_tree_view_new ();

    g_signal_connect(CARDVIEW,
                     "button-press-event", (GCallback) menu_cardview_button_press_event, NULL);

    g_signal_connect(CARDVIEW,
                     "key-press-event", (GCallback) menu_cardview_key_press_event, NULL);


    gtk_container_add (GTK_CONTAINER (scrolled_window), CARDVIEW);

    /* --- Column #0 --- */

    column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title(column,"Items");
    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_set_cell_data_func(column, renderer, internal_cell_renderer_icon_cb, NULL, NULL);

    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start(column, renderer, TRUE);
    gtk_tree_view_column_set_cell_data_func(column, renderer, internal_cell_renderer_markup_cb, NULL, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(CARDVIEW), column);

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

    column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title(column,"Size");

    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start(column, renderer, FALSE);
    gtk_tree_view_column_set_cell_data_func(column, renderer, internal_cell_renderer_size_cb, NULL, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(CARDVIEW), column);

    g_object_set(renderer,
                 "foreground", "blue",
                 NULL);
    /* --- Column #2 --- */

    renderer = custom_cell_renderer_flexi_new(TRUE);
    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (CARDVIEW),
            -1,
            NULL,
            renderer,
            "raw-value", CC_VAL,
            NULL);
    column = gtk_tree_view_get_column(GTK_TREE_VIEW (CARDVIEW),2);
    gtk_tree_view_column_set_resizable(column,TRUE);
    gtk_tree_view_column_set_visible (column,FALSE);
    gtk_tree_view_column_set_clickable(column,TRUE);
    g_signal_connect(column,"clicked",(GCallback)menu_cardview_column_activated,NULL);

    colheader = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,10);
    gtk_box_pack_start (GTK_BOX (colheader), gtk_label_new("Raw value"), FALSE, FALSE, 0);
    if ((colitem = gtk_image_new_from_icon_name("gtk-convert",GTK_ICON_SIZE_MENU)))
    {
        gtk_box_pack_start (GTK_BOX (colheader), colitem, FALSE, FALSE, 0);
    }
    gtk_widget_show_all(colheader);
    gtk_widget_set_tooltip_text(colheader,"Click to switch to 'interpreted' data.");
    gtk_tree_view_column_set_widget(column,colheader);

    /* --- Column #3 --- */

    renderer = custom_cell_renderer_flexi_new(FALSE);
    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (CARDVIEW),
            -1,
            NULL,
            renderer,
            "raw-value", CC_VAL,
            "alt_text", CC_ALT,
            "mime-type", CC_MIME_TYPE,
            NULL);

    column = gtk_tree_view_get_column(GTK_TREE_VIEW (CARDVIEW),3);
    gtk_tree_view_column_set_resizable(column,TRUE);
    gtk_tree_view_column_set_clickable(column,TRUE);
    g_signal_connect(column,"clicked",(GCallback)menu_cardview_column_activated,NULL);

    colheader = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,10);
    gtk_box_pack_start (GTK_BOX (colheader), gtk_label_new("Interpreted value"), FALSE, FALSE, 0);
    if ((colitem = gtk_image_new_from_icon_name("gtk-convert",GTK_ICON_SIZE_MENU)))
    {
        gtk_box_pack_start (GTK_BOX (colheader), colitem, FALSE, FALSE, 0);
    }
    gtk_widget_show_all(colheader);
    gtk_widget_set_tooltip_text(colheader,"Click to switch to 'raw' data.");
    gtk_tree_view_column_set_widget(column,colheader);

    /* add the dat model */

    /* CARD_DATA_STORE = */ dyntree_model_new();

    gtk_tree_view_set_model(GTK_TREE_VIEW(CARDVIEW),GTK_TREE_MODEL(CARD_DATA_STORE));

    g_object_unref(CARD_DATA_STORE);

    return base_container;
}
コード例 #21
0
ファイル: list_upcoming.c プロジェクト: maxiwell/homebank
GtkWidget *create_list_upcoming(void)
{
GtkListStore *store;
GtkWidget *view;
GtkCellRenderer    *renderer;
GtkTreeViewColumn  *column;

	DB( g_print ("\n[list_upcoming] create\n") );

	/* create list store */
	store = gtk_list_store_new(
	  	NUM_LST_DSPUPC,
		G_TYPE_POINTER,
		G_TYPE_BOOLEAN,	/* payee */
		G_TYPE_STRING,	/* memo */
		G_TYPE_DOUBLE,	/* expense */
		G_TYPE_DOUBLE,	/* income */
		G_TYPE_POINTER,	/* account */
	    G_TYPE_BOOLEAN,	/* next on */
		G_TYPE_INT,		/* remaining */
		G_TYPE_INT		/* nb late */
		);

	//treeview
	view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
	g_object_unref(store);

	gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), PREFS->grid_lines);
	//gtk_tree_view_set_search_column (GTK_TREE_VIEW (treeview),
	//			       COLUMN_DESCRIPTION);

	gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), GTK_SELECTION_SINGLE);

	/* column : Late */
	column = gtk_tree_view_column_new();
	//TRANSLATORS: title of list column to inform the scheduled transaction is Late
	gtk_tree_view_column_set_title(column, _("Late"));

	renderer = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func(column, renderer, sched_lateicon_cell_data_function, NULL, NULL);

	renderer = gtk_cell_renderer_text_new ();
	g_object_set(renderer, "xalign", 1.0, NULL);
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func(column, renderer, sched_latetext_cell_data_function, NULL, NULL);

	//gtk_tree_view_column_set_sort_column_id (column, LST_DSPUPC_NB_LATE);
	gtk_tree_view_column_set_alignment (column, 0.5);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);

	/* column : Remaining */
	/*column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("In"));

	renderer = gtk_cell_renderer_text_new ();
	g_object_set(renderer, "xalign", 1.0, NULL);
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func(column, renderer, remaining_cell_data_function, NULL, NULL);
	//gtk_tree_view_column_set_sort_column_id (column, LST_DSPUPC_REMAINING);
	gtk_tree_view_column_set_alignment (column, 0.5);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
	*/
	
	/* column: Next on */
	renderer = gtk_cell_renderer_text_new ();

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Next date"));
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func(column, renderer, date_cell_data_function, NULL, NULL);
	//gtk_tree_view_column_set_sort_column_id (column, LST_DSPUPC_DATE);
	gtk_tree_view_column_set_alignment (column, 0.5);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);

	/* column: Payee */
	renderer = gtk_cell_renderer_text_new ();
	g_object_set(renderer, 
		"ellipsize", PANGO_ELLIPSIZE_END,
	    "ellipsize-set", TRUE,
	    NULL);
	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Payee"));
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func(column, renderer, payee_cell_data_function, NULL, NULL);
	gtk_tree_view_column_set_resizable(column, TRUE);
	//gtk_tree_view_column_add_attribute(column, renderer, "text", 1);
	//gtk_tree_view_column_set_sort_column_id (column, LST_DSPACC_NAME);
	gtk_tree_view_column_set_alignment (column, 0.5);
	gtk_tree_view_column_set_min_width(column, HB_MINWIDTH_LIST/2);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);

	gtk_tree_view_column_set_fixed_width(column, PREFS->pnl_upc_col_pay_width);

	/* column: Memo */
	renderer = gtk_cell_renderer_text_new ();
	g_object_set(renderer, 
		"ellipsize", PANGO_ELLIPSIZE_END,
	    "ellipsize-set", TRUE,
	    NULL);

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Memo"));
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func(column, renderer, memo_cell_data_function, NULL, NULL);
	gtk_tree_view_column_set_resizable(column, TRUE);
	//gtk_tree_view_column_add_attribute(column, renderer, "text", 2);
	//gtk_tree_view_column_set_sort_column_id (column, LST_DSPACC_NAME);
	gtk_tree_view_column_set_alignment (column, 0.5);
	gtk_tree_view_column_set_min_width(column, HB_MINWIDTH_LIST/2);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);

	gtk_tree_view_column_set_fixed_width(column, PREFS->pnl_upc_col_mem_width);

	/* column: Amount */
	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Expense"));
	renderer = gtk_cell_renderer_text_new ();
	g_object_set(renderer, "xalign", 1.0, NULL);
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func(column, renderer, amount_cell_data_function, GINT_TO_POINTER(-1), NULL);
	//gtk_tree_view_column_set_sort_column_id (column, LST_DSPACC_NAME);
	gtk_tree_view_column_set_alignment (column, 0.5);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);

	/* column: Amount */
	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Income"));
	renderer = gtk_cell_renderer_text_new ();
	g_object_set(renderer, "xalign", 1.0, NULL);
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func(column, renderer, amount_cell_data_function, GINT_TO_POINTER(1), NULL);
	//gtk_tree_view_column_set_sort_column_id (column, LST_DSPACC_NAME);
	gtk_tree_view_column_set_alignment (column, 0.5);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);

	/* column: Account */
	renderer = gtk_cell_renderer_text_new ();
	/*g_object_set(renderer, 
		"ellipsize", PANGO_ELLIPSIZE_END,
	    "ellipsize-set", TRUE,
	    NULL);*/

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Account"));
	gtk_tree_view_column_pack_start(column, renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func(column, renderer, account_cell_data_function, NULL, NULL);
	gtk_tree_view_column_set_resizable(column, TRUE);
	//gtk_tree_view_column_set_sort_column_id (column, LST_DSPOPE_DATE);
	gtk_tree_view_column_set_alignment (column, 0.5);
	//gtk_tree_view_column_set_min_width(column, HB_MINWIDTH_LIST);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);





  /* column: empty */
	column = gtk_tree_view_column_new();
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);

	gtk_tree_selection_set_select_function(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), list_account_selectionfunc, NULL, NULL);

	
    /* set initial sort order */
    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), LST_DSPUPC_REMAINING, GTK_SORT_ASCENDING);


	g_signal_connect (view, "destroy", G_CALLBACK (list_upcoming_destroy), NULL);


	return(view);
}
コード例 #22
0
void sensor_config_dialog_create(SensorsApplet *sensors_applet) {
	GtkTreeModel *model;
	GtkTreeIter iter;

        SensorConfigDialog *config_dialog;

        GtkListStore *icon_store;
        IconType count;
        GdkPixbuf *pixbuf;

        GdkColor graph_color;        
        gchar *sensor_label;
        gchar *header_text;
        
	/* instance variables for data */
	gdouble low_value, high_value, multiplier, offset;
	gboolean alarm_enable;
	gchar *low_alarm_command, *high_alarm_command;
	gint alarm_timeout;
        IconType icon_type;
        gchar *graph_color_string;

        config_dialog = g_new0(SensorConfigDialog, 1);
        config_dialog->sensors_applet = sensors_applet;

	gtk_tree_selection_get_selected(sensors_applet->selection,
					&model,
					&iter);
	/* get current values of alarm and its enable */
	gtk_tree_model_get(model, &iter,
			   LOW_VALUE_COLUMN, &low_value,
			   HIGH_VALUE_COLUMN, &high_value,
			   ALARM_ENABLE_COLUMN, &alarm_enable,
			   LOW_ALARM_COMMAND_COLUMN, &low_alarm_command,
                           HIGH_ALARM_COMMAND_COLUMN, &high_alarm_command,
			   ALARM_TIMEOUT_COLUMN, &alarm_timeout,
			   MULTIPLIER_COLUMN, &multiplier,
			   OFFSET_COLUMN, &offset,
                           ICON_TYPE_COLUMN, &icon_type,
                           GRAPH_COLOR_COLUMN, &graph_color_string,
                           LABEL_COLUMN, &sensor_label,
			   -1);
        header_text = g_strdup_printf("%s - %s", _("Sensor Properties"), sensor_label);

	config_dialog->dialog = gtk_dialog_new_with_buttons(header_text,
                                                            GTK_WINDOW(sensors_applet->prefs_dialog->dialog),
                                                            GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
                                                            GTK_STOCK_HELP,
                                                            GTK_RESPONSE_HELP,
                                                            GTK_STOCK_CLOSE,
                                                            GTK_RESPONSE_CLOSE,
                                                            NULL);
        
        g_free(header_text);
        g_free(sensor_label);

	g_object_set(config_dialog->dialog,
		     "border-width", 12,
		     NULL);
	
	g_signal_connect(config_dialog->dialog,
                         "response",
                         G_CALLBACK(sensor_config_dialog_response),
                         config_dialog);
	
	
        /* graph stuff */
        header_text = g_markup_printf_escaped("<b>%s</b>", _("Graph"));
        config_dialog->graph_header = g_object_new(GTK_TYPE_LABEL,
                                   "use-markup", TRUE,
                                   "label", header_text,
                                   "xalign", 0.0,
                                   NULL);
        g_free(header_text);


        gdk_color_parse(graph_color_string,
                        &graph_color);
        
        config_dialog->graph_color_button = GTK_COLOR_BUTTON(gtk_color_button_new_with_color(&graph_color));
	config_dialog->graph_color_button_aligner = g_object_new(GTK_TYPE_ALIGNMENT,
                                                  "child", config_dialog->graph_color_button,
                                                   "xalign", 0.0,
                                                   "xscale", 0.0,
                                                   NULL);

        gtk_color_button_set_title(config_dialog->graph_color_button, _("Graph Color"));
        
        config_dialog->graph_color_label = g_object_new(GTK_TYPE_LABEL,
                                         "label", _("Graph _color"),
					"mnemonic-widget", config_dialog->graph_color_button,
					"use-underline", TRUE,
					"xalign", 0.0,
					NULL);

	g_signal_connect(config_dialog->graph_color_button, "color-set", 
                         G_CALLBACK(sensor_config_dialog_graph_color_set), 
                         config_dialog);

        /* icon stuff */
        header_text = g_markup_printf_escaped("<b>%s</b>", _("Icon"));
        config_dialog->icon_header = g_object_new(GTK_TYPE_LABEL,
                                   "use-markup", TRUE,
                                   "label", header_text,
                                   "xalign", 0.0,
                                   NULL);
        g_free(header_text);

        /* icon type */
        icon_store = gtk_list_store_new(1, GDK_TYPE_PIXBUF);

        /* populate list with icons */
        for (count = CPU_ICON; count < NUM_ICONS; count++) {
                pixbuf = sensors_applet_load_icon(count);
                if (pixbuf) {
                        gtk_list_store_insert(icon_store, &iter, count);
                        gtk_list_store_set(icon_store, &iter,
                                           0, pixbuf,
                                           -1);
                        /* let list hold icons */
                        g_object_unref(pixbuf);
                }
        }
        
        config_dialog->icon_type_combo_box = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(icon_store)));

	config_dialog->icon_type_combo_box_aligner = g_object_new(GTK_TYPE_ALIGNMENT,
                                                   "child", config_dialog->icon_type_combo_box,
                                                   "xalign", 0.0,
                                                   "xscale", 0.0,
                                                   NULL);

        config_dialog->icon_renderer = gtk_cell_renderer_pixbuf_new();
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
                                   GTK_CELL_RENDERER(config_dialog->icon_renderer),
                                   FALSE);

        gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
                                      GTK_CELL_RENDERER(config_dialog->icon_renderer),
                                      "pixbuf", 0);

        gtk_combo_box_set_active(config_dialog->icon_type_combo_box,
                                 icon_type);

	g_signal_connect(config_dialog->icon_type_combo_box, "changed", 
                         G_CALLBACK(sensor_config_dialog_icon_type_changed), 
                         config_dialog);


        
        config_dialog->icon_type_label = g_object_new(GTK_TYPE_LABEL,
 					"label", _("Sensor _icon"),
					"mnemonic-widget", config_dialog->icon_type_combo_box,
					"use-underline", TRUE,
					"xalign", 0.0,
					NULL);

        header_text = g_markup_printf_escaped("<b>%s</b>", _("Scaling Parameters"));
        config_dialog->scale_header = g_object_new(GTK_TYPE_LABEL,
                                   "use-markup", TRUE,
                                   "label", header_text,
                                   "xalign", 0.0,
                                   NULL);
        g_free(header_text);

	/* do multiplier and offset widgets */
	config_dialog->multiplier_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
			      "value", 1.0,
			      "lower", 0.001,
			      "upper", 1000.0,
			      "step-increment", 0.1,
			      "page-increment", 1.0,
			      "page-size", 1.0,
			      NULL);

	
	config_dialog->multiplier_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
					     "adjustment", config_dialog->multiplier_adjust,
					     "digits", VALUE_DECIMAL_PLACES,
					     "value", multiplier,
					     "width-chars", SPINBUTTON_WIDTH_CHARS,
					     NULL);

	config_dialog->multiplier_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT,
						     "child", config_dialog->multiplier_spinbutton,
						     "xalign", 0.0,
						     "xscale", 0.0,
						     NULL);

	config_dialog->multiplier_label = g_object_new(GTK_TYPE_LABEL,
                                                       "label", _("Sensor value _multiplier"),
                                                       "mnemonic-widget", config_dialog->multiplier_spinbutton,
                                                       "use-underline", TRUE,
                                                       "xalign", 0.0,
                                                       NULL);
	
	
	g_signal_connect(config_dialog->multiplier_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_multiplier_changed), config_dialog);
	

	config_dialog->offset_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
				     "value", 0.0,
				     "lower", -1000.000,
				     "upper", 1000.000,
				     "step-increment", 0.01,
				     "page-increment", 1.0,
				     "page-size", 1.0,
				     NULL);

	config_dialog->offset_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
					 "adjustment", config_dialog->offset_adjust,
					 "digits", VALUE_DECIMAL_PLACES,
					 "value", (gdouble)offset,
					 "width-chars", SPINBUTTON_WIDTH_CHARS,
					 NULL);
	
	config_dialog->offset_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT,
						 "child", config_dialog->offset_spinbutton,
						 "xalign", 0.0,
						 "xscale", 0.0,
						 NULL);

	config_dialog->offset_label = g_object_new(GTK_TYPE_LABEL,
				    "label", _("Sensor value _offset"),
				    "mnemonic-widget", config_dialog->offset_spinbutton,
				    "use-underline", TRUE,
				    "xalign", 0.0,
				    NULL);

	g_signal_connect(config_dialog->offset_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_offset_changed), config_dialog);


        /* now do alarm widgets */
        header_text = g_markup_printf_escaped("<b>%s</b>", _("Sensor Limits"));
        config_dialog->limits_header = g_object_new(GTK_TYPE_LABEL,
                                                    "use-markup", TRUE,
                                                    "label", header_text,
                                                    "xalign", 0.0,
                                                    NULL);
        g_free(header_text);

	config_dialog->low_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
                                        "value", 0.0,
                                        "lower", -100000.0,
                                        "upper", 100000.0,
                                        "step-increment", 1.0,
                                        "page-increment", 10.0,
                                        "page-size", 100.0,
                                        NULL);

	
	config_dialog->low_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
                                                           "adjustment", config_dialog->low_value_adjust,
                                                           "digits", VALUE_DECIMAL_PLACES,
                                                           "value", low_value,
                                                           "width-chars", SPINBUTTON_WIDTH_CHARS,

					      NULL);
	
	config_dialog->low_value_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT,
					  "child", config_dialog->low_value_spinbutton,
					  "xalign", 0.0,
					  "xscale", 0.0,
					  NULL);

	config_dialog->low_value_label = g_object_new(GTK_TYPE_LABEL,
                                                      "label", _("Sensor _low value"),
                                                      "mnemonic-widget", config_dialog->low_value_spinbutton,
                                                      "use-underline", TRUE,
                                                      "xalign", 0.0,

					 NULL);

	
	g_signal_connect(config_dialog->low_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_low_value_changed), config_dialog);

	config_dialog->high_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
			      "value", 0.0,
			      "lower", -100000.0,
			      "upper", 100000.0,
			      "step-increment", 1.0,
			      "page-increment", 10.0,
			      "page-size", 100.0,
			      NULL);

	
	config_dialog->high_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
                                                            "adjustment", config_dialog->high_value_adjust,
                                                            "digits", VALUE_DECIMAL_PLACES,
                                                            "value", high_value,
                                                            "width-chars", SPINBUTTON_WIDTH_CHARS,

                                                            NULL);
	
	config_dialog->high_value_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT,
                                                                    "child", config_dialog->high_value_spinbutton,
                                                                    "xalign", 0.0,
                                                                    "xscale", 0.0,
                                                                    NULL);
        
	config_dialog->high_value_label = g_object_new(GTK_TYPE_LABEL,
                                                       "label", _("Sensor _high value"),
                                                       "mnemonic-widget", config_dialog->high_value_spinbutton,
                                                       "use-underline", TRUE,
                                                       "xalign", 0.0,

                                                       NULL);
        
	
	g_signal_connect(config_dialog->high_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_high_value_changed), config_dialog);
	

        header_text = g_markup_printf_escaped("<b>%s</b>", _("Alarm"));
        config_dialog->alarm_header = g_object_new(GTK_TYPE_LABEL,
                                   "use-markup", TRUE,
                                   "label", header_text,
                                   "xalign", 0.0,
                                   NULL);
        g_free(header_text);

	config_dialog->alarm_timeout_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
					    "value", 0.0,
					    "lower", 0.0,
					    "upper", 10000.0,
					    "step-increment", 1.0,
					    "page-increment", 10.0,
					    "page-size", 100.0,
					    NULL);

	config_dialog->alarm_timeout_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
                                                               "adjustment", config_dialog->alarm_timeout_adjust,
                                                               "digits", 0,
                                                               "value", (gdouble)alarm_timeout,
                                                               "width-chars", SPINBUTTON_WIDTH_CHARS,
                                                               "sensitive", alarm_enable,

						NULL);
	config_dialog->alarm_timeout_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT,
							"child", config_dialog->alarm_timeout_spinbutton,
							"xalign", 0.0,
							"xscale", 0.0,
							NULL);
	
	config_dialog->alarm_timeout_label = g_object_new(GTK_TYPE_LABEL,
                                                          "label", _("Alarm _repeat interval (secs)"),
                                                          "mnemonic-widget", config_dialog->alarm_timeout_spinbutton,
                                                          
                                                          "use-underline", TRUE,
                                                          "xalign", 0.0,
                                                          "sensitive", alarm_enable,
                                                          NULL);

	g_signal_connect(config_dialog->alarm_timeout_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_alarm_timeout_changed), config_dialog);

	config_dialog->low_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
                                                              "text", low_alarm_command,
                                                              "width-chars", 25,
                                                              "sensitive", alarm_enable,
                                                              NULL);

	g_free(low_alarm_command);

	config_dialog->low_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
                                                          "use-underline", TRUE,
                                                          "label", _("Lo_w alarm command"),
                                                          "mnemonic-widget", config_dialog->low_alarm_command_entry,
                                                          "xalign", 0.0,
                                                          "sensitive", alarm_enable,

                                                          NULL);

	g_signal_connect(config_dialog->low_alarm_command_entry,
			 "changed",
			 G_CALLBACK(sensor_config_dialog_low_alarm_command_edited),
			 config_dialog);

	config_dialog->high_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
                                                              "text", high_alarm_command,
                                                              "width-chars", 25,
                                                              "sensitive", alarm_enable,
                                                              NULL);

	g_free(high_alarm_command);

	config_dialog->high_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
                                                          "use-underline", TRUE,
                                                          "label", _("Hi_gh alarm command"),
                                                          "mnemonic-widget", config_dialog->high_alarm_command_entry,
                                                          "xalign", 0.0,
                                                          "sensitive", alarm_enable,

                                                          NULL);

	g_signal_connect(config_dialog->high_alarm_command_entry,
			 "changed",
			 G_CALLBACK(sensor_config_dialog_high_alarm_command_edited),
			 config_dialog);

	config_dialog->alarm_enable_checkbutton = g_object_new(GTK_TYPE_CHECK_BUTTON,
						"use-underline", TRUE,
						"label", _("_Enable alarm"),
						"active", alarm_enable,
						"xalign", 0.0,
						NULL);
	
	config_dialog->alarm_enable_aligner = g_object_new(GTK_TYPE_ALIGNMENT,
					    "child", config_dialog->alarm_enable_checkbutton,
					    "xalign", 0.0,
					    "xscale", 0.0,
					    NULL);

	g_signal_connect(config_dialog->alarm_enable_checkbutton, "toggled", G_CALLBACK(sensor_config_dialog_alarm_toggled), config_dialog);
	


        config_dialog->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
        gtk_size_group_add_widget(config_dialog->size_group,
                                  GTK_WIDGET(config_dialog->multiplier_spinbutton));
        gtk_size_group_add_widget(config_dialog->size_group,
                                  GTK_WIDGET(config_dialog->offset_spinbutton));
        gtk_size_group_add_widget(config_dialog->size_group,
                                  GTK_WIDGET(config_dialog->low_value_spinbutton));
        gtk_size_group_add_widget(config_dialog->size_group,
                                  GTK_WIDGET(config_dialog->high_value_spinbutton));
        gtk_size_group_add_widget(config_dialog->size_group,
                                  GTK_WIDGET(config_dialog->alarm_timeout_spinbutton));
        gtk_size_group_add_widget(config_dialog->size_group,
                                  GTK_WIDGET(config_dialog->icon_type_combo_box));
        gtk_size_group_add_widget(config_dialog->size_group,
                                  GTK_WIDGET(config_dialog->graph_color_button));
        g_object_unref(config_dialog->size_group);

	config_dialog->table = g_object_new(GTK_TYPE_TABLE,
			     "column-spacing", 5,
			     "homogeneous", FALSE,
			     "n-columns", 3,
			     "n-rows", 15,
                             "row-spacing", 6,
                             "column-spacing", 12,
			     NULL);


        gtk_table_attach_defaults(config_dialog->table,
                                  GTK_WIDGET(config_dialog->scale_header),
                                  0, 2,
                                  0, 1);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->multiplier_label),
				  1, 2,
				  1, 2);
	
	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->multiplier_spinbutton_aligner),
				  2, 3,
				  1, 2);
	
	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->offset_label),
				  1, 2,
				  2, 3);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->offset_spinbutton_aligner),
				  2, 3,
				  2, 3);
	
	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->limits_header),
				  0, 2,
				  3, 4);

	/* now pack alarm widgets */
        gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->low_value_label),
				  1, 2,
				  4, 5);
	
	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->low_value_spinbutton_aligner),
				  2, 3,
				  4, 5);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->high_value_label),
				  1, 2,
				  5, 6);
	
	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->high_value_spinbutton_aligner),
				  2, 3,
				  5, 6);
	
	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->alarm_header),
				  0, 2,
				  6, 7);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->alarm_enable_aligner),
				  1, 2,
				  7, 8);	

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->alarm_timeout_label),
				  1, 2,
				  8, 9);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->alarm_timeout_spinbutton_aligner),
				  2, 3,
				  8, 9);
	
	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->low_alarm_command_label),
				  1, 2,
				  9, 10);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->low_alarm_command_entry),
				  2, 3,
				  9, 10);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->high_alarm_command_label),
				  1, 2,
				  10, 11);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->high_alarm_command_entry),
				  2, 3,
				  10, 11);

        gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->icon_header),
				  0, 2,
				  11, 12);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->icon_type_label),
				  1, 2,
				  12, 13);
	
        gtk_table_attach_defaults(config_dialog->table,
                                  GTK_WIDGET(config_dialog->icon_type_combo_box_aligner),
                                  2, 3,
                                  12, 13);
        
	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->graph_header),
				  0, 2,
				  13, 14);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->graph_color_label),
				  1, 2,
				  14, 15);

	gtk_table_attach_defaults(config_dialog->table,
				  GTK_WIDGET(config_dialog->graph_color_button_aligner),
				  2, 3,
				  14, 15);

	gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(config_dialog->dialog)->vbox), GTK_WIDGET(config_dialog->table));
	gtk_widget_show_all(config_dialog->dialog);

}		
コード例 #23
0
/**
 * ephy_node_view_add_column:
 * @view: an #EphyNodeView
 * @title: title for the column
 * @value_type: type to be held by the column
 * @prop_id: numeric id corresponding to the column in the model to be shown
 * @flags: flags for the new column
 * @icon_func: a function providing the icon for the column
 * @ret: location to store the created column
 *
 * Adds a new column, corresponding to a @prop_id of the model, to the @view.
 *
 * Returns: the id of the new column
 **/
int
ephy_node_view_add_column (EphyNodeView *view,
			   const char  *title,
			   GType value_type,
			   guint prop_id,
			   EphyNodeViewFlags flags,
			   EphyTreeModelNodeValueFunc icon_func,
			   GtkTreeViewColumn **ret)

{
	GtkTreeViewColumn *gcolumn;
	GtkCellRenderer *renderer;
	int column;
	int icon_column;

	column = ephy_tree_model_node_add_prop_column
		(view->priv->nodemodel, value_type, prop_id);

	gcolumn = (GtkTreeViewColumn *) gtk_tree_view_column_new ();

	if (icon_func)
	{
		icon_column = ephy_tree_model_node_add_func_column
			 (view->priv->nodemodel, GDK_TYPE_PIXBUF, icon_func, view);

		renderer = gtk_cell_renderer_pixbuf_new ();
		gtk_tree_view_column_pack_start (gcolumn, renderer, FALSE);
		gtk_tree_view_column_set_attributes (gcolumn, renderer,
						     "pixbuf", icon_column,
						     NULL);
	}

	renderer = gtk_cell_renderer_text_new ();

	if (flags & EPHY_NODE_VIEW_EDITABLE)
	{
		view->priv->editable_renderer = renderer;
		view->priv->editable_column = gcolumn;
		view->priv->editable_node_column = column;
		view->priv->editable_property = prop_id;

		g_signal_connect (renderer, "edited",
				  G_CALLBACK (cell_renderer_edited), view);
		g_signal_connect (renderer, "editing-canceled",
				  G_CALLBACK (renderer_editing_canceled_cb), view);
	}

	gtk_tree_view_column_pack_start (gcolumn, renderer, TRUE);
	gtk_tree_view_column_set_attributes (gcolumn, renderer,
					     "text", column,
					     NULL);

	gtk_tree_view_column_set_title (gcolumn, title);
	gtk_tree_view_append_column (GTK_TREE_VIEW (view),
				     gcolumn);

	if (flags & EPHY_NODE_VIEW_SHOW_PRIORITY)
	{
		int wcol;

		wcol = ephy_tree_model_node_add_func_column
			(view->priv->nodemodel, G_TYPE_INT,
			 (EphyTreeModelNodeValueFunc) provide_text_weight,
			 view);
		gtk_tree_view_column_add_attribute (gcolumn, renderer,
						    "weight", wcol);
	}

	if (flags & EPHY_NODE_VIEW_SORTABLE)
	{
		/* Now we have created a new column, re-create the
		 * sort model, but ensure that the set_sort function
		 * hasn't been called, see bug #320686 */
		g_assert (view->priv->sort_column == -1);
		g_object_unref (view->priv->sortmodel);
		view->priv->sortmodel = ephy_tree_model_sort_new (view->priv->filtermodel);
		gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->priv->sortmodel));

		gtk_tree_view_column_set_sort_column_id (gcolumn, column);
	}

	if (flags & EPHY_NODE_VIEW_SEARCHABLE)
	{
		gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), column);
		gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), TRUE);
	}
	
	if (flags & EPHY_NODE_VIEW_ELLIPSIZED)
	{
		g_object_set (renderer, "ellipsize-set", TRUE,
			      "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	}

	if (ret != NULL)
		*ret = gcolumn;

	return column;
}
コード例 #24
0
ファイル: filelist.c プロジェクト: DavidMercier/gwyddion
static GtkWidget*
gwy_app_recent_file_list_construct(Controls *controls)
{
    static const struct {
        const gchar *title;
        const guint id;
    }
    columns[] = {
        { "Preview",    FILELIST_THUMB },
        { "File Path",  FILELIST_FILENAME },
    };

    GtkWidget *list;
    GtkTreeSelection *selection;
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;

    g_return_val_if_fail(controls->store, NULL);

    list = gtk_tree_view_new_with_model(controls->filter);
    controls->list = list;
    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);

    /* thumbnail name column */
    renderer = gtk_cell_renderer_pixbuf_new();
    gtk_cell_renderer_set_fixed_size(renderer, THUMB_SIZE, THUMB_SIZE);
    column = gtk_tree_view_column_new_with_attributes(_(columns[0].title),
                                                      renderer, NULL);
    gtk_tree_view_column_set_cell_data_func(column, renderer,
                                            cell_renderer_thumb,
                                            GUINT_TO_POINTER(columns[0].id),
                                            NULL);  /* destroy notify */
    gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);

    renderer = gtk_cell_renderer_text_new();
    gtk_cell_renderer_set_fixed_size(renderer, -1, THUMB_SIZE);
    column = gtk_tree_view_column_new_with_attributes(_(columns[1].title),
                                                      renderer,
                                                      NULL);
    gtk_tree_view_column_set_cell_data_func(column, renderer,
                                            cell_renderer_desc,
                                            GUINT_TO_POINTER(columns[1].id),
                                            NULL);  /* destroy notify */
    gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);

    /* selection */
    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
    gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);

    g_signal_connect_swapped
        (selection, "changed",
         G_CALLBACK(gwy_app_recent_file_list_update_sensitivity), controls);
    g_signal_connect_swapped
        (controls->store, "row-deleted",
         G_CALLBACK(gwy_app_recent_file_list_update_sensitivity), controls);
    g_signal_connect_swapped
        (controls->store, "row-inserted",
         G_CALLBACK(gwy_app_recent_file_list_update_sensitivity), controls);

    g_signal_connect(controls->list, "row-activated",
                     G_CALLBACK(gwy_app_recent_file_list_row_activated),
                     controls);

    return list;
}
コード例 #25
0
ファイル: rombrowser.c プロジェクト: AlexOteiza/n64ios
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);
}
コード例 #26
0
ファイル: eom-plugin-manager.c プロジェクト: fatman2021/eom
static void
plugin_manager_construct_tree (EomPluginManager *pm)
{
	GtkTreeViewColumn *column;
	GtkCellRenderer *cell;
	GtkListStore *model;

	eom_debug (DEBUG_PLUGINS);

	model = gtk_list_store_new (N_COLUMNS,
				    G_TYPE_BOOLEAN,
				    G_TYPE_BOOLEAN,
				    G_TYPE_POINTER);

	gtk_tree_view_set_model (GTK_TREE_VIEW (pm->priv->tree),
				 GTK_TREE_MODEL (model));

	g_object_unref (model);

	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (pm->priv->tree), TRUE);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pm->priv->tree), FALSE);

	/* First column */
	cell = gtk_cell_renderer_toggle_new ();
	g_object_set (cell, "xpad", 6, NULL);
	g_signal_connect (cell,
			  "toggled",
			  G_CALLBACK (active_toggled_cb),
			  pm);
	column = gtk_tree_view_column_new_with_attributes (PLUGIN_MANAGER_ACTIVE_TITLE,
							   cell,
							   "active", ACTIVE_COLUMN,
							   "activatable", AVAILABLE_COLUMN,
							   "sensitive", AVAILABLE_COLUMN,
							   NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (pm->priv->tree), column);

	/* Second column */
	column = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title (column, PLUGIN_MANAGER_NAME_TITLE);
	gtk_tree_view_column_set_resizable (column, TRUE);

	cell = gtk_cell_renderer_pixbuf_new ();
	gtk_tree_view_column_pack_start (column, cell, FALSE);
	g_object_set (cell, "stock-size", GTK_ICON_SIZE_SMALL_TOOLBAR, NULL);
	gtk_tree_view_column_set_cell_data_func (column, cell,
						 plugin_manager_view_icon_cell_cb,
						 pm, NULL);

	cell = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, cell, TRUE);
	g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	gtk_tree_view_column_set_cell_data_func (column, cell,
						 plugin_manager_view_info_cell_cb,
						 pm, NULL);

	gtk_tree_view_column_set_spacing (column, 6);
	gtk_tree_view_append_column (GTK_TREE_VIEW (pm->priv->tree), column);

	/* Sort on the plugin names */
	gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model),
	                                         model_name_sort_func,
        	                                 NULL,
                	                         NULL);
	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
					      GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
					      GTK_SORT_ASCENDING);

	/* Enable search for our non-string column */
	gtk_tree_view_set_search_column (GTK_TREE_VIEW (pm->priv->tree),
					 INFO_COLUMN);
	gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (pm->priv->tree),
					     name_search_cb,
					     NULL,
					     NULL);

	g_signal_connect (pm->priv->tree,
			  "cursor_changed",
			  G_CALLBACK (cursor_changed_cb),
			  pm);

	g_signal_connect (pm->priv->tree,
			  "row_activated",
			  G_CALLBACK (row_activated_cb),
			  pm);

	g_signal_connect (pm->priv->tree,
			  "button-press-event",
			  G_CALLBACK (button_press_event_cb),
			  pm);

	g_signal_connect (pm->priv->tree,
			  "popup-menu",
			  G_CALLBACK (popup_menu_cb),
			  pm);

	gtk_widget_show (pm->priv->tree);
}
コード例 #27
0
ファイル: item_list_view.c プロジェクト: dmitryvk/liferea
ItemListView *
item_list_view_create (GtkWidget *window) 
{
	ItemListView		*ilv;
	GtkCellRenderer		*renderer;
	GtkTreeViewColumn 	*column, *headline_column;
	GtkTreeSelection	*select;
	GtkWidget 		*ilscrolledwindow;

	ilv = g_object_new (ITEM_LIST_VIEW_TYPE, NULL);
		
	ilscrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_show (ilscrolledwindow);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ilscrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (ilscrolledwindow), GTK_SHADOW_IN);

	ilv->priv->treeview = GTK_TREE_VIEW (gtk_tree_view_new ());
	gtk_container_add (GTK_CONTAINER (ilscrolledwindow), GTK_WIDGET (ilv->priv->treeview));
	gtk_widget_show (GTK_WIDGET (ilv->priv->treeview));
	gtk_widget_set_name (GTK_WIDGET (ilv->priv->treeview), "itemlist");
	gtk_tree_view_set_rules_hint (ilv->priv->treeview, TRUE);
	
	g_object_set_data (G_OBJECT (window), "itemlist", ilv->priv->treeview);

	item_list_view_set_tree_store (ilv, item_list_view_create_tree_store ());

	renderer = gtk_cell_renderer_pixbuf_new ();
	column = gtk_tree_view_column_new_with_attributes ("", renderer, "pixbuf", IS_STATEICON, NULL);
	gtk_tree_view_append_column (ilv->priv->treeview, column);
	gtk_tree_view_column_set_sort_column_id (column, IS_STATE);	
	
	renderer = gtk_cell_renderer_pixbuf_new ();
	column = gtk_tree_view_column_new_with_attributes ("", renderer, "pixbuf", IS_ENCICON, NULL);
	gtk_tree_view_append_column (ilv->priv->treeview, column);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (_("Date"), renderer, 
	                                                   "text", IS_TIME_STR,
							   "weight", ITEMSTORE_UNREAD,
							   NULL);
	gtk_tree_view_append_column (ilv->priv->treeview, column);
	gtk_tree_view_column_set_sort_column_id(column, IS_TIME);
	g_object_set (column, "resizable", TRUE, NULL);
	
	renderer = gtk_cell_renderer_pixbuf_new ();
	column = gtk_tree_view_column_new_with_attributes ("", renderer, "pixbuf", IS_FAVICON, NULL);
	gtk_tree_view_column_set_sort_column_id (column, IS_SOURCE);
	gtk_tree_view_append_column (ilv->priv->treeview, column);
	
	renderer = gtk_cell_renderer_text_new ();
	headline_column = gtk_tree_view_column_new_with_attributes (_("Headline"), renderer, 
	                                                   "text", IS_LABEL,
							   "weight", ITEMSTORE_UNREAD,
							   "xalign", ITEMSTORE_ALIGN,
							   NULL);
	gtk_tree_view_append_column (ilv->priv->treeview, headline_column);
	gtk_tree_view_column_set_sort_column_id (headline_column, IS_LABEL);
	g_object_set (headline_column, "resizable", TRUE, NULL);
	g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);

	/* And connect signals */
	g_signal_connect (G_OBJECT (ilv->priv->treeview), "button_press_event", G_CALLBACK (on_item_list_view_button_press_event), ilv);
	g_signal_connect (G_OBJECT (ilv->priv->treeview), "row_activated", G_CALLBACK (on_Itemlist_row_activated), ilv);
	g_signal_connect (G_OBJECT (ilv->priv->treeview), "key-press-event", G_CALLBACK (on_item_list_view_key_press_event), ilv);
	g_signal_connect (G_OBJECT (ilv->priv->treeview), "popup_menu", G_CALLBACK (on_item_list_view_popup_menu), ilv);

	gtk_widget_set_has_tooltip (GTK_WIDGET (ilv->priv->treeview), TRUE);
	g_signal_connect (G_OBJECT (ilv->priv->treeview), "query-tooltip", G_CALLBACK (on_item_list_view_query_tooltip), headline_column);

	/* Setup the selection handler */
	select = gtk_tree_view_get_selection (ilv->priv->treeview);
	gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
	g_signal_connect (G_OBJECT (select), "changed",
	                  G_CALLBACK (on_itemlist_selection_changed), ilv);
		  
	return ilv;
}
コード例 #28
0
ButtonConfigGui::ButtonConfigGui(SettingsDialog* dlg, GtkWidget* w,  Settings* settings, int button, bool withDevice)
{
	XOJ_INIT_TYPE(ButtonConfigGui);

	this->settings = settings;
	this->button = button;
	this->withDevice = withDevice;

	GtkWidget* table = gtk_table_new(8, 2, false);

	if (withDevice)
	{
		this->cbDevice = gtk_combo_box_new_text();

		gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbDevice), _C("No device"));

		GList* devices = gdk_devices_list();
		for (GList* l = devices; l != NULL; l = l->next)
		{
			GdkDevice* dev = (GdkDevice*) l->data;

			string devType = "";
			if (dev->source == GDK_SOURCE_MOUSE)
			{
				devType = _("mouse");
			}
			else if (dev->source == GDK_SOURCE_PEN)
			{
				devType = _("pen");
			}
			else if (dev->source == GDK_SOURCE_ERASER)
			{
				devType = _("eraser");
			}
			else if (dev->source == GDK_SOURCE_CURSOR)
			{
				devType = _("cursor");
			}

			char* txt = g_strdup_printf("%s (%s)", dev->name, devType.c_str());
			gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbDevice), txt);
			g_free(txt);
		}

		gtk_table_attach(GTK_TABLE(table), newLabel(_C("Device")), 0, 1, 0, 1, GTK_FILL, GTK_FILL, 20, 0);
		gtk_table_attach(GTK_TABLE(table), this->cbDevice, 1, 2, 0, 1,
						 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0);

		cbDisableDrawing = gtk_check_button_new_with_label(_C("Disable drawing for this device"));

		gtk_table_attach(GTK_TABLE(table), cbDisableDrawing, 1, 2, 1, 2,
						 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0);

	}
	else
	{
		this->cbDevice = NULL;
		this->cbDisableDrawing = NULL;
	}

	GtkListStore* typeModel = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
	GtkTreeIter iter;

	ADD_TYPE_CB("empty.svg",			_C("Don't change"),		TOOL_NONE);
	ADD_TYPE_CB("tool_pencil.svg",		_C("Pen"),				TOOL_PEN);
	ADD_TYPE_CB("tool_eraser.svg",		_C("Eraser"),			TOOL_ERASER);
	ADD_TYPE_CB("tool_highlighter.png",	_C("Hilighter"),			TOOL_HILIGHTER);
	ADD_TYPE_CB("tool_text.svg",		_C("Text"),				TOOL_TEXT);
	ADD_TYPE_CB("tool_image.svg",		_C("Insert image"),		TOOL_IMAGE);
	ADD_TYPE_CB("stretch.svg",			_C("Vertical space"),	TOOL_VERTICAL_SPACE);
	ADD_TYPE_CB("lasso.svg",			_C("Select region"),		TOOL_SELECT_REGION);
	ADD_TYPE_CB("rect-select.svg",		_C("Select rectangle"),	TOOL_SELECT_RECT);
	//ADD_TYPE_CB("rect-draw.svg",		_C("Draw rectangle"),		TOOL_DRAW_RECT);
	//ADD_TYPE_CB("circle-draw.svg",	_C("Draw circle"),		TOOL_DRAW_CIRCLE);
	ADD_TYPE_CB("hand.svg",				_C("Hand"),				TOOL_HAND);

	GtkCellRenderer* renderer = NULL;

	this->cbTool = gtk_combo_box_new_with_model(GTK_TREE_MODEL(typeModel));
	g_signal_connect(cbTool, "changed", G_CALLBACK(&cbSelectCallback), this);

	renderer = gtk_cell_renderer_pixbuf_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(this->cbTool), renderer, false);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(this->cbTool), renderer, "pixbuf", 0, NULL);

	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(this->cbTool), renderer, true);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(this->cbTool), renderer, "text", 1, NULL);

	gtk_table_attach(GTK_TABLE(table), newLabel(_C("Tool")), 0, 1, 2, 3, GTK_FILL, GTK_FILL, 20, 0);
	gtk_table_attach(GTK_TABLE(table), cbTool, 1, 2, 2, 3,
					 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0);

	this->cbThickness = gtk_combo_box_new_text();
	gtk_combo_box_append_text(GTK_COMBO_BOX(cbThickness), _C("Don't change"));
	gtk_combo_box_append_text(GTK_COMBO_BOX(cbThickness), _C("Thin"));
	gtk_combo_box_append_text(GTK_COMBO_BOX(cbThickness), _C("Medium"));
	gtk_combo_box_append_text(GTK_COMBO_BOX(cbThickness), _C("Thick"));
	gtk_combo_box_set_active(GTK_COMBO_BOX(cbThickness), 0);

	gtk_table_attach(GTK_TABLE(table), newLabel(_C("Thickness")), 0, 1, 3, 4,
					GTK_FILL, GTK_FILL, 20, 0);
	gtk_table_attach(GTK_TABLE(table), this->cbThickness, 1, 2, 3, 4,
					 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0);

	this->colorButton = gtk_color_button_new();
	gtk_table_attach(GTK_TABLE(table), newLabel(_C("Color")), 0, 1, 4, 5, GTK_FILL, GTK_FILL, 20, 0);
	gtk_table_attach(GTK_TABLE(table), colorButton, 1, 2, 4, 5,
					 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0);

	this->cbDrawingType = gtk_combo_box_new_text();
	gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbDrawingType), _C("Don't change"));
	gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbDrawingType), _C("Enable Ruler"));
	gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbDrawingType), _C("Enable Stroke Recognizer"));
	gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbDrawingType), _C("Disable Ruler & Stroke Recognizer"));

	gtk_table_attach(GTK_TABLE(table), newLabel(_C("Ruler & Stroke Reco.")), 0, 1, 5, 6, GTK_FILL, GTK_FILL, 20, 0);
	gtk_table_attach(GTK_TABLE(table), this->cbDrawingType, 1, 2, 5, 6,
					 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0);

	this->cbEraserType = gtk_combo_box_new_text();
	gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbEraserType), _C("Don't change"));
	gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbEraserType), _C("Standard"));
	gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbEraserType), _C("Whiteout"));
	gtk_combo_box_append_text(GTK_COMBO_BOX(this->cbEraserType), _C("Delete stroke"));

	gtk_table_attach(GTK_TABLE(table), newLabel(_C("Eraser type")), 0, 1, 8, 9, GTK_FILL, GTK_FILL, 20, 0);
	gtk_table_attach(GTK_TABLE(table), this->cbEraserType, 1, 2, 8, 9,
					 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0);

	gtk_container_add(GTK_CONTAINER(w), table);
	gtk_widget_show_all(table);

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

  gtk_init (&argc, &argv);

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

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

  current_root = g_strdup ("/");

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

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

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

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

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

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

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

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

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
コード例 #30
0
ファイル: action-list.c プロジェクト: bebarino/gtkparasite
static void
parasite_actionlist_init(ParasiteActionList *actionlist,
                         ParasiteActionListClass *klass)
{
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;
    GTypeClass *uimanager_type;
    guint uimanager_signal;

    actionlist->priv = PARASITE_ACTIONLIST_GET_PRIVATE(actionlist);
    actionlist->priv->uimanagers = NULL;

    actionlist->priv->model =
        gtk_tree_store_new(NUM_COLUMNS,
                           G_TYPE_STRING,   // ACTION_LABEL
                           G_TYPE_STRING,   // ACTION_NAME
                           G_TYPE_STRING,   // ACTION_ICON
                           G_TYPE_STRING,   // ROW_COLOR,
                           G_TYPE_STRING,   // SORT_NAME
                           G_TYPE_POINTER); // ADDRESS
    gtk_tree_view_set_model(GTK_TREE_VIEW(actionlist),
                            GTK_TREE_MODEL(actionlist->priv->model));

    column = gtk_tree_view_column_new();
    gtk_tree_view_append_column(GTK_TREE_VIEW(actionlist), column);
    gtk_tree_view_column_set_title(column, "Label");

    renderer = gtk_cell_renderer_pixbuf_new();
    gtk_tree_view_column_pack_start(column, renderer, FALSE);
    gtk_tree_view_column_set_attributes(column, renderer,
                                        "stock-id", ACTION_ICON,
                                        NULL);

    renderer = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start(column, renderer, FALSE);
    gtk_tree_view_column_set_attributes(column, renderer,
                                        "text", ACTION_LABEL,
                                        "foreground", ROW_COLOR,
                                        NULL);

    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes("Action",
                                                      renderer,
                                                      "text", ACTION_NAME,
                                                      "foreground", ROW_COLOR,
                                                      NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(actionlist), column);

    gtk_tree_sortable_set_sort_column_id(
        GTK_TREE_SORTABLE(actionlist->priv->model),
        SORT_NAME, GTK_SORT_ASCENDING);

    // Listen to all "actions-changed" signal emissions
    uimanager_type = g_type_class_ref(GTK_TYPE_UI_MANAGER);
    uimanager_signal = g_signal_lookup("actions-changed", GTK_TYPE_UI_MANAGER);
    g_signal_add_emission_hook(uimanager_signal, 0,
                               actions_changed_cb,
                               actionlist,
                               NULL);
    g_type_class_unref(uimanager_type);
}