Ejemplo n.º 1
0
static void
draw_panel_label(GkrellmPanel *p, gboolean to_bg)
	{
	GkrellmLabel		*lbl	= p->label;
	GkrellmTextstyle	*ts		= p->textstyle;
	GkrellmMargin		*m;
	gchar				*s;
	gint				xdst;

	if (   lbl && ts
		&& ((s = lbl->string) != NULL)
		&& lbl->position >= 0
	   )
		{
		m = gkrellm_get_style_margins(p->style);
		lbl->width = gkrellm_gdk_string_width(ts->font, s) + ts->effect;
		xdst = gkrellm_label_x_position(lbl->position, p->w,
					lbl->width, m->left);
		lbl->x_panel = xdst;
		gkrellm_draw_string(p->pixmap, ts, xdst, lbl->y_panel, s);
		if (to_bg)
			gkrellm_draw_string(p->bg_pixmap, ts, xdst, lbl->y_panel, s);
		}
	}
Ejemplo n.º 2
0
static void
create_plugin(GtkWidget *vbox, gint first_create) {
  GkrellmStyle     *style;
  GkrellmTextstyle *ts, *ts_alt;
  GkrellmMargin    *margin;
  GdkPixmap       *pixmap;
  GdkBitmap       *mask;
  gint            y;
  gint            x;
  gchar *text_utf8 = NULL, *text_locale = NULL;

  if (first_create) {
    panel = gkrellm_panel_new0();
    gkrellm_disable_plugin_connect(plugin_monitor,close_radio);
    /* create the frequency menu */
    create_freq_menu();
  } else
    gkrellm_destroy_decal_list(panel);

  style = gkrellm_meter_style(style_id);

  /* Each GkrellmStyle has two text styles.  The theme designer has picked the
     |  colors and font sizes, presumably based on knowledge of what you draw
     |  on your panel.  You just do the drawing.  You probably could assume
     |  the ts font is larger than the ts_alt font, but again you can be
     |  overridden by the theme designer.
  */
  ts = gkrellm_meter_textstyle(style_id);
  ts_alt = gkrellm_meter_alt_textstyle(style_id);
  panel->textstyle = ts;      /* would be used for a panel label */

  y = 2;			/* some border */
  station_text = gkrellm_create_decal_text(panel, _("Hello World"), ts_alt, style, 2, y, 40);

  /* Create a pixmap decal and place it to the right of station_text.  Use
     |  decals from the builtin decal_misc.xpm.
  */
  pixmap = gkrellm_decal_misc_pixmap();
  mask = gkrellm_decal_misc_mask();

  x = station_text->x + station_text->w + 4;
  decal_onoff_pix = gkrellm_create_decal_pixmap(panel, pixmap, mask,
						N_MISC_DECALS, NULL, x, y);

  /* Configure the panel to hold the above created decals, add in a little
     |  bottom margin for looks, and create the panel.
  */
  gkrellm_panel_configure(panel, NULL, style);
  gkrellm_panel_create(vbox, plugin_monitor,panel);

  /* After the panel is created, the decals can be converted into buttons.
     |  First draw the initial text into the text decal button and then
     |  put the text decal into a meter button.  But for the decal_onoff_pix,
     |  we can directly convert it into a decal button since it is a pixmap
     |  decal.  Just pass the frame we want to be the out image and the
     |  frame for the in or pressed image.
  */
  gkrellm_locale_dup_string(&text_utf8, station_name(radio_getfreq()), &text_locale);
  gkrellm_draw_decal_text(panel, station_text, text_locale,
			  button_state);

  margin = gkrellm_get_style_margins(style);
  gkrellm_put_decal_in_meter_button(panel, station_text, cb_button,
				    GINT_TO_POINTER(1),margin);
  onoff_button = 
    gkrellm_make_decal_button(panel, decal_onoff_pix, cb_button,
			      GINT_TO_POINTER(2),
			      onoff_state ? D_MISC_BUTTON_ON : D_MISC_BUTTON_OUT,
			      D_MISC_BUTTON_IN);

  /* Note: all of the above gkrellm_draw_decal_XXX() calls will not
     |  appear on the panel until a  gkrellm_draw_layers(panel); call is
     |  made.  This will be done in update_plugin(), otherwise we would
     |  make the call here and anytime the decals are changed.
  */

  if (first_create) {
    g_signal_connect(GTK_OBJECT (panel->drawing_area), "expose_event",
		       (GtkSignalFunc) panel_expose_event, NULL);
    g_signal_connect(GTK_OBJECT (panel->drawing_area), "button_release_event",
		       GTK_SIGNAL_FUNC(button_release_event), NULL);
    g_signal_connect(GTK_OBJECT (panel->drawing_area), "scroll_event",
		       GTK_SIGNAL_FUNC(scroll_event), NULL);
    reopen_radio();
  }
  
  gkrellm_draw_panel_layers(panel);
}