Example #1
0
/*
 * taken from gkrellmms-2.1.22/gkrellmms.c#create_gkrellmms
 */
void audkrellm_create_led( GkrellmMargin *m ) {
  GkrellmPiximage  *led_image = NULL;

  if( gkrellm_load_piximage( "led_indicator", NULL,
                             &led_image, GKRELLMMS_STYLE ) ) {
    audkrellm_led_decal
      = gkrellm_make_scaled_decal_pixmap( audkrellm_control_panel,
                                          led_image, audkrellm_style,
                                          4, 0, -1, 0, 0);
    led_off_index     = 0;
    led_running_index = 1;
    led_paused_index  = 2;
    led_playing_index = 3;
  } else {
    audkrellm_led_decal
      = gkrellm_create_decal_pixmap( audkrellm_control_panel,
                                     gkrellm_decal_misc_pixmap(),
                                     gkrellm_decal_misc_mask(),
                                     N_MISC_DECALS, audkrellm_style, 0, -1 );
    led_off_index     = D_MISC_LED0;
    led_running_index = D_MISC_LED1;
    led_paused_index  = D_MISC_LED1;
    led_playing_index = D_MISC_LED1;
  }
  audkrellm_led_decal->x = gkrellm_chart_width()
                         - audkrellm_led_decal->w
                         - m->right;

  gkrellm_draw_decal_pixmap( audkrellm_control_panel, audkrellm_led_decal,
                             led_off_index );
}
Example #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);
}
Example #3
0
static void
create_plugin(GtkWidget *vbox, gint first_create)
	{
	GkrellmDecalbutton	*button;
	GkrellmStyle	*style;
	GkrellmTextstyle *ts, *ts_alt;
	GdkPixmap		*pixmap;
	GdkBitmap		*mask;
	gint			y;
	gint			x;

	/* See comments about first create in demo2.c
	*/
	if (first_create)
		panel = gkrellm_panel_new0();

	style = gkrellm_meter_style(style_id);

	/* Each Style 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 can assume that the
	|  ts font is larger than the ts_alt font.
	*/
	ts = gkrellm_meter_textstyle(style_id);
	ts_alt = gkrellm_meter_alt_textstyle(style_id);


	/* ==== Create a text decal that will be used to scroll text. ====
	|  Make it the full panel width (minus the margins).  Position it at top
	|  border and left margin of the style.  The "Ay" string is a vertical
	|  sizing string for the decal and not an initialization string.
	*/
	text1_decal = gkrellm_create_decal_text(panel, "Ay", ts, style,
				-1,     /* x = -1 places at left margin */
				-1,     /* y = -1 places at top margin	*/
				-1);    /* w = -1 makes decal the panel width minus margins */
	y = text1_decal->y + text1_decal->h + 2;


	/* ==== Create a scaled button ====
	|  This is the easiest and most versatile way to create a button and is
	|  a new function for GKrellM 2.0.0.  Here we use the builtin default
	|  button image which is a simple 2 frame in/out image.  If you supply
	|  your own image, there can be as many frames as you wish which can be
	|  used for state indicating purposes.  Make two buttons, one large and one
	|  small to demonstrate scaling capability.  Make the small one auto-hide.
	|  See demo4 for a more complicated scaled button which has an irregular
	|  shape and a custom in_button callback to detect when the mouse is on
	|  a non-transparent part of the button.
	*/
	button = gkrellm_make_scaled_button(panel,
				NULL,               /* GkrellmPiximage image to use to   */
				                    /*   create the button images. Use a */
				                    /*   builtin default if NULL         */
				cb_button,          /* Button clicked callback function  */
				GINT_TO_POINTER(0), /* Arg to callback function          */
				FALSE,              /* auto_hide: if TRUE, button is visible */
				                    /*   only when mouse is in the panel */
				FALSE,              /* set_default_border: if TRUE, apply a */
				                    /*   default border of 1,1,1,1.  If false*/
				                    /*   use the GkrellmPiximage border which*/
				                    /*   in this case is 0,0,0,0         */
				0,                  /* Image depth if image != NULL      */
				0,                  /* Initial out frame if image != NULL */
				0,                  /* Pressed frame if image != NULL    */
				2,                  /* x position of button  */
				y,                  /* y position of button  */
				13,                 /* Width for scaling the button  */
				15);                /* Height for scaling the button */

	x = button->decal->x + button->decal->w + 2;
	button = gkrellm_make_scaled_button(panel, NULL, cb_button,
				GINT_TO_POINTER(1), TRUE, FALSE, 0, 0, 0,
				x, y, 6, 8);


	/* ==== Create a text decal and convert it into a decal button. ====
	|  Text decals are converted into buttons by being put into a meter or
	|  panel button.  This "put" overlays the text decal with special button
	|  in and out images that have a transparent interior and a non-transparent
	|  border. The "Hello" string is not an initialization string, it is just
	|  a vertical sizing string.  After the decal is created, draw the
	|  initial text onto the decal.
	*/
	x = button->decal->x + button->decal->w + 2;
	text2_decal = gkrellm_create_decal_text(panel, "Hello", ts_alt, style,
				x,
				y,      /* Place below the scrolling text1_decal     */
				0);     /* w = 0 makes decal the sizing string width */

	gkrellm_put_decal_in_meter_button(panel, text2_decal,
				cb_button,          /* Button clicked callback function */
				GINT_TO_POINTER(2), /* Arg to callback function      */
				NULL);              /* Optional margin struct to pad the size */

	gkrellm_draw_decal_text(panel, text2_decal, button_text[button_state],
				button_state);


	/* ==== Create a pixmap decal and convert it into a decal button ====
	|  Pixmap decals are directly converted into buttons (no put operation)
	|  because pixmap decals have frames which will provide the in and out
	|  button images.  A plugin custom image may be loaded and rendered to
	|  a pixmap to be used for the button, but here I'm using the pre-loaded
	|  pixmap from the builtin decal_misc.xpm image.  First make a decal out
	|  of the pixmap.  Then pass the decal frames we want to be the in/out
	|  images when we make the decal button.
	*/
	pixmap = gkrellm_decal_misc_pixmap();
	mask = gkrellm_decal_misc_mask();
	x = text2_decal->x + text2_decal->w + 2;

	pixmap_decal = gkrellm_create_decal_pixmap(panel, pixmap, mask,
				N_MISC_DECALS, NULL, x, y);

	gkrellm_make_decal_button(panel, pixmap_decal,
				cb_button,          /* Button clicked callback function */
				GINT_TO_POINTER(3), /* Arg to callback function */
				D_MISC_BUTTON_OUT,  /* Button out (not pressed) frame */
				D_MISC_BUTTON_IN);  /* Button pressed frame */


	/* Configure the panel to hold the above created decals, and create it.
	*/
	gkrellm_panel_configure(panel, NULL, style);
	gkrellm_panel_create(vbox, monitor, panel);

	/* Note: the above gkrellm_draw_decal_text() call will not
	|  appear on the panel until a gkrellm_draw_panel_layers() call is
	|  made.  This will be done in update_plugin(), otherwise we would
	|  make the call here after the panel is created and anytime the
	|  decals are changed.
	*/

	if (first_create)
	    g_signal_connect(G_OBJECT (panel->drawing_area), "expose_event",
    	        G_CALLBACK(panel_expose_event), NULL);
	}