Re: [gtk-list] Re: Icons and DnD?



Michael Sobolev wrote:

> Hmm...  You know, I have been trying to write a small program that should be
> using pixmaps.  Moreover, I wanted those pixmaps to respond on certain events.
> For creating every pixmap I used the following code.  I cannot be sure if this
> code is correct, but the program I've been writing behaves as I expect it to
> behave.
>
> GtkWidget *create_item (GtkWidget *parent, GtkStyle *style, GtkTooltips *tips, ProgramItem *item)
> {
>     GtkWidget *result, *pixmap;
>     GdkPixmap *gdk_pixmap;
>     GdkBitmap *gdk_pixmap_mask;
>
>     gdk_pixmap = gdk_pixmap_create_from_xpm (parent->window, &gdk_pixmap_mask,
>         &style->bg[GTK_STATE_NORMAL], item->icon_name);
>
>     result = gtk_event_box_new ();
>
>     pixmap = gtk_pixmap_new (gdk_pixmap, gdk_pixmap_mask);
>     gtk_container_add (GTK_CONTAINER (result), pixmap);
>     gtk_widget_show (pixmap);
>
>     gtk_tooltips_set_tip (tips, result, item->tip, NULL);
>
>     gtk_widget_show (result);
>
>     return result;
> }
>
> The created items I inserted into a hbox...
>
> Hope this helps,
>

Hmm....Check my code...it's c++ but really easy to understand

void VFileManager::ShowFileIcon(VFmStruct *file)
{
  cout << "called ShowFileIcon()" << endl;
  Gtk_VBox pbox(false, 0); // pixmap box
  Gtk_EventBox eventbox; // eventbox

  eventbox.add(file->icon); // add the file icon to the eventbox
  pbox.pack_start(&eventbox, FALSE, FALSE, 0); // pack the eventbox into the VBox
  Gtk_Label file_l(file->name); // new label
  pbox.pack_start(&file_l, FALSE, FALSE, 3); // pack the name of the file into the VBox

  // add icon

  // show icon
  eventbox.show();
  pbox.show();
  file_l.show();
  file->icon->show();
}

When I run the prog, i get the sigsegv and  ** WARNING **: file gtkbox.c: line 163
(gtk_box_pack_start): "child->parent == NULL" if i don't add the event box but use just the icon and
the pbox.
And i get this -- ** WARNING **: file gtkwidget.c: line 2469 (gtk_widget_set_parent):
"widget->parent == NULL" when I do it as described above.

It seems that I can not pack into boxes because they don't have a parent widget.  But what should i
pack(add?) the eventbox or pbox for that matter to?  I use fixed widget which holds all the pixmaps.
Should i use some other widget for that?


Thank you.
Marsel Osipov


> --
> Mike
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]