static void CreatePixmapBox(int index, Picture *logo, Picture *pix) { GtkWidget *dialog, *pixmap, *label; const char *text = UI_dialog_string(index); dialog = gtk_dialog_new(); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); pixmap = gtk_pixmap_new(logo->pix, logo->mask); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), pixmap); gtk_widget_show(pixmap); if (pix != NULL) { pixmap = gtk_pixmap_new(pix->pix, pix->mask); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), pixmap); gtk_widget_show(pixmap); } if (text != NULL) { label = gtk_label_new(text); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); gtk_widget_show(label); } new_button(dialog, "OK", NULL, NULL); gtk_widget_realize(dialog); dialogs[index] = dialog; }
/* Create actual buttons */ GtkWidget * create_discard_buttons (void) { GtkWidget *table; GtkWidget *table2; GtkWidget *frame; GtkWidget *main_vbox; GtkWidget *b1; GtkWidget *b2; GtkWidget *pixmapwid1, *pixmapwid2; GtkTooltips *tooltips; tooltips=gtk_tooltips_new_2(); gtk_tooltips_set_delay_2(tooltips,1500); pixmapwid1=gtk_pixmap_new(larrow_pixmap, larrow_mask); gtk_widget_show(pixmapwid1); pixmapwid2=gtk_pixmap_new(rarrow_pixmap, rarrow_mask); gtk_widget_show(pixmapwid2); /* Create a table to hold the text widget and scrollbars */ table = gtk_table_new (1, 1, FALSE); main_vbox = gtk_vbox_new (FALSE, 1); gtk_container_border_width (GTK_CONTAINER (main_vbox), 1); gtk_container_add (GTK_CONTAINER (table), main_vbox); frame = gtk_frame_new ("Disc "); gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); gtk_widget_show (main_vbox); table2 = gtk_table_new (2, 1, FALSE); b1 = gtk_button_new(); gtk_container_add(GTK_CONTAINER(b1), pixmapwid1); gtk_table_attach (GTK_TABLE (table2), b1, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1); gtk_signal_connect_object (GTK_OBJECT (b1), "clicked", GTK_SIGNAL_FUNC(discard_left), GTK_OBJECT (table2)); gtk_tooltips_set_tip_2(tooltips, b1, "Increase 'From' Time", NULL); gtk_widget_show(b1); b2 = gtk_button_new(); gtk_container_add(GTK_CONTAINER(b2), pixmapwid2); gtk_table_attach (GTK_TABLE (table2), b2, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1); gtk_signal_connect_object (GTK_OBJECT (b2), "clicked", GTK_SIGNAL_FUNC(discard_right), GTK_OBJECT (table2)); gtk_tooltips_set_tip_2(tooltips, b2, "Decrease 'To' Time", NULL); gtk_widget_show(b2); gtk_container_add (GTK_CONTAINER (frame), table2); gtk_widget_show(table2); return(table); }
/* Create shift buttons */ GtkWidget * create_edge_buttons (void) { GtkWidget *table; GtkWidget *table2; GtkWidget *frame; GtkWidget *main_vbox; GtkWidget *b1; GtkWidget *b2; GtkWidget *pixmapwid1, *pixmapwid2; GtkTooltips *tooltips; tooltips=gtk_tooltips_new_2(); gtk_tooltips_set_delay_2(tooltips,1500); pixmapwid1=gtk_pixmap_new(GLOBALS->larrow_pixmap, GLOBALS->larrow_mask); gtk_widget_show(pixmapwid1); pixmapwid2=gtk_pixmap_new(GLOBALS->rarrow_pixmap, GLOBALS->rarrow_mask); gtk_widget_show(pixmapwid2); /* Create a table to hold the text widget and scrollbars */ table = gtk_table_new (1, 1, FALSE); main_vbox = gtk_vbox_new (FALSE, 1); gtk_container_border_width (GTK_CONTAINER (main_vbox), 1); gtk_container_add (GTK_CONTAINER (table), main_vbox); frame = gtk_frame_new ("Edge "); gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); gtk_widget_show (main_vbox); table2 = gtk_table_new (2, 1, FALSE); b1 = gtk_button_new(); gtk_container_add(GTK_CONTAINER(b1), pixmapwid1); gtk_table_attach (GTK_TABLE (table2), b1, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1); gtk_signal_connect_object (GTK_OBJECT (b1), "clicked", GTK_SIGNAL_FUNC(service_left_edge), GTK_OBJECT (table2)); gtk_tooltips_set_tip_2(tooltips, b1, "Find next transition of highlighted trace scanning left", NULL); gtk_widget_show(b1); b2 = gtk_button_new(); gtk_container_add(GTK_CONTAINER(b2), pixmapwid2); gtk_table_attach (GTK_TABLE (table2), b2, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1); gtk_signal_connect_object (GTK_OBJECT (b2), "clicked", GTK_SIGNAL_FUNC(service_right_edge), GTK_OBJECT (table2)); gtk_tooltips_set_tip_2(tooltips, b2, "Find next transition of highlighted trace scanning right", NULL); gtk_widget_show(b2); gtk_container_add (GTK_CONTAINER (frame), table2); gtk_widget_show(table2); return(table); }
/* * CreateWidgetFromXpm * * Using the window information and the string with the icon color/data, * create a widget that represents the data. Once done, this widget can * be added to buttons or other container widgets. */ GtkWidget *CreateWidgetFromXpm (GtkWidget *window, gchar **xpm_data) { // got this code from Xmps GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; GtkWidget *pixmap; colormap = gtk_widget_get_colormap(window); gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, NULL, xpm_data); if (gdkpixmap == NULL) { printf("Error\n"); return (NULL); } #ifdef HAVE_GTK_2_0 pixmap = gtk_image_new_from_pixmap(gdkpixmap, mask); #else pixmap = gtk_pixmap_new (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); #endif gtk_widget_show(pixmap); return pixmap; }
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { m_needParent = TRUE; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxStaticBitmap creation failed") ); return false; } m_bitmap = bitmap; wxBitmap bmp(bitmap.Ok() ? bitmap : wxBitmap(bogus_xpm)); m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL); if (bitmap.Ok()) SetBitmap(bitmap); PostCreation(size); m_parent->DoAddChild( this ); return true; }
static GtkWidget * create_button_with_pixmap(GtkWidget *window, gchar **bits, gint data, gchar *thelp) { GtkWidget *pw, *button; GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; style = gtk_widget_get_style(window); pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->bg[GTK_STATE_NORMAL], bits); pw = gtk_pixmap_new(pixmap, mask); gtk_widget_show(pw); button = gtk_button_new(); gtk_container_add(GTK_CONTAINER(button), pw); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(generic_cb), GINT_TO_POINTER(data)); gtk_widget_show(button); gtk_tooltips_set_tip(ttip, button, thelp, NULL); return button; }
static GtkWidget * AddMenuCheckItem(GtkWidget *window1, const char * immagine_xpm, GtkWidget* Menu,const char* label, gboolean state, int Number) { GtkWidget * Label = NULL; GtkWidget * Pixmap = NULL; GtkWidget * hbox = NULL; GtkWidget * Item = NULL; GdkPixmap *PixmapIcon = NULL; GdkColor transparent; GdkBitmap *MaskIcon = NULL; PixmapIcon = gdk_pixmap_create_from_xpm_d (window1->window, &MaskIcon, &transparent,(gchar **)immagine_xpm ); Pixmap = gtk_pixmap_new (PixmapIcon, MaskIcon); gdk_pixmap_unref (PixmapIcon); Item=gtk_check_menu_item_new(); Label = gtk_label_new (label); hbox = gtk_hbox_new (FALSE, 8); gtk_box_pack_start (GTK_BOX (hbox), Pixmap, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), Label, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (Item), hbox); gtk_menu_append( GTK_MENU( Menu ),Item ); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(Item),state); gtk_signal_connect_object( GTK_OBJECT(Item),"activate", GTK_SIGNAL_FUNC(ActivateMenuItem),(gpointer)Number ); gtk_menu_item_right_justify (GTK_MENU_ITEM (Item)); gtk_widget_show_all(Item); return Item; }
GtkWidget * AddSubMenu( GtkWidget *window1, const char * immagine_xpm, GtkWidget * Menu,const char * label ) { GtkWidget * Label = NULL; GtkWidget * Pixmap = NULL; GtkWidget * hbox = NULL; GtkWidget * Item = NULL; GtkWidget * SubItem = NULL; GdkPixmap * PixmapIcon = NULL; GdkColor transparent; GdkBitmap * MaskIcon = NULL; PixmapIcon = gdk_pixmap_create_from_xpm_d (window1->window, &MaskIcon, &transparent,(gchar **)immagine_xpm); Pixmap = gtk_pixmap_new (PixmapIcon, MaskIcon); gdk_pixmap_unref (PixmapIcon); SubItem=gtk_menu_item_new(); Item=gtk_menu_new(); Label = gtk_label_new (label); hbox = gtk_hbox_new (FALSE, 8); gtk_box_pack_start (GTK_BOX (hbox), Pixmap, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), Label, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (SubItem), hbox); gtk_menu_append( GTK_MENU( Menu ),SubItem ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( SubItem ),Item ); gtk_widget_show_all( SubItem ); return Item; }
//____________________________________________ // Used to pack an icon onto a button // Adapted from GTK API tutorial //____________________________________________ GtkWidget *GUI_PixmapButton(GdkWindow * window, const gchar ** xpmd, const gchar * tooltip, gint border) { // GtkWidget *button; GtkWidget *pixmap; GdkPixmap *xpm; GdkBitmap *mask; xpm = gdk_pixmap_create_from_xpm_d(window, &mask, NULL, (gchar **)xpmd); pixmap = gtk_pixmap_new(xpm, mask); button = gtk_button_new(); gtk_container_set_border_width(GTK_CONTAINER(button), border); gtk_container_add(GTK_CONTAINER(button), pixmap); if (tooltips == NULL) tooltips = gtk_tooltips_new(); if (tooltip != NULL) gtk_tooltips_set_tip(tooltips, button, tooltip, NULL); gtk_widget_show_all(button); return button; }
void add_to_toolbar (GtkWidget *mainWin, gchar *tooltipText, gchar ** xpmIcon, GtkSignalFunc f, gpointer data, GtkWidget *box, int Beginning) { GtkWidget *button, *gpixmap; GdkPixmap *pixmap; GdkBitmap *bitmap; GtkTooltips *tooltip; GtkStyle *style; if (f == NULL) button = gtk_label_new(" "); else { button = gtk_button_new(); tooltip = gtk_tooltips_new(); gtk_tooltips_set_tip(tooltip,button,tooltipText, NULL); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", f, (gpointer)data); style = gtk_widget_get_style(mainWin); pixmap = gdk_pixmap_create_from_xpm_d(mainWin->window,&bitmap, &style->bg[GTK_STATE_NORMAL], xpmIcon); gpixmap = gtk_pixmap_new(pixmap,bitmap); gtk_widget_show(gpixmap); gtk_container_add(GTK_CONTAINER(button), gpixmap); } gtk_widget_show(button); if (Beginning) gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); else gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); }
int clip_GTK_CTREENODEGETPIXMAP(ClipMachine * cm) { C_widget *cctree = _fetch_cw_arg(cm); C_object *cnode = _fetch_cobject(cm,_clip_spar(cm,2)); gint column = _clip_parni(cm,3); GdkPixmap *pixmap; GdkBitmap *mask; C_widget *cpixmap; CHECKCWID(cctree,GTK_IS_CTREE); CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE); CHECKOPT(3,NUMERIC_t); if (_clip_parinfo(cm,3)==UNDEF_t) column = 1; if (gtk_ctree_node_get_pixmap(GTK_CTREE(cctree->widget), GTK_CTREE_NODE(cnode->object),column-1,&pixmap,&mask)) { if (pixmap) { cpixmap = _list_get_cwidget_by_data(cm,pixmap); if (!cpixmap) cpixmap = _register_widget(cm,gtk_pixmap_new(pixmap,mask),NULL); if (cpixmap) _clip_mclone(cm,RETPTR(cm),&cpixmap->obj); } } return 0; err: return 1; }
void gmdb_form_add_icon(gchar *text) { GList *glist = NULL; GtkWidget *li; GtkWidget *label; GtkWidget *box; GtkWidget *pixmapwid; GdkPixmap *pixmap; GdkBitmap *mask; li = gtk_list_item_new (); box = gtk_hbox_new (FALSE,5); pixmap = gdk_pixmap_colormap_create_from_xpm( NULL, gtk_widget_get_colormap(app), &mask, NULL, "table.xpm"); /* a pixmap widget to contain the pixmap */ pixmapwid = gtk_pixmap_new( pixmap, mask ); gtk_widget_show( pixmapwid ); gtk_box_pack_start (GTK_BOX (box), pixmapwid, FALSE, TRUE, 0); label = gtk_label_new (text); gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0); gtk_container_add(GTK_CONTAINER(li), box); glist = g_list_append (glist, li); gtk_widget_show (label); gtk_widget_show_all (li); gtk_hlist_append_items(GTK_HLIST(form_hlist), glist); }
static void CreateDialog(int index, int hascancel, Picture *icon, const char *buttonlabel, GtkSignalFunc func) { GtkWidget *dialog, *pixmap, *label, *hbox; dialog = gtk_dialog_new(); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); hbox = gtk_hbox_new(FALSE, 0); if (icon != NULL) { pixmap = gtk_pixmap_new(icon->pix, icon->mask); gtk_container_add(GTK_CONTAINER(hbox), pixmap); } label = gtk_label_new(UI_dialog_string(index)); gtk_container_add(GTK_CONTAINER(hbox), label); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); gtk_widget_show_all(hbox); if (buttonlabel == NULL) buttonlabel = "OK"; new_button(dialog, buttonlabel, func, NULL); if (hascancel) new_button(dialog, "Cancel", NULL, NULL); gtk_widget_realize(dialog); dialogs[index] = dialog; }
void message_dialog (gchar *message) { GtkWidget *dialog; GtkWidget *vbox; GtkWidget *hbox; GdkColormap *colormap; GtkStyle *style; GdkBitmap *mask; GdkPixmap *pixmap; GtkWidget *image; GtkWidget *label; GtkWidget *button; dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); #if GTK_MAJOR_VERSION == 2 gtk_window_set_decorated (GTK_WINDOW(dialog), FALSE); #endif gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS); gtk_container_set_border_width (GTK_CONTAINER(dialog), 12); vbox = gtk_vbox_new (FALSE, 10); gtk_container_add (GTK_CONTAINER(dialog), vbox); hbox = gtk_hbox_new (FALSE, 10); gtk_box_pack_start_defaults (GTK_BOX(vbox), hbox); style = gtk_widget_get_style (dialog); colormap = gtk_widget_get_colormap(dialog); pixmap = gdk_pixmap_colormap_create_from_xpm (dialog->window, colormap, &mask, NULL, "/etc/icons/error.xpm"); image = gtk_pixmap_new (pixmap, mask); gtk_box_pack_start_defaults (GTK_BOX(hbox), image); label = gtk_label_new (message); gtk_box_pack_start_defaults (GTK_BOX(hbox), label); button = gtk_button_new_with_label ("Fechar"); gtk_signal_connect (GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_box_pack_start_defaults (GTK_BOX(vbox), button); gtk_widget_show_all (dialog); gtk_widget_grab_focus (button); gtk_main (); gtk_widget_destroy (dialog); while (gtk_events_pending ()) gtk_main_iteration (); }
GtkWidget *make_pixmap_toggle_button(struct mapwin *mw,char **xpmdata) { GdkBitmap *mask=NULL; GdkPixmap *gpm = gdk_pixmap_create_from_xpm_d(mw->map->window, &mask,NULL,xpmdata); GtkWidget *gtpm = gtk_pixmap_new(gpm,mask); GtkWidget *but=gtk_toggle_button_new(); gtk_container_add(GTK_CONTAINER(but),gtpm); gtk_widget_show(gtpm); return but; }
static GtkWidget *aligned_pixmap (GdkPixmap *pix, GdkBitmap *mask) { GtkWidget *pixmap; GtkWidget *alignment; alignment = gtk_alignment_new (0.5, 0.5, 0, 0); pixmap = gtk_pixmap_new (pix, mask); gtk_container_add (GTK_CONTAINER (alignment), pixmap); gtk_widget_show (pixmap); return alignment; }
GtkWidget *NewPixmap(gchar ** data, GdkWindow * window, GdkColor * background) { GtkWidget *wpixmap; GdkPixmap *pixmap; GdkBitmap *mask; pixmap = gdk_pixmap_create_from_xpm_d(window, &mask, background, data); wpixmap = gtk_pixmap_new(pixmap, mask); return wpixmap; }
/* This is an internally used function to create pixmaps. */ GtkWidget* create_pixmap (GtkWidget *widget, const gchar *filename) { gchar *found_filename = NULL; GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; GtkWidget *pixmap; GList *elem; if (!filename || !filename[0]) return create_dummy_pixmap (widget); /* We first try any pixmaps directories set by the application. */ elem = pixmaps_directories; while (elem) { found_filename = check_file_exists ((gchar*)elem->data, filename); if (found_filename) break; elem = elem->next; } /* If we haven't found the pixmap, try the source directory. */ if (!found_filename) { found_filename = check_file_exists ("../pixmaps", filename); } if (!found_filename) { g_warning (_("Couldn't find pixmap file: %s"), filename); return create_dummy_pixmap (widget); } colormap = gtk_widget_get_colormap (widget); gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, NULL, found_filename); if (gdkpixmap == NULL) { g_warning (_("Error loading pixmap file: %s"), found_filename); g_free (found_filename); return create_dummy_pixmap (widget); } g_free (found_filename); pixmap = gtk_pixmap_new (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); return pixmap; }
/* Create a pixmap widget from an xpm file */ GtkWidget *c_gtk_pixmap_create_from_xpm (GtkWidget *widget, char *fname) { GdkBitmap *mask; GdkPixmap *pixmap; /* Widget must be realized before we can attach a pixmap to it */ if (widget->window == NULL) gtk_widget_realize (widget); pixmap = gdk_pixmap_create_from_xpm (widget->window, &mask, &widget->style->bg[GTK_STATE_NORMAL], fname); return (gtk_pixmap_new (pixmap, mask)); }
void about (void) { GtkWidget *AboutWindow; GtkWidget *PixmapWidget; GtkWidget *HSeparator; GdkPixmap *Pixmap; GdkBitmap *Mask; GtkStyle *Style; GtkWidget *Button; GtkWidget *AboutLabel; AboutWindow = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW(AboutWindow), "About " APP_NAME); gtk_window_set_policy (GTK_WINDOW(AboutWindow), FALSE, FALSE, FALSE); gtk_window_set_position (GTK_WINDOW(AboutWindow), GTK_WIN_POS_CENTER); gtk_window_set_modal (GTK_WINDOW(AboutWindow), TRUE); gtk_window_set_transient_for (GTK_WINDOW(AboutWindow), GTK_WINDOW(MainWindow)); gtk_signal_connect_object (GTK_OBJECT(AboutWindow), "delete_event", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT(AboutWindow)); gtk_signal_connect_object (GTK_OBJECT (AboutWindow), "destroy", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT(AboutWindow)); gtk_widget_realize (AboutWindow); Style = gtk_widget_get_style (AboutWindow); Pixmap = gdk_pixmap_create_from_xpm_d (AboutWindow->window, &Mask, &Style->bg[GTK_STATE_NORMAL], about_xpm); PixmapWidget = gtk_pixmap_new (Pixmap, Mask); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(AboutWindow) -> vbox), PixmapWidget, FALSE, FALSE, 0); HSeparator = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(AboutWindow) -> vbox), HSeparator, FALSE, FALSE, 0); AboutLabel = gtk_label_new (APP_NAME " " VERSION_NUMBER "\n" APP_MOTTO "\n\n" APP_URL); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(AboutWindow) -> vbox), AboutLabel, FALSE, FALSE, 10); Button = gtk_button_new_with_label (" Resume "); gtk_signal_connect_object (GTK_OBJECT(Button), "clicked", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT(AboutWindow)); GTK_WIDGET_SET_FLAGS (Button, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(AboutWindow) -> action_area), Button, TRUE, TRUE, 0); gtk_widget_grab_default (Button); gtk_widget_show_all (AboutWindow); print_msg ("Display About window..."); }
GtkWidget * CreateWidgetFromXpm (GtkWidget * parent, gchar ** xpm_data) { GdkBitmap *mask; GdkPixmap *pixmap_data; GtkWidget *pixmap_widget; pixmap_data = gdk_pixmap_create_from_xpm_d (parent->window, &mask, NULL, (gchar **) xpm_data); pixmap_widget = gtk_pixmap_new (pixmap_data, mask); gtk_widget_show (pixmap_widget); return (pixmap_widget); }
GtkWidget * build_dockapp(char *configfile) { static GtkWidget *mainwin; static GtkWidget *mainbox; static GtkWidget *box; static GtkWidget *pixmap; static GdkBitmap *mask; static GtkWidget *pixmap_widget; static struct wmtrash *wmtrash; wmtrash = malloc(sizeof(struct wmtrash)); memset(wmtrash, 0, sizeof(struct wmtrash)); char *image_path_file; strncpy (wmtrash->param_img, "trashicon", MEDIUM_STRING); strncpy (wmtrash->param_fm, "filemanager", MEDIUM_STRING); strncpy (wmtrash->param_path, "trashpath", MEDIUM_STRING); strncpy (wmtrash->configfile, configfile, MEDIUM_STRING); image_path_file = malloc(LONG_STRING); parse_from_config(wmtrash->configfile, wmtrash->param_img, wmtrash->imagefile); sprintf(image_path_file, "%s/%s", __ICONPATH, wmtrash->imagefile); parse_from_config(wmtrash->configfile, wmtrash->param_fm, wmtrash->fm); parse_from_config(wmtrash->configfile, wmtrash->param_path, wmtrash->path); // GTK stuff ******************************************************************* gtk_widget_destroy(mainwin); mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize(mainwin); mainbox = create_main_dockapp_icon_window(mainwin, 52); box = gtk_event_box_new(); pixmap = (gpointer) gdk_pixmap_create_from_xpm (mainwin->window, &mask, NULL, image_path_file); pixmap_widget = gtk_pixmap_new((gpointer) pixmap, mask); gtk_container_add(GTK_CONTAINER(box), pixmap_widget); gtk_container_add (GTK_CONTAINER (mainbox), box); gtk_signal_connect (GTK_OBJECT(box), "button_press_event", GTK_SIGNAL_FUNC(launchonclick), wmtrash); free(image_path_file); return mainwin; }
/*** sfeBuildTreeItemWithImage - create a new treeview item which contains *** the appropriate image for the given node type as well as a label with *** the node's name. ***/ GtkWidget* sfeBuildTreeItemWithImage(pStructInf data_item) { GtkWidget *hbox, *label, *pixmap, *treeitem, *hiddenlabel; int i, n_icons, found; GtkStyle *style; gchar hiddenlabel_text[32]; /** Figure out which pixmap file to use. **/ found = SFE_DEFAULT_ICON; n_icons = sizeof(icon_table) / sizeof(icon_table[0]); for (i=0;i<n_icons;i++) if (!strcasecmp(data_item->UsrType, icon_table[i].Type)) found = i; /** build the gdk pixmap structure if needed **/ if (!icon_table[found].Pixmap) { style = gtk_widget_get_style(SFE_Globals.TreeView); icon_table[found].Pixmap = gdk_pixmap_create_from_xpm_d(SFE_Globals.Window->window, &(icon_table[found].Mask), &style->bg[GTK_STATE_NORMAL], (gchar**) icon_table[found].XPM); } /** Create the hbox, label, and pixmap **/ hbox = gtk_hbox_new(FALSE,1); pixmap = gtk_pixmap_new(icon_table[found].Pixmap, icon_table[found].Mask); gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); gtk_widget_show(pixmap); label = gtk_label_new(data_item->Name); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); gtk_widget_show(hbox); /** We need a hidden label to reference the structure **/ snprintf(hiddenlabel_text, 32, "%16.16lx", (unsigned long)(data_item)); hiddenlabel = gtk_label_new(hiddenlabel_text); gtk_box_pack_start(GTK_BOX(hbox), hiddenlabel, FALSE, FALSE, 0); /** Create the tree item and plop the hbox in it **/ treeitem = gtk_tree_item_new(); gtk_container_add(GTK_CONTAINER(treeitem), hbox); return treeitem; }
int main (int argc, char *argv[] ) { /* GtkWidget is the storage type for widgets */ GtkWidget *window, *pixmap, *fixed; GdkPixmap *gdk_pixmap; GdkBitmap *mask; GtkStyle *style; GdkGC *gc; /* Create the main window, and attach delete_event signal to terminate * the application. Note that the main window will not have a titlebar * since we're making it a popup. */ gtk_init (&argc, &argv); window = gtk_window_new( GTK_WINDOW_POPUP ); gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (close_application), NULL); gtk_widget_show (window); /* Now for the pixmap and the pixmap widget */ style = gtk_widget_get_default_style(); gc = style->black_gc; gdk_pixmap = gdk_pixmap_create_from_xpm_d( window->window, &mask, &style->bg[GTK_STATE_NORMAL], WheelbarrowFull_xpm ); pixmap = gtk_pixmap_new( gdk_pixmap, mask ); gtk_widget_show( pixmap ); /* To display the pixmap, we use a fixed widget to place the pixmap */ fixed = gtk_fixed_new(); gtk_widget_set_usize( fixed, 200, 200 ); gtk_fixed_put( GTK_FIXED(fixed), pixmap, 0, 0 ); gtk_container_add( GTK_CONTAINER(window), fixed ); gtk_widget_show( fixed ); /* This masks out everything except for the image itself */ gtk_widget_shape_combine_mask( window, mask, 0, 0 ); /* show the window */ gtk_widget_set_uposition( window, 20, 400 ); gtk_widget_show( window ); gtk_main (); return(0); }
/* This is an internally used function to create pixmaps. */ static GtkWidget* create_dummy_pixmap (GtkWidget *widget) { GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; GtkWidget *pixmap; colormap = gtk_widget_get_colormap (widget); gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, NULL, dummy_pixmap_xpm); if (gdkpixmap == NULL) g_error ("Couldn't create replacement pixmap."); pixmap = gtk_pixmap_new (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); return pixmap; }
static GtkWidget * create_pixmap_label(GtkWidget *window, gchar **bits) { GtkWidget *pw; GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; style = gtk_widget_get_style(window); pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->bg[GTK_STATE_NORMAL], bits); pw = gtk_pixmap_new(pixmap, mask); gtk_widget_show(pw); return pw; }
void open_about_menu(GtkWidget *widget, gpointer data) { GtkWidget *options_window, *button, *vbox, *label, *pixmap_w; GdkPixmap *pixmap; /*GtkStyle *style; removed by Bernhard*/ options_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); /* style = gtk_style_new(); Removed too, till I find out why, style->bg->red = 65535; The problem is the push_style and style->bg->blue = 65535; pop_style removed from GTK 2.0 style->bg->green = 65535; use gtk_widget_modify_* instead gtk_widget_push_style(style); gtk_widget_set_style(GTK_WIDGET(options_window), style); gtk_widget_pop_style(); */ vbox = gtk_vbox_new (FALSE, 10); gtk_window_set_title (GTK_WINDOW(options_window), "Linux Video Studio - About"); gtk_container_set_border_width (GTK_CONTAINER (options_window), 15); gtk_widget_show(options_window); pixmap = gdk_pixmap_create_from_xpm_d(options_window->window, NULL, NULL, linux_studio_logo_xpm); pixmap_w = gtk_pixmap_new(pixmap, NULL); gtk_box_pack_start(GTK_BOX(vbox), pixmap_w, FALSE, FALSE, 0); gtk_widget_show(pixmap_w); label = gtk_label_new("Linux Video Studio " VERSION "\n\n" \ "Created by:\nRonald Bultje <*****@*****.**>\n" \ "Bernhard Praschinger <*****@*****.**>\n\n" \ "Images by Laurens Buhler <*****@*****.**>\n"); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); button = gtk_button_new_with_label(" Close "); g_signal_connect_swapped (G_OBJECT(button), "clicked", G_CALLBACK (gtk_widget_destroy), G_OBJECT(options_window)); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show(button); gtk_container_add (GTK_CONTAINER (options_window), vbox); gtk_widget_show(vbox); }
static GtkWidget * create_border_pixmap(GtkBorderCombo *border_combo, gchar *border[18]) { GtkWidget *widget; GtkWidget *pixmap; GdkPixmap *border_pixmap; widget=GTK_WIDGET(border_combo); border_pixmap=gdk_pixmap_create_from_xpm_d( widget->window, NULL, &(widget->style->bg[GTK_STATE_NORMAL]), border); pixmap=gtk_pixmap_new(border_pixmap, NULL); return pixmap; }
GtkWidget * create_pixmap (GtkWidget * widget, const gchar * file) { GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; GtkWidget *pixmap; GtkStyle *style; colormap = gtk_widget_get_colormap (app.main_window); style = gtk_widget_get_style (app.main_window); gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, NULL, file); pixmap = gtk_pixmap_new (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); return pixmap; }
int main( int argc, char *argv[] ) { /* GtkWidget is the storage type for widgets */ GtkWidget *window, *pixmapwid, *button; GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; /* create the main window, and attach delete_event signal to terminating the application */ gtk_init( &argc, &argv ); window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_signal_connect( GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (close_application), NULL ); gtk_container_set_border_width( GTK_CONTAINER (window), 10 ); gtk_widget_show( window ); /* now for the pixmap from gdk */ style = gtk_widget_get_style( window ); pixmap = gdk_pixmap_create_from_xpm_d( window->window, &mask, &style->bg[GTK_STATE_NORMAL], (gchar **)xpm_data ); /* a pixmap widget to contain the pixmap */ pixmapwid = gtk_pixmap_new( pixmap, mask ); gtk_widget_show( pixmapwid ); /* a button to contain the pixmap widget */ button = gtk_button_new(); gtk_container_add( GTK_CONTAINER(button), pixmapwid ); gtk_container_add( GTK_CONTAINER(window), button ); gtk_widget_show( button ); gtk_signal_connect( GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(button_clicked), NULL ); /* show the window */ gtk_main (); return 0; }