Exemple #1
0
static void
create_plugin(GtkWidget *vbox, gint first_create)
	{
	GkrellmStyle	*style;
	GkrellmTextstyle *ts, *ts_alt;
	GdkPixmap		*pixmap;
	GdkBitmap		*mask;
	gint			y;
	gint			x;


	if (first_create)
		panel = gkrellm_panel_new0();

	style = gkrellm_meter_style(style_id);
	ts = gkrellm_meter_textstyle(style_id);
	ts_alt = gkrellm_meter_alt_textstyle(style_id);
	text1_btc = 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 */
	text_ltc_decal = gkrellm_create_decal_text(panel, "Ay", ts, style,
				-1,     /* x = -1 places at left margin */
				text1_btc->y + text1_btc->h + 2,     /* y = -1 places at top margin	*/
				-1);    /* w = -1 makes decal the panel width minus margins */
	text_ftc_decal = gkrellm_create_decal_text(panel, "Ay", ts, style,
				-1,     /* x = -1 places at left margin */
				text_ltc_decal->y + text_ltc_decal->h + 2,     /* y = -1 places at top margin	*/
				-1);    /* w = -1 makes decal the panel width minus margins */

	gkrellm_panel_configure(panel, NULL, style);
	gkrellm_panel_create(vbox, monitor, panel);


	}
static void
create_panel(GtkWidget *vbox, Reader *reader, gint first_create)
{
      //    GkrellmKrell           *k;
    GkrellmStyle           *style;
    //    GkrellmPiximage   *krell_piximage;
    gchar *text;

    if (first_create)
        reader->panel = gkrellm_panel_new0();
    else
        gkrellm_destroy_krell_list(reader->panel);

    /* Create a krell.  A Krell structure is allocated and linked into
    |  the list of krells pointed to by panel->krell.
    */
    style = gkrellm_meter_style(DEFAULT_STYLE_ID);
    //GTK2 style->label_position = LABEL_CENTER;
    //    krell_piximage = gkrellm_krell_meter_piximage(DEFAULT_STYLE_ID);
    //    k = gkrellm_create_krell(panel, krell_piximage, style);
    //    k->full_scale = 30;

    /* Configure panel calculates the panel height needed for the "Plugin" label.
    |  and the krell.
    */
    reader->panel->textstyle = gkrellm_meter_textstyle(DEFAULT_STYLE_ID);
    gkrellm_panel_configure(reader->panel, "SNMP", style);

    //    reader->panel->textstyle = gkrellm_panel_alt_textstyle(DEFAULT_STYLE_ID);


    /* Build the configured panel with a background image and pack it into
    |  the vbox assigned to this monitor.
    */
//dep:    gkrellm_create_panel(vbox, reader->panel, gkrellm_bg_meter_piximage(DEFAULT_STYLE_ID));
    gkrellm_panel_create(vbox, mon, reader->panel);
    gkrellm_monitor_height_adjust(reader->panel->h);

    if (first_create) {
        gtk_signal_connect(GTK_OBJECT (reader->panel->drawing_area),
			   "expose_event",
			   (GtkSignalFunc) panel_expose_event, NULL);
	reader->tooltip=gtk_tooltips_new();
    }

    /* refresh the display */
    text = render_label(reader);
    gkrellm_dup_string(&reader->panel->label->string, text);
    g_free(text);
}
Exemple #3
0
static void
create_plugin( GtkWidget *vbox, gint first_create )
{
	GdkImlibImage   *krell_image;
	TextStyle		*ts, *ts_alt;
	Style 			*panel_style,
   					*slider_style;

	if ( first_create )
		panel = gkrellm_panel_new0();

	panel_style = gkrellm_meter_style( style_id );
	
	slider_style = gkrellm_krell_slider_style();
	krell_image = gkrellm_krell_slider_image();
	krell = gkrellm_create_krell( panel, krell_image, slider_style );

	gkrellm_monotonic_krell_values( krell, FALSE );
	gkrellm_set_krell_full_scale( krell, MAX_LCD, 1 );

	gkrellm_panel_configure( panel, NULL, panel_style );
	gkrellm_panel_create( vbox, monitor, panel );
	
	ts     = gkrellm_meter_textstyle( style_id );
	ts_alt = gkrellm_meter_alt_textstyle( style_id );

	text = gkrellm_create_decal_text( panel, "LCD",
			ts_alt, panel_style, 3, -1, -1 );
	
	if ( first_create ){
		gtk_signal_connect( GTK_OBJECT(panel->drawing_area),
				"expose_event", (GtkSignalFunc)plug_expose_event,
			   	NULL );
		gtk_signal_connect( GTK_OBJECT(panel->drawing_area),
				"button_press_event", (GtkSignalFunc)panel_button_press,
			   	NULL );
		gtk_signal_connect( GTK_OBJECT(panel->drawing_area),
				"button_release_event", (GtkSignalFunc)panel_button_release,
			   	NULL );
		gtk_signal_connect( GTK_OBJECT(panel->drawing_area),
				"motion_notify_event", (GtkSignalFunc)slider_motion,
			   	NULL );
	}
}
Exemple #4
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);
}
static void
create_proc_monitor(GtkWidget *vbox, gint first_create)
	{
	GkrellmChart		*cp;
	GkrellmChartdata	*cd;
	GkrellmChartconfig	*cf;
	GkrellmPanel		*p;
	GkrellmStyle		*style;

	if (first_create)
		{
		proc.chart = gkrellm_chart_new0();
		proc.chart->panel = gkrellm_panel_new0();
		}
	cp = proc.chart;
	p = cp->panel;

	style = gkrellm_panel_style(style_id);
	gkrellm_create_krell(p, gkrellm_krell_panel_piximage(style_id), style);

	gkrellm_chart_create(proc.vbox, mon_proc, cp, &proc.chart_config);
	gkrellm_set_draw_chart_function(cp, refresh_proc_chart, proc.chart);
	cd = gkrellm_add_default_chartdata(cp, _("Load"));
	gkrellm_monotonic_chartdata(cd, FALSE);
	gkrellm_set_chartdata_draw_style_default(cd, CHARTDATA_LINE);
	proc.forks_cd = gkrellm_add_default_chartdata(cp, _("Forks"));
	gkrellm_set_chartdata_flags(proc.forks_cd, CHARTDATA_ALLOW_HIDE);

	cf = cp->config;
	gkrellm_chartconfig_fixed_grids_connect(cf, setup_proc_scaling, NULL);
	gkrellm_chartconfig_grid_resolution_connect(cf, setup_proc_scaling, NULL);
	gkrellm_chartconfig_grid_resolution_adjustment(cf, FALSE,
			LOAD_SCALING, 0.5, 5.0, 0.5, 0.5, 1, 50);
	gkrellm_chartconfig_grid_resolution_label(cf,
					_("Average process load per minute"));

	gkrellm_alloc_chartdata(cp);
	setup_proc_scaling();

	/* I put motherboard temp on Proc panel (if temperature sensors found)
	*/
	gkrellm_sensors_create_decals(p, style_id,
					&proc.sensor_decal, &proc.fan_decal);

	gkrellm_panel_configure(p, proc.panel_label, style);

	gkrellm_panel_create(proc.vbox, mon_proc, p);

	proc.save_label_position = p->label->position;
	if (proc.sensor_decal)
		adjust_sensors_display(TRUE);

	new_text_format = TRUE;
	if (first_create)
		{
		g_signal_connect(G_OBJECT(cp->drawing_area), "expose_event",
				G_CALLBACK(proc_expose_event), NULL);
		g_signal_connect(G_OBJECT(p->drawing_area), "expose_event",
				G_CALLBACK(proc_expose_event), NULL);
		g_signal_connect(G_OBJECT(cp->drawing_area),"button_press_event",
				G_CALLBACK(cb_proc_extra), NULL);
		g_signal_connect(G_OBJECT(p->drawing_area), "button_press_event",
				G_CALLBACK(cb_panel_press), NULL);
		}
	else
		refresh_proc_chart(cp);
	gkrellm_setup_launcher(p, &proc_launch, CHART_PANEL_TYPE, 4);
	}
Exemple #6
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);
	}
static void create_plugin(GtkWidget* vbox, gint first_create) {
  GkrellmStyle* style;
  GkrellmPiximage* krell_image;
  GkrellmTextstyle* ts;
  gint y = -1;
  unsigned int cpu;

  /* called when GKrellM is re-built at every theme or horizontal
     size change
  */
  if (first_create)
  	panel = gkrellm_panel_new0();

  read_khz();

  for ( cpu=0; cpu<ncpu; ++cpu ) {

    style = gkrellm_meter_style(style_id);
    /* text style */
    ts = gkrellm_meter_textstyle(style_id);

    /* the governor text */
    text_decal_gov[cpu] =
      gkrellm_create_decal_text(panel, "abcdefghijklmnopqrstuvwxyz", ts, style,
        -1,     /* x = -1 places at left margin */
         y,     /* y = -1 places at top margin */
        -1);    /* w = -1 makes decal the panel width minus margins */
    if (gov_enable) {
      governor_text[cpu] = governor[cpu];
      y = text_decal_gov[cpu]->y + text_decal_gov[cpu]->h + 1;
    } else {
      governor_text[cpu] = empty;
    }

    /* the frequency text */
    text_decal_freq[cpu] =
      gkrellm_create_decal_text(panel, "0123456789 MHz", ts, style,
        -1,     /* x = -1 places at left margin */
         y,     /* y = -1 places at top margin */
        -1);    /* w = -1 makes decal the panel width minus margins */

    y = text_decal_freq[cpu]->y + text_decal_freq[cpu]->h + 1;

    /* the slider */
    if (slider_enable) {
      krell_image = gkrellm_krell_slider_piximage();
      gkrellm_set_style_slider_values_default(style,
	y,     /* y offset */
	0, 0); /* Left and right krell margins */
      slider_krell[cpu] = gkrellm_create_krell(panel, krell_image, style);
      y = slider_krell[cpu]->y0 + slider_krell[cpu]->h_frame + 2;

      gkrellm_monotonic_krell_values(slider_krell[cpu], FALSE);
      gkrellm_set_krell_full_scale(slider_krell[cpu],
                                   slider_krell[cpu]->w_scale, 1);
      gkrellm_update_krell(panel, slider_krell[cpu], 0);

      update_slider_position(slider_krell[cpu],
                             slider_krell[cpu]->w_scale*khz[cpu]/khz_max,
                             cpu);
    }
  }

  slider_enable_current = slider_enable;
  gov_enable_current = gov_enable;

  /* configure and create the panel  */
  gkrellm_panel_configure(panel, "", style);
  gkrellm_panel_create(vbox, monitor, panel);

  if (first_create) {
    g_signal_connect(G_OBJECT (panel->drawing_area), "expose_event",
                     G_CALLBACK(panel_expose_event), NULL);
    g_signal_connect(G_OBJECT(panel->drawing_area), "button_press_event",
                     G_CALLBACK(cb_panel_press), NULL );
    g_signal_connect(G_OBJECT(panel->drawing_area), "button_release_event",
                     G_CALLBACK(cb_panel_release), NULL );
    g_signal_connect(G_OBJECT(panel->drawing_area), "motion_notify_event",
                     G_CALLBACK(cb_panel_motion), NULL);
  }
}