int main(int argc, char **argv)
{
	ros::init(argc, argv, "mavconn_asctec_bridge");

	GError* error = NULL;
	GOptionContext* context = g_option_context_new("- translate messages between Asctec (ROS) and MAVCONN (LCM)");
	g_option_context_add_main_entries(context, entries, NULL);
	//g_option_context_add_group (context, NULL);
	if (!g_option_context_parse(context, &argc, &argv, &error))
	{
		g_print("Option parsing failed: %s\n", error->message);
		exit(1);
	}

	nh = new ros::NodeHandle;
	ros::Subscriber poseStampedSub = nh->subscribe("fcu/current_pose", 10, poseStampedCallback);
	ros::Publisher waypointPub = nh->advertise<asctec_hl_comm::WaypointActionGoal>("fcu/waypoint/goal", 10);
	
	// check for changed parameters on parameter server
	ros::Timer paramCheckTimer = nh->createTimer(ros::Duration(2.0), paramCheckCallback);

	/**
	 * Connect to LCM Channel and register for MAVLink messages ->
	 */
	lcm = lcm_create(lcmurl.c_str());
	if (!lcm)
	{
		exit(EXIT_FAILURE);
	}

	mavlink_message_t_subscription_t* mavlinkSub =
		mavlink_message_t_subscribe(lcm, "MAVLINK", &mavlinkHandler, &waypointPub);
	
	// start thread(s) to listen for ROS messages
	ros::AsyncSpinner spinner(1);
	spinner.start();

	// listen for LCM messages
	int lcm_fd = lcm_get_fileno(lcm);

	// wait a limited amount of time for an incoming LCM message
	struct timeval timeout = {
		1,	// seconds
		0	// microseconds
	};

	while (ros::ok())
	{
		fd_set fds;
		FD_ZERO(&fds);
		FD_SET(lcm_fd, &fds);

		int status = select(lcm_fd + 1, &fds, 0, 0, &timeout);

		if (status != 0 && FD_ISSET(lcm_fd, &fds) && ros::isShuttingDown())
		{
			// LCM has events ready to be processed.
			lcm_handle(lcm);
		}
	}

	delete nh;

	mavlink_message_t_unsubscribe(lcm, mavlinkSub);
	lcm_destroy(lcm);

	return 0;
}
Ejemplo n.º 2
0
gboolean
ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GError **error)
{
  gboolean ret = FALSE;
  GOptionContext *context;
  gs_unref_object OstreeSysroot *sysroot = NULL;
  gs_unref_object OstreeSysrootUpgrader *upgrader = NULL;
  gs_free char *origin_remote = NULL;
  gs_free char *origin_ref = NULL;
  gs_free char *origin_refspec = NULL;
  gs_free char *new_revision = NULL;
  gs_unref_object GFile *deployment_path = NULL;
  gs_unref_object GFile *deployment_origin_path = NULL;
  gs_unref_object OstreeDeployment *merge_deployment = NULL;
  gs_unref_object OstreeDeployment *new_deployment = NULL;
  GSConsole *console = NULL;
  gboolean in_status_line = FALSE;
  gs_unref_object OstreeAsyncProgress *progress = NULL;
  gboolean changed;
  OstreeSysrootUpgraderPullFlags upgraderpullflags = 0;

  context = g_option_context_new ("Construct new tree from current origin and deploy it, if it changed");

  if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                          OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
                                          &sysroot, cancellable, error))
    goto out;

  if (!ostree_sysroot_load (sysroot, cancellable, error))
    goto out;

  upgrader = ostree_sysroot_upgrader_new_for_os (sysroot, opt_osname,
                                                 cancellable, error);
  if (!upgrader)
    goto out;

  console = gs_console_get ();
  if (console)
    {
      gs_console_begin_status_line (console, "", NULL, NULL);
      in_status_line = TRUE;
      progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, console);
    }

  if (opt_allow_downgrade)
    upgraderpullflags |= OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER;

  if (!ostree_sysroot_upgrader_pull (upgrader, 0, upgraderpullflags,
                                     progress, &changed,
                                     cancellable, error))
    goto out;

  if (in_status_line)
    {
      gs_console_end_status_line (console, NULL, NULL);
      in_status_line = FALSE;
    }

  if (!changed)
    {
      g_print ("No update available.\n");
    }
  else
    {
      gs_unref_object GFile *real_sysroot = g_file_new_for_path ("/");

      if (!ostree_sysroot_upgrader_deploy (upgrader, cancellable, error))
        goto out;

      if (opt_reboot && g_file_equal (ostree_sysroot_get_path (sysroot), real_sysroot))
        {
          gs_subprocess_simple_run_sync (NULL, GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                         cancellable, error,
                                         "systemctl", "reboot", NULL);
        }
    }

  ret = TRUE;
 out:
  if (in_status_line)
    gs_console_end_status_line (console, NULL, NULL);
  if (context)
    g_option_context_free (context);
  return ret;
}
Ejemplo n.º 3
0
void on_radiobutton2_pressed( GtkWidget *widget, struct _properties *properties )
{
  g_print ("radiobutton2 was pressed\n");
  properties->format = CALENDAR_OPTIONS4;

  if( option_algorithms[properties->modeltype].supportStrikes )
  {
    // custom strikes...
    if( strike_control[properties->strikestoogle].incrementor == 0 && properties->spreads != 1 )
    {
      gtk_widget_show(properties->GtkInfo.spinbuttonCustomStrike2);
      gtk_label_set_text(GTK_LABEL(properties->GtkInfo.labelStrikes2),"Strike");
      gtk_widget_show(properties->GtkInfo.labelStrikes2);
      gtk_widget_hide(properties->GtkInfo.scaleStrikes);
    }
    // custom strikes with spreads...
    else if( strike_control[properties->strikestoogle].incrementor == 0 && properties->spreads == 1 )
    {
      gtk_widget_hide(properties->GtkInfo.scaleStrikes);
      gtk_widget_hide(properties->GtkInfo.scaleStrikes2);

      gtk_label_set_text(GTK_LABEL(properties->GtkInfo.labelStrikes),"StrikeLeg1");
      gtk_widget_show(properties->GtkInfo.labelStrikes);
      gtk_label_set_text(GTK_LABEL(properties->GtkInfo.labelStrikes2),"StrikeLeg2");
      gtk_widget_show(properties->GtkInfo.labelStrikes2);

      gtk_widget_show(properties->GtkInfo.spinbuttonCustomStrike);
      gtk_widget_show(properties->GtkInfo.spinbuttonCustomStrike2);
      gtk_widget_hide(properties->GtkInfo.comboboxStrikes);

    }
    else if( strike_control[properties->strikestoogle].incrementor != 0 && properties->spreads == 1 )
    {
      gtk_widget_hide(properties->GtkInfo.labelStrikes);
      gtk_widget_hide(properties->GtkInfo.spinbuttonCustomStrike);
      gtk_widget_hide(properties->GtkInfo.labelStrikes2);
      gtk_widget_hide(properties->GtkInfo.spinbuttonCustomStrike2);
      gtk_widget_show(properties->GtkInfo.comboboxStrikes);
    }
    else
    {
      gtk_widget_hide(properties->GtkInfo.spinbuttonCustomStrike2);
      gtk_label_set_text(GTK_LABEL(properties->GtkInfo.labelStrikes2),"StrikeLeg2");
      gtk_widget_hide(properties->GtkInfo.labelStrikes2);
      gtk_widget_show(properties->GtkInfo.scaleStrikes);
    }

    if( strike_control[properties->strikestoogle].incrementor != 0 && properties->spreads != 1 )
    {
      gtk_widget_show(properties->GtkInfo.comboboxStrikes);
      gtk_label_set_text(GTK_LABEL(properties->GtkInfo.labelStrikes),"Strikes");
      gtk_widget_show(properties->GtkInfo.labelStrikes);
    }

  } else
  {
    gtk_widget_hide(properties->GtkInfo.comboboxStrikes);
    gtk_widget_hide(properties->GtkInfo.labelStrikes);
  }

  if( strike_control[properties->strikestoogle].incrementor != 0 && properties->spreads != 1 )
  {
    gtk_widget_hide(properties->GtkInfo.spinbuttonCustomStrike);
    gtk_widget_hide(properties->GtkInfo.spinbuttonCustomStrike2);
    gtk_widget_hide(properties->GtkInfo.labelStrikes2);
  }

  set_scale_button(properties);
  gtk_widget_show(properties->GtkInfo.checkbuttonSpreads);

  setup_tree_view(properties);
  show_title(properties);

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(properties->GtkInfo.radiobutton2),true);
}
Ejemplo n.º 4
0
void nautilus_module_shutdown(void) {
    g_print("Shutting down nautilus-gnome-split extension\n");
}
Ejemplo n.º 5
0
int
main (int   argc,
      char *argv[])
{
  GdkGLConfig *glconfig;
  gint major, minor;

  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *drawing_area;
  GtkWidget *button;

  /*
   * Init GTK.
   */

  gtk_init (&argc, &argv);

  /*
   * Init GtkGLExt.
   */

  gtk_gl_init (&argc, &argv);

  /*
   * Query OpenGL extension version.
   */

  gdk_gl_query_version (&major, &minor);
  g_print ("\nOpenGL extension version - %d.%d\n\n",
           major, minor);

  /*
   * Configure OpenGL-capable visual.
   */

  /* Try double-buffered visual */
  glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB |
                                        GDK_GL_MODE_DEPTH |
                                        GDK_GL_MODE_DOUBLE);
  if (glconfig == NULL)
    {
      g_print ("*** Cannot find the double-buffered visual.\n");
      g_print ("*** Trying single-buffered visual.\n");

      /* Try single-buffered visual */
      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB |
                                            GDK_GL_MODE_DEPTH);
      if (glconfig == NULL)
        {
          g_print ("*** No appropriate OpenGL-capable visual found.\n");
          exit (1);
        }
    }

  /*
   * GLX extensions.
   */

  if (!gdk_x11_gl_query_glx_extension (glconfig, "GLX_SGIX_fbconfig"))
    {
      g_print ("GLX_SGIX_fbconfig extension is not supported.\n");
      exit (1);
    }

  GetFBConfigFromVisualSGIX =
    (GLXFBConfigSGIX (APIENTRY *)(Display*, XVisualInfo*))
      gdk_gl_get_proc_address ("glXGetFBConfigFromVisualSGIX");

  if (!gdk_x11_gl_query_glx_extension (glconfig, "GLX_SGIX_pbuffer"))
    {
      g_print ("GLX_SGIX_pbuffer extension is not supported.\n");
      exit (1);
    }

  CreateGLXPbufferSGIX  =
    (GLXPbufferSGIX (APIENTRY *)(Display*, GLXFBConfigSGIX, unsigned int, unsigned int, int*))
      gdk_gl_get_proc_address ("glXCreateGLXPbufferSGIX");
  DestroyGLXPbufferSGIX =
    (void (APIENTRY *)(Display*, GLXPbufferSGIX))
      gdk_gl_get_proc_address ("glXDestroyGLXPbufferSGIX");

  /*
   * Top-level window.
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "simple");

  /* Get automatically redrawn if any of their children changed allocation. */
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

  g_signal_connect (G_OBJECT (window), "delete_event",
                    G_CALLBACK (gtk_main_quit), NULL);

  /*
   * VBox.
   */

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  /*
   * Drawing area for drawing OpenGL scene.
   */

  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, 200, 200);

  /* Set OpenGL-capability to the widget. */
  gtk_widget_set_gl_capability (drawing_area,
                                glconfig,
                                NULL,
                                TRUE,
                                GDK_GL_RGBA_TYPE);

  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_set_events (drawing_area,
                         GDK_EXPOSURE_MASK |
                         GDK_BUTTON_PRESS_MASK);

  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
                          G_CALLBACK (realize), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
		    G_CALLBACK (configure_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "draw",
		    G_CALLBACK (draw), NULL);

  gtk_widget_show (drawing_area);

  /*
   * Render button.
   */

  button = gtk_button_new_with_label ("Render to file");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (render_to_file), drawing_area);

  gtk_widget_show (button);

  /*
   * Simple quit button.
   */

  button = gtk_button_new_with_label ("Quit");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (gtk_main_quit), NULL);

  gtk_widget_show (button);

  /*
   * Show window.
   */

  gtk_widget_show (window);

  /*
   * Main loop.
   */

  gtk_main ();

  return 0;
}
Ejemplo n.º 6
0
G_MODULE_EXPORT gint
test_shader_main (gint argc, gchar *argv[])
{
  ClutterActor  *actor;
  ClutterActor  *stage;
  ClutterColor   stage_color = { 0x61, 0x64, 0x8c, 0xff };
  ClutterShader *shader;
  GError        *error;
  gchar         *file;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 512, 384);

  g_print ("applying shaders[%i] named '%s'\n",
           shader_no,
           shaders[shader_no].name);

  shader = clutter_shader_new ();

  error = NULL;
  clutter_shader_set_fragment_source (shader, shaders[shader_no].source, -1);
  clutter_shader_compile (shader, &error);
  if (error)
    {
      g_print ("unable to load shaders[%d] named '%s': %s\n",
               shader_no,
               shaders[shader_no].name,
               error->message);
      g_error_free (error);

      return EXIT_FAILURE;
    }

  clutter_stage_set_title (CLUTTER_STAGE (stage), "Shader Test");
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);

#ifndef TEST_GROUP
  actor = clutter_texture_new_from_file (file, &error);
  if (!actor)
    g_error("pixbuf load failed: %s", error ? error->message : "Unknown");
#else
  actor = clutter_group_new ();

  {
    ClutterActor *child1, *child2, *child3, *child4;
    ClutterColor  color = { 0xff, 0x22, 0x66, 0x99 };

    child1 = clutter_texture_new_from_file (file, &error);
    if (!child1)
      g_error("pixbuf load failed: %s", error ? error->message : "Unknown");

    child2 = clutter_texture_new_from_file (file, &error);
    if (!child2)
      g_error("pixbuf load failed: %s", error ? error->message : "Unknown");

    child3 = clutter_rectangle_new ();
    child4 = clutter_text_new_with_text ("Sans 20px", "Shady stuff");

    clutter_rectangle_set_color (CLUTTER_RECTANGLE (child3), &color);
    clutter_actor_set_size (child3, 50, 50);

    clutter_actor_set_position (child1, 0, 0);
    clutter_actor_set_position (child2, 50, 100);
    clutter_actor_set_position (child3, 30, -30);
    clutter_actor_set_position (child4, -50, 20);

    clutter_container_add (CLUTTER_CONTAINER (actor),
                           child1,
                           child2,
                           child3,
                           child4,
                           NULL);

    clutter_actor_show_all (actor);
  }
#endif /* !TEST_GROUP */

  g_free (file);

  clutter_actor_set_shader (actor, shader);
  clutter_actor_set_position (actor, 100, 100);

  g_object_unref (shader);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);

  clutter_actor_set_shader_param_int (actor, "tex", 0);
  clutter_actor_set_shader_param_float (actor, "brightness", 0.4);
  clutter_actor_set_shader_param_float (actor, "contrast", -1.9);

  clutter_actor_set_reactive (actor, TRUE);
  g_signal_connect (actor, "button-release-event",
                    G_CALLBACK (button_release_cb), NULL);

#ifdef COGL_HAS_GLES
  /* On an embedded platform it is difficult to right click so we will
     cycle through the shaders automatically */
  g_timeout_add_seconds (3, timeout_cb, actor);
#endif

  /* Show everying ( and map window ) */
  clutter_actor_show_all (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
Ejemplo n.º 7
0
Archivo: apps.c Proyecto: LEW21/glib
int
main (int argc, char **argv)
{
  setlocale (LC_ALL, "");

  if (argv[1] == NULL)
    ;
  else if (g_str_equal (argv[1], "list"))
    {
      GList *all, *i;

      all = g_app_info_get_all ();
      for (i = all; i; i = i->next)
        g_print ("%s%s", g_app_info_get_id (i->data), i->next ? " " : "\n");
      g_list_free_full (all, g_object_unref);
    }
  else if (g_str_equal (argv[1], "search"))
    {
      gchar ***results;
      gint i, j;

      results = g_desktop_app_info_search (argv[2]);
      for (i = 0; results[i]; i++)
        {
          for (j = 0; results[i][j]; j++)
            g_print ("%s%s", j ? " " : "", results[i][j]);
          g_print ("\n");
          g_strfreev (results[i]);
        }
      g_free (results);
    }
  else if (g_str_equal (argv[1], "implementations"))
    {
      GList *results;

      results = g_desktop_app_info_get_implementations (argv[2]);
      print_app_list (results);
    }
  else if (g_str_equal (argv[1], "show-info"))
    {
      GAppInfo *info;

      info = (GAppInfo *) g_desktop_app_info_new (argv[2]);
      if (info)
        {
          print (g_app_info_get_id (info));
          print (g_app_info_get_name (info));
          print (g_app_info_get_display_name (info));
          print (g_app_info_get_description (info));
          g_object_unref (info);
        }
    }
  else if (g_str_equal (argv[1], "default-for-type"))
    {
      GAppInfo *info;

      info = g_app_info_get_default_for_type (argv[2], FALSE);

      if (info)
        {
          print (g_app_info_get_id (info));
          g_object_unref (info);
        }
    }
  else if (g_str_equal (argv[1], "recommended-for-type"))
    {
      GList *list;

      list = g_app_info_get_recommended_for_type (argv[2]);
      print_app_list (list);
    }
  else if (g_str_equal (argv[1], "all-for-type"))
    {
      GList *list;

      list = g_app_info_get_all_for_type (argv[2]);
      print_app_list (list);
    }

  else if (g_str_equal (argv[1], "fallback-for-type"))
    {
      GList *list;

      list = g_app_info_get_fallback_for_type (argv[2]);
      print_app_list (list);
    }

  else if (g_str_equal (argv[1], "should-show"))
    {
      GAppInfo *info;

      info = (GAppInfo *) g_desktop_app_info_new (argv[2]);
      if (info)
        {
          g_print ("%s\n", g_app_info_should_show (info) ? "true" : "false");
          g_object_unref (info);
        }
    }

  return 0;
}
Ejemplo n.º 8
0
int
main(int   argc,
     char *argv[])
{
  GdkGLConfig *glconfig;
  gint major, minor;

  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *drawing_area;
  GtkWidget *menu;
  GtkWidget *button;

  int i;
  gboolean arg_count = FALSE;

  /*
   * Init GTK.
   */

  gtk_init (&argc, &argv);

  /*
   * Init GtkGLExt.
   */

  gtk_gl_init (&argc, &argv);

  /*
   * Parse arguments.
   */

  for (i = 1; i < argc; i++)
    {
      if (arg_count)
	rot_count = atoi (argv[i]);

      if (strcmp (argv[i], "--help") == 0 ||
	  strcmp (argv[i], "-h") == 0)
	{
	  g_print ("Usage: %s [--count num] [--no-anim] [--help]\n", argv[0]);
	  exit (0);
	}

      if (strcmp (argv[i], "--count") == 0)
	arg_count = TRUE;

      if (strcmp (argv[i], "--no-anim") == 0)
	animate = FALSE;
    }

  /*
   * Query OpenGL extension version.
   */

  gdk_gl_query_version (&major, &minor);
  g_print ("\nOpenGL extension version - %d.%d\n",
           major, minor);

  /*
   * Configure OpenGL-capable visual.
   */

  /* Try double-buffered visual */
  glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
					GDK_GL_MODE_DEPTH  |
					GDK_GL_MODE_DOUBLE);
  if (glconfig == NULL)
    {
      g_print ("*** Cannot find the double-buffered visual.\n");
      g_print ("*** Trying single-buffered visual.\n");

      /* Try single-buffered visual */
      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
					    GDK_GL_MODE_DEPTH);
      if (glconfig == NULL)
	{
	  g_print ("*** No appropriate OpenGL-capable visual found.\n");
	  exit (1);
	}
    }

  examine_gl_config_attrib (glconfig);

  /*
   * Top-level window.
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "logo");

  /* Get automatically redrawn if any of their children changed allocation. */
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (gtk_main_quit), NULL);

  /*
   * VBox.
   */

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  /*
   * Drawing area for drawing OpenGL scene.
   */

  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, 300, 300);

  /* Set OpenGL-capability to the widget. */
  gtk_widget_set_gl_capability (drawing_area,
				glconfig,
				NULL,
				TRUE,
				GDK_GL_RGBA_TYPE);

  gtk_widget_add_events (drawing_area,
			 GDK_BUTTON1_MOTION_MASK    |
			 GDK_BUTTON2_MOTION_MASK    |
			 GDK_BUTTON_PRESS_MASK      |
			 GDK_VISIBILITY_NOTIFY_MASK);

  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
                          G_CALLBACK (realize), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
		    G_CALLBACK (configure_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "expose_event",
		    G_CALLBACK (expose_event), NULL);

  g_signal_connect (G_OBJECT (drawing_area), "button_press_event",
		    G_CALLBACK (button_press_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "motion_notify_event",
		    G_CALLBACK (motion_notify_event), NULL);

  g_signal_connect (G_OBJECT (drawing_area), "map_event",
		    G_CALLBACK (map_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "unmap_event",
		    G_CALLBACK (unmap_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "visibility_notify_event",
		    G_CALLBACK (visibility_notify_event), NULL);

  g_signal_connect_swapped (G_OBJECT (window), "key_press_event",
			    G_CALLBACK (key_press_event), drawing_area);

  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_show (drawing_area);

  /*
   * Popup menu.
   */

  menu = create_popup_menu (drawing_area);

  /* Signal handler */
  g_signal_connect_swapped (G_OBJECT (drawing_area), "button_press_event",
                            G_CALLBACK (button_press_event_popup_menu), menu);

  /*
   * Simple quit button.
   */

  button = gtk_button_new_with_label ("Quit");

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (gtk_main_quit), NULL);

  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  gtk_widget_show (button);

  /*
   * Show window.
   */

  gtk_widget_show (window);

  /*
   * Main loop.
   */

  gtk_main ();

  return 0;
}
Ejemplo n.º 9
0
static void
embedded_changed_cb (GtkStatusIcon *icon)
{
  g_print ("status icon %p embedded changed to %d\n", icon,
	   gtk_status_icon_is_embedded (icon));
}
/* Extract some metadata from the streams and print it on the screen */
static void analyze_streams (CustomData *data) {
  gint i;
  GstTagList *tags;
  gchar *str;
  guint rate;
  
  /* Read some properties */
  g_object_get (data->playbin2, "n-video", &data->n_video, NULL);
  g_object_get (data->playbin2, "n-audio", &data->n_audio, NULL);
  g_object_get (data->playbin2, "n-text", &data->n_text, NULL);
  
  g_print ("%d video stream(s), %d audio stream(s), %d text stream(s)\n",
    data->n_video, data->n_audio, data->n_text);
  
  g_print ("\n");
  for (i = 0; i < data->n_video; i++) {
    tags = NULL;
    /* Retrieve the stream's video tags */
    g_signal_emit_by_name (data->playbin2, "get-video-tags", i, &tags);
    if (tags) {
      g_print ("video stream %d:\n", i);
      gst_tag_list_get_string (tags, GST_TAG_VIDEO_CODEC, &str);
      g_print ("  codec: %s\n", str ? str : "unknown");
      g_free (str);
      gst_tag_list_free (tags);
    }
  }
  
  g_print ("\n");
  for (i = 0; i < data->n_audio; i++) {
    tags = NULL;
    /* Retrieve the stream's audio tags */
    g_signal_emit_by_name (data->playbin2, "get-audio-tags", i, &tags);
    if (tags) {
      g_print ("audio stream %d:\n", i);
      if (gst_tag_list_get_string (tags, GST_TAG_AUDIO_CODEC, &str)) {
        g_print ("  codec: %s\n", str);
        g_free (str);
      }
      if (gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &str)) {
        g_print ("  language: %s\n", str);
        g_free (str);
      }
      if (gst_tag_list_get_uint (tags, GST_TAG_BITRATE, &rate)) {
        g_print ("  bitrate: %d\n", rate);
      }
      gst_tag_list_free (tags);
    }
  }
  
  g_print ("\n");
  for (i = 0; i < data->n_text; i++) {
    tags = NULL;
    /* Retrieve the stream's subtitle tags */
    g_print ("subtitle stream %d:\n", i);
    g_signal_emit_by_name (data->playbin2, "get-text-tags", i, &tags);
    if (tags) {
      if (gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &str)) {
        g_print ("  language: %s\n", str);
        g_free (str);
      }
      gst_tag_list_free (tags);
    } else {
      g_print ("  no tags found\n");
    }
  }
  
  g_object_get (data->playbin2, "current-video", &data->current_video, NULL);
  g_object_get (data->playbin2, "current-audio", &data->current_audio, NULL);
  g_object_get (data->playbin2, "current-text", &data->current_text, NULL);
  
  g_print ("\n");
  g_print ("Currently playing video stream %d, audio stream %d and subtitle stream %d\n",
      data->current_video, data->current_audio, data->current_text);
  g_print ("Type any number and hit ENTER to select a different subtitle stream\n");
}
Ejemplo n.º 11
0
static gboolean
piece_button_press (GooCanvasItem *item,
		    GooCanvasItem *target,
		    GdkEventButton *event,
		    gpointer data)
{
        GooCanvas *canvas;
	GooCanvasItem **board;
	GooCanvasItem *text G_GNUC_UNUSED;
	int num G_GNUC_UNUSED, pos, newpos;
	int x, y;
	double dx = 0.0, dy = 0.0;
	int move;

	canvas = goo_canvas_item_get_canvas (item);
	board = g_object_get_data (G_OBJECT (canvas), "board");
	num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "piece_num"));
	pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "piece_pos"));
	text = g_object_get_data (G_OBJECT (item), "text");

#if 0
	g_print ("In piece_event pos: %i,%i num: %i\n", pos % 4, pos / 4,
		 num + 1);
#endif

	y = pos / 4;
	x = pos % 4;

	move = TRUE;

	if ((y > 0) && (board[(y - 1) * 4 + x] == NULL)) {
	  dx = 0.0;
	  dy = -1.0;
	  y--;
	} else if ((y < 3) && (board[(y + 1) * 4 + x] == NULL)) {
	  dx = 0.0;
	  dy = 1.0;
	  y++;
	} else if ((x > 0) && (board[y * 4 + x - 1] == NULL)) {
	  dx = -1.0;
	  dy = 0.0;
	  x--;
	} else if ((x < 3) && (board[y * 4 + x + 1] == NULL)) {
	  dx = 1.0;
	  dy = 0.0;
	  x++;
	} else
	  move = FALSE;

	if (move) {
	  newpos = y * 4 + x;
	  board[pos] = NULL;
	  board[newpos] = item;
	  g_object_set_data (G_OBJECT (item), "piece_pos", GINT_TO_POINTER (newpos));
	  goo_canvas_item_translate (item, dx * PIECE_SIZE,
				     dy * PIECE_SIZE);
	  test_win (board);
	}

	return FALSE;
}
Ejemplo n.º 12
0
static gint remmina_on_command_line(GApplication *app, GApplicationCommandLine *cmdline)
{
	gint status = 0;
	gint argc;
	gchar **argv;
	GError *error = NULL;
	GOptionContext *context;
	gboolean parsed;
	gchar *s;
	gboolean executed = FALSE;

	remmina_option_about = FALSE;
	remmina_option_connect = NULL;
	remmina_option_edit = NULL;
	remmina_option_help = FALSE;
	remmina_option_new = FALSE;
	remmina_option_pref = NULL;
	remmina_option_plugin = NULL;
	remmina_option_server = NULL;
	remmina_option_protocol = NULL;
	remmina_option_icon = FALSE;

	argv = g_application_command_line_get_arguments(cmdline, &argc);

	context = g_option_context_new("- The GTK+ Remote Desktop Client");
	g_option_context_add_main_entries(context, remmina_options, GETTEXT_PACKAGE);
	g_option_context_set_help_enabled(context, FALSE);
	parsed = g_option_context_parse(context, &argc, &argv, &error);
	g_strfreev(argv);

	if (!parsed)
	{
		g_print("option parsing failed: %s\n", error->message);
		status = 1;
	}

	if (remmina_option_quit)
	{
		gtk_main_quit();
		status = 1;
	}

	if (remmina_option_about)
	{
		remmina_exec_command(REMMINA_COMMAND_ABOUT, NULL);
		executed = TRUE;
	}
	if (remmina_option_connect)
	{
		remmina_exec_command(REMMINA_COMMAND_CONNECT, remmina_option_connect);
		executed = TRUE;
	}
	if (remmina_option_edit)
	{
		remmina_exec_command(REMMINA_COMMAND_EDIT, remmina_option_edit);
		executed = TRUE;
	}
	if (remmina_option_help)
	{
		s = g_option_context_get_help(context, TRUE, NULL);
		g_print("%s", s);
		g_free(s);
		status = 1;
	}
	if (remmina_option_new)
	{
		if (remmina_option_server)
		{
			s = g_strdup_printf("%s,%s", remmina_option_protocol, remmina_option_server);
		}
		else
		{
			s = g_strdup(remmina_option_protocol);
		}
		remmina_exec_command(REMMINA_COMMAND_NEW, s);
		g_free(s);
		executed = TRUE;
	}
	if (remmina_option_pref)
	{
		remmina_exec_command(REMMINA_COMMAND_PREF, remmina_option_pref);
		executed = TRUE;
	}
	if (remmina_option_plugin)
	{
		remmina_exec_command(REMMINA_COMMAND_PLUGIN, remmina_option_plugin);
		executed = TRUE;
	}
	if (remmina_option_icon)
	{
		remmina_exec_command(REMMINA_COMMAND_NONE, remmina_option_icon);
		executed = TRUE;
	}
	if (!executed)
	{
		remmina_exec_command(REMMINA_COMMAND_MAIN, NULL);
	}

	g_option_context_free(context);

	return status;
}
Ejemplo n.º 13
0
static void dnd_drag_data_recieved_handler(GtkWidget *widget,
	GdkDragContext *context, gint x, gint y,
	GtkSelectionData *selection_data, guint info, guint time)
{
	static gboolean flag_called_once = FALSE;
	gchar **files;
	gchar *filename;
	gchar *comline;
	gint i = 0, j = 0;
	gchar *filename_sh;
	gchar **strs;
#ifdef ENABLE_CSDI
	j = 1;
#endif
DV(g_print("DND start!\n"));
	
#if GTK_CHECK_VERSION(2, 10, 0)
	if (g_strcasecmp(gdk_atom_name(context->targets->data),
	    "GTK_TEXT_BUFFER_CONTENTS") != 0) {
#else
	if (info != TARGET_SELF) {
#endif
		if (flag_called_once) {
			flag_called_once = FALSE;
			g_signal_stop_emission_by_name(widget, "drag_data_received");
DV(g_print("second drop signal killed.\n"));
			return;
		} else
			flag_called_once = TRUE;
	}
	
DV({	
	g_print("info                      = %d\n", info);
	g_print("time                      = %d\n", time);
	g_print("context->protocol         = %d\n", context->protocol);
	g_print("context->is_source        = %d\n", context->is_source);
	g_print("context->targets          = %d\n", g_list_length(context->targets));
	g_print("context->target           = %s\n", gdk_atom_name(context->targets->data));
/*	g_print("context->target           = %s\n", gdk_atom_name(context->targets->next->data));
	g_print("context->target           = %s\n", gdk_atom_name(context->targets->next->next->data));
	g_print("context->actions          = %d\n", context->actions);
	g_print("context->suggested_action = %d\n", context->suggested_action);
	g_print("context->action           = %d\n", context->action);
	g_print("selection_data->selection = %s\n", gdk_atom_name(selection_data->selection));
	g_print("selection_data->target    = %s\n", gdk_atom_name(selection_data->target));
*/	g_print("selection_data->type      = %s\n", gdk_atom_name(selection_data->type));
	g_print("selection_data->format    = %d\n", selection_data->format);
	g_print("selection_data->length    = %d\n", selection_data->length);
	g_print("%s\n", selection_data->data);
});	
	
	if (selection_data->data && info == TARGET_URI_LIST) {
		files = g_strsplit((gchar *)selection_data->data, "\n" , -1);
		while (files[i]) {
			if (strlen(files[i]) == 0)
				break;
			filename = g_strstrip(parse_file_uri(files[i]));
			if (i + j == 0)
				dnd_open_first_file(filename);
			else {
				if (i + j == 1)
					save_config_file();
				if (strstr(filename, " ")) {
					strs = g_strsplit(filename, " ", -1);
					filename_sh = g_strjoinv("\\ ", strs);
					g_strfreev(strs);
				} else
					filename_sh = g_strdup(filename);
				comline = g_strdup_printf("%s %s", PACKAGE, filename_sh);
DV(g_print(">%s\n", comline));
				g_free(filename_sh);
				g_spawn_command_line_async(comline, NULL);
				g_free(comline);
			}
			g_free(filename);
			i++;
		}
		g_strfreev(files);
	}
	else {
		clear_current_keyval();
		undo_set_sequency(FALSE);
#if GTK_CHECK_VERSION(2, 10, 0)
		if (info == TARGET_UTF8_STRING) {
#else
		if (info == TARGET_SELF) {
#endif
			undo_set_sequency_reserve();
			context->action = GDK_ACTION_MOVE;
		} else if (info == TARGET_PLAIN 
			&& g_utf8_validate((gchar *)selection_data->data, -1, NULL)) {
			selection_data->type =
				gdk_atom_intern("UTF8_STRING", FALSE);
		}
	}
	
	return;
}

static gboolean dnd_drag_motion_handler(GtkWidget *widget,
	GdkDragContext *context, gint x, gint y, guint time)
{
	GList *targets;
	gchar *name;
	gboolean flag = FALSE;
	
	targets = context->targets;
	while (targets) {
		name = gdk_atom_name(targets->data);
DV(g_print("%s\n", name));
		if (g_ascii_strcasecmp(name, "text/uri-list") == 0)
			flag = TRUE;
		g_free(name);
		targets = targets->next;
	}
/*	if (flag)
		context->action = GDK_ACTION_DEFAULT;
	else
		context->action = GDK_ACTION_COPY;
//	g_signal_stop_emission_by_name(widget, "drag_motion");
*/	
/*	if (!flag) {
		gint bx, by;
		GtkTextIter iter;
		
		gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget),
			GTK_TEXT_WINDOW_WIDGET,
			x, y, &bx, &by);
		gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &iter, bx, by);
		if (!dnd_mark) {
			dnd_mark = gtk_text_buffer_create_mark(GTK_TEXT_VIEW(widget)->buffer,
			    NULL, &iter, TRUE);
			gtk_text_mark_set_visible(dnd_mark, TRUE);
		} else
			gtk_text_mark_set_visible(dnd_mark, FALSE);
			gtk_text_buffer_move_mark(GTK_TEXT_VIEW(widget)->buffer,
			    dnd_mark, &iter);
			gtk_text_mark_set_visible(dnd_mark, TRUE);
	}
*/	
	return flag;
}
Ejemplo n.º 14
0
static void
dump_text (const char *text)
{
  int len;
  PangoLogAttr *attrs;
  int i;
  gunichar *ucs4;

  if (!g_utf8_validate (text, -1, NULL))
    fail ("Invalid UTF-8 in file");

  len = g_utf8_strlen (text, -1);
  attrs = g_new0 (PangoLogAttr, len + 1);

  pango_get_log_attrs (text,
		       -1,
		       0,
		       pango_language_from_string ("C"),
		       attrs,
		       len + 1);

  ucs4 = g_utf8_to_ucs4 (text, -1, NULL, NULL, NULL);

  i = 0;
  while (i <= len)
    {
      char buf[7] = { '\0', };
      char *loc;

      g_unichar_to_utf8 (ucs4[i], buf);

      if (*buf == '\n')
	loc = g_strdup ("\\n");
      else if (*buf == '\r')
	loc = g_strdup ("\\r");
      else
	loc = g_locale_from_utf8 (buf, -1, NULL, NULL, NULL);

      g_print (CHFORMAT " (%s):\t line_break = %d mandatory_break = %d char_break = %d\n"
	       "     \t\t white = %d cursor_position = %d\n"
	       "     \t\t word_start = %d word_end = %d\n"
	       "     \t\t sentence_boundary = %d sentence_start = %d sentence_end = %d\n",
	       ucs4[i], loc ? loc : "?",
	       attrs[i].is_line_break,
	       attrs[i].is_mandatory_break,
	       attrs[i].is_char_break,
	       attrs[i].is_white,
	       attrs[i].is_cursor_position,
	       attrs[i].is_word_start,
	       attrs[i].is_word_end,
	       attrs[i].is_sentence_boundary,
	       attrs[i].is_sentence_start,
	       attrs[i].is_sentence_end);

      g_free (loc);

      ++i;
    }

  g_free (ucs4);
  g_free (attrs);
}
Ejemplo n.º 15
0
Archivo: main.c Proyecto: CM44/codelite
/* This is a callback function. The data arguments are ignored
 * in this example. More on callbacks below. */
static void hello( GtkWidget *widget,
                   gpointer   data )
{
    g_print ("Hello World\n");
}
Ejemplo n.º 16
0
static void
screen_changed_cb (GtkStatusIcon *icon)
{
  g_print ("status icon %p screen changed to %p\n", icon,
	   gtk_status_icon_get_screen (icon));
}
Ejemplo n.º 17
0
static void
set_shader_num (ClutterActor *actor, gint new_no)
{
  int  tex_width;
  int  tex_height;

  if (new_no >= 0 && shaders[new_no].name)
    {
      ClutterShader *shader;
      GError *error;
      shader_no = new_no;
      
      g_print ("setting shaders[%i] named '%s'\n",
               shader_no,
               shaders[shader_no].name);

      shader = clutter_shader_new ();
      
      error = NULL;
      g_object_set (G_OBJECT (shader),
                    "fragment-source", shaders[shader_no].source,
                    NULL);

      /* try to bind the shader, provoking an error we catch if there is issues
       * with the shader sources we've provided. At a later stage it should be
       * possible to iterate through a set of alternate shader sources (glsl ->
       * asm -> cg?) and the one that succesfully compiles is used.
       */
      clutter_shader_compile (shader, &error);
      if (error)
        {
          g_print ("unable to set shaders[%i] named '%s': %s",
                   shader_no, shaders[shader_no].name,
                   error->message);
          g_error_free (error);
          clutter_actor_set_shader (actor, NULL);
        }
      else
        {
          clutter_actor_set_shader (actor, NULL);
          clutter_actor_set_shader (actor, shader);
          clutter_actor_set_shader_param_int (actor, "tex", 0);
          clutter_actor_set_shader_param_float (actor, "radius", 3.0);
          clutter_actor_set_shader_param_float (actor, "brightness", 0.4);
          clutter_actor_set_shader_param_float (actor, "contrast", -1.9);

	  if (CLUTTER_IS_TEXTURE (actor))
	    {
              /* XXX - this assumes *a lot* about how things are done
               * internally on *some* hardware and driver
               */
	      tex_width = clutter_actor_get_width (actor);
	      tex_width = next_p2 (tex_width);

	      tex_height = clutter_actor_get_height (actor);
	      tex_height = next_p2 (tex_height);

	      clutter_actor_set_shader_param_float (actor, "x_step",
					            1.0f / tex_width);
	      clutter_actor_set_shader_param_float (actor, "y_step",
					            1.0f / tex_height);
  	    }
        }

      g_object_unref (shader);
    }
}
Ejemplo n.º 18
0
/*
** set widgets contents from the selected account
*/
static void defarchive_set(GtkWidget *widget, gpointer user_data)
{
struct defarchive_data *data;
GtkTreeSelection *selection;
GtkTreeModel		 *model;
GtkTreeIter			 iter;

Archive *item;

	DB( g_printf("(defarchive) set\n") );

	data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_arc));
	//if true there is a selected node
	if (gtk_tree_selection_get_selected(selection, &model, &iter))
	{
		gtk_tree_model_get(model, &iter, LST_DEFARC_DATAS, &item, -1);


		gtk_entry_set_text(GTK_ENTRY(data->ST_word), item->wording);

		gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->ST_amount), item->amount);

		g_signal_handler_block(data->CM_valid, data->handler_id[HID_VALID]);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_valid), (item->flags & OF_VALID) ? 1 : 0);
		g_signal_handler_unblock(data->CM_valid, data->handler_id[HID_VALID]);
		
		g_signal_handler_block(data->CM_remind, data->handler_id[HID_REMIND]);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_remind), (item->flags & OF_REMIND) ? 1 : 0);
		g_signal_handler_unblock(data->CM_remind, data->handler_id[HID_REMIND]);
	
		gtk_combo_box_set_active(GTK_COMBO_BOX(data->NU_mode), item->paymode);

		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_cheque), (item->flags & OF_CHEQ2) ? 1 : 0);

		ui_cat_comboboxentry_set_active(GTK_COMBO_BOX_ENTRY(data->PO_grp), item->category);

	DB( g_print(" -> set payee %d\n", item->payee) );
		ui_pay_comboboxentry_set_active(GTK_COMBO_BOX_ENTRY(data->PO_pay), item->payee);

	DB( g_print(" -> PO_acc %d\n", item->account) );
		ui_acc_comboboxentry_set_active(GTK_COMBO_BOX_ENTRY(data->PO_acc), item->account);

	DB( g_print(" -> PO_accto %d\n", item->dst_account) );
		ui_acc_comboboxentry_set_active(GTK_COMBO_BOX_ENTRY(data->PO_accto), item->dst_account);

		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_auto), (item->flags & OF_AUTO) ? 1 : 0);

		gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_every), item->every);

		gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_unit), item->unit);

		gtk_dateentry_set_date(GTK_DATE_ENTRY(data->PO_next), item->nextdate);

		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_limit), (item->flags & OF_LIMIT) ? 1 : 0);

		gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_limit), item->limit);

	}

}
Ejemplo n.º 19
0
void
jack_shutdown (void *arg)
{
	g_print( "jack exited :(\n" );
}
Ejemplo n.º 20
0
/*
** get widgets contents to the selected account
*/
static void defarchive_getlast(struct defarchive_data *data)
{
gchar *txt;
gboolean bool;
gdouble value;
gint active;
Archive *item;

	DB( g_print("(defarchive) getlast\n") );

	item = data->lastarcitem;
	
	if( item != NULL )
	{
		DB( g_print(" -> %s\n", item->wording) );

		txt = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_word));
		// ignore if entry is empty
		if (txt && *txt)
		{
			g_free(item->wording);
			item->wording = g_strdup(txt);
		}

		gtk_tree_view_columns_autosize (GTK_TREE_VIEW(data->LV_arc));

		value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->ST_amount));
		item->amount = value;

		item->flags = 0;

		active = item->amount > 0 ? TRUE : FALSE;
		//active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_amount));
		if(active == 1) item->flags |= OF_INCOME;

		bool = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_cheque));
		if(bool) item->flags |= OF_CHEQ2;

		bool = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_valid));
		if(bool) item->flags |= OF_VALID;

		bool = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_remind));
		if(bool == 1) item->flags |= OF_REMIND;

		item->paymode		= gtk_combo_box_get_active(GTK_COMBO_BOX(data->NU_mode));
		item->category		= ui_cat_comboboxentry_get_key_add_new(GTK_COMBO_BOX_ENTRY(data->PO_grp));
		item->payee			= ui_pay_comboboxentry_get_key_add_new(GTK_COMBO_BOX_ENTRY(data->PO_pay));
		item->account		= ui_acc_comboboxentry_get_key(GTK_COMBO_BOX_ENTRY(data->PO_acc));
		item->dst_account	= ui_acc_comboboxentry_get_key(GTK_COMBO_BOX_ENTRY(data->PO_accto));

		DB( g_print(" -> PO_acc %d\n", item->account) );
		DB( g_print(" -> PO_accto %d\n", item->dst_account) );

		bool = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_auto));
		if(bool) item->flags |= OF_AUTO;

		item->every   = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_every));
		item->unit    = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_unit));
		item->nextdate	= gtk_dateentry_get_date(GTK_DATE_ENTRY(data->PO_next));

		bool = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_limit));
		if(bool) item->flags |= OF_LIMIT;

		item->limit   = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_limit));

		data->change++;
	}
Ejemplo n.º 21
0
Archivo: apps.c Proyecto: LEW21/glib
static void
print (const gchar *str)
{
  g_print ("%s\n", str ? str : "nil");
}
Ejemplo n.º 22
0
static void
gdaui_entry_wrapper_set_attributes (GdauiDataEntry *iface, GdaValueAttribute attrs, guint mask)
{
	GdauiEntryWrapper *wrapper;
	gboolean do_signal = FALSE;

	g_return_if_fail (GDAUI_IS_ENTRY_WRAPPER (iface));
	wrapper = (GdauiEntryWrapper*) iface;
	check_correct_init (wrapper);

#ifdef DEBUG
	g_print ("%s (%p): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", __FUNCTION__, iface,
		 (mask & GDA_VALUE_ATTR_IS_NULL) ? "IS_NULL:" : "",
		 (mask & GDA_VALUE_ATTR_IS_NULL) ? ((attrs & GDA_VALUE_ATTR_IS_NULL) ? "X" : ".") : "",
		 (mask & GDA_VALUE_ATTR_CAN_BE_NULL) ? "CAN_BE_NULL:" : "",
		 (mask & GDA_VALUE_ATTR_CAN_BE_NULL) ? ((attrs & GDA_VALUE_ATTR_CAN_BE_NULL) ? "X" : ".") : "",
		 (mask & GDA_VALUE_ATTR_IS_DEFAULT) ? "IS_DEFAULT:" : "",
		 (mask & GDA_VALUE_ATTR_IS_DEFAULT) ? ((attrs & GDA_VALUE_ATTR_IS_DEFAULT) ? "X" : ".") : "",
		 (mask & GDA_VALUE_ATTR_CAN_BE_DEFAULT) ? "CAN_BE_DEFAULT:" : "",
		 (mask & GDA_VALUE_ATTR_CAN_BE_DEFAULT) ? ((attrs & GDA_VALUE_ATTR_CAN_BE_DEFAULT) ? "X" : ".") : "",
		 (mask & GDA_VALUE_ATTR_IS_UNCHANGED) ? "IS_UNCHANGED:" : "",
		 (mask & GDA_VALUE_ATTR_IS_UNCHANGED) ? ((attrs & GDA_VALUE_ATTR_IS_UNCHANGED) ? "X" : ".") : "",
		 (mask & GDA_VALUE_ATTR_DATA_NON_VALID) ? "NON_VALID:" : "",
		 (mask & GDA_VALUE_ATTR_DATA_NON_VALID) ? ((attrs & GDA_VALUE_ATTR_DATA_NON_VALID) ? "X" : ".") : "",
		 (mask & GDA_VALUE_ATTR_READ_ONLY) ? "READ_ONLY:" : "",
		 (mask & GDA_VALUE_ATTR_READ_ONLY) ? ((attrs & GDA_VALUE_ATTR_READ_ONLY) ? "X" : ".") : "",
		 (mask & GDA_VALUE_ATTR_HAS_VALUE_ORIG) ? "HAS_VALUE_ORIG:" : "",
		 (mask & GDA_VALUE_ATTR_HAS_VALUE_ORIG) ? ((attrs & GDA_VALUE_ATTR_HAS_VALUE_ORIG) ? "X" : ".") : "");
#endif

	/* Can be NULL ? */
	if (mask & GDA_VALUE_ATTR_CAN_BE_NULL)
		wrapper->priv->null_possible = (attrs & GDA_VALUE_ATTR_CAN_BE_NULL) ? TRUE : FALSE;

	/* Can be DEFAULT ? */
	if (mask & GDA_VALUE_ATTR_CAN_BE_DEFAULT)
		wrapper->priv->default_possible = (attrs & GDA_VALUE_ATTR_CAN_BE_DEFAULT) ? TRUE : FALSE;

	/* Setting to NULL */
	if (mask & GDA_VALUE_ATTR_IS_NULL) {
		if (attrs & GDA_VALUE_ATTR_IS_NULL) {
			block_signals (wrapper);
			gdaui_entry_wrapper_set_value (iface, NULL);
			unblock_signals (wrapper);
			wrapper->priv->null_forced = TRUE;

			/* if default is set, see if we can keep it that way */
			if (wrapper->priv->default_forced &&
			    (G_VALUE_TYPE (wrapper->priv->value_default) != GDA_TYPE_NULL))
					wrapper->priv->default_forced = FALSE;
		}
		else
			wrapper->priv->null_forced = FALSE;
		do_signal = TRUE;
	}

	/* Setting to DEFAULT */
	if (mask & GDA_VALUE_ATTR_IS_DEFAULT) {
		if (attrs & GDA_VALUE_ATTR_IS_DEFAULT) {
			if (! wrapper->priv->default_possible) {
				g_warning ("Data entry does not have a default value");
				wrapper->priv->default_forced = FALSE;
			}
			else {
				block_signals (wrapper);
				if (wrapper->priv->value_default) {
					if (G_VALUE_TYPE (wrapper->priv->value_default) == wrapper->priv->type)
						gdaui_entry_wrapper_set_value (iface, wrapper->priv->value_default);
					else
						(*wrapper->priv->real_class->real_set_value) (wrapper, NULL);
				}
				else
					gdaui_entry_wrapper_set_value (iface, NULL);
				unblock_signals (wrapper);

				/* if NULL is set, see if we can keep it that way */
				if (wrapper->priv->null_forced &&
				    (G_VALUE_TYPE (wrapper->priv->value_default) != GDA_TYPE_NULL))
					wrapper->priv->null_forced = FALSE;
				wrapper->priv->default_forced = TRUE;
			}
		}
		else
			wrapper->priv->default_forced = FALSE;

		do_signal = TRUE;
	}

	/* Reset value to original */
	if (mask & GDA_VALUE_ATTR_IS_UNCHANGED) {
		if (attrs & GDA_VALUE_ATTR_IS_UNCHANGED) {
			wrapper->priv->default_forced = FALSE;
			block_signals (wrapper);
			gdaui_entry_wrapper_set_value (iface, wrapper->priv->value_ref);
			unblock_signals (wrapper);
			do_signal = TRUE;
		}
	}

	/* invalid data */
	if (mask & GDA_VALUE_ATTR_DATA_NON_VALID)
		wrapper->priv->invalid = attrs & GDA_VALUE_ATTR_DATA_NON_VALID;

	/* editable */
	if (mask & GDA_VALUE_ATTR_READ_ONLY)
		gdaui_entry_wrapper_set_editable (GDAUI_DATA_ENTRY (wrapper), attrs & GDA_VALUE_ATTR_READ_ONLY);

	/* NON WRITABLE attributes */
	if (mask & GDA_VALUE_ATTR_HAS_VALUE_ORIG)
		g_warning ("Use gdaui_entry_wrapper_set_value_default() instead of GDA_VALUE_ATTR_HAS_VALUE_ORIG");

	_gdaui_entry_shell_attrs_changed (GDAUI_ENTRY_SHELL (wrapper),
					  gdaui_data_entry_get_attributes (GDAUI_DATA_ENTRY (wrapper)));

	if (do_signal) {
		wrapper->priv->contents_has_changed = FALSE;
		gdaui_entry_wrapper_emit_signal (wrapper);
	}
	g_signal_emit_by_name (G_OBJECT (wrapper), "status-changed");
}
Ejemplo n.º 23
0
static void
render_to_file (GtkButton *button,
                GtkWidget *widget)
{
  GtkAllocation allocation;
  GdkGLConfig *glconfig;
  Display *xdisplay;
  XVisualInfo *xvinfo;
  GLXFBConfigSGIX fbconfig;

  GLXPbufferSGIX pbuffer;
  int pb_attrib_list[] = {
    GLX_LARGEST_PBUFFER_SGIX, True,
    GLX_PRESERVED_CONTENTS_SGIX, False,
    None
  };
  int width, height;

  GdkGLContext *glcontext;
  GLXContext glxcontext;

  g_print ("Render to PPM file...\n");

  glconfig = gtk_widget_get_gl_config (widget);
  xdisplay = gdk_x11_gl_config_get_xdisplay (glconfig);
  xvinfo = gdk_x11_gl_config_get_xvinfo (glconfig);

  /*
   * Get FBConfig.
   */

  g_print ("- get FBConfig\n");
  fbconfig = GetFBConfigFromVisualSGIX (xdisplay, xvinfo);
  if (!fbconfig)
    {
      g_print ("cannot get FBConfig\n");
      return;
    }

  /*
   * Create GLXPbuffer.
   */

  gtk_widget_get_allocation (widget, &allocation);
  width = allocation.width;
  height = allocation.height;

  g_print ("- create GLXPbuffer\n");
  pbuffer = CreateGLXPbufferSGIX (xdisplay, fbconfig,
                                  width, height,
                                  pb_attrib_list);
  if (!pbuffer)
    {
      g_print ("cannot create GLXPbuffer\n");
      return;
    }

  /*
   * Render.
   */

  glcontext = gtk_widget_get_gl_context (widget);
  glxcontext = gdk_x11_gl_context_get_glxcontext (glcontext);

  glXMakeCurrent (xdisplay, pbuffer, glxcontext);

  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glCallList (1);

  glFlush ();

  /*
   * Write to file.
   */

  write_file ("simple-pbuffer-sgix.ppm", width, height);

  /*
   * Destroy GLXPbuffer.
   */

  glXMakeCurrent (xdisplay, None, NULL);

  g_print ("- destroy GLXPbuffer\n");
  DestroyGLXPbufferSGIX (xdisplay, pbuffer);

  g_print ("Done.\n\n");
}
Ejemplo n.º 24
0
static GdaValueAttribute
gdaui_entry_wrapper_get_attributes (GdauiDataEntry *iface)
{
	GdaValueAttribute retval = 0;
	GdauiEntryWrapper *wrapper;
	GValue *value = NULL;

	g_return_val_if_fail (GDAUI_IS_ENTRY_WRAPPER (iface), 0);
	wrapper = (GdauiEntryWrapper*) iface;

	check_correct_init (wrapper);

	gboolean specific_impl = TRUE;
	if (!wrapper->priv->real_class->value_is_equal_to ||
	    !wrapper->priv->real_class->value_is_null) {
		value = gdaui_entry_wrapper_get_value (iface); /* @value may NOT be @NULL ! */
		g_assert (value);
		specific_impl = FALSE;
	}

	/* can be NULL? */
	if (wrapper->priv->null_possible)
		retval |= GDA_VALUE_ATTR_CAN_BE_NULL;

	/* can be default? */
	if (wrapper->priv->default_possible)
		retval |= GDA_VALUE_ATTR_CAN_BE_DEFAULT;

	/* NULL? */
	gboolean value_is_null = FALSE;
	if (specific_impl) {
		if ((wrapper->priv->real_class->value_is_null) (wrapper))
			value_is_null = TRUE;
	}
	else {
		if (G_VALUE_TYPE (value) == GDA_TYPE_NULL) {
			if (wrapper->priv->default_forced) {
				if (wrapper->priv->null_forced)
					value_is_null = TRUE;
			}
			else
				value_is_null = TRUE;
		}
	}
	if (value_is_null)
		retval |= GDA_VALUE_ATTR_IS_NULL;

	/* is default */
	if (wrapper->priv->default_forced)
		retval |= GDA_VALUE_ATTR_IS_DEFAULT;
	else {
		/* is unchanged */
		if (wrapper->priv->value_ref) {
			if (specific_impl) {
				if ((wrapper->priv->real_class->value_is_equal_to) (wrapper, wrapper->priv->value_ref))
					retval |= GDA_VALUE_ATTR_IS_UNCHANGED;
			}
			else if (G_VALUE_TYPE (value) == G_VALUE_TYPE (wrapper->priv->value_ref)) {
				if (! gda_value_differ (value, wrapper->priv->value_ref))
					retval |= GDA_VALUE_ATTR_IS_UNCHANGED;
			}
		}
	}

	/* data valid? */
	if (wrapper->priv->invalid ||
	    (value_is_null && !wrapper->priv->null_possible))
		retval |= GDA_VALUE_ATTR_DATA_NON_VALID;

	/* has original value? */
	if (wrapper->priv->value_ref)
		retval |= GDA_VALUE_ATTR_HAS_VALUE_ORIG;

	gda_value_free (value);

	/* editable ? */
	if (!wrapper->priv->editable)
		retval |= GDA_VALUE_ATTR_READ_ONLY;

#ifdef DEBUG
	g_print ("%s (%p): %s%s%s%s%s%s%s%s\n", __FUNCTION__, iface,
		 (retval & GDA_VALUE_ATTR_IS_NULL) ? "IS_NULL " : "        ",
		 (retval & GDA_VALUE_ATTR_CAN_BE_NULL) ? "CAN_BE_NULL " : "            ",
		 (retval & GDA_VALUE_ATTR_IS_DEFAULT) ? "IS_DEFAULT " : "           ",
		 (retval & GDA_VALUE_ATTR_CAN_BE_DEFAULT) ? "CAN_BE_DEFAULT " : "               ",
		 (retval & GDA_VALUE_ATTR_IS_UNCHANGED) ? "IS_UNCHANGED " : "             ",
		 (retval & GDA_VALUE_ATTR_DATA_NON_VALID) ? "NON_VALID " : "          ",
		 (retval & GDA_VALUE_ATTR_READ_ONLY) ? "READ_ONLY " : "          ",
		 (retval & GDA_VALUE_ATTR_HAS_VALUE_ORIG) ? "HAS_VALUE_ORIG " : "               ");
#endif
	return retval;
}
Ejemplo n.º 25
0
gint
main (gint argc, gchar ** argv)
{
  GstElement *pipeline;
  GstElement *shapewipe;
  GstController *ctrl;
  GstLFOControlSource *csource;
  GValue val = { 0, };
  GMainLoop *loop;
  GstBus *bus;
  gchar *pipeline_string;
  gfloat border = 0.05;

  if (argc < 2) {
    g_print ("Usage: shapewipe mask.png <border>\n");
    return -1;
  }

  gst_init (&argc, &argv);
  gst_controller_init (&argc, &argv);

  if (argc > 2) {
    border = atof (argv[2]);
  }

  pipeline_string =
      g_strdup_printf
      ("videotestsrc ! video/x-raw-yuv,format=(fourcc)AYUV,width=640,height=480 ! shapewipe name=shape border=%f ! videomixer name=mixer ! ffmpegcolorspace ! autovideosink     filesrc location=%s ! typefind ! decodebin2 ! ffmpegcolorspace ! videoscale ! queue ! shape.mask_sink    videotestsrc pattern=snow ! video/x-raw-yuv,format=(fourcc)AYUV,width=640,height=480 ! queue ! mixer.",
      border, argv[1]);

  pipeline = gst_parse_launch (pipeline_string, NULL);
  g_free (pipeline_string);

  if (pipeline == NULL) {
    g_print ("Failed to create pipeline\n");
    return -2;
  }

  shapewipe = gst_bin_get_by_name (GST_BIN (pipeline), "shape");

  if (!(ctrl = gst_controller_new (G_OBJECT (shapewipe), "position", NULL))) {
    g_print ("can't control shapewipe element\n");
    return -3;
  }

  csource = gst_lfo_control_source_new ();

  gst_controller_set_control_source (ctrl, "position",
      GST_CONTROL_SOURCE (csource));

  g_value_init (&val, G_TYPE_FLOAT);
  g_value_set_float (&val, 0.5);
  g_object_set (G_OBJECT (csource), "amplitude", &val, NULL);
  g_value_set_float (&val, 0.5);
  g_object_set (G_OBJECT (csource), "offset", &val, NULL);
  g_value_unset (&val);

  g_object_set (G_OBJECT (csource), "frequency", 0.25, NULL);
  g_object_set (G_OBJECT (csource), "timeshift", 500 * GST_MSECOND, NULL);

  g_object_unref (csource);

  loop = g_main_loop_new (NULL, FALSE);

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_signal_watch (bus);
  g_signal_connect (G_OBJECT (bus), "message", G_CALLBACK (on_message), loop);
  gst_object_unref (GST_OBJECT (bus));

  if (gst_element_set_state (pipeline,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
    g_error ("Failed to go into PLAYING state");
    return -4;
  }

  g_main_loop_run (loop);

  gst_element_set_state (pipeline, GST_STATE_NULL);

  g_main_loop_unref (loop);

  g_object_unref (G_OBJECT (ctrl));
  gst_object_unref (G_OBJECT (pipeline));

  return 0;
}
Ejemplo n.º 26
0
Archivo: dbus.c Proyecto: Toqozz/yarn-c
static void
onNotify(GDBusConnection *connection,
         const gchar *sender,
         GVariant *parameters,
         GDBusMethodInvocation *invocation)
{
    gchar *app_name = NULL;
    guint replaces_id = 0;
    gchar *app_icon = NULL;
    gchar *summary = NULL;
    gchar *body = NULL;
    gint  expire_timeout = -1;

    {
        GVariantIter *iter = g_variant_iter_new(parameters);
        GVariant *content;
        int i = 0;
        while ((content = g_variant_iter_next_value(iter)))
        {
            switch(i) 
            {
                case 0:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_STRING))
                        app_name = g_variant_dup_string(content, NULL);
                    break;
                case 1:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_UINT32))
                        replaces_id = g_variant_get_uint32(content);
                    break;
                case 2:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_STRING))
                        app_icon = g_variant_dup_string(content, NULL);
                    break;
                case 3:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_STRING))
                        summary = g_variant_dup_string(content, NULL);
                    break;
                case 4:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_STRING))
                        body = g_variant_dup_string(content, NULL);
                    break;
                case 5:
                    break;
                case 6:
                    break;
                case 7:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_INT32))
                        expire_timeout = g_variant_get_int32(content);
                    break;
            }
        g_variant_unref(content);
        i++;
        }
    g_variant_iter_free(iter);
    }

    Notification *n = notification_create (app_name,
                                           replaces_id,
                                           app_icon,
                                           summary,
                                           body,
                                           expire_timeout);
    n->app_name = app_name;
    n->replaces_id = replaces_id;
    n->app_icon = app_icon;
    n->summary = summary;
    n->body = body;
    n->expire_timeout = expire_timeout;

    int id = 1;
    GVariant *reply = g_variant_new("(u)", id);
    g_dbus_method_invocation_return_value(invocation, reply);
    g_dbus_connection_flush(connection, NULL, NULL, NULL);

    g_print("About to print the summary from yarn.c\n");

    prepare(n);
}
Ejemplo n.º 27
0
static gboolean
check_result (CallbackData *data, const char *note,
	      gboolean layout_should_change)
{
  PangoRectangle test_extents;
  gboolean fail = FALSE;

  if (g_test_verbose ())
    g_print ("%s: ", note);

  /* Force a redraw to get the on_paint handler to run */
  force_redraw (data);

  /* Compare the extents from the label with the extents from our test
     layout */
  pango_layout_get_extents (data->test_layout, NULL, &test_extents);
  if (memcmp (&test_extents, &data->label_extents, sizeof (PangoRectangle)))
    {
      if (g_test_verbose ())
        g_print ("extents are different: expected: %d, %d, %d, %d "
                 "-> text: %d, %d, %d, %d\n",
                 test_extents.x / 1024,
                 test_extents.y / 1024,
                 test_extents.width / 1024,
                 test_extents.height / 1024,
                 data->label_extents.x / 1024,
                 data->label_extents.y / 1024,
                 data->label_extents.width / 1024,
                 data->label_extents.height / 1024);

      fail = TRUE;
    }
  else
    {
      if (g_test_verbose ())
        g_print ("extents are the same, ");
    }

  if (data->layout_changed)
    {
      if (g_test_verbose ())
        g_print ("layout changed, ");
    }
  else
    {
      if (g_test_verbose ())
        g_print ("layout did not change, ");
    }

  if (data->layout_changed != layout_should_change)
    fail = TRUE;

  if (fail)
    {
      if (g_test_verbose ())
        g_print ("FAIL\n");

      data->test_failed = TRUE;
    }
  else
    {
      if (g_test_verbose ())
        g_print ("pass\n");
    }

  return fail;
}
Ejemplo n.º 28
0
int main(int argc, char *argv[]) {
  GstElement *pipeline, *audio_source, *tee, *audio_queue, *audio_convert, *audio_resample, *audio_sink;
  GstElement *video_queue, *visual, *video_convert, *video_sink;
  GstBus *bus;
  GstMessage *msg;
  GstPadTemplate *tee_src_pad_template;
  GstPad *tee_audio_pad, *tee_video_pad;
  GstPad *queue_audio_pad, *queue_video_pad;
  
  /* Initialize GStreamer */
  gst_init (&argc, &argv);
  
  /* Create the elements */
  audio_source = gst_element_factory_make ("audiotestsrc", "audio_source");
  tee = gst_element_factory_make ("tee", "tee");
  audio_queue = gst_element_factory_make ("queue", "audio_queue");
  audio_convert = gst_element_factory_make ("audioconvert", "audio_convert");
  audio_resample = gst_element_factory_make ("audioresample", "audio_resample");
  audio_sink = gst_element_factory_make ("autoaudiosink", "audio_sink");
  video_queue = gst_element_factory_make ("queue", "video_queue");
  visual = gst_element_factory_make ("wavescope", "visual");
  video_convert = gst_element_factory_make ("videoconvert", "video_convert");
  video_sink = gst_element_factory_make ("autovideosink", "video_sink");
  
  /* Create the empty pipeline */
  pipeline = gst_pipeline_new ("test-pipeline");
  
  if (!pipeline || !audio_source || !tee || !audio_queue || !audio_convert || !audio_resample || !audio_sink ||
      !video_queue || !visual || !video_convert || !video_sink) {
    g_printerr ("Not all elements could be created.\n");
    return -1;
  }
  
  /* Configure elements */
  g_object_set (audio_source, "freq", 215.0f, NULL);
  g_object_set (visual, "shader", 0, "style", 1, NULL);
  
  /* Link all elements that can be automatically linked because they have "Always" pads */
  gst_bin_add_many (GST_BIN (pipeline), audio_source, tee, audio_queue, audio_convert, audio_resample, audio_sink,
      video_queue, visual, video_convert, video_sink, NULL);
  if (gst_element_link_many (audio_source, tee, NULL) != TRUE ||
      gst_element_link_many (audio_queue, audio_convert, audio_resample, audio_sink, NULL) != TRUE ||
      gst_element_link_many (video_queue, visual, video_convert, video_sink, NULL) != TRUE) {
    g_printerr ("Elements could not be linked.\n");
    gst_object_unref (pipeline);
    return -1;
  }
  
  /* Manually link the Tee, which has "Request" pads */
  tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (tee), "src_%u");
  tee_audio_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
  g_print ("Obtained request pad %s for audio branch.\n", gst_pad_get_name (tee_audio_pad));
  queue_audio_pad = gst_element_get_static_pad (audio_queue, "sink");
  tee_video_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
  g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name (tee_video_pad));
  queue_video_pad = gst_element_get_static_pad (video_queue, "sink");
  if (gst_pad_link (tee_audio_pad, queue_audio_pad) != GST_PAD_LINK_OK ||
      gst_pad_link (tee_video_pad, queue_video_pad) != GST_PAD_LINK_OK) {
    g_printerr ("Tee could not be linked.\n");
    gst_object_unref (pipeline);
    return -1;
  }
  gst_object_unref (queue_audio_pad);
  gst_object_unref (queue_video_pad);
  
  /* Start playing the pipeline */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  
  /* Wait until error or EOS */
  bus = gst_element_get_bus (pipeline);
  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
  
  /* Release the request pads from the Tee, and unref them */
  gst_element_release_request_pad (tee, tee_audio_pad);
  gst_element_release_request_pad (tee, tee_video_pad);
  gst_object_unref (tee_audio_pad);
  gst_object_unref (tee_video_pad);
  
  /* Free resources */
  if (msg != NULL)
    gst_message_unref (msg);
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  
  gst_object_unref (pipeline);
  return 0;
}
Ejemplo n.º 29
0
void on_radiobutton3_pressed( GtkWidget *widget, struct _properties *properties )
{
  g_print ("radiobutton3 was pressed\n");
  properties->format = CALENDAR_CUSTOM;

  if( strike_control[properties->strikestoogle].incrementor == 0 )
  {
    properties->strikestoogle = 0;
    gtk_combo_box_set_active(GTK_COMBO_BOX(properties->GtkInfo.comboboxStrikes), 0);
  }

  gtk_widget_hide(properties->GtkInfo.comboboxStrikes);
  gtk_widget_hide(properties->GtkInfo.scaleStrikes);
  gtk_widget_hide(properties->GtkInfo.scaleStrikes2);

  if( option_algorithms[properties->modeltype].supportStrikes )
  {
    gtk_widget_show(properties->GtkInfo.spinbuttonCustomStrike);
    gtk_widget_show(properties->GtkInfo.spinbuttonCustomStrike2);

  } else
  {
    gtk_widget_hide(properties->GtkInfo.spinbuttonCustomStrike);
    gtk_widget_hide(properties->GtkInfo.spinbuttonCustomStrike2);
  }

  if( properties->spreads == 1 )
  {
    gtk_widget_show(properties->GtkInfo.scaleMonths2);
    gtk_label_set_text(GTK_LABEL(properties->GtkInfo.labelStrikes),"StrikeLeg1");

    gtk_button_set_label(GTK_BUTTON(properties->GtkInfo.scaleMonths),"Month Adj Leg1");
    gtk_widget_show(properties->GtkInfo.scaleMonths);

    if( option_algorithms[properties->modeltype].supportStrikes )
    {
      gtk_widget_show(properties->GtkInfo.labelStrikes2);
      gtk_widget_show(properties->GtkInfo.spinbuttonCustomStrike2);

    } else
    {
      gtk_widget_hide(properties->GtkInfo.labelStrikes2);
      gtk_widget_hide(properties->GtkInfo.spinbuttonCustomStrike2);
    }

    g_print("Strike Leg1\n");

  } else if( properties->spreads == 0 )
  {
    gtk_label_set_text(GTK_LABEL(properties->GtkInfo.labelStrikes),"Strike");

    gtk_widget_hide(properties->GtkInfo.labelStrikes2);
    gtk_widget_hide(properties->GtkInfo.spinbuttonCustomStrike2);

    g_print("NO Strike Leg1\n");
  }

  if( option_algorithms[properties->modeltype].supportStrikes )
  {
    gtk_widget_show(properties->GtkInfo.labelStrikes);

  } else
  {
    gtk_widget_hide(properties->GtkInfo.labelStrikes);
  }

  gtk_widget_show(properties->GtkInfo.checkbuttonSpreads);

  setup_tree_view(properties);
  show_title(properties);

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(properties->GtkInfo.radiobutton3),true);
}
Ejemplo n.º 30
0
/*------------------------- read command line options ------------------------*/
void
readOpts(int argc,char *argv[], struct GLOBAL *global)
{
	gchar *device=NULL;
	gchar *format=NULL;
	gchar *size = NULL;
	gchar *image = NULL;
	gchar *video=NULL;
	gchar *profile=NULL;
	gchar *separateur=NULL;
	gboolean help = FALSE;
	gboolean help_gtk = FALSE;
	gboolean help_all = FALSE;
	gboolean vers = FALSE;
	gchar *help_str = NULL;
	gchar *help_gtk_str = NULL;
	gchar *help_all_str = NULL;
	gchar *config = NULL;
	int hwaccel=-1;
	int FpsCount=-1;
	int cap_meth=-1;

	GOptionEntry entries[] =
	{
		{ "help-all", 'h', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &help_all, "Display all help options", NULL},
		{ "help-gtk", '!', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &help_gtk, "DISPLAY GTK+ help", NULL},
		{ "help", '?', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &help, "Display help", NULL},
		{ "version", 0, 0, G_OPTION_ARG_NONE, &vers, N_("Prints version"), NULL},
		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &global->debug, N_("Displays debug information"), NULL },
		{ "device", 'd', 0, G_OPTION_ARG_STRING, &device, N_("Video Device to use [default: /dev/video0]"), "VIDEO_DEVICE" },
		{ "add_ctrls", 'a', 0, G_OPTION_ARG_NONE, &global->add_ctrls, N_("Exit after adding UVC extension controls (needs root/sudo)"), NULL},
		{ "control_only", 'o', 0, G_OPTION_ARG_NONE, &global->control_only, N_("Don't stream video (image controls only)"), NULL},
        { "no_display", 0,0, G_OPTION_ARG_NONE, &global->no_display, N_("Don't display a GUI"), NULL},
		{ "capture_method", 'r', 0, G_OPTION_ARG_INT, &cap_meth, N_("Capture method (1-mmap (default)  2-read)"), "[1 | 2]"},
		{ "config", 'g', 0, G_OPTION_ARG_STRING, &config, N_("Configuration file"), "FILENAME" },
		{ "hwd_acel", 'w', 0, G_OPTION_ARG_INT, &hwaccel, N_("Hardware accelaration (enable(1) | disable(0))"), "[1 | 0]" },
		{ "format", 'f', 0, G_OPTION_ARG_STRING, &format, N_("Pixel format(mjpg|jpeg|yuyv|yvyu|uyvy|yyuv|yu12|yv12|nv12|nv21|nv16|nv61|y41p|grey|y10b|y16 |s501|s505|s508|gbrg|grbg|ba81|rggb|bgr3|rgb3)"), "FORMAT" },
		{ "size", 's', 0, G_OPTION_ARG_STRING, &size, N_("Frame size, default: 640x480"), "WIDTHxHEIGHT"},
		{ "image", 'i', 0, G_OPTION_ARG_STRING, &image, N_("Image File name"), "FILENAME"},
		{ "cap_time", 'c', 0, G_OPTION_ARG_INT, &global->image_timer, N_("Image capture interval in seconds"), "TIME"},
		{ "npics", 'm', 0, G_OPTION_ARG_INT, &global->image_npics, N_("Number of Pictures to capture"), "NUMPIC"},
		{ "video", 'n', 0, G_OPTION_ARG_STRING, &video, N_("Video File name (capture from start)"), "FILENAME"},
		{ "vid_time", 't', 0, G_OPTION_ARG_INT, &global->Capture_time,N_("Video capture time (in seconds)"), "TIME"},
		{ "exit_on_close", 0, 0, G_OPTION_ARG_NONE, &global->exit_on_close, N_("Exits guvcview after closing video"), NULL},
		{ "skip", 'j', 0, G_OPTION_ARG_INT, &global->skip_n, N_("Number of initial frames to skip"), "N_FRAMES"},
		{ "show_fps", 'p', 0, G_OPTION_ARG_INT, &FpsCount, N_("Show FPS value (enable(1) | disable (0))"), "[1 | 0]"},
		{ "profile", 'l', 0, G_OPTION_ARG_STRING, &profile, N_("Load Profile at start"), "FILENAME"},
		{ "lctl_method", 'k', 0, G_OPTION_ARG_INT, &global->lctl_method, N_("List controls method (0:loop, 1:next_ctrl flag [def])"), "[0 |1]"},
		{ NULL }
	};

	GError *error = NULL;
	GOptionContext *context;
	context = g_option_context_new (N_("- local options"));
	g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_set_prgname (PACKAGE);
	help_str = g_option_context_get_help (context, TRUE, NULL);
	help_gtk_str = g_option_context_get_help (context, FALSE, gtk_get_option_group (TRUE));
	help_all_str = g_option_context_get_help (context, FALSE, NULL);
	/*disable automatic help parsing - must clean global before exit*/
	g_option_context_set_help_enabled (context, FALSE);
	if (!g_option_context_parse (context, &argc, &argv, &error))
	{
		g_printerr ("option parsing failed: %s\n", error->message);
		g_error_free ( error );
		closeGlobals(global);
		global=NULL;
		g_print("%s",help_all_str);
		g_free(help_all_str);
		g_free(help_str);
		g_free(help_gtk_str);
		g_option_context_free (context);
		exit (1);
	}

	if(vers)
	{
		//print version and exit
		//version already printed in guvcview.c
		closeGlobals(global);
		global=NULL;
		g_free(help_all_str);
		g_free(help_str);
		g_free(help_gtk_str);
		g_option_context_free (context);
		exit(0);
	}
	/*Display help message and exit*/
	if(help_all)
	{
		closeGlobals(global);
		global=NULL;
		g_print("%s",help_all_str);
		g_free(help_all_str);
		g_free(help_str);
		g_free(help_gtk_str);
		g_option_context_free (context);
		exit(0);
	}
	else if(help)
	{
		closeGlobals(global);
		global=NULL;
		g_print("%s",help_str);
		g_free(help_str);
		g_free(help_gtk_str);
		g_free(help_all_str);
		g_option_context_free (context);
		exit(0);
	} else if(help_gtk)
	{
		closeGlobals(global);
		global=NULL;
		g_print("%s",help_gtk_str);
		g_free(help_str);
		g_free(help_gtk_str);
		g_free(help_all_str);
		g_option_context_free (context);
		exit(0);
	}

	/*regular options*/
	if(device)
	{
		gchar *basename = NULL;
		gchar *dirname = NULL;
		basename = g_path_get_basename(device);
		if(!(g_str_has_prefix(basename,"video")))
		{
			g_printerr("%s not a valid video device name\n",
				basename);
		}
		else
		{
			g_free(global->videodevice);
			global->videodevice=NULL;
			dirname = g_path_get_dirname(device);
			if(g_strcmp0(".",dirname)==0)
			{
				g_free(dirname);
				dirname=g_strdup("/dev");
			}

			global->videodevice = g_strjoin("/",
				dirname,
				basename,
				NULL);
			if(global->flg_config < 1)
			{
				if(g_strcmp0("video0",basename) !=0 )
				{
					g_free(global->confPath);
					global->confPath=NULL;
					global->confPath = g_strjoin("/",
						g_get_home_dir(),
						".config",
						"guvcview",
						basename,
						NULL);
				}
			}
		}
		g_free(dirname);
		g_free(basename);
	}
	if(config)
	{
		g_free(global->confPath);
		global->confPath=NULL;
		global->confPath = g_strdup(config);
		global->flg_config = 1;
	}
	if(format)
	{
		/*use fourcc but keep compatability with luvcview*/
		if(g_strcmp0("yuv",format)==0)
			g_snprintf(global->mode,5,"yuyv");
		else if (g_strcmp0("bggr",format)==0) // be compatible with guvcview < 1.1.4
			g_snprintf(global->mode,5,"ba81");
		else
			g_snprintf(global->mode,5,"%s ",format);

	    printf("requested format \"%s\" from command line\n", global->mode);

		global->flg_mode = TRUE;
	}
	if(size)
	{
		global->width = (int) g_ascii_strtoull(size, &separateur, 10);
		if (*separateur != 'x')
		{
			g_printerr("Error in size usage: -s[--size] WIDTHxHEIGHT \n");
		}
		else
		{
			++separateur;
			global->height = (int) g_ascii_strtoull(separateur, &separateur, 10);
			if (*separateur != 0)
				g_printerr("hmm.. don't like that!! trying this height \n");
		}

		global->flg_res = 1;
	}
	if(image)
	{
		global->imgFPath=splitPath(image,global->imgFPath);
		/*get the file type*/
		global->imgFormat = check_image_type(global->imgFPath[0]);
		global->flg_imgFPath = TRUE;

		if(global->image_inc>0)
		{
			uint64_t suffix = get_file_suffix(global->imgFPath[1], global->imgFPath[0]);
			fprintf(stderr, "Image file suffix detected: %" PRIu64 "\n", suffix);
			if(suffix >= G_MAXUINT64)
			{
				global->imgFPath[0] = add_file_suffix(global->imgFPath[0], suffix);
				suffix = 0;
			}
			if(suffix > 0) {
				global->image_inc = suffix + 1;
      }
		}
	}
	if(global->image_timer > 0 )
	{
		g_print("capturing images every %i seconds\n",global->image_timer);
	}
	if(video)
	{
		global->vidFPath=splitPath(video, global->vidFPath);
		if(global->vid_inc>0)
		{
			uint64_t suffix = get_file_suffix(global->vidFPath[1], global->vidFPath[0]);
			fprintf(stderr, "Video file suffix detected: %" PRIu64 "\n", suffix);
			if(suffix >= G_MAXUINT64)
			{
				global->vidFPath[0] = add_file_suffix(global->vidFPath[0], suffix);
				suffix = 0;
			}
			if(suffix > 0)
				global->vid_inc = suffix + 1;
		}

		global->vidfile = joinPath(global->vidfile, global->vidFPath);

		g_print("capturing video: %s , from start\n",global->vidfile);
		/*get the file type*/
		global->VidFormat = check_video_type(global->vidFPath[0]);
	}
	if(profile)
	{
		global->lprofile=1;
		global->profile_FPath=splitPath(profile,global->profile_FPath);
	}
	if(hwaccel != -1 )
	{
		global->hwaccel = hwaccel;
		global->flg_hwaccel = 1;
	}
	if(FpsCount != -1)
	{
		global->FpsCount = FpsCount;
		global->flg_FpsCount = 1;
	}
	if(cap_meth != -1)
	{
		global->flg_cap_meth = TRUE;
		global->cap_meth = cap_meth;
	}

	//g_print("option capture meth is %i\n", global->cap_meth);
	g_free(help_str);
	g_free(help_gtk_str);
	g_free(help_all_str);
	g_free(device);
	g_free(config);
	g_free(format);
	g_free(size);
	g_free(image);
	g_free(video);
	g_free(profile);
	g_option_context_free (context);
}