Example #1
1
int
main (int    argc,
      char **argv)
{
  GThread *thread1, *thread2;
  GClosure *closure;
  GTest *object;
  guint i;

  g_thread_init (NULL);
  g_print ("START: %s\n", argv[0]);
  g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK));
  g_type_init ();

  object = g_object_new (G_TYPE_TEST, NULL);
  closure = g_cclosure_new (G_CALLBACK (test_signal_handler), TEST_POINTER2, destroy_data);

  g_signal_connect_closure (object, "test-signal1", closure, FALSE);
  g_signal_connect_closure (object, "test-signal2", closure, FALSE);

  stopping = FALSE;

  thread1 = g_thread_create (thread1_main, closure, TRUE, NULL);
  thread2 = g_thread_create (thread2_main, closure, TRUE, NULL);

  for (i = 0; i < 1000000; i++)
    {
      static guint count = 0;
      test_emissions (object);
      if (++count % 10000 == 0)
        {
          g_printerr (".\n");
          g_thread_yield(); /* force context switch */
        }
    }

  stopping = TRUE;
  g_print ("\nstopping\n");

  /* wait for thread shutdown */
  g_thread_join (thread1);
  g_thread_join (thread2);

  /* finalize object, destroy signals, run cleanup code */
  g_object_unref (object);

  g_print ("stopped\n");

  g_assert (seen_thread1 != FALSE);
  g_assert (seen_thread2 != FALSE);
  g_assert (seen_test_int1 != FALSE);
  g_assert (seen_test_int2 != FALSE);
  g_assert (seen_signal_handler != FALSE);
  g_assert (seen_cleanup != FALSE);

  return 0;
}
Example #2
0
GtkAccelGroup* maintainr_shell_get_shortcuts (MaintainrShell *shell)
{
	GtkAccelGroup *group;

	group = gtk_accel_group_new ();
	gtk_accel_group_connect (group, GDK_KEY_Up, GDK_CONTROL_MASK, 0, g_cclosure_new (G_CALLBACK (scroll_in_projects), shell, NULL));
	gtk_accel_group_connect (group, GDK_KEY_Down, GDK_CONTROL_MASK, 0, g_cclosure_new (G_CALLBACK (scroll_in_projects), shell, NULL));
	return group;
}
Example #3
0
void connect_key_accels(dt_iop_module_t *self)
{
  GClosure *closure;

  closure = g_cclosure_new(G_CALLBACK(key_softproof_callback), (gpointer)self, NULL);
  dt_accel_connect_iop(self, "toggle softproofing", closure);

  closure = g_cclosure_new(G_CALLBACK(key_gamutcheck_callback), (gpointer)self, NULL);
  dt_accel_connect_iop(self, "toggle gamutcheck", closure);
}
Example #4
0
void connect_key_accels(dt_lib_module_t *self)
{
  /* setup key accelerators */

  // view accels
  dt_accel_connect_lib(self, "zoom max",
                       g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_zoom_max_callback), self, NULL));
  dt_accel_connect_lib(self, "zoom in",
                       g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_zoom_in_callback), self, NULL));
  dt_accel_connect_lib(self, "zoom out",
                       g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_zoom_out_callback), self, NULL));
  dt_accel_connect_lib(self, "zoom min",
                       g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_zoom_min_callback), self, NULL));

  // selection accels
  dt_accel_connect_lib(
      self, "select all",
      g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_select_callback), GINT_TO_POINTER(0), NULL));
  dt_accel_connect_lib(
      self, "select none",
      g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_select_callback), GINT_TO_POINTER(1), NULL));
  dt_accel_connect_lib(
      self, "invert selection",
      g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_select_callback), GINT_TO_POINTER(2), NULL));
  dt_accel_connect_lib(
      self, "select film roll",
      g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_select_callback), GINT_TO_POINTER(3), NULL));
  dt_accel_connect_lib(
      self, "select untouched",
      g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_select_callback), GINT_TO_POINTER(4), NULL));
}
Example #5
0
void connect_key_accels(dt_lib_module_t *self)
{
  /* setup key accelerators */

  // view accels
  dt_accel_connect_lib(self, "zoom max",
                       g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_zoom_max_callback), self, NULL));
  dt_accel_connect_lib(self, "zoom in",
                       g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_zoom_in_callback), self, NULL));
  dt_accel_connect_lib(self, "zoom out",
                       g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_zoom_out_callback), self, NULL));
  dt_accel_connect_lib(self, "zoom min",
                       g_cclosure_new(G_CALLBACK(_lib_lighttable_key_accel_zoom_min_callback), self, NULL));
}
Example #6
0
void
netstatus_connect_signal_while_alive (gpointer    object,
                                      const char *detailed_signal,
                                      GCallback   func,
                                      gpointer    func_data,
                                      gpointer    alive_object)
{
  GClosure *closure;
  GType     type;
  guint     signal_id = 0;
  GQuark    detail = 0;
  
  type = G_OBJECT_TYPE (object);

  if (!g_signal_parse_name (detailed_signal, type, &signal_id, &detail, FALSE))
    {
      g_warning (G_STRLOC ": unable to parse signal \"%s\" for type \"%s\"",
                 detailed_signal, g_type_name (type));
      return;
    }

  closure = g_cclosure_new (func, func_data, NULL);
  g_object_watch_closure (G_OBJECT (alive_object), closure);
  g_signal_connect_closure_by_id (object, signal_id, detail, closure, FALSE);
}
Example #7
0
static void
build_search_entry(GitgWindow *window, GtkBuilder *builder)
{
	GtkWidget *box = GTK_WIDGET(gtk_builder_get_object(builder, "hbox_top"));
	GtkWidget *entry = sexy_icon_entry_new();
	
	GtkImage *image = GTK_IMAGE(gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU));
	sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(entry), SEXY_ICON_ENTRY_PRIMARY, image);
	
	gtk_tree_view_set_search_entry(window->priv->tree_view, GTK_ENTRY(entry));
	gtk_widget_show(entry);
	gtk_box_pack_end(GTK_BOX(box), entry, FALSE, FALSE, 0);
	
	GtkBuilder *b = gitg_utils_new_builder( "gitg-menus.xml");
	
	GtkUIManager *manager = GTK_UI_MANAGER(gtk_builder_get_object(b, "uiman"));
	window->priv->search_popup = GTK_WIDGET(g_object_ref(gtk_ui_manager_get_widget(manager, "/ui/search_popup")));
	
	gtk_builder_connect_signals(b, window);
	g_object_unref(b);
	
	g_signal_connect(entry, "icon-pressed", G_CALLBACK(on_search_icon_pressed), window);
	gtk_tree_view_set_search_column(window->priv->tree_view, 1);
	
	gtk_tree_view_set_search_equal_func(window->priv->tree_view, search_equal_func, window, NULL);
	
	GtkAccelGroup *group = gtk_accel_group_new();
	
	GClosure *closure = g_cclosure_new(G_CALLBACK(focus_search), entry, NULL); 
	gtk_accel_group_connect(group, GDK_f, GDK_CONTROL_MASK, 0, closure); 
	gtk_window_add_accel_group(GTK_WINDOW(window), group);
}
Example #8
0
void snippets_set_accelerator (GuSnippets* sc, gchar* config) {
    /* config has the form: Key,Accel_key,Name */
    GClosure* closure = NULL;
    GdkModifierType mod;
    guint keyval = 0;
    gchar** configs = g_strsplit (config, ",", 0);
    Tuple2* data = g_new0 (Tuple2, 1);
    Tuple2* closure_data = g_new0 (Tuple2, 1);

    /* Return if config does not contains accelerator */
    if (strlen (configs[1]) == 0) {
        g_strfreev (configs);
        return;
    }

    data->first = (gpointer)sc;
    data->second = (gpointer)g_strdup (configs[0]);


    closure = g_cclosure_new (G_CALLBACK (snippets_accel_cb), data, NULL);
    closure_data->first = (gpointer)data->second;
    closure_data->second = (gpointer)closure;

    sc->closure_data = g_list_append (sc->closure_data, closure_data);
    gtk_accelerator_parse (configs[1], &keyval, &mod);

    /* Return without connect if accel is not valid */
    if (!gtk_accelerator_valid (keyval, mod)) return;

    snippets_accel_connect (sc, keyval, mod, closure);
    g_strfreev (configs);
}
Example #9
0
/*#
    @method connect_group
    @brief Installs an accelerator in this group.
    @param accel_key key of the accelerator
    @param accel_mods modifier combination of the accelerator
    @param accel_flags a flag mask to configure this accelerator
    @param callback a function or method to be executed upon accelerator activation

    The connect_group() method installs an accelerator in the accelerator group.
    When the accelerator group is being activated, the function (or method)
    specified by callback will be invoked if the accelerator key and modifier key
    match those specified by accel_key and accel_mods.

    The value of modifier is a combination of the GDK Modifier Constants.
    accel_flags is a combination of gtk.ACCEL_VISIBLE and gtk.ACCEL_LOCKED.

    The callback function is defined as:

    function callback(acceleratable, keyval, modifier)

    where acceleratable is the object that
    the accel_group is attached to (e.g. a gtk.Window), keyval is the accelerator
    key and modifier is the key modifier. callback returns True if the accelerator
    was handled by callback.
 */
FALCON_FUNC AccelGroup::connect_group( VMARG )
{
    Item* i_key = vm->param( 0 );
    Item* i_mods = vm->param( 1 );
    Item* i_flags = vm->param( 2 );
    Item* i_cb = vm->param( 3 );
#ifndef NO_PARAMETER_CHECK
    if ( !i_key || !i_key->isString()
        || !i_mods || !i_mods->isInteger()
        || !i_flags || !i_flags->isInteger()
        || !i_cb || !( i_cb->isCallable() || i_cb->isComposed() ) )
        throw_inv_params( "S,GdkModifierType,GtkAccelFlags,C" );
#endif
    MYSELF;
    GET_OBJ( self );
    String* chr = i_key->asString();
    guint keyval = chr->length() ? chr->getCharAt( 0 ) : 0;

    GarbageLock* lock = CoreGObject::lockItem( _obj, *i_cb );
    GClosure* cl = g_cclosure_new( G_CALLBACK( &AccelGroup::activate_cb ),
                                   (gpointer) lock,
                                   NULL );
    g_object_watch_closure( _obj, cl );

    gtk_accel_group_connect( GET_ACCELGROUP( vm->self() ),
                             keyval,
                             (GdkModifierType) i_mods->asInteger(),
                             (GtkAccelFlags) i_flags->asInteger(),
                             cl );
}
Example #10
0
void dt_accel_connect_button_lib(dt_lib_module_t *module, const gchar *path,
                                 GtkWidget *button)
{
  GClosure *closure = g_cclosure_new(G_CALLBACK(_press_button_callback),
                                     (gpointer)button, NULL);
  dt_accel_connect_lib(module, path, closure);
}
Example #11
0
GtkWidget *
aw_popup_dialog_append (AwPopupDialog         *dialog,
                        const char            *title,
                        const char            *details,
                        AwPopupDialogCallback  callback,
                        gpointer               user_data)
{
  GtkWidget *button, *content_area;
  GClosure  *closure;

  g_return_val_if_fail (AW_IS_POPUP_DIALOG (dialog), NULL);

  button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH |
                                        HILDON_SIZE_FINGER_HEIGHT,
                                        HILDON_BUTTON_ARRANGEMENT_VERTICAL,
                                        title, details);

  closure = g_cclosure_new (G_CALLBACK (callback), user_data, NULL);
  g_closure_set_marshal (closure, aw_cclosure_marshal_BOOLEAN__VOID);

  g_signal_connect_data (button, "clicked",
                         G_CALLBACK (aw_popup_dialog_clicked_cb),
                         closure, (GClosureNotify) g_closure_unref, 0);

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  gtk_container_add (GTK_CONTAINER (content_area), button);
  gtk_widget_show (button);

  return button;
}
Example #12
0
static guint
nux_area_accessible_add_focus_handler(AtkComponent* component,
                                      AtkFocusHandler handler)
{
  GSignalMatchType match_type;
  gulong ret;
  guint signal_id;

  g_return_val_if_fail(NUX_IS_AREA_ACCESSIBLE(component), 0);

  match_type = (GSignalMatchType)(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC);
  signal_id = g_signal_lookup("focus-event", ATK_TYPE_OBJECT);

  ret = g_signal_handler_find(component, match_type, signal_id, 0, NULL,
                              (gpointer) handler, NULL);
  if (!ret)
  {
    return g_signal_connect_closure_by_id(component,
                                          signal_id, 0,
                                          g_cclosure_new(G_CALLBACK(handler), NULL,
                                                         (GClosureNotify) NULL),
                                          FALSE);
  }
  else
    return 0;
}
Example #13
0
void
moo_plugin_method_new (const char     *name,
                       GType           ptype,
                       GCallback       method,
                       GClosureMarshal c_marshaller,
                       GType           return_type,
                       guint           n_params,
                       ...)
{
    va_list args;
    GClosure *closure;

    g_return_if_fail (g_type_is_a (ptype, MOO_TYPE_PLUGIN));
    g_return_if_fail (name != NULL);
    g_return_if_fail (method != NULL);
    g_return_if_fail (c_marshaller != NULL);

    closure = g_cclosure_new (method, NULL, NULL);
    g_closure_sink (g_closure_ref (closure));

    va_start (args, n_params);
    moo_plugin_method_new_valist (name, ptype, closure, c_marshaller,
                                  return_type, n_params, args);
    va_end (args);

    g_closure_unref (closure);
}
static void
create_child (void)
{
  GError *err;
  GIOChannel *in_channels[2];
  GIOChannel *out_channels[2];
  GIOChannel **sub_channels;
  GSource *source;
  
  sub_channels = g_new (GIOChannel *, 2);
  
  io_pipe (in_channels);
  io_pipe (out_channels);
  
  sub_channels[0] = in_channels[0];
  sub_channels[1] = out_channels[1];

  source = g_io_create_watch (out_channels[0], G_IO_IN | G_IO_HUP);
  g_assert(source != NULL);
  g_source_set_closure (source,
  g_cclosure_new (G_CALLBACK (input_callback), in_channels[1], NULL));
  g_source_attach (source, NULL);

  g_thread_create(run_child,sub_channels,FALSE,&err);

}
Example #15
0
static void
g_object_connect_property (GObject    *object,
                           GParamSpec *spec,
                           GCallback   func,
                           gpointer    data,
                           GObject    *alive_object)
{
  GClosure *closure;
  gchar *with_detail;
  DisconnectData *dd;

  if (is_child_property (spec))
    with_detail = g_strconcat ("child-notify::", spec->name, NULL);
  else
    with_detail = g_strconcat ("notify::", spec->name, NULL);

  dd = g_new (DisconnectData, 1);

  closure = g_cclosure_new (func, data, NULL);
  g_closure_add_invalidate_notifier (closure, dd, signal_removed);
  dd->id = g_signal_connect_closure (object, with_detail, closure, FALSE);
  dd->instance = object;
  dd->alive_object = alive_object;

  g_object_set_data_full (G_OBJECT (alive_object), "alive-object-data",
                          dd, disconnect_func);

  g_free (with_detail);
}
Example #16
0
void connect_key_accels(dt_view_t *self)
{
#if 0
  GClosure *closure = g_cclosure_new(G_CALLBACK(film_strip_key_accel),
                                     (gpointer)self, NULL);
  dt_accel_connect_view(self, "toggle film strip", closure);
#endif
}
Example #17
0
static void modulewindow_init(ModuleWindow * mw)
{
	GClosure *gclosure;
	GtkAccelGroup *accel_group;

	g_signal_connect(G_OBJECT(mw), "destroy",
			 G_CALLBACK(modulewindow_destroy_cb),
			 mw);

        gtk_window_set_default_size (GTK_WINDOW(mw), MODULEWINDOW_DEFAULT_WIDTH, MODULEWINDOW_DEFAULT_HEIGHT);

	gtk_container_border_width(GTK_CONTAINER(mw), 1);

	accel_group = gtk_accel_group_new();
	gtk_window_add_accel_group(GTK_WINDOW(mw), accel_group);

	/*
	 * close the window when Ctrl and w are pressed.
	 *      accel key combo is static. perhaps there is a better
	 *      way to do this?
	 */
	gclosure =
	    g_cclosure_new((GCallback) modulewindow_close_cb, NULL, NULL);
	gtk_accel_group_connect(accel_group, GDK_w, GDK_CONTROL_MASK, 0,
				gclosure);

	/* Set up the boxes */
	mw->mainbox = gtk_vbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(mw), mw->mainbox);
	gtk_widget_show(mw->mainbox);

	mw->headbox = gtk_hbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(mw->mainbox), mw->headbox, FALSE, TRUE,
			   0);
	gtk_widget_show(mw->headbox);

        /* On button */
	mw->onbutton = gtk_toggle_button_new_with_label("On");
	gtk_box_pack_start(GTK_BOX(mw->headbox), mw->onbutton, FALSE,
			   FALSE, 1);
	gtk_widget_show(mw->onbutton);

	gclosure = g_cclosure_new((GCallback) modulewindow_toggle, mw, NULL);
	gtk_accel_group_connect(accel_group, GDK_Escape, 0, 0, gclosure);

}
Example #18
0
void connect_key_accels(dt_view_t *self)
{
  GClosure *closure;

  // Film strip shortcuts
  closure = g_cclosure_new(G_CALLBACK(film_strip_key_accel), (gpointer)self, NULL);
  dt_accel_connect_view(self, "toggle film strip", closure);
}
Example #19
0
void
dt_styles_create_from_image (const char *name,const char *description,int32_t imgid,GList *filter)
{
  int id=0;
  sqlite3_stmt *stmt;

  /* first create the style header */
  if (!dt_styles_create_style_header(name,description) ) return;

  if ((id=dt_styles_get_id_by_name(name)) != 0)
  {
    /* create the style_items from source image history stack */
    if (filter)
    {
      GList *list=filter;
      char tmp[64];
      char include[2048]= {0};
      g_strlcat(include,"num in (", 2048);
      do
      {
        if(list!=g_list_first(list))
          g_strlcat(include,",", 2048);
        sprintf(tmp,"%ld",(long int)list->data);
        g_strlcat(include,tmp, 2048);
      }
      while ((list=g_list_next(list)));
      g_strlcat(include,")", 2048);
      char query[4096]= {0};
      sprintf(query,"insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params,blendop_version,multi_priority,multi_name) select ?1, num,module,operation,op_params,enabled,blendop_params,blendop_version,multi_priority,multi_name from history where imgid=?2 and %s",include);
      DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), query, -1, &stmt, NULL);
    }
    else
      DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params,blendop_version,multi_priority,multi_name) select ?1, num,module,operation,op_params,enabled,blendop_params,blendop_version,multi_priority,multi_name from history where imgid=?2", -1, &stmt, NULL);
    DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
    DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, imgid);
    sqlite3_step (stmt);
    sqlite3_finalize (stmt);

    /* backup style to disk */
    char stylesdir[1024];
    dt_loc_get_user_config_dir(stylesdir, 1024);
    g_strlcat(stylesdir,"/styles",1024);
    g_mkdir_with_parents(stylesdir,00755);

    dt_styles_save_to_file(name,stylesdir,FALSE);

    char tmp_accel[1024];
    gchar* tmp_name = g_strdup(name); // freed by _destro_style_shortcut_callback
    snprintf(tmp_accel,1024,"styles/Apply %s",name);
    dt_accel_register_global( tmp_accel, 0, 0);
    GClosure *closure;
    closure = g_cclosure_new(
                G_CALLBACK(_apply_style_shortcut_callback),
                tmp_name, _destroy_style_shortcut_callback);
    dt_accel_connect_global(tmp_accel, closure);
    dt_control_log(_("style named '%s' successfully created"),name);
  }
}
Example #20
0
void connect_key_accels(dt_view_t *self)
{
  GClosure *closure;

  // Film strip shortcuts
  closure = g_cclosure_new(G_CALLBACK(film_strip_key_accel),
                           (gpointer)self, NULL);
  dt_accel_connect_view(self, "toggle film strip", closure);

  // Zoom shortcuts
  closure = g_cclosure_new(G_CALLBACK(zoom_key_accel), (gpointer)1, NULL);
  dt_accel_connect_view(self, "zoom close-up", closure);

  closure = g_cclosure_new(G_CALLBACK(zoom_key_accel), (gpointer)2, NULL);
  dt_accel_connect_view(self, "zoom fill", closure);

  closure = g_cclosure_new(G_CALLBACK(zoom_key_accel), (gpointer)3, NULL);
  dt_accel_connect_view(self, "zoom fit", closure);

  // enable shortcut to export with current export settings:
  closure = g_cclosure_new(G_CALLBACK(export_key_accel_callback),
                           (gpointer)self->data, NULL);
  dt_accel_connect_view(self, "export", closure);

  // Shortcut to skip images
  closure = g_cclosure_new(G_CALLBACK(skip_f_key_accel_callback),
                           (gpointer)self->data, NULL);
  dt_accel_connect_view(self, "image forward", closure);

  closure = g_cclosure_new(G_CALLBACK(skip_b_key_accel_callback),
                           (gpointer)self->data, NULL);
  dt_accel_connect_view(self, "image back", closure);

}
/**
 * bonobo_ui_component_add_listener:
 * @component: the component to add it to
 * @id: the programmatic name of the id
 * @fn: the callback function for invoking it
 * @user_data: the associated user data for the callback
 * 
 * Add a listener for stateful events.
 **/
void
bonobo_ui_component_add_listener (BonoboUIComponent  *component,
				  const char         *id,
				  BonoboUIListenerFn  fn,
				  gpointer            user_data)
{
	bonobo_ui_component_add_listener_full (
		component, id, g_cclosure_new (G_CALLBACK (fn), user_data, NULL));
}
static GstStateChangeReturn gst_er_dtls_enc_change_state(GstElement *element, GstStateChange transition)
{
    GstErDtlsEnc *self = GST_ER_DTLS_ENC(element);
    GstStateChangeReturn ret;

    switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
        if (self->connection_id) {
            self->connection = gst_er_dtls_dec_fetch_connection(self->connection_id);

            if (!self->connection) {
                GST_WARNING_OBJECT(self,
                    "invalid connection id: '%s', connection not found or already in use",
                    self->connection_id);
                return GST_STATE_CHANGE_FAILURE;
            }

            g_signal_connect_object(self->connection,
                "on-encoder-key", G_CALLBACK(on_key_received), self, 0);

            er_dtls_connection_set_send_callback(self->connection,
                g_cclosure_new(G_CALLBACK(on_send_data), self, NULL));
        } else {
            GST_WARNING_OBJECT(self, "trying to change state to ready without connection id");
            return GST_STATE_CHANGE_FAILURE;
        }
        break;
    case GST_STATE_CHANGE_READY_TO_PAUSED:
        GST_DEBUG_OBJECT(self, "starting connection %s", self->connection_id);
        er_dtls_connection_start(self->connection, self->is_client);

        gst_pad_set_active(self->src, TRUE);
        break;
    case GST_STATE_CHANGE_PAUSED_TO_READY:
        GST_DEBUG_OBJECT(self, "stopping connection %s", self->connection_id);
        gst_pad_set_active(self->src, FALSE);

        er_dtls_connection_stop(self->connection);
        break;
    case GST_STATE_CHANGE_READY_TO_NULL:
        GST_DEBUG_OBJECT(self, "closing connection %s", self->connection_id);
        er_dtls_connection_close(self->connection);
        er_dtls_connection_set_send_callback(self->connection, NULL);

        if (self->connection) {
            g_object_unref(self->connection);
            self->connection = NULL;
        }
        break;
    default:
        break;
    }

    ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);

    return ret;
}
Example #23
0
/**
 * pka_subscription_set_handlers:
 * @subscription: A #PkaSubscription.
 * @context: A #PkaContext.
 * @manifest_func: A manifest callback function.
 * @manifest_data: Data for @manifest_func.
 * @manifest_destroy: A #GDestroyNotify to call when @manifest_func is no
 *    longer needed.
 * @sample_func: A sample callback function.
 * @sample_data: Data for @sample_func.
 * @sample_destroy: A #GDestroyNotify to call when @sample_func is no
 *    longer needed.
 *
 * Sets the manifest and sample callback methods for the subscription.
 * @manifest_func will be called when a manifest is received from a source
 * on the subscription.  @sample_func will be called when a sample is received
 * from the subscription.
 *
 * Returns: None.
 * Side effects: None.
 */
void
pka_subscription_set_handlers (PkaSubscription  *subscription,     /* IN */
                               PkaContext       *context,          /* IN */
                               PkaManifestFunc   manifest_func,    /* IN */
                               gpointer          manifest_data,    /* IN */
                               GDestroyNotify    manifest_destroy, /* IN */
                               PkaSampleFunc     sample_func,      /* IN */
                               gpointer          sample_data,      /* IN */
                               GDestroyNotify    sample_destroy,   /* IN */
                               GError          **error)            /* IN */
{
	GClosure *manifest;
	GClosure *sample;

	g_return_if_fail(subscription != NULL);
	g_return_if_fail(context != NULL);

	ENTRY;
	/*
	 * Create the closures and set the marshaller.
	 */
	manifest = g_cclosure_new(G_CALLBACK(manifest_func),
	                          manifest_data,
	                          (GClosureNotify)manifest_destroy);
	sample = g_cclosure_new(G_CALLBACK(sample_func),
	                        sample_data,
	                        (GClosureNotify)sample_destroy);
	g_closure_set_marshal(manifest, pka_marshal_VOID__POINTER_ULONG);
	g_closure_set_marshal(sample, pka_marshal_VOID__POINTER_ULONG);
	/*
	 * Store the closures. Requires writer lock.
	 */
	g_static_rw_lock_writer_lock(&subscription->rw_lock);
	if (subscription->manifest_closure) {
		g_closure_unref(subscription->manifest_closure);
	}
	if (subscription->sample_closure) {
		g_closure_unref(subscription->sample_closure);
	}
	subscription->manifest_closure = manifest;
	subscription->sample_closure = sample;
	g_static_rw_lock_writer_unlock(&subscription->rw_lock);
	EXIT;
}
Example #24
0
static void
_check_toplevel (AtkObject *obj)
{
  AtkObject *root_obj;
  const gchar *name_string, *version_string;
  gint max_depth;

  g_print ("Start of _check_toplevel\n");
  root_obj = atk_get_root();

  if (!already_accessed_atk_object(root_obj))
    {
      g_signal_connect_closure (root_obj, "children_changed::add",
		g_cclosure_new (G_CALLBACK (_notify_toplevel_child_added),
		NULL, NULL),
		FALSE);

      g_signal_connect_closure (root_obj, "children_changed::remove",
		g_cclosure_new (G_CALLBACK (_notify_toplevel_child_removed),
		NULL, NULL),
		FALSE);
    }

  name_string = atk_get_toolkit_name();
  version_string = atk_get_toolkit_version();
  g_print ("Toolkit name <%s> version <%s>\n", name_string,
    version_string);

  if (g_getenv("TEST_ACCESSIBLE_DEPTH") != NULL)
    max_depth = string_to_int(g_getenv("TEST_ACCESSIBLE_DEPTH"));
  else
    max_depth = 2;

  display_children_to_depth(root_obj, max_depth, 0, 0);
  g_print ("End of _check_toplevel\n");

  if (!g_register_listener)
    {
      g_print("Adding global event listener on buttons\n");
      g_register_listener = TRUE;
      g_signal_listener = atk_add_global_event_listener(_button_press_event_watcher,
        "Gtk:GtkButton:pressed");
    }
}
Example #25
0
void connect_key_accels(dt_lib_module_t *self)
{
  dt_lib_tagging_t *d = (dt_lib_tagging_t*)self->data;

  dt_accel_connect_button_lib(self, "attach", d->attach_button);
  dt_accel_connect_button_lib(self, "detach", d->detach_button);
  dt_accel_connect_button_lib(self, "new", d->new_button);
  dt_accel_connect_button_lib(self, "delete", d->delete_button);
  dt_accel_connect_lib(self, "tag", g_cclosure_new(G_CALLBACK(_lib_tagging_tag_show), self, NULL));
}
Example #26
0
static int register_shortcut_event(lua_State* L) {
  // 1 is the event name (checked)
  // 2 is the action to perform (checked)
  // 3 is the key itself
  int result = register_keyed_event(L); // will raise an error in case of duplicate key
  const char* tmp = luaL_checkstring(L,3);
  dt_accel_register_lua(tmp,0,0);
  dt_accel_connect_lua(tmp, g_cclosure_new(G_CALLBACK(shortcut_callback),strdup(luaL_checkstring(L,3)),closure_destroy));
  return result;
}
/**
 * bonobo_ui_component_add_verb:
 * @component: the component to add it to
 * @cname: the programmatic name of the verb
 * @fn: the callback function for invoking it
 * @user_data: the associated user data for the callback
 *
 * Add a verb to the UI component, that can be invoked by
 * the container.
 **/
void
bonobo_ui_component_add_verb (BonoboUIComponent  *component,
			      const char         *cname,
			      BonoboUIVerbFn      fn,
			      gpointer            user_data)
{
	bonobo_ui_component_add_verb_full (
		component, cname, g_cclosure_new (
			G_CALLBACK (fn), user_data, NULL));
}
Example #28
0
void
gtksharp_override_virtual_method (GType g_type, const gchar *name, GCallback callback)
{
	guint id;
	GClosure *closure;
	if (g_type_class_peek (g_type) == NULL)
		g_type_class_ref (g_type);
	id = g_signal_lookup (name, g_type);
	closure = g_cclosure_new (callback, NULL, NULL);
	g_signal_override_class_closure (id, g_type, closure);
}
/**
 * bonobo_shlib_factory_new:
 * @component_id: The GOAD id that this factory implements
 * @poa: the poa.
 * @act_impl_ptr: Activation shlib handle
 * @factory_cb: A callback which is used to create new BonoboObject instances.
 * @user_data: The closure data to be passed to the @factory callback routine.
 *
 * This is a helper routine that simplifies the creation of factory
 * objects for GNOME objects.  The @factory function will be
 * invoked by the CORBA server when a request arrives to create a new
 * instance of an object supporting the Bonobo::Shlib interface.
 * The factory callback routine is passed the @data pointer to provide
 * the creation function with some state information.
 *
 * Returns: A BonoboShlibFactory object that has an activated
 * Bonobo::ShlibFactory object that has registered with the GNOME
 * name server.
 */
BonoboShlibFactory *
bonobo_shlib_factory_new (const char           *component_id,
			  PortableServer_POA    poa,
			  gpointer              act_impl_ptr,
			  BonoboFactoryCallback factory_cb,
			  gpointer              user_data)
{
	return bonobo_shlib_factory_new_closure (
		component_id, poa, act_impl_ptr,
		g_cclosure_new (G_CALLBACK (factory_cb), user_data, NULL));
}
void
matecomponent_event_source_client_add_listener (MateComponent_Unknown           object,
					 MateComponentListenerCallbackFn event_callback,
					 const char              *opt_mask,
					 CORBA_Environment       *opt_ev,
					 gpointer                 user_data)
{
	matecomponent_event_source_client_add_listener_closure (
		object, g_cclosure_new (G_CALLBACK (event_callback), user_data, NULL),
		opt_mask, opt_ev);
}