Пример #1
0
/*
 * 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;
}
Пример #2
0
/*
 * Creates a new GtkWidget of class GtkImage, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
GtkWidget *
gb_image_new (GbWidgetNewData * data)
{
  GtkWidget *new_widget;
  new_widget = gtk_image_new_from_pixmap (gbwidget.gdkpixmap, gbwidget.mask);
  return new_widget;
}
Пример #3
0
GtkWidget *createpixmap(GtkWidget *w, GtkWidget *but, 
		const gchar **pippo, const gchar *tip, bool istoggled)
{
	/* create and return button with pixmap */

	GtkWidget *image;
	GtkTooltips *tooltip;
	GdkPixmap *pixmap;
	GdkBitmap *mask;
	GtkStyle *style;

	style=gtk_widget_get_style(w);
	gtk_widget_realize(w);
	pixmap=gdk_pixmap_create_from_xpm_d(w->window, &mask, 
			&style->bg[GTK_STATE_NORMAL], (gchar **)pippo);
	image = gtk_image_new_from_pixmap(pixmap, mask);
	
	if(!istoggled)
		but=gtk_button_new();
	else
		but=gtk_toggle_button_new();

	gtk_container_add(GTK_CONTAINER(but), image);
	tooltip = gtk_tooltips_new();
	gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltip), but, tip, NULL);
	return but;
	
}
Пример #4
0
/*
 * Creates a new GtkWidget of class GtkToggleToolButton, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 */
static GtkWidget*
gb_toggle_tool_button_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget, *image;
  GbWidget *pixmap_gbwidget;

  /* Place the pixmap icon in the button initially (even when loading). */
  pixmap_gbwidget = gb_widget_lookup_class ("GtkImage");
  if (pixmap_gbwidget)
    {
      image = gtk_image_new_from_pixmap (pixmap_gbwidget->gdkpixmap,
					 pixmap_gbwidget->mask);
    }
  else
    {
      image = gtk_image_new ();
      g_warning ("Couldn't find GtkPixmap data");
    }
  gtk_widget_show (image);

  new_widget = (GtkWidget*) gtk_toggle_tool_button_new ();

  gtk_tool_button_set_label (GTK_TOOL_BUTTON (new_widget), "");
  gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (new_widget), image);

  return new_widget;
}
Пример #5
0
void
create_about_dialog(void)
{
	char work[256];
	GtkWidget *about_dialog;
	GtkWidget *main_widget;
	GtkWidget *ver_label;
	GtkWidget *ok_button;
	GtkWidget *neko_image;
	GdkColormap *colormap;
	GdkPixmap *neko_pixmap;
	GdkBitmap *mask;

	uninstall_idle_process();

	about_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(about_dialog), "About Neko Project II");
	gtk_window_set_position(GTK_WINDOW(about_dialog), GTK_WIN_POS_CENTER);
	gtk_window_set_modal(GTK_WINDOW(about_dialog), TRUE);
	gtk_window_set_resizable(GTK_WINDOW(about_dialog), FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(about_dialog), 10);
	g_signal_connect(GTK_OBJECT(about_dialog), "destroy",
	    GTK_SIGNAL_FUNC(about_destroy), NULL);

	main_widget = gtk_hbox_new(FALSE, 3);
	gtk_widget_show(main_widget);
	gtk_container_add(GTK_CONTAINER(about_dialog), main_widget);

	colormap = gtk_widget_get_colormap(about_dialog);
	neko_pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap,
	    &mask, NULL, (gchar **)np2_icon);
	if (neko_pixmap == NULL)
		g_error("Couldn't create replacement pixmap.");
	neko_image = gtk_image_new_from_pixmap(neko_pixmap, mask);
	g_object_unref(neko_pixmap);
	g_object_unref(mask);
	gtk_widget_show(neko_image);
	gtk_box_pack_start(GTK_BOX(main_widget), neko_image, FALSE, FALSE, 10);

	milstr_ncpy(work, "Neko Project II\n", sizeof(work));
	milstr_ncat(work, NP2VER_CORE, sizeof(work));
#if defined(NP2VER_X11)
	milstr_ncat(work, NP2VER_X11, sizeof(work));
#endif
	ver_label = gtk_label_new(work);
	gtk_widget_show(ver_label);
	gtk_box_pack_start(GTK_BOX(main_widget), ver_label, FALSE, FALSE, 10);

	ok_button = gtk_button_new_from_stock(GTK_STOCK_OK);
	gtk_widget_show(ok_button);
	gtk_box_pack_end(GTK_BOX(main_widget), ok_button, FALSE, TRUE, 0);
	g_signal_connect_swapped(GTK_OBJECT(ok_button), "clicked",
	    GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(about_dialog));
	GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT);
	GTK_WIDGET_SET_FLAGS(ok_button, GTK_HAS_DEFAULT);
	gtk_widget_grab_default(ok_button);

	gtk_widget_show_all(about_dialog);
}
Пример #6
0
static void button_set_image_xpm(GtkWidget *button, char **xpm)
/* Creates a button with an XPM icon */
{
        GdkPixmap *pixmap;
        GdkBitmap *mask;
        GtkWidget *image;

        pixmap = gdk_pixmap_colormap_create_from_xpm_d
                 (NULL, gdk_colormap_get_system(), &mask, NULL, xpm);
        image = gtk_image_new_from_pixmap(pixmap, mask);
        g_object_unref(pixmap);
        gtk_button_set_image(GTK_BUTTON(button), image);
}
Пример #7
0
GtkWidget* Installer::GetTitaniumIcon()
{
    GdkColormap* colormap = gtk_widget_get_colormap(this->window);
    GdkBitmap *mask = NULL;
    GdkPixmap* pixmap = gdk_pixmap_colormap_create_from_xpm_d(
        NULL,
        colormap,
        &mask,
        NULL,
        (gchar**) titanium_xpm);
    return gtk_image_new_from_pixmap(pixmap, mask);

}
Пример #8
0
GtkWidget *make_image(GdkDrawable *drawable, char **xpm, const char *tooltip)
{
	GdkPixmap *pixmap;
	GtkWidget *image;
	GdkColor white = get_color("white");

	pixmap = gdk_pixmap_create_from_xpm_d(drawable, NULL, &white, xpm);
	image = gtk_image_new_from_pixmap(pixmap, NULL);
	gtk_misc_set_padding(GTK_MISC(image), 1, 1);
	if (tooltip)
		gtk_widget_set_tooltip_markup(image, tooltip);
	return image;
}
Пример #9
0
GtkWidget *make_transparent_image(GdkDrawable *drawable, char **xpm,
    const char *tooltip)
{
	GdkPixmap *pixmap;
	GdkBitmap *mask;
	GtkWidget *image;

	pixmap = gdk_pixmap_create_from_xpm_d(drawable, &mask, NULL, xpm);
	image = gtk_image_new_from_pixmap(pixmap, mask);
	gtk_misc_set_padding(GTK_MISC(image), 1, 1);
	if (tooltip)
		gtk_widget_set_tooltip_markup(image, tooltip);
	return image;
}
Пример #10
0
static GtkWidget *build_port_menu(void)
{
	gint i;
	GtkWidget *item;
	GdkPixmap *pixmap;
	GtkWidget *image;
	GtkWidget *menu;
	MapTheme *theme = theme_get_current();

	menu = gtk_menu_new();

	for (i = 0; i <= ANY_RESOURCE; i++) {
		item =
		    gtk_image_menu_item_new_with_mnemonic(gettext
							  (port_names[i]));

		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
		g_signal_connect(G_OBJECT(item), "activate",
				 G_CALLBACK(select_port_resource_cb),
				 GINT_TO_POINTER(i));

		pixmap = theme->port_tiles[i];
		if (i >= NO_RESOURCE || pixmap == NULL)
			continue;

		image = gtk_image_new_from_pixmap(pixmap, NULL);
		gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
					      image);
	}
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),
			      gtk_separator_menu_item_new());
	for (i = 0; i < 6; i++) {
		item =
		    gtk_check_menu_item_new_with_label(Q_
						       (port_direction_names
							[i]));
		gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM
						      (item), TRUE);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
		g_signal_connect(G_OBJECT(item), "toggled",
				 G_CALLBACK(select_port_direction_cb),
				 GINT_TO_POINTER(i));
		port_directions[i] = item;
	}
	gtk_widget_show_all(menu);

	return menu;
}
Пример #11
0
static void headerview_show_xface(HeaderView *headerview, MsgInfo *msginfo)
{
    gchar xface[2048];
    GdkPixmap *pixmap;
    GdkBitmap *mask;
    GtkWidget *hbox = headerview->hbox;

    if (!msginfo->xface || strlen(msginfo->xface) < 5) {
        if (headerview->image &&
                GTK_WIDGET_VISIBLE(headerview->image)) {
            gtk_widget_hide(headerview->image);
            gtk_widget_queue_resize(hbox);
        }
        return;
    }
    if (!GTK_WIDGET_VISIBLE(headerview->hbox)) return;

    strncpy(xface, msginfo->xface, sizeof(xface));

    if (uncompface(xface) < 0) {
        g_warning("uncompface failed\n");
        if (headerview->image)
            gtk_widget_hide(headerview->image);
        return;
    }

    create_xpm_from_xface(xpm_xface, xface);

    pixmap = gdk_pixmap_create_from_xpm_d
             (hbox->window, &mask, &hbox->style->white, xpm_xface);

    if (!headerview->image) {
        GtkWidget *image;

        image = gtk_image_new_from_pixmap(pixmap, mask);
        gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
        gtk_widget_show(image);
        headerview->image = image;
    } else {
        gtk_image_set_from_pixmap(GTK_IMAGE(headerview->image),
                                  pixmap, mask);
        gtk_widget_show(headerview->image);
    }

    gdk_pixmap_unref(pixmap);
}
Пример #12
0
void replace_button_icon(GladeXML * xml, GdkDrawable * window,
			 GtkStyle * style, gchar * btn_name, gchar ** xpm)
{
	GdkPixmap *pixmap;
	GdkBitmap *mask;
	GtkToolButton *button;
	GtkWidget *image;

	pixmap = gdk_pixmap_create_from_xpm_d(window, &mask,
					      &style->bg[GTK_STATE_NORMAL],
					      xpm);

	button = GTK_TOOL_BUTTON(glade_xml_get_widget(xml, btn_name));
	image = gtk_image_new_from_pixmap(pixmap, mask);
	gtk_widget_show(image);
	gtk_tool_button_set_icon_widget(button, image);
}
static GtkWidget *
create_pixmap (GtkWidget *w, const char **data)
{
	GtkWidget *pixmap;
	GdkColormap *colormap;
	GdkPixmap *gdkpixmap;
	GdkBitmap *mask;

	colormap = gtk_widget_get_colormap (w);
	gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask,
							 NULL, const_cast<gchar **>(data));

	pixmap = gtk_image_new_from_pixmap (gdkpixmap, mask);
	gdk_pixmap_unref (gdkpixmap);
	gdk_bitmap_unref (mask);
	return pixmap;
}
Пример #14
0
void build_tape_status_widget(app_shell_type *as, GdkWindow *window)
{
    GtkWidget *frame;

    as->tape_status.event_box = gtk_event_box_new();

    frame = gtk_frame_new(NULL);
    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);

    as->tape_status.box = gtk_hbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(frame), as->tape_status.box);
    gtk_widget_show(as->tape_status.box);

    gtk_container_add(GTK_CONTAINER(as->tape_status.event_box), frame);
    gtk_widget_show(frame);

    gtk_widget_set_tooltip_text(GTK_WIDGET(gtk_widget_get_parent(gtk_widget_get_parent(as->tape_status.box))), "");

    /* Tape Label */
    as->tape_status.label = gtk_label_new(_("Tape 000"));
    gtk_container_add(GTK_CONTAINER(as->tape_status.box), as->tape_status.label);
    /* gtk_misc_set_alignment(GTK_MISC (as->tape_status.label), 0, -1); */
    gtk_widget_show(as->tape_status.label);

    /* Tape control */
#if !defined(HAVE_CAIRO)
    as->tape_status.control_pixmap = gdk_pixmap_new(window, CTRL_WIDTH, CTRL_HEIGHT, -1);
    as->tape_status.control = gtk_image_new_from_pixmap(as->tape_status.control_pixmap, NULL);
#else
    as->tape_status.control = gtk_drawing_area_new();
#endif
    gtk_widget_set_size_request(as->tape_status.control, CTRL_WIDTH, CTRL_HEIGHT);
    gtk_box_pack_start(GTK_BOX(as->tape_status.box), as->tape_status.control, FALSE, FALSE, 4);
    gtk_widget_show(as->tape_status.control);

    gtk_widget_set_events(as->tape_status.event_box, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK);
    g_signal_connect(G_OBJECT(as->tape_status.event_box), "button-press-event", G_CALLBACK(tape_popup_cb), (gpointer)NULL);
#if defined(HAVE_CAIRO)
#if GTK_CHECK_VERSION(3, 0, 0)
    g_signal_connect(G_OBJECT(as->tape_status.control), "draw", G_CALLBACK(tape_draw), (gpointer)as->canvas);
#else
    g_signal_connect(G_OBJECT(as->tape_status.control), "expose-event", G_CALLBACK(tape_draw), (gpointer)as->canvas);
#endif
#endif
}
Пример #15
0
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);
    g_signal_connect (G_OBJECT (window), "delete_event",
                      G_CALLBACK (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_image_new_from_pixmap (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_size_request (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_show (window);
    gtk_main ();
          
    return 0;
}
Пример #16
0
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);
    g_signal_connect (window, "delete-event",
                      G_CALLBACK (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_image_new_from_pixmap (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);

    g_signal_connect (button, "clicked",
                      G_CALLBACK (button_clicked), NULL);

    /* show the window */
    gtk_main ();

    return 0;
}
Пример #17
0
/*
 * Creates a new GtkWidget of class GtkRadioToolButton, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 */
static GtkWidget*
gb_radio_tool_button_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget, *image;
  GbWidget *pixmap_gbwidget;
  GSList *group_list = NULL;

  /* When creating a radiotoolbutton we try to place it in the same group
     as other radiotoolbuttons in the same toolbar. */
  if (data->action == GB_CREATING)
    {
      GtkWidget *parent = data->parent;
      while (parent && !GTK_IS_TOOLBAR (parent))
	parent = parent->parent;
      if (parent)
	gb_widget_children_foreach (parent,
				    (GtkCallback) find_parents_group,
				    &group_list);
    }

  /* Place the pixmap icon in the button initially (even when loading). */
  pixmap_gbwidget = gb_widget_lookup_class ("GtkImage");
  if (pixmap_gbwidget)
    {
      image = gtk_image_new_from_pixmap (pixmap_gbwidget->gdkpixmap,
					 pixmap_gbwidget->mask);
    }
  else
    {
      image = gtk_image_new ();
      g_warning ("Couldn't find GtkPixmap data");
    }
  gtk_widget_show (image);

  new_widget = (GtkWidget*) gtk_radio_tool_button_new (group_list);

  gtk_tool_button_set_label (GTK_TOOL_BUTTON (new_widget), "");
  gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (new_widget), image);

  return new_widget;
}
Пример #18
0
GtkWidget *gui_button_x(gchar *text,
                          gpointer cb, gpointer arg,
                          GtkWidget *box)
{
GtkWidget *hbox, *button, *label, *image;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;

/* create button */
button = gtk_button_new();
hbox = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(button), hbox);

/* create image */
style = gtk_widget_get_style(window);
pixmap = gdk_pixmap_create_from_xpm_d
          (window->window, &mask, &style->white, go_xpm);
image = gtk_image_new_from_pixmap(pixmap, mask);

gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);

/* create label */
if (box)
  {
/* packing sub-widget */
  hbox = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0);
  if (text)
    {
    label = gtk_label_new(text);
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
    }
  gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
  }

if (cb)
  g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cb), arg);

return(button);
}
Пример #19
0
void
CRevise_group::create_plane (glong x, glong y)
{
	gchar tmpstr[246];
	sprintf(tmpstr,_("G%d"),revise_zu_index[y]+1);
	plane_button[y] = new tTextButton;
	plane_button[y]->create (g_pReciteWord->fixed,
				 Skin->revise_group.plane_button[y].x[0],
				 Skin->revise_group.plane_button[y].y[0],
				 Skin->revise_group.plane_button_p.w,
				 Skin->revise_group.plane_button_p.h,
				 Skin->revise_group.plane_button_text_1.x[0],
				 Skin->revise_group.plane_button_text_1.y[0],
				 Skin->revise_group.plane_button_text_2.x[0],
				 Skin->revise_group.plane_button_text_2.y[0],
				 Skin->revise_group.plane_button_p.p[0],
				 Skin->revise_group.plane_button_p.p[1],
				 tmpstr,
				 on_revise_group_plane_clicked,
				 (gpointer)y);
	plane[y] = new tPixButton;
	plane[y]->create (g_pReciteWord->fixed,
			  Skin->revise_group.plane[x][y].x[0],
			  Skin->revise_group.plane[x][y].y[0],
			  Skin->revise_group.plane[x][y].p[0],
			  Skin->revise_group.plane[x][y].p[1],
			  (GdkPixmap *) NULL, on_revise_group_plane_clicked,
			  (gpointer)y);
	const gchar tooltips[5][3]={"F1","F2","F3","F4","F5"};
	gtk_tooltips_set_tip (g_pReciteWord->tooltips, plane[y]->event_box,tooltips[y],"");
	if (Skin->revise_group.plane_h[x][y].w)
	{
		plane_h[y] =
			gtk_image_new_from_pixmap (Skin->revise_group.plane_h[x][y].p[0],
					NULL);
		gtk_fixed_put (GTK_FIXED (g_pReciteWord->fixed), plane_h[y],
			       Skin->revise_group.plane_h[x][y].x[0],
			       Skin->revise_group.plane_h[x][y].y[0]);
		gtk_widget_show (plane_h[y]);
	}
}
Пример #20
0
GtkWidget *build_line(gint start_x, gint start_y
        , gint width, gint height, GtkWidget *hour_line, GdkColor *line_color)
{
    GdkColormap *pic1_cmap;
    GdkVisual *pic1_vis;
    GdkPixmap *pic1;
    GdkGC *pic1_gc;
    GtkWidget *new_hour_line;
    gint depth = 16;
    gboolean first = FALSE;

    /*
     * GdkPixbuf *scaled;
    scaled = gdk_pixbuf_scale_simple (pix, w, h, GDK_INTERP_BILINEAR);
    */
     
    pic1_cmap = gdk_colormap_get_system();
    pic1_vis = gdk_colormap_get_visual(pic1_cmap);
    depth = pic1_vis->depth;
    if (hour_line == NULL) {
        pic1 = gdk_pixmap_new(NULL, width, height, depth);
        gdk_drawable_set_colormap(pic1, pic1_cmap);
        first = TRUE;
    }
    else
        gtk_image_get_pixmap(GTK_IMAGE(hour_line), &pic1, NULL);
    pic1_gc = gdk_gc_new(pic1);
    if (first) {
        gdk_gc_set_foreground(pic1_gc, line_color);
        gdk_draw_rectangle(pic1, pic1_gc, TRUE, start_x, start_y, width, height);
    }
    else {
        gdk_draw_rectangle(pic1, pic1_gc, TRUE, start_x, start_y, width, height);
    }
    
    new_hour_line = gtk_image_new_from_pixmap(pic1, NULL);
    g_object_unref(pic1_gc);
    g_object_unref(pic1);
    return(new_hour_line);
}
Пример #21
0
/*! \brief Creates a new GtkImage displaying a GTK stock icon if available.
 *
 * If a stock GTK icon with the requested name was not found, this function
 * falls back to the bitmap icons provided in the distribution.
 *
 * \param stock Name of the stock icon ("new", "open", etc.)
 * \param w_current Schematic top level
 * \return Pointer to the new GtkImage object.
 */
static GtkWidget *x_window_stock_pixmap(const char *stock, GSCHEM_TOPLEVEL *w_current)
{
  GtkWidget *wpixmap = NULL;
  GdkPixmap *pixmap;
  GdkBitmap *mask;
  GtkStockItem item;

  GdkWindow *window=w_current->main_window->window;
  GdkColor *background=&w_current->main_window->style->bg[GTK_STATE_NORMAL];

  gchar *filename=g_strconcat(w_current->toplevel->bitmap_directory,
                              G_DIR_SEPARATOR_S, 
                              "gschem-", stock, ".xpm", NULL);

  gchar *stockid=g_strconcat("gtk-", stock, NULL);

  /* First check if GTK knows this stock icon */
  if(gtk_stock_lookup(stockid, &item)) {
    wpixmap = gtk_image_new_from_stock(stockid, 
                                       GTK_ICON_SIZE_SMALL_TOOLBAR);
  } else {
    /* Fallback to the original custom icon */
    pixmap = gdk_pixmap_create_from_xpm (window, &mask, 
                                         background, filename);
    if (pixmap != NULL) {
      wpixmap = gtk_image_new_from_pixmap (pixmap, mask);
    } else {
     s_log_message("Could not find image at file: %s.\n", filename);
     wpixmap = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE , 
					GTK_ICON_SIZE_SMALL_TOOLBAR);
    }
  }

  g_free(filename);
  g_free(stockid);

  return wpixmap;
}
Пример #22
0
Файл: osd.c Проект: iolo/liteamp
Osd *osd_new(void)
{
    Osd *self;

    self = g_object_new(TYPE_OSD, NULL);

    GTK_WINDOW(self)->type = GTK_WINDOW_POPUP;

    self->image = gtk_image_new_from_pixmap(NULL, NULL);
    gtk_widget_show(self->image);

    gtk_container_add(GTK_CONTAINER(self), self->image);

    //FIXME:
    gtk_window_move(GTK_WINDOW(self), 0, 0);
    gtk_window_resize(GTK_WINDOW(self), 1, 1);
    gtk_widget_show(GTK_WIDGET(self));

    self->layout = gtk_widget_create_pango_layout(GTK_WIDGET(self), NULL);

    gtk_widget_hide(GTK_WIDGET(self));

    return self;
}
Пример #23
0
GtkWidget *build_drive_status_widget(app_shell_type *as, GdkWindow *window)
{
    GtkWidget *drive_box, *frame;
    int i;
    char *empty = util_concat("<", _("empty"), ">", NULL);

    drive_box = gtk_hbox_new(FALSE, 0);
    for (i = 0; i < NUM_DRIVES; i++) {
        char label[256];

        as->drive_status[i].event_box = gtk_event_box_new();

        frame = gtk_frame_new(NULL);
        gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);

        sprintf(label, _("Drive %d "), i + 8);
        as->drive_status[i].box = gtk_hbox_new(FALSE, 0);

        gtk_container_add(GTK_CONTAINER(frame), as->drive_status[i].box);
        gtk_widget_show(as->drive_status[i].box);

        gtk_container_add(GTK_CONTAINER(as->drive_status[i].event_box), frame);
        gtk_widget_show(frame);

        gtk_widget_set_tooltip_text(GTK_WIDGET(gtk_widget_get_parent(gtk_widget_get_parent(as->drive_status[i].box))), empty);

        /* Label */
        as->drive_status[i].label = (void *)gtk_label_new(g_strdup(label));
        gtk_box_pack_start(GTK_BOX(as->drive_status[i].box), (GtkWidget *)as->drive_status[i].label, TRUE, TRUE, 0);
        gtk_widget_show((GtkWidget *)as->drive_status[i].label);

        /* Track Label */
        as->drive_status[i].track_label = gtk_label_new("");
        gtk_box_pack_start(GTK_BOX(as->drive_status[i].box), as->drive_status[i].track_label, FALSE, FALSE, 0);
        gtk_widget_show(as->drive_status[i].track_label);      

        /* Single Led */
#if !defined(HAVE_CAIRO)
        as->drive_status[i].led_pixmap = gdk_pixmap_new(window, LED_WIDTH, LED_HEIGHT, -1);
        as->drive_status[i].led = gtk_image_new_from_pixmap(as->drive_status[i].led_pixmap, NULL);
#else
        as->drive_status[i].led = gtk_drawing_area_new();
#endif
        gtk_widget_set_size_request(as->drive_status[i].led, LED_WIDTH, LED_HEIGHT);
        gtk_box_pack_start(GTK_BOX(as->drive_status[i].box), (GtkWidget *)as->drive_status[i].led, FALSE, FALSE, 4);
        gtk_widget_show(as->drive_status[i].led);

        /* Led1 for double Led drive */
#if !defined(HAVE_CAIRO)
        as->drive_status[i].led1_pixmap = gdk_pixmap_new(window, LED_WIDTH / 2, LED_HEIGHT, -1);
        as->drive_status[i].led1 = gtk_image_new_from_pixmap(as->drive_status[i].led1_pixmap, NULL);
        gtk_widget_set_size_request(as->drive_status[i].led1, LED_WIDTH / 2, LED_HEIGHT);
        gtk_box_pack_start(GTK_BOX(as->drive_status[i].box), (GtkWidget *)as->drive_status[i].led1, FALSE, FALSE, 1);
        gtk_widget_show(as->drive_status[i].led1);
#endif
        /* Led2 for double Led drive */
#if !defined(HAVE_CAIRO)
        as->drive_status[i].led2_pixmap = gdk_pixmap_new(window, LED_WIDTH / 2, LED_HEIGHT, -1);
        as->drive_status[i].led2 = gtk_image_new_from_pixmap(as->drive_status[i].led2_pixmap, NULL);
        gtk_widget_set_size_request(as->drive_status[i].led2, LED_WIDTH / 2, LED_HEIGHT);
        gtk_box_pack_start(GTK_BOX(as->drive_status[i].box), (GtkWidget *)as->drive_status[i].led2, FALSE, FALSE, 1);
        gtk_widget_show(as->drive_status[i].led2);
#endif
        /* Pack everything together */
        gtk_box_pack_start(GTK_BOX(drive_box), as->drive_status[i].event_box, FALSE, FALSE, 0);

        gtk_widget_set_events(as->drive_status[i].event_box, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK);
        g_signal_connect(G_OBJECT(as->drive_status[i].event_box), "button-press-event", G_CALLBACK(fliplist_popup_cb), (gpointer)(int_to_void_ptr(i)));
        gtk_widget_show(as->drive_status[i].event_box);

#if defined(HAVE_CAIRO)
#if GTK_CHECK_VERSION(3, 0, 0)
        g_signal_connect(G_OBJECT(as->drive_status[i].led), "draw", G_CALLBACK(leds_draw), int_to_void_ptr(i));
#else
        g_signal_connect(G_OBJECT(as->drive_status[i].led), "expose-event", G_CALLBACK(leds_draw), int_to_void_ptr(i));
#endif
#endif
    }
    lib_free(empty);
    return drive_box;
}
Пример #24
0
void gaym_gtkconv_update_thumbnail(GaimConversation * conv, struct fetch_thumbnail_data
                                   *thumbnail_data)
{
    GaimGtkConversation *gtkconv;

    char filename[256];
    FILE *file;
    GError *err = NULL;

    size_t len;

    GdkPixbuf *buf;
    GdkPixbuf *scale;
    GdkPixmap *pm;
    GdkBitmap *bm;
    int scale_width, scale_height;


    GaimAccount *account;
    GaimPluginProtocolInfo *prpl_info = NULL;
    g_return_if_fail(conv != NULL);
    g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv));
    g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_CHAT);

    gtkconv = GAIM_GTK_CONVERSATION(conv);

    GaymChatIcon *icon_data = g_hash_table_lookup(icons, conv);

    if (!thumbnail_data)
        return;
    if (!icon_data->show_icon)
        return;

    const char *data = thumbnail_data->pic_data;
    len = thumbnail_data->pic_data_len;

    account = gaim_conversation_get_account(conv);
    if (account && account->gc)
        prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl);


    if (icon_data->anim != NULL)
        g_object_unref(G_OBJECT(icon_data->anim));

    icon_data->anim = NULL;

    if (icon_data->icon_timer != 0)
        g_source_remove(icon_data->icon_timer);

    icon_data->icon_timer = 0;

    if (icon_data->iter != NULL)
        g_object_unref(G_OBJECT(icon_data->iter));

    icon_data->iter = NULL;

    if (!gaim_prefs_get_bool
        ("/gaim/gtk/conversations/im/show_buddy_icons"))
        return;

    if (gaim_conversation_get_gc(conv) == NULL)
        return;


    /* this is such an evil hack, i don't know why i'm even considering
       it. we'll do it differently when gdk-pixbuf-loader isn't leaky
       anymore. */
    /* gdk-pixbuf-loader was leaky? is it still? */

    g_snprintf(filename, sizeof(filename),
               "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d",
               g_get_tmp_dir(), thumbnail_data->who, getpid());

    if (!(file = g_fopen(filename, "wb")))
        return;

    fwrite(data, 1, len, file);
    fclose(file);
    icon_data->anim = gdk_pixbuf_animation_new_from_file(filename, &err);

    /* make sure we remove the file as soon as possible */
    g_unlink(filename);

    if (err) {
        gaim_debug(GAIM_DEBUG_ERROR, "gtkconv",
                   "Buddy icon error: %s\n", err->message);
        g_error_free(err);
    }



    if (!icon_data->anim)
        return;

    if (gdk_pixbuf_animation_is_static_image(icon_data->anim)) {
        icon_data->iter = NULL;
        buf = gdk_pixbuf_animation_get_static_image(icon_data->anim);
    } else {
        icon_data->iter = gdk_pixbuf_animation_get_iter(icon_data->anim, NULL); /* LEAK 
                                                                                 */
        buf = gdk_pixbuf_animation_iter_get_pixbuf(icon_data->iter);
    }

    get_icon_scale_size(icon_data->anim,
                        prpl_info ? &prpl_info->icon_spec : NULL,
                        &scale_width, &scale_height);
    scale =
        gdk_pixbuf_scale_simple(buf,
                                MAX(gdk_pixbuf_get_width(buf) *
                                    scale_width /
                                    gdk_pixbuf_animation_get_width
                                    (icon_data->anim), 1),
                                MAX(gdk_pixbuf_get_height(buf) *
                                    scale_height /
                                    gdk_pixbuf_animation_get_height
                                    (icon_data->anim), 1),
                                GDK_INTERP_NEAREST);

    gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100);
    g_object_unref(G_OBJECT(scale));


    icon_data->event = gtk_event_box_new();
    gtk_container_add(GTK_CONTAINER(icon_data->frame), icon_data->event);
    gtk_widget_set_size_request(GTK_WIDGET(icon_data->frame), scale_width,
                                scale_height);

    // g_signal_connect(G_OBJECT(icon_data->event), "button-press-event",
    // G_CALLBACK(icon_menu), conv);
    gtk_widget_show(icon_data->event);
    icon_data->icon = gtk_image_new_from_pixmap(pm, bm);
    gtk_container_add(GTK_CONTAINER(icon_data->event), icon_data->icon);
    gtk_widget_show(icon_data->icon);

    g_object_unref(G_OBJECT(pm));

    if (bm)
        g_object_unref(G_OBJECT(bm));


}
Пример #25
0
void
CMark::show ()
{
	init ();

	fixed = gtk_fixed_new ();
	gtk_fixed_set_has_window(GTK_FIXED(fixed),TRUE);
	gtk_widget_set_size_request (fixed, Skin->mark.mark.w,
			      Skin->mark.mark.h);
	if (g_pReciteWord->status==STATUS_REVISE_TEST)
	{
		gtk_fixed_put (GTK_FIXED (g_pReciteWord->fixed), fixed, Skin->mark.mark.x[0], Skin->mark.mark.y[0]);
	}
	else
	{
		gtk_fixed_put (GTK_FIXED (g_pReciteWord->fixed), fixed,
		       (Skin->reciteword.width - Skin->mark.mark.w) / 2,
		       (Skin->reciteword.height -
			Skin->mark.mark.h) / 2);
	}
	gtk_widget_show (fixed);
	SetBackPixmap (fixed, Skin->mark.mark.p[0]);

	ok_button.create (fixed, Skin->mark.ok_button.x[0],
			  Skin->mark.ok_button.y[0],
			  Skin->mark.ok_button.p[0],
			  Skin->mark.ok_button.p[1],
			  Skin->mark.ok_button.p[2],
			  NULL, on_mark_ok_clicked);
	gchar tmpstr[256];
	if (g_pReciteWord->status==STATUS_REVISE_TEST)
	{
		gint wrongcount=0;
		for (int i = 0;i < g_pReciteWord->now_zu_wordcount; i++)
		{
			if (g_pReciteWord->revise_test->tested_wordlist_item_status[i] == S_right_2)
			{
				wrongcount++;
			}
		}		
		gint score=(((g_pReciteWord->now_zu_wordcount-wrongcount)*100)/g_pReciteWord->now_zu_wordcount);
		sprintf(tmpstr,"%2d",score);

		mark_label = gtk_label_new (tmpstr);
		gtk_widget_set_name (mark_label, "mark-mark_label");
		gtk_fixed_put (GTK_FIXED (fixed), mark_label,
		       Skin->mark.revise_test_mark_label.x[0],
		       Skin->mark.revise_test_mark_label.y[0]);
		gtk_widget_show (mark_label);
		sprintf(tmpstr,_("%d minutes and %d seconds"),(g_pReciteWord->revise_test->timecount / 60),(g_pReciteWord->revise_test->timecount % 60));
		info_label = gtk_label_new (tmpstr);
		gtk_fixed_put (GTK_FIXED (fixed), info_label,
		       Skin->mark.revise_test_time_label.x[0],
		       Skin->mark.revise_test_time_label.y[0]);
		gtk_widget_show (info_label);
	}
	else if (g_pReciteWord->status==STATUS_TYPING)
	{
		typing_pixmap = gtk_image_new_from_pixmap (Skin->mark.typing_pixmap.p[0], NULL);
		gtk_fixed_put (GTK_FIXED (fixed), typing_pixmap,
		       Skin->mark.typing_pixmap.x[0],
		       Skin->mark.typing_pixmap.y[0]);
		gtk_widget_show(typing_pixmap);
		
		sprintf(tmpstr,"%3d",g_pReciteWord->typing->speed_value);
		mark_label = gtk_label_new (tmpstr);
		gtk_widget_set_name (mark_label, "mark-mark_label");
		gtk_fixed_put (GTK_FIXED (fixed), mark_label,
		       Skin->mark.typing_mark_label.x[0],
		       Skin->mark.typing_mark_label.y[0]);
		gtk_widget_show (mark_label);
	}

}
Пример #26
0
static GtkWidget *
display_simple_dialog(gint type, gint btn_mask, char *message)
{
  GtkWidget   *win, *main_vb, *top_hb, *msg_vb, *type_pm, *msg_label, *ask_cb,
              *bbox, *ok_bt, *yes_bt, *bt, *save_bt, *dont_save_bt;
  GdkPixmap   *pixmap;
  GdkBitmap   *mask;
  GtkStyle    *style;
  GdkColormap *cmap;
  const gchar **icon;

  /* Main window */
  switch (type) {
  case ESD_TYPE_WARN :
    icon = stock_dialog_warning_48_xpm;
    break;
  case ESD_TYPE_CONFIRMATION:
    icon = stock_dialog_warning_48_xpm;
    break;
  case ESD_TYPE_ERROR:
    icon = stock_dialog_error_48_xpm;
    break;
  case ESD_TYPE_STOP :
    icon = stock_dialog_stop_48_xpm;
    break;
  case ESD_TYPE_INFO :
  default :
    icon = stock_dialog_info_48_xpm;
    break;
  }

  /*
   * The GNOME HIG:
   *
   *	http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-windows
   *
   * says that the title should be empty for alert boxes, so there's "less
   * visual noise and confounding text."
   *
   * The Windows HIG:
   *
   *	http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch09f.asp
   *
   * says it should
   *
   *	...appropriately identify the source of the message -- usually
   *	the name of the object.  For example, if the message results
   *	from editing a document, the title text is the name of the
   *	document, optionally followed by the application name.  If the
   *	message results from a non-document object, then use the
   *	application name."
   *
   * and notes that the title is important "because message boxes might
   * not always the the result of current user interaction" (e.g., some
   * app might randomly pop something up, e.g. some browser letting you
   * know that it couldn't fetch something because of a timeout).
   *
   * It also says not to use "warning" or "caution", as there's already
   * an icon that tells you what type of alert it is, and that you
   * shouldn't say "error", as that provides no useful information.
   *
   * So we give it a title on Win32, and don't give it one on UN*X.
   * For now, we give it a Win32 title of just "Wireshark"; we should
   * arguably take an argument for the title.
   */
  if(btn_mask == ESD_BTN_NONE) {
	win = splash_window_new();
  } else {
#ifdef _WIN32
    win = dlg_window_new("Wireshark");
#else
    win = dlg_window_new("");
#endif
  }

  gtk_window_set_modal(GTK_WINDOW(win), TRUE);
  gtk_container_set_border_width(GTK_CONTAINER(win), 6);

  /* Container for our rows */
  main_vb = gtk_vbox_new(FALSE, 12);
  gtk_container_add(GTK_CONTAINER(win), main_vb);
  gtk_widget_show(main_vb);

  /* Top row: Icon and message text */
  top_hb = gtk_hbox_new(FALSE, 12);
  gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6);
  gtk_container_add(GTK_CONTAINER(main_vb), top_hb);
  gtk_widget_show(top_hb);

  /* icon */
  style = gtk_widget_get_style(win);
  cmap  = gdk_colormap_get_system();
  pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL, cmap,  &mask,
    &style->bg[GTK_STATE_NORMAL], (gchar **) icon);
  type_pm = gtk_image_new_from_pixmap(pixmap, mask);
  gtk_misc_set_alignment (GTK_MISC (type_pm), 0.5f, 0.0f);
  gtk_container_add(GTK_CONTAINER(top_hb), type_pm);
  gtk_widget_show(type_pm);

  /* column for message and optional check button */
  msg_vb = gtk_vbox_new(FALSE, 6);
  gtk_box_set_spacing(GTK_BOX(msg_vb), 24);
  gtk_container_add(GTK_CONTAINER(top_hb), msg_vb);
  gtk_widget_show(msg_vb);

  /* message */
  msg_label = gtk_label_new(message);

  gtk_label_set_markup(GTK_LABEL(msg_label), message);
  gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
#if GTK_CHECK_VERSION(2,9,0)
  g_object_set(gtk_widget_get_settings(msg_label),
    "gtk-label-select-on-focus", FALSE, NULL);
#endif

  gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
  gtk_misc_set_alignment (GTK_MISC (type_pm), 0.5f, 0.0f);
  gtk_container_add(GTK_CONTAINER(msg_vb), msg_label);
  gtk_label_set_line_wrap(GTK_LABEL(msg_label), TRUE);
  gtk_widget_show(msg_label);

  if(btn_mask == ESD_BTN_NONE) {
	gtk_widget_show(win);
	return win;
  }

  /* optional check button */
  ask_cb = gtk_check_button_new_with_label("replace with text...");
  gtk_container_add(GTK_CONTAINER(msg_vb), ask_cb);
  g_object_set_data(G_OBJECT(win), CHECK_BUTTON, ask_cb);

  /* Button row */
  switch(btn_mask) {
  case(ESD_BTN_OK):
    bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
    break;
  case(ESD_BTN_OK | ESD_BTN_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTN_CLEAR | ESD_BTN_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_CLEAR, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_YES_NO_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_SAVE_DONTSAVE_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_SAVE, WIRESHARK_STOCK_DONT_SAVE, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_SAVE, WIRESHARK_STOCK_QUIT_DONT_SAVE, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_YES_NO):
    bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, NULL);
    break;
  default:
    g_assert_not_reached();
    bbox = NULL;
    break;
  }
  gtk_container_add(GTK_CONTAINER(main_vb), bbox);
  gtk_widget_show(bbox);

  ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
  if(ok_bt) {
      g_object_set_data(G_OBJECT(ok_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_OK));
      g_signal_connect(ok_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  save_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_SAVE);
  if (save_bt) {
      g_object_set_data(G_OBJECT(save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_SAVE));
      g_signal_connect(save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  dont_save_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_DONT_SAVE);
  if (dont_save_bt) {
      g_object_set_data(G_OBJECT(dont_save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_DONT_SAVE));
      g_signal_connect(dont_save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }
  
  dont_save_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_QUIT_DONT_SAVE);
  if (dont_save_bt) {
      g_object_set_data(G_OBJECT(dont_save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_QUIT_DONT_SAVE));
      g_signal_connect(dont_save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }
  bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLEAR);
  if(bt) {
      g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CLEAR));
      g_signal_connect(bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  yes_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_YES);
  if(yes_bt) {
      g_object_set_data(G_OBJECT(yes_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_YES));
      g_signal_connect(yes_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_NO);
  if(bt) {
      g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_NO));
      g_signal_connect(bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
  if(bt) {
      g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CANCEL));
      window_set_cancel_button(win, bt, simple_dialog_cancel_cb);
  }

  if(!bt) {
      if(yes_bt) {
          window_set_cancel_button(win, yes_bt, simple_dialog_cancel_cb);
      } else {
          window_set_cancel_button(win, ok_bt, simple_dialog_cancel_cb);
      }
  }

  dlg_button_focus_nth(bbox, 0);

  gtk_widget_show(win);

  return win;
}
Пример #27
0
void
CReciteWord::create ()
{
	init ();

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);


	gtk_widget_set_events(window,GDK_SCROLL_MASK);
	gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
	gtk_widget_set_app_paintable(window,TRUE);
	gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
	gtk_widget_set_size_request (window, Skin->reciteword.width, Skin->reciteword.height);
	gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
	gtk_window_set_title (GTK_WINDOW (window), _("ReciteWord"));

	gtk_widget_realize(window);
	skin_load_reciteword (window);
	skin_load_face (window);

	gtk_window_set_icon (GTK_WINDOW(window),Skin->face.icon.p[0]);
	
	tooltips = gtk_tooltips_new ();
	
	fixed = gtk_fixed_new ();
	//gtk_fixed_set_has_window(GTK_FIXED(fixed),TRUE);
	gtk_container_add (GTK_CONTAINER (window), fixed);
	gtk_widget_show (fixed);
	SetBackPixmap (fixed, Skin->face.face.p[0]);

	help_button.create (fixed, Skin->face.help_button.x[0],
			    Skin->face.help_button.y[0], Skin->face.help_button.p[0],
			    Skin->face.help_button.p[1],
			    Skin->face.help_button.p[2], PopupHelp, NULL);
	record_button.create (fixed, Skin->face.record_button.x[0],
			      Skin->face.record_button.y[0],
			      Skin->face.record_button.p[0],
			      Skin->face.record_button.p[1],
			      Skin->face.record_button.p[2], PopupRecord, NULL);
	option_button.create (fixed, Skin->face.option_button.x[0],
			     Skin->face.option_button.y[0],
			     Skin->face.option_button.p[0],
			     Skin->face.option_button.p[1],
			     Skin->face.option_button.p[2], PopupOption, NULL);
	dict_button.create (fixed, Skin->face.dict_button.x[0],
			    Skin->face.dict_button.y[0], Skin->face.dict_button.p[0],
			    Skin->face.dict_button.p[1],
			    Skin->face.dict_button.p[2], PopupDict, NULL);
	about_button.create (fixed, Skin->face.about_button.x[0],
			     Skin->face.about_button.y[0],
			     Skin->face.about_button.p[0],
			     Skin->face.about_button.p[1],
			     Skin->face.about_button.p[2], PopupAbout, NULL);

	GtkWidget *event_box = gtk_event_box_new ();
	gtk_fixed_put (GTK_FIXED (fixed), event_box, Skin->face.menubar.x[0],
		       Skin->face.menubar.y[0]);
	GtkWidget *pixmap_widget = gtk_image_new_from_pixmap (Skin->face.menubar.p[0], NULL);
	gtk_container_add (GTK_CONTAINER (event_box), pixmap_widget);
	gtk_widget_show (pixmap_widget);
	gtk_widget_show (event_box);

	g_signal_connect (G_OBJECT (event_box), "enter_notify_event",
			  G_CALLBACK (on_menu_bar_enter_notify), this);
	g_signal_connect (G_OBJECT (window), "enter_notify_event",
			  G_CALLBACK (on_window_enter_notify), this);

	g_signal_connect (G_OBJECT (window), "button_press_event",
			  G_CALLBACK (on_mainwnd_button_press), this);
	g_signal_connect (G_OBJECT (window), "scroll_event",
			  G_CALLBACK (on_mainwnd_scroll), this);
	g_signal_connect (G_OBJECT (window), "delete_event",
			  G_CALLBACK (on_mainwnd_delete_event), this);
	gtk_widget_show (window);
	gdk_threads_enter();
	gtk_main ();
	gdk_threads_leave();
}
Пример #28
0
GtkWidget * 
gui_icon_button(const gchar *id, const gchar *text,
                  gpointer cb, gpointer arg,
                  GtkWidget *box)
{
gint stock = TRUE;
gpointer data;
GtkWidget *hbox, *button, *label, *image=NULL;
GdkBitmap *mask;
GdkPixmap *pixmap;
GtkStyle *style;

/* button */
button = gtk_button_new();
hbox = gtk_hbox_new(FALSE, 4);
gtk_container_add(GTK_CONTAINER(button), hbox);


/* CURRENT */
if (g_ascii_strncasecmp(id, "IMAGE_", 6) == 0)
  {
  data = image_table_lookup(id);
  if (data)
    {
    image = gtk_image_new_from_pixbuf(data);
    stock = FALSE;
    }
  else
    printf("[%s] : image not found.\n", id);
  }


/* GDIS icons */
if (g_ascii_strncasecmp(id, "GDIS_PAUSE", 10) == 0)
  {
  style = gtk_widget_get_style(window);

  pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->white,
                                        pause_xpm);
  image = gtk_image_new_from_pixmap(pixmap, mask);

  stock = FALSE;
  }
if (g_ascii_strncasecmp(id, "GDIS_PLAY", 9) == 0)
  {
  style = gtk_widget_get_style(window);

  pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->white,
                                        play_xpm);
  image = gtk_image_new_from_pixmap(pixmap, mask);

  stock = FALSE;
  }
if (g_ascii_strncasecmp(id, "GDIS_REWIND", 11) == 0)
  {
  style = gtk_widget_get_style(window);

  pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->white,
                                        rewind_xpm);
  image = gtk_image_new_from_pixmap(pixmap, mask);

  stock = FALSE;
  }
if (g_ascii_strncasecmp(id, "GDIS_FASTFORWARD", 16) == 0)
  {
  style = gtk_widget_get_style(window);

  pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->white,
                                        fastforward_xpm);
  image = gtk_image_new_from_pixmap(pixmap, mask);

  stock = FALSE;
  }
if (g_ascii_strncasecmp(id, "GDIS_STOP", 9) == 0)
  {
  style = gtk_widget_get_style(window);

  pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->white,
                                        stop_xpm);
  image = gtk_image_new_from_pixmap(pixmap, mask);

  stock = FALSE;
  }
if (g_ascii_strncasecmp(id, "GDIS_STEP_FORWARD", 17) == 0)
  {
  style = gtk_widget_get_style(window);

  pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->white,
                                        step_forward_xpm);
  image = gtk_image_new_from_pixmap(pixmap, mask);

  stock = FALSE;
  }
if (g_ascii_strncasecmp(id, "GDIS_STEP_BACKWARD", 18) == 0)
  {
  style = gtk_widget_get_style(window);

  pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->white,
                                        step_backward_xpm);
  image = gtk_image_new_from_pixmap(pixmap, mask);

  stock = FALSE;
  }

/* standard GTK */
if (stock)
  image = gtk_image_new_from_stock(id, GTK_ICON_SIZE_BUTTON);

/* label dependent packing  */
if (text)
  {
  gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
  label = gtk_label_new(text);
  gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
  }
else
  {
  gtk_box_pack_start(GTK_BOX(hbox), image, TRUE, FALSE, 0);
  }

/* packing & callback */
if (box)
  gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);

if (cb)
  g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cb), arg);

return(button);
}
Пример #29
0
void CreateOneToolbar( GtkWidget * Box, int NumTable, short int PtrOnToolBarElementsList[][NBR_ELE_TOOLBAR_X_MAX], char * PtrOnToolTipsText[][NBR_ELE_TOOLBAR_X_MAX] )
{
	int CurrentAvail = 0;
	while( ToolbarBtnRadio[ CurrentAvail ]!=NULL && CurrentAvail<NBR_ELE_IN_TOOLBAR )
		CurrentAvail++;
	if ( CurrentAvail<NBR_ELE_IN_TOOLBAR )
	{
		StrElement ToolBarEle;
		int ScanToolBarX,ScanToolBarY;
		GSList * PtrListRadiosBtn = NULL;
		ScanToolBarX = 0;
		ScanToolBarY = 0;
		ToolbarTable[ NumTable ] = gtk_table_new( NBR_ELE_TOOLBAR_X_MAX, NBR_ELE_TOOLBAR_Y_MAX, FALSE/*homogeneous*/ );
		gtk_box_pack_start (GTK_BOX(Box), ToolbarTable[ NumTable ], TRUE, TRUE, 0);
		do
		{
			ToolBarEle.Type = PtrOnToolBarElementsList[ScanToolBarY][ScanToolBarX];
			ToolBarEle.ConnectedWithTop = 0;
			if ( ToolBarEle.Type==EDIT_POINTER )
			{
				if ( PtrOnToolBarElementsList!=ToolBarElementsSequential )
					NumWidgetEditPointer[ NUM_TOOLBAR_FOR_RUNGS ] = CurrentAvail;
				else
					NumWidgetEditPointer[ NUM_TOOLBAR_FOR_SEQ ] = CurrentAvail;
			}

			if ( ToolBarEle.Type!=0 )
			{
				GdkGC * gc = drawing_area->style->bg_gc[0];
				char * pHelpText = PtrOnToolTipsText[ ScanToolBarY ][ ScanToolBarX ];
				ToolbarPixmap[ CurrentAvail ] = gdk_pixmap_new( GDK_DRAWABLE(drawing_area->window), PIXELS_SIZE_IN_TOOLBAR, PIXELS_SIZE_IN_TOOLBAR, -1 );
				gdk_draw_rectangle (GDK_DRAWABLE(ToolbarPixmap[ CurrentAvail ]), gc, TRUE, 0, 0, PIXELS_SIZE_IN_TOOLBAR, PIXELS_SIZE_IN_TOOLBAR);
	
	#ifdef SEQUENTIAL_SUPPORT
				if ( PtrOnToolBarElementsList==ToolBarElementsSequential )
					DrawSeqElementForToolBar(ToolbarPixmap[ CurrentAvail ], 0, 0, PIXELS_SIZE_IN_TOOLBAR, ToolBarEle.Type );
				else
	#endif
					DrawElement(ToolbarPixmap[ CurrentAvail ], 0, 0, PIXELS_SIZE_IN_TOOLBAR, PIXELS_SIZE_IN_TOOLBAR, ToolBarEle, TRUE);
	
				ToolbarImage[ CurrentAvail ] = gtk_image_new_from_pixmap( ToolbarPixmap[ CurrentAvail ], NULL );
				ToolbarBtnRadio[ CurrentAvail ] = gtk_radio_button_new( PtrListRadiosBtn );
				PtrListRadiosBtn = gtk_radio_button_get_group (GTK_RADIO_BUTTON(ToolbarBtnRadio[ CurrentAvail ]));
				gtk_button_set_relief (GTK_BUTTON( ToolbarBtnRadio[ CurrentAvail ] ), GTK_RELIEF_NONE);
				gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON(ToolbarBtnRadio[ CurrentAvail ]), FALSE);
				gtk_container_add( GTK_CONTAINER( ToolbarBtnRadio[ CurrentAvail ] ), ToolbarImage[ CurrentAvail ] );
				gtk_widget_show( ToolbarImage[ CurrentAvail ] );
				gtk_table_attach( GTK_TABLE( ToolbarTable[ NumTable ] ), ToolbarBtnRadio[ CurrentAvail ], 
									ScanToolBarX, ScanToolBarX+1, ScanToolBarY, ScanToolBarY+1,
									0, 0, 0, 0 );

				gtk_signal_connect( GTK_OBJECT (ToolbarBtnRadio[ CurrentAvail ]), "clicked", (GtkSignalFunc) ButtonToolbarSignal, GINT_TO_POINTER((int)ToolBarEle.Type) );

				if (pHelpText!=NULL )
					gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], pHelpText, NULL);

				gtk_widget_show( ToolbarBtnRadio[ CurrentAvail ] );
				CurrentAvail++;
			}//if ( ToolBarEle.Type!=0 )

			ScanToolBarX++;
			if (ScanToolBarX>=NBR_ELE_TOOLBAR_X_MAX)
			{
				ScanToolBarX = 0;
				ScanToolBarY++;
			}
		}
		while( PtrOnToolBarElementsList[ScanToolBarY][ScanToolBarX]!=-1 );
	}
}
Пример #30
0
Installer::Installer(
	std::string app_name,
	std::string confirm_title,
	std::string message) :
		app_name(app_name),
		confirm_title(confirm_title),
		message(message),
		current_job(NULL),
		cancel(false),
		error("")
{

	this->download_finished = false;
	this->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(this->window), 10);
	gtk_window_set_default_size(GTK_WINDOW(this->window), WINDOW_WIDTH, WINDOW_HEIGHT);
	gtk_window_resize(GTK_WINDOW(this->window), WINDOW_WIDTH, WINDOW_HEIGHT);
	gtk_window_set_gravity(GTK_WINDOW(this->window), GDK_GRAVITY_CENTER);

	std::string title = this->app_name + " - Installer";
	gtk_window_set_title(GTK_WINDOW(this->window), title.c_str());

	g_signal_connect (
		G_OBJECT(this->window),
		"destroy",
		G_CALLBACK(destroy_cb),
		(gpointer) this);

	gtk_window_move(
		GTK_WINDOW(this->window),
		gdk_screen_width()/2 - WINDOW_WIDTH/2,
		gdk_screen_height()/2 - WINDOW_HEIGHT/2);

	GdkColormap* colormap = gtk_widget_get_colormap(this->window);
	GdkBitmap *mask = NULL;
	GdkPixmap* icon = gdk_pixmap_colormap_create_from_xpm_d(
		NULL,
		colormap,
		&mask,
		NULL,
		(gchar**) titanium_xpm);
	GtkWidget* image = gtk_image_new_from_pixmap(icon, mask);
	this->label = gtk_label_new("Downloading packages..");

	GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 5);
	gtk_box_pack_start(GTK_BOX(hbox), this->label, FALSE, FALSE, 0);

	this->bar = gtk_progress_bar_new();

	GtkWidget* hbox2 = gtk_hbox_new(FALSE, 0);
	GtkWidget* cancel_but = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
	gtk_box_pack_start(GTK_BOX(hbox2), cancel_but, TRUE, FALSE, 0);

	g_signal_connect (
		G_OBJECT(cancel_but),
		"clicked",
		G_CALLBACK(cancel_cb),
		(gpointer) this);

	GtkWidget* vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), this->bar, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 10);

	gtk_container_add(GTK_CONTAINER(this->window), vbox);

}