Пример #1
0
static void update_plugin() {
  if(!pGK->second_tick) {
    return;
  }

  if (gov_enable_current) {
    read_governors();
  }
  read_khz();

  unsigned int cpu;
  if (slider_enable_current) {
    for( cpu=0; cpu<ncpu; ++cpu ) {
      if (!slider_in_motion[cpu]) {
        int krellpos = slider_krell[cpu]->w_scale*khz[cpu]/khz_max;
        gkrellm_update_krell(panel, slider_krell[cpu], krellpos);
      }
    }
  }
  
  char theText[length];
  for ( cpu=0; cpu<ncpu; ++cpu ) {
    sprintf(theText, "%d MHz", (int)((khz[cpu]+500)/1000));
    text_decal_freq[cpu]->x_off = 0;
    gkrellm_draw_decal_text(panel, text_decal_freq[cpu], theText, -1);
    text_decal_gov[cpu]->x_off = 0;
    gkrellm_draw_decal_text(panel, text_decal_gov[cpu], governor_text[cpu], -1);
  }  

  gkrellm_draw_panel_layers(panel);
}
Пример #2
0
static void
update_plugin()
	{
	gint		w_scroll, w_decal;
	static gint	x_scroll;

    if (command_pipe)
    {
    	command_done();

    }
	 if(GK.timer_ticks % 6 == 0)
    {
        run_command();
    }

#if defined(GKRELLM_HAVE_DECAL_SCROLL_TEXT)
	gkrellm_decal_scroll_text_set_text(panel, text1_btc, btc_text);
	gkrellm_decal_scroll_text_get_size(text1_btc, &w_scroll, NULL);
	gkrellm_decal_get_size(text1_btc, &w_decal, NULL);
	x_scroll -= 1;
	if (x_scroll <= -w_scroll)
		x_scroll = scroll_loop_mode ? 0 : w_decal;
	gkrellm_decal_text_set_offset(text1_btc, x_scroll, 0);
#else
	w_decal = text1_btc->w;
	w_scroll = gdk_string_width(text1_btc->text_style.font, scroll_text);
	x_scroll -= 1;
	if (x_scroll <= -w_scroll)
		x_scroll = w_decal;
	text1_btc->x_off = x_scroll;
	gkrellm_draw_decal_text(panel, text1_btc, scroll_text, x_scroll);
#endif
	gkrellm_draw_panel_layers(panel);
	}
Пример #3
0
static void
update_plugin()
	{
	gint		w_scroll, w_decal;
	static gint	x_scroll;

#if defined(GKRELLM_HAVE_DECAL_SCROLL_TEXT)
	/* Gkrellm version 2.2.0 adds a scrolling text mode to a text decal so
	|  that inherently slow Pango text draws can be avoided at each scroll
	|  step as long as the sroll text string is unchanged.
	*/
	gkrellm_decal_scroll_text_set_text(panel, text1_decal, scroll_text);
	gkrellm_decal_scroll_text_get_size(text1_decal, &w_scroll, NULL);
	gkrellm_decal_get_size(text1_decal, &w_decal, NULL);
	x_scroll -= 1;
	if (x_scroll <= -w_scroll)
		x_scroll = scroll_loop_mode ? 0 : w_decal;
	gkrellm_decal_text_set_offset(text1_decal, x_scroll, 0);
#else
	w_decal = text1_decal->w;
	w_scroll = gdk_string_width(text1_decal->text_style.font, scroll_text);
	x_scroll -= 1;
	if (x_scroll <= -w_scroll)
		x_scroll = w_decal;
	text1_decal->x_off = x_scroll;
	gkrellm_draw_decal_text(panel, text1_decal, scroll_text, x_scroll);
#endif

	gkrellm_draw_panel_layers(panel);
	}
Пример #4
0
void 
do_switch_station(int nr) {
  gchar *text_utf8 = NULL, *text_locale = NULL;
  nr %= nstations;
  currentstation = nr;
  start_mute_timer();
  radio_setfreq(stations[nr].freq);
  gkrellm_locale_dup_string(&text_utf8, stations[nr].station_name, &text_locale);
  gkrellm_draw_decal_text(panel, station_text, 
      text_locale, -1);
  gkrellm_draw_panel_layers(panel);
  gkrellm_config_modified();
}
Пример #5
0
static void
cb_button(GkrellmDecalbutton *button, gpointer data)
	{
	if (GPOINTER_TO_INT(data) == 0)
		{
		printf("Large scaled button pressed.\n");
#if defined(GKRELLM_HAVE_DECAL_SCROLL_TEXT)
		/* Demonstrate the scroll looping mode.
		*/
		printf("Toggling horizontal loop mode.\n");
		scroll_loop_mode = !scroll_loop_mode;
		scroll_text = scroll_loop_mode
					? "Some scrolling text -- "
					: "Some scrolling text";

		gkrellm_decal_scroll_text_horizontal_loop(text1_decal,
					scroll_loop_mode);
#endif
		}
	else if (GPOINTER_TO_INT(data) == 1)
		printf("Small auto-hiding scaled button pressed\n");
	else if (GPOINTER_TO_INT(data) == 2)
		{
		printf("button for text2_decal pressed\n");
		button_state = !button_state;

		/* Draw new text on the button.  For gkrellm versions < 2.2.0, decal
		|  drawing occurs only if the decal "value" (the last argument)
		|  changes.  The "value" is ignored in gkrellm versions >= 2.2.0
		|  and text is internally checked for changes before being redrawn.
		|  To be compatible with all versions, just pass the index of the
		|  text string we draw because it will change each time a different
		|  string is drawn.
		*/
		gkrellm_draw_decal_text(panel, text2_decal,
					button_text[button_state], button_state);

		/* Decal draws don't show up until gkrellm_draw_panel_layers() is
		|  called.  This is done in update_plugin(), so doing it here is only
		|  useful if the update_plugin() updates infrequently and we don't
		|  want a delay before the change is seen.  So for this demo, it does
		|  not need to be done here, but I do it anyway for emphasis.
		*/
		gkrellm_draw_panel_layers(panel);
		}
	else if (GPOINTER_TO_INT(data) == 3)
		printf("button for pixmap_decal pressed\n");
	}
Пример #6
0
static void
update_slider(void)
{
	int bright;
   
	if ( GK.ten_second_tick || (last_lcd<0) ) {
		bright = read_vaio_lcd();

		gkrellm_update_krell( panel, krell, bright );
	
		gkrellm_draw_decal_text( panel, text, "LCD", -1 );

		gkrellm_draw_layers( panel );
		last_lcd = bright;
	}
}
Пример #7
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);
}
Пример #8
0
static void set_text_freq(float freq) {
  gchar *text_utf8 = NULL, *text_locale = NULL;
  gkrellm_locale_dup_string(&text_utf8, station_name(freq), &text_locale);
  gkrellm_draw_decal_text(panel, station_text, text_locale, -1);
  gkrellm_draw_panel_layers(panel);
}
Пример #9
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);
	}