예제 #1
0
void ColorCurve::update_samples()
{
  if(!_invalidated||_dont_update>0)
    return;
  _invalidated = false;

  gsize n_samples = _samples.size();
  gdouble inv_n_samples = 1.f/gdouble(n_samples);

  for(gsize i=0; i<n_samples; ++i)
  {
    gdouble offset = gdouble(i)*inv_n_samples;

    gdouble r = value_curve->get_value(red_curve->get_value(offset));
    gdouble g = value_curve->get_value(green_curve->get_value(offset));
    gdouble b = value_curve->get_value(blue_curve->get_value(offset));
    gdouble a = alpha_curve->get_value(offset);

    if(get_hide_alpha())
      a = offset;

    _samples[i].set(r, g, b, a);
  }

  signal_changed().emit();
}
예제 #2
0
void XttGeGtk::set_size( int width, int height)
{
  int		default_width;
  int		default_height;
  GdkGeometry   geometry;

  default_width = width + 20;
  default_height = height + 20;

  gtk_window_resize( GTK_WINDOW(toplevel), default_width, default_height);

  // This condition is due to a bug in Reflection X 11.0.5...
  if ( !((XNav *)parent_ctx)->gbl.no_graph_ratio) {
    // Note, equal min and max aspect will cause recursive resize on LXDE
    geometry.min_aspect = gdouble(default_width)/default_height;
    geometry.max_aspect = gdouble(default_width)/default_height * 1.02;
    gtk_window_set_geometry_hints( GTK_WINDOW(toplevel), GTK_WIDGET(toplevel),
    				   &geometry, GDK_HINT_ASPECT);
  }
}
예제 #3
0
  static void fill_state(State& state)
  {
    ProcessStack& process_stack = get_singletonA()->process_stack;

    state.reset();

    if(process_stack.size())
    {
      Glib::RefPtr<ProcessStackEntry> top = *process_stack.rbegin();
      g_assert(top);

      if(get_singletonA()->what_doing.empty())
      {
        state.state = top->_what_doing;
      }else
      {
        if(get_singletonA()->what_doing.empty())
          state.state = top->_what_doing;
        else
          state.state = Glib::ustring::compose("%1  [%2]", top->_what_doing, get_singletonA()->what_doing);
      }

      state.is_aborted  = top->_is_aborted;

      if(top->_n_total_steps)
      {
        state.has_progress  = true;
        state.p = gdouble(top->curr_step()) / gdouble(top->_n_total_steps);
      }

      state.abortable = top->_abortable;
    }else if(get_singletonA()->what_doing.empty())
    {
      state.state = "Ready";
    }else
    {
      state.state = get_singletonA()->what_doing;
    }
  }
void PlaybinSession::setVolume(int volume)
{
    if (d->playbin != 0)
    {
        d->volume = gdouble(volume) / 10;

        if (!d->muted)
        {
            g_object_set(G_OBJECT(d->playbin), "volume", d->volume, NULL);

            emit volumeChanged(volume);
        }
    }
}
예제 #5
0
void WGeGtk::set_size( int width, int height)
{
  int		default_width;
  int		default_height;
  GdkGeometry   geometry;

  default_width = width + 20;
  default_height = height + 20;

  gtk_window_resize( GTK_WINDOW(toplevel), default_width, default_height);

  geometry.min_aspect = geometry.max_aspect = gdouble(default_width)/default_height;
  gtk_window_set_geometry_hints( GTK_WINDOW(toplevel), GTK_WIDGET(toplevel),
				 &geometry, GDK_HINT_ASPECT);

  //if ( !scrollbar && !navigator)
  //  graph->set_default_layout();
}
예제 #6
0
XttGeGtk::XttGeGtk( GtkWidget *xg_parent_wid, void *xg_parent_ctx, const char *xg_name, 
		    const char *xg_filename, int xg_scrollbar, int xg_menu, int xg_navigator, 
		    int xg_width, int xg_height, int x, int y, double scan_time, 
		    const char *object_name, int use_default_access, unsigned int access,
		    unsigned int options, void *basewidget,
		    int (*xg_command_cb) (void *, char *, void *),
		    int (*xg_get_current_objects_cb) (void *, pwr_sAttrRef **, int **),
		    int (*xg_is_authorized_cb) (void *, unsigned int)) :
  XttGe( xg_parent_ctx, xg_name, xg_filename, xg_scrollbar, xg_menu, xg_navigator, xg_width,
	 xg_height, x, y, scan_time, object_name, use_default_access, access, options,
	 xg_command_cb, xg_get_current_objects_cb, xg_is_authorized_cb), 
  parent_wid(xg_parent_wid), nav_shell(0), value_dialog(0), confirm_widget(0), message_dia_widget(0)
{
  int	window_width = 600;
  int   window_height = 500;
  GdkGeometry   geometry;
  pwr_tStatus sts;
  GtkMenuBar *menu_bar;
  char 		title[300];

  if ( xg_width != 0 && xg_height != 0) {
    window_width = xg_width;
    window_height = xg_height;
  }
  else {
    sts = Graph::get_dimension( filename, "pwrp_exe:", &window_width, &window_height);
    if ( EVEN(sts)) {
      window_width = 600;
      window_height = 500;
    }
  }
  cdh_StrncpyCutOff( title, name, sizeof(title), 1);
  char *titleutf8 = g_convert( title, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);

  // Gtk
  if ( !(options & ge_mOptions_Embedded)) {
    toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					   "default-height", window_height,
					   "default-width", window_width,
					   "title", titleutf8,
					   NULL);
    g_free( titleutf8);

    geometry.min_aspect = gdouble(window_width)/window_height;
    geometry.max_aspect = gdouble(window_width)/window_height * 1.02;
    gtk_window_set_geometry_hints( GTK_WINDOW(toplevel), GTK_WIDGET(toplevel),
				   &geometry, GDK_HINT_ASPECT);

    g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
    g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
    g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);
    
    CoWowGtk::SetWindowIcon( toplevel);

    if ( basewidget) {
      gtk_window_set_transient_for(GTK_WINDOW(toplevel), GTK_WINDOW(basewidget));
    }

  }
  else {
    toplevel = parent_wid;
  }

  if ( xg_menu) {
    GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
    gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

    menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

    // File Entry
    GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
    g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);

    GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

    GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

    // View menu
    GtkWidget *view_zoom_in = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
    g_signal_connect(view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this);
    gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
				'i', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

    GtkWidget *view_zoom_out = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
    g_signal_connect(view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this);
    gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
				'o', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

    GtkWidget *view_zoom_reset = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
    g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this);

    GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);

    GtkWidget *view = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_View"));
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

    // Menu Help
    GtkWidget *help_help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
    g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);

    GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

    GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
  }

  graph_form = gtk_vbox_new( FALSE, 0);
  graph = new GraphGtk( this, graph_form, "Plant", 
		&grow_widget, &sts, "pwrp_exe:", graph_eMode_Runtime, 
		scrollbar, 1, object_name, use_default_access, access);
  // graph->set_scantime( scan_time);
  graph->message_cb = &message_cb;
  graph->close_cb = &graph_close_cb;
  graph->init_cb = &graph_init_cb;
  graph->change_value_cb = &ge_change_value_cb;
  graph->confirm_cb = &confirm_cb;
  graph->message_dialog_cb = &message_dialog_cb;
  graph->command_cb = &ge_command_cb;
  graph->display_in_xnav_cb = &ge_display_in_xnav_cb;
  graph->is_authorized_cb = &ge_is_authorized_cb;
  graph->get_current_objects_cb = &ge_get_current_objects_cb;
  graph->popup_menu_cb = &ge_popup_menu_cb;
  graph->call_method_cb = &ge_call_method_cb;
  graph->sound_cb = &ge_sound_cb;
  graph->eventlog_cb = &ge_eventlog_cb;

  //g_signal_connect( graph_form, "check_resize", G_CALLBACK(action_resize), this);
  g_signal_connect( ((GraphGtk *)graph)->grow_widget, "size_allocate", G_CALLBACK(action_resize), this);

  if ( xg_menu)
    gtk_box_pack_start( GTK_BOX(graph_form), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(graph_form), GTK_WIDGET(grow_widget), TRUE, TRUE, 0);

  if ( !(options & ge_mOptions_Embedded)) {
    gtk_container_add( GTK_CONTAINER(toplevel), graph_form);

    gtk_widget_show_all( toplevel);

    if ( navigator) {
      // Create navigator popup
      nav_shell = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					      "default-height", 200,
					      "default-width", 200,
					      "title", "Navigator",
					      NULL);
      g_signal_connect( nav_shell, "delete_event", G_CALLBACK(nav_delete_event), this);

      ((GraphGtk *)graph)->create_navigator( nav_shell);
      gtk_container_add( GTK_CONTAINER(nav_shell), ((GraphGtk *)graph)->nav_widget);

      gtk_widget_show_all( nav_shell);
      ((Graph *)graph)->set_nav_background_color();
    }

    if ( !(x == 0 && y == 0)) {
      // Set position
      gtk_window_move( GTK_WINDOW(toplevel), x, y);
    }

    if ( options & ge_mOptions_FullScreen)
      gtk_window_fullscreen( GTK_WINDOW(toplevel));
    else if ( options & ge_mOptions_Maximize)
      gtk_window_maximize( GTK_WINDOW(toplevel)); // TODO
    else if ( options & ge_mOptions_FullMaximize)
      gtk_window_maximize( GTK_WINDOW(toplevel));
    else if ( options & ge_mOptions_Iconify)
      gtk_window_iconify( GTK_WINDOW(toplevel));
    else if ( options & ge_mOptions_Invisible)
      g_object_set( toplevel, "visible", FALSE, NULL);
  }
  else {
    gtk_widget_set_size_request( graph_form, window_width, window_height);
  }

}
예제 #7
0
WGeGtk::WGeGtk( GtkWidget *wge_parent_wid, void *wge_parent_ctx, char *wge_name, char *wge_filename,
	  int wge_scrollbar, int wge_menu, int wge_navigator, int wge_width, int wge_height, 
	  int x, int y, char *object_name, int wge_modal = 0) :
  WGe(wge_parent_ctx, wge_name, wge_filename, wge_scrollbar, wge_menu, wge_navigator, wge_width,
      wge_height, x, y, object_name, wge_modal),
  parent_wid(wge_parent_wid), nav_shell(0), value_dialog(0), confirm_widget(0)
{
  int	window_width = 600;
  int   window_height = 500;
  GdkGeometry   geometry;
  pwr_tStatus sts;
  GtkMenuBar *menu_bar;
  char 		title[300];

  if ( wge_width != 0 && wge_height != 0) {
    window_width = wge_width;
    window_height = wge_height;
  }
  cdh_StrncpyCutOff( title, name, sizeof(title), 1);

  // Gtk
  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					 "default-height", window_height,
					 "default-width", window_width,
					 "title", title,
					 NULL);

  CoWowGtk::SetWindowIcon( toplevel);

  geometry.min_aspect = geometry.max_aspect = gdouble(window_width)/window_height;
  gtk_window_set_geometry_hints( GTK_WINDOW(toplevel), GTK_WIDGET(toplevel),
				 &geometry, GDK_HINT_ASPECT);

  if ( !(x == 0 && y == 0)) {
    // Set position...
  }

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);


  if ( wge_menu) {
    GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
    gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

    menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

    // File Entry
    GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
    g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);

    GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

    GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

    // View menu
    GtkWidget *view_zoom_in = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
    g_signal_connect(view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this);
    gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
				'i', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

    GtkWidget *view_zoom_out = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
    g_signal_connect(view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this);
    gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
				'o', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

    GtkWidget *view_zoom_reset = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
    g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this);

    GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);

    GtkWidget *view = gtk_menu_item_new_with_mnemonic("_View");
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

    // Menu Help
    GtkWidget *help_help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
    g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);

    GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

    GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
  }

  graph_form = gtk_vbox_new( FALSE, 0);
  graph = new GraphGtk( this, graph_form, "Plant", 
		&grow_widget, &sts, "pwrp_exe:", graph_eMode_Runtime, 
		scrollbar, 1, object_name, 0, 0);
  ((Graph *)graph)->message_cb = &message;
  ((Graph *)graph)->close_cb = &graph_close_cb;
  ((Graph *)graph)->init_cb = &graph_init_cb;
  ((Graph *)graph)->change_value_cb = &change_value_cb;
  ((Graph *)graph)->confirm_cb = &confirm_cb;
  ((Graph *)graph)->message_dialog_cb = &message_dialog_cb;
  ((Graph *)graph)->command_cb = &wge_command_cb;
  ((Graph *)graph)->is_authorized_cb = &wge_is_authorized_cb;

  //g_signal_connect( graph_form, "check_resize", G_CALLBACK(action_resize), this);
  g_signal_connect( ((GraphGtk *)graph)->grow_widget, "size_allocate", G_CALLBACK(action_resize), this);

  if ( wge_menu)
    gtk_box_pack_start( GTK_BOX(graph_form), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(graph_form), GTK_WIDGET(grow_widget), TRUE, TRUE, 0);

  gtk_container_add( GTK_CONTAINER(toplevel), graph_form);

  gtk_widget_show_all( toplevel);

  if ( navigator) {
    // Create navigator popup
    nav_shell = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					    "default-height", 200,
					    "default-width", 200,
					    "title", "Navigator",
					    NULL);
    g_signal_connect( nav_shell, "delete_event", G_CALLBACK(nav_delete_event), this);

    ((GraphGtk *)graph)->create_navigator( nav_shell);
    gtk_container_add( GTK_CONTAINER(nav_shell), ((GraphGtk *)graph)->nav_widget);

    gtk_widget_show_all( nav_shell);
    ((Graph *)graph)->set_nav_background_color();
  }
}
예제 #8
0
/*!
  \brief When the user selects the OK button the new table is calculated
  packaged up, dumped to a file as well as being sent to the ECU to live 
  a long and happy life
  \param widget is the OK button the user clicked
  \param data is unused
  \returns TRUE on success, FALSE otherwise
  */
G_MODULE_EXPORT gboolean afr_calibrate_calc_and_dl(GtkWidget *widget, gpointer data)
{
	static gdouble diywbBv[] = { 0.00, 1.40, 1.45, 1.50, 1.55, 1.60, 
		1.65, 1.70, 1.75, 1.80, 1.85, 1.90, 1.95, 2.00, 2.05, 2.10,
		2.15, 2.20, 2.25, 2.30, 2.35, 2.40, 2.45, 2.50, 2.55, 2.60,
		2.65,  2.70,  2.75,  2.80,  2.85,  2.90,  4.00,  5.01 };
	static gdouble diywbBa[] = { 7.42, 10.08, 10.23, 10.38, 10.53, 10.69,
		10.86, 11.03, 11.20, 11.38, 11.57, 11.76, 11.96, 12.17, 12.38,
		12.60, 12.83, 13.07, 13.31, 13.57, 13.84, 14.11, 14.40, 14.70,
		15.25, 15.84, 16.48, 17.18, 17.93, 18.76, 19.66, 20.66, 40.00,
		60.00 };
	static gdouble lbwbBv[] = {0.00,  2.05,  4.21,  4.98,  5.01};
	static gdouble lbwbBa[] = {1.00, 11.00, 14.70, 16.00, 99.00};
	static gdouble teSVoutBv[] = { 1.024, 1.076, 1.126, 1.177, 1.227,
		1.278, 1.330, 1.380, 1.431, 1.481, 1.532, 1.581,
		1.626, 1.672, 1.717, 1.761, 1.802, 1.842, 1.883,
		1.926, 1.971, 2.015, 2.053, 2.104, 2.150, 2.192,
		2.231, 2.267, 2.305, 2.347, 2.398, 2.455, 2.514,
		2.556, 2.602, 2.650, 2.698, 2.748, 2.797, 2.846,
		2.900, 2.945, 2.991, 3.037, 3.083, 3.129, 3.175,
		3.221, 3.266, 3.313, 3.359, 3.404, 3.451, 3.496,
		3.542, 3.587, 3.634, 3.680, 3.725, 3.772, 3.817,
		3.863, 3.910, 3.955, 4.001 };
	static gdouble teSVoutBa[] = { 8.95, 9.11, 9.26, 9.41, 9.56, 9.71,
		9.87, 10.02, 10.17, 10.32, 10.47, 10.63, 10.78,
		10.93, 11.08, 11.24, 11.39, 11.54, 11.69, 11.86,
		12.04, 12.23, 12.39, 12.62, 12.83, 13.03, 13.21,
		13.4, 13.59, 13.82, 14.1, 14.43, 14.83, 15.31,
		15.85, 16.47, 17.15, 17.9, 18.7, 19.57, 20.5,
		21.5, 22.59, 23.78, 25.1, 26.54, 28.14, 29.9,
		31.87, 34.11, 36.81, 40.27, 45.1, 52.38, 63.92,
		82.66, 99.0, 99.0, 99.0, 99.0, 99.0, 99.0, 99.0,
		99.0, 99.0};
	static gdouble aemLinBv[] = { 0.00, 0.16, 0.31, 0.47, 0.62, 0.78,
		0.94, 1.09, 1.25, 1.40, 1.56, 1.72, 1.87, 2.03, 2.18,
		2.34, 2.50, 2.65, 2.81, 2.96, 3.12, 3.27, 3.43, 3.59,
		3.74, 3.90, 4.05, 4.21, 4.37, 4.52, 4.68, 4.83, 4.99, 5.01 };
	static gdouble aemLinBa[] = { 9.72, 10.01, 10.35, 10.64, 10.98,
		11.27, 11.55, 11.90, 12.18, 12.47, 12.81, 13.10, 13.44,
		13.73, 14.01, 14.35, 14.64, 14.93, 15.27, 15.56, 15.84,
		16.18, 16.47, 16.81, 17.10, 17.39, 17.73, 18.01, 18.36,
		18.64, 18.93, 19.27, 19.56, 99.00 };
	static gdouble aemNonBv[] = { 0.00, 0.16, 0.31, 0.47, 0.62, 0.78,
		0.94, 1.09, 1.25, 1.40, 1.56, 1.72, 1.87, 2.03, 2.18,
		2.34, 2.50, 2.65, 2.81, 2.96, 3.12, 3.27, 3.43, 3.59,
		3.74, 3.90, 4.05, 4.21, 4.37, 4.52, 4.68, 4.83, 4.99,
		5.01 };
	static gdouble aemNonBa[] = { 8.41, 8.52, 8.64, 8.81, 8.98, 9.09,
		9.26, 9.44, 9.61, 9.78, 9.95, 10.12, 10.29, 10.47,
		10.69, 10.92, 11.15, 11.38, 11.67, 11.95, 12.24, 12.58,
		12.92, 13.27, 13.67, 14.13, 14.64, 15.21, 15.84, 16.53,
		17.27, 18.19, 19.44, 99.00 };
	static gdouble fjoBv[] = { 0.000, 0.811, 0.816, 1.256, 1.325,
		1.408, 1.447, 1.667, 1.784, 1.804, 1.872, 1.984, 2.023,
		2.126, 2.209, 2.268, 2.414, 2.454, 2.473, 2.502, 2.522,
		2.581, 2.610, 2.717, 2.766, 2.820, 2.908, 2.933, 2.977,
		3.021, 3.079, 3.099, 3.104, 5.000 };
	static gdouble fjoBa[] = { 0.000, 9.996, 10.011, 11.113, 11.290,
		11.481, 11.569, 12.142, 12.451, 12.510, 12.730, 13.024,
		13.142, 13.465, 13.715, 13.892, 14.377, 14.524, 14.597,
		14.759, 14.876, 15.273, 15.479, 16.302, 16.714, 17.170,
		18.008, 18.243, 18.684, 19.184, 19.801, 19.977, 20.007,
		29.400 };
	static gdouble zeitronixBv[] = { 0.000, 0.150, 0.310, 0.460, 0.620,
		0.780, 0.930, 1.090, 1.240, 1.400, 1.560, 1.710, 1.870,
		2.020, 2.180, 2.340, 2.500, 2.650, 2.800, 2.960, 3.000,
		3.120, 3.270, 5.010 };
	static gdouble zeitronixBa[] = { 0.000, 9.700, 9.900, 10.100,
		10.300, 10.500, 10.700, 11.000, 11.400, 11.700, 12.100,
		12.400, 12.800, 13.200, 13.700, 14.200, 14.700, 15.600,
		16.900, 18.500, 18.800, 19.900, 21.200, 99.000 };
	static gdouble genericBv[4] = { 0.0, 1.0,  4.0, 5.01 };
	static gdouble genericBa[4] = { 0.0, 9.7, 19.7, 99.0 };
	gdouble *Bv = NULL;
	gdouble *Ba = NULL;
	gdouble voltage = 0.0;
	gdouble deltaVoltage = 0.0;
	gdouble vPct = 0.0;
	gint nB = 0;
	gint iV = 0;
	gint adcCount = 0;
	gchar * filename = NULL;
	gdouble afr = 0.0;
	gdouble (*Fv)(gint adc) = NULL;
	gboolean NB = FALSE;
	guint8 table[nADC];
	time_t tim;
	FILE *f = NULL;
	Firmware_Details *firmware = NULL;
	extern gconstpointer *global_data;

	firmware = DATA_GET(global_data,"firmware");

#define USE_TABLE(prefix) \
	Bv = prefix ## Bv; \
	Ba = prefix ## Ba; \
	nB = (sizeof(prefix ## Bv) / sizeof(gdouble));


#define USE_FUNC(prefix) \
	Fv = prefix ## Fv

	switch (afr_enum)
	{
		case narrowBand:
			NB = TRUE;
			USE_FUNC(NB);
			break;
		case diyWB:
			USE_TABLE(diywb);
			break; 
		case dynojetLinear:
			USE_FUNC (djWBlin);
			break;
		case fjo:
			USE_TABLE(fjo);
			break;
		case aemLinear:
			USE_TABLE(aemLin);
			break;
		case aemNonLinear:
			USE_TABLE(aemNon);
			break;
		case twintec:
			USE_FUNC (inno05);
			break;
		case techEdgeLinear:
			USE_FUNC (teWBlin);
			break;
		case techEdgeNonLinear:
			USE_TABLE(teSVout);
			break;
		case innovate12:
			USE_FUNC (inno12);
			break;
		case innovate05:
			USE_FUNC (inno05);
			break;
		case innovateLC1:
			USE_FUNC (innoLC1);
			break;
		case lambdaBoy:
			USE_TABLE(lbwb);
			break;
		case zeitronix:
			USE_TABLE(zeitronix);
			break;
		case genericWB:
			genericBv[1] = g_ascii_strtod(gtk_entry_get_text(GTK_ENTRY(lookup_widget_f("voltage1_entry"))),NULL);
			genericBv[2] = g_ascii_strtod(gtk_entry_get_text(GTK_ENTRY(lookup_widget_f("voltage2_entry"))),NULL);
			genericBa[1] = g_ascii_strtod(gtk_entry_get_text(GTK_ENTRY(lookup_widget_f("afr1_entry"))),NULL);
			genericBa[2] = g_ascii_strtod(gtk_entry_get_text(GTK_ENTRY(lookup_widget_f("afr2_entry"))),NULL);
			USE_TABLE(generic);
			break;
		default:
			printf(_("default case, shouldn't have gotten here. afr_enum is %i"),afr_enum);
			break;
	}
	filename = g_build_filename(HOME(), "afrtable.log",NULL);
	f = fopen(filename, "w");
	g_free(filename);
	iV = 0;
	afr = 0.0;
	time(&tim);

	fprintf(f, "//------------------------------------------------------------------------------\n");
	fprintf(f, "//--  Generated by MegaTunix %s", ctime(&tim));
	fprintf(f, "//--  This file merely records what was sent to your MS-II, and may be        --\n");
	fprintf(f, "//--  deleted at any time.                                                    --\n");
	fprintf(f, "//--  Selected type: %-57s--\n", afr_name);
	fprintf(f, "//------------------------------------------------------------------------------\n");
	fprintf(f, "#ifndef GCC_BUILD\n");
	fprintf(f, "#pragma ROM_VAR EGO_ROM\n");
	fprintf(f, "#endif\n");
	fprintf(f, "const unsigned char egofactor_table[%d] EEPROM_ATTR = {\n", nADC);
	fprintf(f, "         //     afr  adcCount voltage\n");
	for (adcCount = 0; adcCount < nADC; adcCount++) 
	{
		voltage = adcCount / (nADC-1.0) * 5.0;
		if (NB) 
		{
			afr = 0.0;
			table[adcCount] = (adcCount > nADC/5.0) ? 0 : (gint16)(nADC/5.0 - adcCount);
		}
		else 
		{
			if (Fv)
				afr = Fv(adcCount);
			else 
			{
				/* Use curve data from tabular expression of transfer function.*/
				while (voltage > Bv[iV]) 
					iV++;
				deltaVoltage = Bv[iV] - Bv[iV-1];
				if (fabs(deltaVoltage) < 1e-10) /* Curve data is crap.*/
					afr = 999.0;
				else 
				{
					vPct = 1.0 - (Bv[iV] - voltage) / deltaVoltage;
					afr  = vPct * (Ba[iV] - Ba[iV-1]) + Ba[iV-1];
				}
			}
			table[adcCount] = (guint8)(afr*10.0+0.5);
		}

		fprintf(f, "   %4d%c // %7.3f   %4d   %6.3f\n", table[adcCount], (adcCount<nADC-1)?',':' ', afr, adcCount, voltage);
	}
	fprintf(f, "};\n");
	fprintf(f, "#ifndef GCC_BUILD\n");
	fprintf(f, "#pragma ROM_VAR DEFAULT\n");
	fprintf(f, "#endif\n");
	fprintf(f, "//------------------------------------------------------------------------------\n");
	fclose(f);

	ms_table_write(firmware->ego_table_page,
			firmware->page_params[firmware->ego_table_page]->length,
			(guint8 *)table);

	return TRUE;
}
예제 #9
0
파일: asscan.c 프로젝트: dank101/3BSD
toktype yylex()
{
	register	ptrall	bufptr;	
	register	toktype		val;	
	register	struct	exp	*locxp;

	bufptr = tokptr;		/*copy in the global value*/
   top:
	if (bufptr < tokub){
		gtoken(val, bufptr);
		switch(yylval = val){
			case	PARSEEOF :
					yylval = val = PARSEEOF;
					break;
			case	INT:
					locxp = xp++;
					glong(locxp->xvalue, bufptr);
				  makevalue:
					locxp->xtype = XABS;
					locxp->xloc = 0;
					locxp->xname = NULL;
					yylval = (int)locxp;
					break;
			case	FLTNUM:	/*case patched on 3-Jan-80*/
					locxp = xp++;
					gdouble(locxp->doubval.dvalue, bufptr);
					/*
					 *	We make sure that locxp->xvalue
					 *	is not in the range suitable for
					 *	a short literal.  The field
					 *	xvalue is only used for
					 *	integers, not doubles, but when
					 *	we test for short literals
					 *	in ascode.c, we look
					 *	at the field xvalue when
					 *	it encounters an in line
					 *	floating number. Ergo,
					 *	give it a bad value.
					 */
					locxp->xvalue = -1;
					goto makevalue;
			case	NAME:
					gptr(yylval, bufptr);
					lastnam = (struct symtab *)yylval;
					break;
			case	SIZESPEC:
			case 	REG:
			case	INSTn:
			case	INST0:
					gchar(yylval, bufptr);
					break;
			case	IJXXX:
					gchar(yylval, bufptr);
					gptr(lastjxxx, bufptr);
					break;
			case	ILINESKIP:
					gint(yylval, bufptr);
					lineno += yylval;
					goto top;
			case	SKIP:	
					eatskiplg(bufptr);
					goto top;
			case	VOID:	
					goto top;
			case 	STRING:
					strptr = &strbuf[strno ^= 1];
					strptr->str_lg = *((lgtype *)bufptr);
					movestr(&strptr->str[0],
						(char *)bufptr + sizeof(lgtype),
						strptr->str_lg);
					eatstrlg(bufptr);
					yylval = (int)strptr;
					break;
			case 	ISTAB:
			case	ISTABSTR:
			case	ISTABNONE:
			case	ISTABDOT:
			case	IALIGN:
					gptr(yylval, bufptr);
					break;
		} /*end of the switch*/

#ifdef DEBUG

		if (toktrace)
		switch(val){
			case 	INT:	printf("Class integer val %d\n",
						((struct exp *)yylval)->xvalue);
					break;
			case 	FLTNUM: printf("Class floating point num value %4.3f\n",
					((struct exp *)yylval) -> doubval.dvalue);
					break;
			case	NAME:	printf("Class name, \"%.8s\"\n",
						((struct symtab *)yylval)->name);
					break;
			case	REG:	printf("Class register, number %d\n",
						yylval);
					break;
			case	INSTn:	printf("Class INSTn, %.8s\n",
						itab[0xFF &yylval]->name);
					break;
			case	IJXXX:	printf("Class IJXXX, %.8s\n",
						itab[0xFF &yylval]->name);
					break;
			case	INST0:	printf("Class INST0, %.8s\n",
						itab[0xFF &yylval]->name);
					break;
			case	STRING:	printf("Class string, length %d\n",
						((struct strdesc *)yylval)->str_lg);
					break;
			default:	printf("Pass: %d Tok: %d Other class: %d, 0%o, '%c'\n",
						passno,
						bufptr -  firsttoken,
						val,val, val);
					break;
		}		/*end of the debug switch*/
#endif

	}	/*end of this buffer*/
	else {
		if (useVM){
			bufno += 1;
			emptybuf = emptybuf->tok_next;
			if (emptybuf == 0){
				struct	tokbufdesc *newdallop;
				int	i;
				if (passno == 2)
					goto badread;
				emptybuf = newdallop = 
				  (struct tokbufdesc *)sbrk(
					TOKDALLOP*sizeof (struct tokbufdesc));
				if (emptybuf == (struct tokbufdesc *)-1)
					goto badwrite;
				for (i=0; i < TOKDALLOP; i++){
					buftail->tok_next = newdallop;
					buftail = newdallop;
					newdallop += 1;
				}
				buftail->tok_next = 0;
			}	/*end of need to get more buffers*/
			(toktype *)bufptr = &(emptybuf->toks[0]);
			if (passno == 1)
				scan_dot_s(emptybuf);
		} else {	/*don't use VM*/
			bufno ^= 1;
			emptybuf = &tokbuf[bufno];
			((toktype *)bufptr) = &(emptybuf->toks[0]);
			if (passno == 1){
				/*
				 *	First check if there are things to write
				 *	out at all
				 */
				if (emptybuf->tok_count >= 0){
					if (fwrite(emptybuf, sizeof *emptybuf, 1, tmpfil) != 1){
					  badwrite:
						yyerror("Unexpected end of file writing the interpass tmp file");
						exit(2);
					}
				}
				scan_dot_s(emptybuf);
			} else {	/*pass 2*/
				if (fread(emptybuf, sizeof *emptybuf, 1, tmpfil) != 1){
				  badread:
					yyerror("Unexpected end of file while reading the interpass tmp file");
					exit(1);
				}
			}	/*end of pass2*/
		}	/*end of using a real live file*/
		(char *)tokub = (char *)bufptr + emptybuf->tok_count;
#ifdef DEBUG
		firsttoken = bufptr;
		if (debug)
			printf("created buffernumber %d with %d tokens\n",
				bufno, emptybuf->tok_count);
#endif
			goto top;
	}	/*end of reading/creating a new buffer*/
	tokptr = bufptr;		/*copy back the global value*/
	return(val);
}	/*end of yylex*/
예제 #10
0
    virtual void process()
    {
        // This happens in the installer thread, so we cannot mess with
        // anything else.

        HZIP zip = NULL;

        try
        {
            g_debug( "STARTING INSTALL OF %s", info.source_file.c_str() );

            //.................................................................

            if ( ! verify_and_strip_signatures() )
            {
                throw String( "SIGNATURE CHECK FAILED" );
            }

            //.................................................................
            // Open the source file to make sure it is ok

            zip = OpenZip( info.source_file.c_str(), NULL );

            if ( ! zip )
            {
                throw String( "FAILED TO OPEN ZIP FILE" );
            }

            ZIPENTRY entry;

            //.................................................................
            // Figure out how many items are in the zip file

            if ( ZR_OK != GetZipItem( zip, -1, &entry ) )
            {
                throw String( "FAILED TO GET ZIP ENTRY COUNT" );
            }

            int entry_count = entry.index;

            if ( entry_count <= 0 )
            {
                throw String( "ZIP FILE HAS TOO FEW ENTRIES" );
            }

            //.................................................................
            // Now go through all the items in the zip file, figure out
            // their total uncompressed size and find the 'app' file.

            guint64 total_uncompressed_size = 0;

            String app_file_zip_path;

            int app_file_zip_index = -1;

            guint64 app_file_uncompressed_size = 0;

            for ( int i = 0; i < entry_count; ++i )
            {
                if ( ZR_OK != GetZipItem( zip, i, &entry ) )
                {
                    throw String( "FAILED TO GET ZIP ENTRY" );
                }

                total_uncompressed_size += entry.unc_size;

                // See if this is the app file

                if ( app_file_zip_path.empty() )
                {
                    // THIS IS PLATFORM SPECIFIC

                    if ( ! ( entry.attr & S_IFDIR ) )
                    {
                        gchar * basename = g_path_get_basename( entry.name );

                        if ( ! strcmp( basename , "app" ) )
                        {
                            app_file_zip_path = entry.name;

                            app_file_zip_index = i;

                            app_file_uncompressed_size = entry.unc_size;
                        }

                        g_free( basename );
                    }
                }
            }

            if ( app_file_zip_path.empty() )
            {
                throw String( "ZIP FILE IS MISSING APP FILE" );
            }

            if ( app_file_uncompressed_size == 0 )
            {
                throw String( "APP FILE UNCOMPRESSED SIZE IS INCORRECT" );
            }

            g_debug( "FOUND APP FILE IN ZIP AT %s", app_file_zip_path.c_str() );

            //.................................................................
            // Uncompress the app file to memory and load its metadata.
            // We must ensure it is valid and its app_id is the same as the
            // one passed in.

            // g_new0 serves to NULL-terminate the contents, which
            // load_metadata_from_data expects.

            gchar * app_file_buffer = g_new0( gchar, app_file_uncompressed_size * 2 );

            if ( ! app_file_buffer )
            {
                throw String( "FAILED TO ALLOCATE MEMORY TO UNCOMPRESS APP FILE" );
            }

            FreeLater free_later;

            free_later( app_file_buffer );

            if ( ZR_OK != UnzipItem( zip, app_file_zip_index, app_file_buffer, app_file_uncompressed_size * 2 ) )
            {
                throw String( "FAILED TO UNCOMPRESS APP FILE" );
            }

            App::Metadata metadata;

            if ( ! App::load_metadata_from_data( app_file_buffer, metadata ) )
            {
                throw String( "FAILED TO READ METADATA" );
            }

            if ( metadata.id != info.app_id )
            {
                throw String( "APP ID DOES NOT MATCH" );
            }

            //.................................................................
            // Figure out where to unzip it to
            // - should be in the same volume as the app's data directory
            //
            // The app may already live in  trickplay/apps/<id hash>/source
            //
            // We could unzip it to         trickplay/apps/installing/<id hash>
            //      The benefit of this is that it would be easy to clean up unfinished
            //      installations by deleting everything in "installing".
            //
            // We could unzip it to         trickplay/apps/<id hash>/installing
            //      This puts it event closer to its final destination, but we would
            //      have to do more work to clean up. CHOOSING THIS ONE FOR NOW

            gchar * unzip_path = g_build_filename( info.app_directory.c_str(), "installing", NULL );

            free_later( unzip_path );

            //.................................................................
            // If our destination directory already exists, it is probably
            // from a failed attempt to install this app. We need to get rid of it.

            if ( g_file_test( unzip_path, G_FILE_TEST_EXISTS ) )
            {
                g_debug( "DELETING OLD INSTALL DIRECTORY %s", unzip_path );

                if ( ! recursive_delete_path( unzip_path ) )
                {
                    throw String( "FAILED TO DELETE OLD INSTALL DIRECTORY" );
                }
            }

            if ( 0 != g_mkdir_with_parents( unzip_path, 0700 ) )
            {
                throw String( "FAILED TO CREATE INSTALL DIRECTORY" );
            }

            //.................................................................
            // TODO: We should now check for free space - and make sure we have at
            // least total_uncompressed_size available.


            //.................................................................
            // OK, everything seems to be in order.
            // We get the dirname of the path to the app file in the zip.
            // So, for example, inside the zip, the app file might be in
            // "foor/bar/app". We have to take all the files in the zip that
            // are in "foo/bar" and unzip them to our real destination.

            gchar * app_file_zip_dirname = g_path_get_dirname( app_file_zip_path.c_str() );
            g_assert(app_file_zip_dirname);

            free_later( app_file_zip_dirname );

            guint app_file_zip_dirname_length = strlen( app_file_zip_dirname );

            // If there is no dirname, the above gets set to "."

            bool no_zip_root = ! strcmp( app_file_zip_dirname, "." );

            // Now, it is time to unzip

            g_debug( "UNZIPPING TO %s", unzip_path );

            guint64 total_processed = 0;

            Util::GTimer progress_timer;

#ifndef TP_PRODUCTION

            static float slow = -1;

            if ( slow == -1 )
            {
                if ( const char * e = g_getenv( "TP_INSTALL_DELAY" ) )
                {
                    slow = atof( e );
                }
                else
                {
                    slow = 0;
                }
            }

#endif

            for ( int i = 0; i < entry_count; ++i )
            {

#ifndef TP_PRODUCTION

                if ( slow )
                {
                    usleep( slow * G_USEC_PER_SEC );
                }

#endif

                if ( ZR_OK != GetZipItem( zip, i, &entry ) )
                {
                    throw String( "FAILED TO GET ZIP ENTRY" );
                }

                gchar * destination_file_name = NULL;

                if ( no_zip_root )
                {
                    destination_file_name = g_build_filename( unzip_path, entry.name, NULL );
                }
                else if ( g_str_has_prefix( entry.name, app_file_zip_dirname ) )
                {
                    destination_file_name = g_build_filename( unzip_path, entry.name + app_file_zip_dirname_length, NULL );
                }

                if ( ! destination_file_name )
                {
                    g_debug( "  SKIPPING %s", entry.name );
                }
                else
                {
                    free_later( destination_file_name );

                    g_debug( "  UNZIPPING %s", entry.name );

                    if ( ZR_OK != UnzipItem( zip, i, destination_file_name ) )
                    {
                        throw String( "FAILED TO UNZIP" );
                    }
                }

                // Report progress

                total_processed += entry.unc_size;

                if ( progress_timer.elapsed() >= 1 )
                {
                    progress_timer.reset();

                    info.status = Installer::Info::INSTALLING;
                    info.percent_installed = gdouble( total_processed ) / gdouble( total_uncompressed_size ) * 100.0;

                    send_progress();
                }
            }

            //.................................................................
            // At this point, the app should be uncompressed to the "installing"
            // directory and ready to go.

            //.................................................................
            // Finally, under the right conditions, we delete the existing install
            // of the app and move the "installing" directory over it.

            info.moved = false;

            gchar * source_path = g_build_filename( info.app_directory.c_str(), "source", NULL );

            free_later( source_path );

            bool source_exists = g_file_test( source_path, G_FILE_TEST_EXISTS );

            // If the source directory exists and the app is locked, we can
            // delete the source directory

            if ( source_exists && info.locked )
            {
                if ( ! recursive_delete_path( source_path ) )
                {
                    throw String( "FAILED TO DELETE PREVIOUS APP SOURCE" );
                }

                source_exists = false;
            }

            // If the source directory does not already exist, or we deleted in the
            // previous step, we can rename the install directory.

            if ( ! source_exists )
            {
                if ( 0 != g_rename( unzip_path, source_path ) )
                {
                    throw String( "FAILED TO RENAME INSTALL DIRECTORY TO SOURCE DIRECTORY" );
                }

                info.moved = true;
            }

            // Once this is done, the caller needs to call 'complete_install'. This will
            // move the app to its final resting place (if necessary) and also add its
            // entry to the system database.

            g_debug( "FINISHED INSTALL OF %s TO %s", info.app_id.c_str(), info.moved ? source_path : unzip_path );

            info.status = Installer::Info::FINISHED;

            info.install_directory = unzip_path;

            info.app_directory = source_path;

            send_progress();

            // Caller is also reponsible for getting rid of the original zip file.
        }
        catch( const String & e )
        {
            g_warning( "FAILED TO INSTALL %s FROM %s : %s", info.app_id.c_str(), info.source_file.c_str(), e.c_str() );

            info.status = Installer::Info::FAILED;

            send_progress( );
        }

        // Close the zip file

        if ( zip )
        {
            CloseZip( zip );
        }

        // Always return true - to keep the thread running
    }
예제 #11
0
ControllerLIRC::ControllerLIRC( TPContext * context , const char * uds , guint _repeat )
:
    connection( 0 ),
    controller( 0 ),
    timer( 0 ),
    repeat( gdouble( _repeat ) / 1000.0 )
{
    g_assert( context );
    g_assert( uds );

    //.........................................................................
    // Get the address of the Unix Domain Socket

    GSocketAddress * socket_address = g_unix_socket_address_new( uds );

    if ( ! socket_address )
    {
        tpwarn( "FAILED TO CREATE SOCKET ADDRESS WITH '%d'" , uds );
        return;
    }

    //.........................................................................
    // Create a socket client and attempt to connect to the address

    GSocketClient * client = g_socket_client_new();

    connection = g_socket_client_connect( client , G_SOCKET_CONNECTABLE( socket_address ) , NULL , NULL );

    g_object_unref( socket_address );

    g_object_unref( client );

    if ( ! connection )
    {
        tplog( "FAILED TO CONNECT TO LIRC SOCKET" );
        return;
    }

    //.........................................................................
    // Now, get the socket's input stream, create a data input stream from it
    // and start reading lines.

    GDataInputStream * input_stream = g_data_input_stream_new( g_io_stream_get_input_stream( G_IO_STREAM( connection ) ) );

    g_assert( input_stream );

    g_data_input_stream_read_line_async( input_stream , 0 , NULL , line_read , this );

    g_object_unref( input_stream );

    //.........................................................................
    // Add the controller

    TPControllerSpec controller_spec;

    memset( & controller_spec , 0 , sizeof( controller_spec ) );

    controller_spec.capabilities = TP_CONTROLLER_HAS_KEYS;

    controller = tp_context_add_controller( context , "Remote" , & controller_spec , 0 );

    g_assert( controller );

    //.........................................................................
    // Populate the key map

    key_map[ "0"         ] = TP_KEY_0;
    key_map[ "1"         ] = TP_KEY_1;
    key_map[ "2"         ] = TP_KEY_2;
    key_map[ "3"         ] = TP_KEY_3;
    key_map[ "4"         ] = TP_KEY_4;
    key_map[ "5"         ] = TP_KEY_5;
    key_map[ "6"         ] = TP_KEY_6;
    key_map[ "7"         ] = TP_KEY_7;
    key_map[ "8"         ] = TP_KEY_8;
    key_map[ "9"         ] = TP_KEY_9;
    key_map[ "MUTE"      ] = TP_KEY_MUTE;
    key_map[ "CH_UP"     ] = TP_KEY_CHAN_UP;
    key_map[ "VOL_UP"    ] = TP_KEY_VOL_UP;
    key_map[ "CH_DOWN"   ] = TP_KEY_CHAN_DOWN;
    key_map[ "VOL_DOWN"  ] = TP_KEY_VOL_DOWN;
    key_map[ "UP"        ] = TP_KEY_UP;
    key_map[ "LEFT"      ] = TP_KEY_LEFT;
    key_map[ "OK"        ] = TP_KEY_OK;
    key_map[ "RIGHT"     ] = TP_KEY_RIGHT;
    key_map[ "DOWN"      ] = TP_KEY_DOWN;
    key_map[ "MENU"      ] = TP_KEY_MENU;
    key_map[ "EXIT"      ] = TP_KEY_EXIT;
    key_map[ "PLAY"      ] = TP_KEY_PLAY;
    key_map[ "PAUSE"     ] = TP_KEY_PAUSE;
    key_map[ "STOP"      ] = TP_KEY_STOP;
    key_map[ "|<<"       ] = TP_KEY_PREV;
    key_map[ ">>|"       ] = TP_KEY_NEXT;
    key_map[ "RECORD"    ] = TP_KEY_REC;
    key_map[ "<<"        ] = TP_KEY_REW;
    key_map[ ">>"        ] = TP_KEY_FFWD;
    key_map[ "RED"       ] = TP_KEY_RED;
    key_map[ "GREEN"     ] = TP_KEY_GREEN;
    key_map[ "YELLOW"    ] = TP_KEY_YELLOW;
    key_map[ "BLUE"      ] = TP_KEY_BLUE;
    key_map[ "BACK"      ] = TP_KEY_BACK;

    timer = g_timer_new();

    tplog( "READY" );
}
예제 #12
0
GtkTextTag *
create_text_tag_from_style(const css::styles &aStyles)
{
	GtkTextTag *tag = gtk_text_tag_new(aStyles.name.c_str());

	switch (aStyles.vertical_align)
	{
	case css::vertical_align::inherit:
		break;
	case css::vertical_align::baseline:
		g_object_set(G_OBJECT(tag), "rise-set", TRUE, "rise", 0, NULL);
		break;
	case css::vertical_align::sub:
		g_object_set(G_OBJECT(tag), "rise-set", TRUE, "rise", -4096, NULL);
		break;
	case css::vertical_align::super:
		g_object_set(G_OBJECT(tag), "rise-set", TRUE, "rise", 4096, NULL);
		break;
	}

	switch (aStyles.text_align)
	{
	case css::text_align::inherit:
		break;
	case css::text_align::left:
		g_object_set(G_OBJECT(tag), "justification-set", TRUE, "justification", GTK_JUSTIFY_LEFT, NULL);
		break;
	case css::text_align::right:
		g_object_set(G_OBJECT(tag), "justification-set", TRUE, "justification", GTK_JUSTIFY_RIGHT, NULL);
		break;
	case css::text_align::center:
		g_object_set(G_OBJECT(tag), "justification-set", TRUE, "justification", GTK_JUSTIFY_CENTER, NULL);
		break;
	case css::text_align::justify:
		g_object_set(G_OBJECT(tag), "justification-set", TRUE, "justification", GTK_JUSTIFY_FILL, NULL);
		break;
	}

	switch (aStyles.text_decoration)
	{
	case css::text_decoration::inherit:
		break;
	case css::text_decoration::none:
		g_object_set(G_OBJECT(tag), "strikethrough-set", TRUE, "strikethrough", FALSE, NULL);
		g_object_set(G_OBJECT(tag), "underline-set", TRUE, "underline", PANGO_UNDERLINE_NONE, NULL);
		break;
	case css::text_decoration::underline:
		g_object_set(G_OBJECT(tag), "underline-set", TRUE, "underline", PANGO_UNDERLINE_SINGLE, NULL);
		break;
	case css::text_decoration::line_through:
		g_object_set(G_OBJECT(tag), "strikethrough-set", TRUE, "strikethrough", TRUE, NULL);
		break;
	}

	switch (aStyles.font_style)
	{
	case css::font_style::inherit:
		break;
	case css::font_style::normal:
		g_object_set(G_OBJECT(tag), "style-set", TRUE, "style", PANGO_STYLE_NORMAL, NULL);
		break;
	case css::font_style::italic:
		g_object_set(G_OBJECT(tag), "style-set", TRUE, "style", PANGO_STYLE_ITALIC, NULL);
		break;
	case css::font_style::oblique:
		g_object_set(G_OBJECT(tag), "style-set", TRUE, "style", PANGO_STYLE_OBLIQUE, NULL);
		break;
	}

	switch (aStyles.font_variant_caps)
	{
	case css::font_variant_caps::inherit:
		break;
	case css::font_variant_caps::normal:
		g_object_set(G_OBJECT(tag), "variant-set", TRUE, "variant", PANGO_VARIANT_NORMAL, NULL);
		break;
	case css::font_variant_caps::small_caps:
		g_object_set(G_OBJECT(tag), "variant-set", TRUE, "variant", PANGO_VARIANT_SMALL_CAPS, NULL);
		break;
	}

	switch (aStyles.font_weight)
	{
	case css::font_weight::inherit:
		break;
	case css::font_weight::normal:
		g_object_set(G_OBJECT(tag), "weight-set", TRUE, "weight", PANGO_WEIGHT_NORMAL, NULL);
		break;
	case css::font_weight::bold:
		g_object_set(G_OBJECT(tag), "weight-set", TRUE, "weight", PANGO_WEIGHT_BOLD, NULL);
		break;
	}

	if (!aStyles.font_family.empty())
		g_object_set(G_OBJECT(tag), "family-set", TRUE, "family", aStyles.font_family.c_str(), NULL);

	if (aStyles.font_size.units() != css::length::inherit)
		g_object_set(G_OBJECT(tag), "size-set", TRUE, "size-points", gdouble(aStyles.font_size.as(css::length::points).value()), NULL);

	if (aStyles.margin.top.units() != css::length::inherit)
		g_object_set(G_OBJECT(tag), "pixels-above-lines-set", TRUE, "pixels-above-lines", gint(aStyles.margin.top.as(css::length::pixels).value()), NULL);

	if (aStyles.margin.bottom.units() != css::length::inherit)
		g_object_set(G_OBJECT(tag), "pixels-below-lines-set", TRUE, "pixels-below-lines", gint(aStyles.margin.bottom.as(css::length::pixels).value()), NULL);

	if (aStyles.margin.left.units() != css::length::inherit)
		g_object_set(G_OBJECT(tag), "left-margin-set", TRUE, "left-margin", gint(aStyles.margin.left.as(css::length::pixels).value()), NULL);

	if (aStyles.margin.right.units() != css::length::inherit)
		g_object_set(G_OBJECT(tag), "right-margin-set", TRUE, "right-margin", gint(aStyles.margin.right.as(css::length::pixels).value()), NULL);

	return tag;
}