void
gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
                                GtkWidget         *dialog)
{
  GimpDialogFactory      *dialog_factory;
  GimpDialogFactoryEntry *entry;
  GList                  *list;
  gboolean                toplevel;

  g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
  g_return_if_fail (GTK_IS_WIDGET (dialog));

  if (g_list_find (factory->open_dialogs, dialog))
    {
      g_warning ("%s: dialog already registered", G_STRFUNC);
      return;
    }

  dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);

  if (! (dialog_factory && (entry || GIMP_IS_DOCK (dialog))))
    {
      g_warning ("%s: dialog was not created by a GimpDialogFactory",
                 G_STRFUNC);
      return;
    }

  if (dialog_factory != factory)
    {
      g_warning ("%s: dialog was created by a different GimpDialogFactory",
                 G_STRFUNC);
      return;
    }

  toplevel = GTK_WIDGET_TOPLEVEL (dialog);

  if (entry) /* dialog is a toplevel (but not a GimpDock) or a GimpDockable */
    {
      GIMP_LOG (DIALOG_FACTORY, "adding %s \"%s\"",
                toplevel ? "toplevel" : "dockable",
                entry->identifier);

      for (list = factory->session_infos; list; list = g_list_next (list))
        {
          GimpSessionInfo *info = list->data;

          if ((info->toplevel_entry == entry) ||
              (info->dockable_entry == entry))
            {
              if (info->widget)
                {
                  if (entry->singleton)
                    {
                      g_warning ("%s: singleton dialog \"%s\" created twice",
                                 G_STRFUNC, entry->identifier);

                      GIMP_LOG (DIALOG_FACTORY,
                                "corrupt session info: %p (widget %p)",
                                info, info->widget);

                      return;
                    }

                  continue;
                }

              info->widget = dialog;

              GIMP_LOG (DIALOG_FACTORY,
                        "updating session info %p (widget %p) for %s \"%s\"",
                        info, info->widget,
                        toplevel ? "toplevel" : "dockable",
                        entry->identifier);

              if (toplevel && entry->session_managed &&
                  ! GTK_WIDGET_VISIBLE (dialog))
                {
                  gimp_session_info_set_geometry (info);
                }

              break;
            }
        }

      if (! list) /*  didn't find a session info  */
        {
          GimpSessionInfo *info = gimp_session_info_new ();

          info->widget = dialog;

          GIMP_LOG (DIALOG_FACTORY,
                    "creating session info %p (widget %p) for %s \"%s\"",
                    info, info->widget,
                    toplevel ? "toplevel" : "dockable",
                    entry->identifier);

          if (toplevel)
            {
              info->toplevel_entry = entry;

              /*  if we create a new session info, we never call
               *  gimp_session_info_set_geometry(), but still the
               *  dialog needs GDK_HINT_USER_POS so it keeps its
               *  position when hidden/shown within this(!) session.
               */
              if (entry->session_managed)
                g_signal_connect (dialog, "configure-event",
                                  G_CALLBACK (gimp_dialog_factory_set_user_pos),
                                  NULL);
            }
          else
            {
              info->dockable_entry = entry;
            }

          factory->session_infos = g_list_append (factory->session_infos, info);
        }
    }
  else /*  dialog is a GimpDock  */
    {
      GIMP_LOG (DIALOG_FACTORY, "adding dock");

      for (list = factory->session_infos; list; list = g_list_next (list))
        {
          GimpSessionInfo *info = list->data;

          /*  take the first empty slot  */
          if (! info->toplevel_entry &&
              ! info->dockable_entry &&
              ! info->widget)
            {
              info->widget = dialog;

              GIMP_LOG (DIALOG_FACTORY,
                        "updating session info %p (widget %p) for dock",
                        info, info->widget);

              gimp_session_info_set_geometry (info);

              break;
            }
        }

      if (! list) /*  didn't find a session info  */
        {
          GimpSessionInfo *info = gimp_session_info_new ();

          info->widget = dialog;

          GIMP_LOG (DIALOG_FACTORY,
                    "creating session info %p (widget %p) for dock",
                    info, info->widget);

          /*  let new docks appear at the pointer position  */
          gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);

          /*  if we create a new session info, we never call
           *  gimp_session_info_set_geometry(), but still the
           *  dialog needs GDK_HINT_USER_POS so it keeps its
           *  position when hidden/shown within this(!) session.
           */
          g_signal_connect (dialog, "configure-event",
                            G_CALLBACK (gimp_dialog_factory_set_user_pos),
                            NULL);

          factory->session_infos = g_list_append (factory->session_infos, info);
        }

      g_signal_emit (factory, factory_signals[DOCK_ADDED], 0, dialog);
    }

  factory->open_dialogs = g_list_prepend (factory->open_dialogs, dialog);

  g_signal_connect_object (dialog, "destroy",
                           G_CALLBACK (gimp_dialog_factory_remove_dialog),
                           factory,
                           G_CONNECT_SWAPPED);

  if ((entry && entry->session_managed && toplevel) || GIMP_IS_DOCK (dialog))
    g_signal_connect_object (dialog, "configure-event",
                             G_CALLBACK (gimp_dialog_factory_dialog_configure),
                             factory,
                             0);
}
Exemple #2
0
static void
client_view_ready_cb (GObject *source_object,
                      GAsyncResult *result,
                      gpointer user_data)
{
	EBookClient *book_client = E_BOOK_CLIENT (source_object);
	EBookClientView *client_view = NULL;
	EAddressbookModel *model = user_data;
	GError *error = NULL;

	e_book_client_get_view_finish (
		book_client, result, &client_view, &error);

	/* Sanity check. */
	g_return_if_fail (
		((client_view != NULL) && (error == NULL)) ||
		((client_view == NULL) && (error != NULL)));

	if (error != NULL) {
		eab_error_dialog (
			NULL, NULL, _("Error getting book view"), error);
		g_error_free (error);
		return;
	}

	remove_book_view (model);
	free_data (model);

	model->priv->client_view = client_view;
	if (model->priv->client_view) {
		model->priv->create_contact_id = g_signal_connect (
			model->priv->client_view, "objects-added",
			G_CALLBACK (view_create_contact_cb), model);
		model->priv->remove_contact_id = g_signal_connect (
			model->priv->client_view, "objects-removed",
			G_CALLBACK (view_remove_contact_cb), model);
		model->priv->modify_contact_id = g_signal_connect (
			model->priv->client_view, "objects-modified",
			G_CALLBACK (view_modify_contact_cb), model);
		model->priv->status_message_id = g_signal_connect (
			model->priv->client_view, "progress",
			G_CALLBACK (view_progress_cb), model);
		model->priv->view_complete_id = g_signal_connect (
			model->priv->client_view, "complete",
			G_CALLBACK (view_complete_cb), model);

		model->priv->search_in_progress = TRUE;
	}

	g_signal_emit (model, signals[MODEL_CHANGED], 0);
	g_signal_emit (model, signals[SEARCH_STARTED], 0);
	g_signal_emit (model, signals[STOP_STATE_CHANGED], 0);

	if (model->priv->client_view) {
		e_book_client_view_start (model->priv->client_view, &error);

		if (error != NULL) {
			g_warning (
				"%s: Failed to start client view: %s",
				G_STRFUNC, error->message);
			g_error_free (error);
		}
	}
}
Exemple #3
0
static void
entry_text_changed(GntEntry *entry)
{
	g_signal_emit(entry, signals[SIG_TEXT_CHANGED], 0);
}
static void
on_call_state (DBusGProxy *proxy,
               guint state,
               guint causetype,
               guint cause,
               ModemCall *self)
{
  ModemCallPrivate *priv = self->priv;

  g_assert (proxy); g_assert (self); g_assert (priv->proxy == proxy);

  DEBUG ("CallState (%s (%u), %u, %u) from %s%s",
      modem_call_get_state_name (state),
      state, causetype, cause, dbus_g_proxy_get_path (proxy),
      priv->handler ? "" : " (no channel)");

  g_object_set (self, "state", state,
      causetype > MODEM_CALL_CAUSE_TYPE_NETWORK
      /* Unknown causetype, ignore */
      ? NULL
      : "causetype", causetype,
      "cause", cause,
      NULL);

  switch (state)
    {
    case MODEM_CALL_STATE_INCOMING:
      g_object_set (self, "terminating", TRUE, NULL);
      break;
    case MODEM_CALL_STATE_DIALING:
      g_object_set (self, "originating", TRUE, NULL);
      break;

    case MODEM_CALL_STATE_INVALID:
      g_object_set (self,
          "remote", NULL,
          "emergency", NULL,
          "originating", FALSE,
          "terminating", FALSE,
          "onhold", FALSE,
          "multiparty", FALSE,
          NULL);
      break;
    }

  if (priv->handler == NULL)
    {
      switch (state)
        {
        case MODEM_CALL_STATE_DIALING:
        case MODEM_CALL_STATE_ALERTING:
        case MODEM_CALL_STATE_INCOMING:
        case MODEM_CALL_STATE_WAITING:
        case MODEM_CALL_STATE_ACTIVE:
        case MODEM_CALL_STATE_HELD:
          {
            char const *remote = priv->remote ? priv->remote : "";
            if (priv->terminating)
              g_signal_emit_by_name (priv->service, "incoming", self, remote);
            else if (priv->originating)
              g_signal_emit_by_name (priv->service, "created", self, remote);
          }
          break;
        default:
          break;
        }
    }

  g_signal_emit (self, call_signals[SIGNAL_STATE], 0, state, causetype, cause);

  if (state == MODEM_CALL_STATE_TERMINATED)
    {
      g_object_set (self,
          "remote", NULL,
          "emergency", NULL,
          "originating", FALSE,
          "terminating", FALSE,
          "onhold", FALSE,
          "multiparty", FALSE,
          NULL);
    }
}
static void fire (QCADUndoEntry *undo_entry, gboolean bUndo)
  {g_signal_emit (G_OBJECT (undo_entry), qcad_undo_entry_signals[QCAD_UNDO_ENTRY_APPLY_SIGNAL], 0, bUndo) ;}
/* with PAD_LOCK */
static GstRtpSsrcDemuxPad *
create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc,
    GstClockTime timestamp)
{
  GstPad *rtp_pad, *rtcp_pad;
  GstElementClass *klass;
  GstPadTemplate *templ;
  gchar *padname;
  GstRtpSsrcDemuxPad *demuxpad;

  GST_DEBUG_OBJECT (demux, "creating pad for SSRC %08x", ssrc);

  klass = GST_ELEMENT_GET_CLASS (demux);
  templ = gst_element_class_get_pad_template (klass, "src_%d");
  padname = g_strdup_printf ("src_%d", ssrc);
  rtp_pad = gst_pad_new_from_template (templ, padname);
  g_free (padname);

  templ = gst_element_class_get_pad_template (klass, "rtcp_src_%d");
  padname = g_strdup_printf ("rtcp_src_%d", ssrc);
  rtcp_pad = gst_pad_new_from_template (templ, padname);
  g_free (padname);

  /* we use the first timestamp received to calculate the difference between
   * timestamps on all streams */
  GST_DEBUG_OBJECT (demux, "SSRC %08x, first timestamp %" GST_TIME_FORMAT,
      ssrc, GST_TIME_ARGS (timestamp));

  /* wrap in structure and add to list */
  demuxpad = g_new0 (GstRtpSsrcDemuxPad, 1);
  demuxpad->ssrc = ssrc;
  demuxpad->rtp_pad = rtp_pad;
  demuxpad->rtcp_pad = rtcp_pad;

  GST_DEBUG_OBJECT (demux, "first timestamp %" GST_TIME_FORMAT,
      GST_TIME_ARGS (timestamp));

  gst_pad_set_element_private (rtp_pad, demuxpad);
  gst_pad_set_element_private (rtcp_pad, demuxpad);

  demux->srcpads = g_slist_prepend (demux->srcpads, demuxpad);

  /* copy caps from input */
  gst_pad_set_caps (rtp_pad, GST_PAD_CAPS (demux->rtp_sink));
  gst_pad_use_fixed_caps (rtp_pad);
  gst_pad_set_caps (rtcp_pad, GST_PAD_CAPS (demux->rtcp_sink));
  gst_pad_use_fixed_caps (rtcp_pad);

  gst_pad_set_event_function (rtp_pad, gst_rtp_ssrc_demux_src_event);
  gst_pad_set_query_function (rtp_pad, gst_rtp_ssrc_demux_src_query);
  gst_pad_set_iterate_internal_links_function (rtp_pad,
      gst_rtp_ssrc_demux_iterate_internal_links);
  gst_pad_set_active (rtp_pad, TRUE);

  gst_pad_set_event_function (rtcp_pad, gst_rtp_ssrc_demux_src_event);
  gst_pad_set_iterate_internal_links_function (rtcp_pad,
      gst_rtp_ssrc_demux_iterate_internal_links);
  gst_pad_set_active (rtcp_pad, TRUE);

  gst_element_add_pad (GST_ELEMENT_CAST (demux), rtp_pad);
  gst_element_add_pad (GST_ELEMENT_CAST (demux), rtcp_pad);

  g_signal_emit (G_OBJECT (demux),
      gst_rtp_ssrc_demux_signals[SIGNAL_NEW_SSRC_PAD], 0, ssrc, rtp_pad);

  return demuxpad;
}
Exemple #7
0
static void fm_job_emit_cancelled(FmJob* job)
{
    g_signal_emit(job, signals[CANCELLED], 0);
}
static void
time_changed (MnpClockArea *area, MnpWorldClock *clock)
{
    g_signal_emit (clock, signals[TIME_CHANGED], 0);
}
static void
dialog_response (GtkDialog *dialog,
                 gint response,
                 gpointer user_data)
{
    NMAWirelessDialog *self = NMA_WIRELESS_DIALOG (user_data);
    NMAWirelessDialogPrivate *priv = NMA_WIRELESS_DIALOG_GET_PRIVATE (self);
    NMSetting *setting;
    GtkTreeModel *model;
    GtkTreeIter iter;
    WirelessSecurity *sec = NULL;

    if (response != GTK_RESPONSE_OK)
        goto out;

    if (!priv->connection) {
        /* Create new connection */
        char *id;
        char *uuid;
        GByteArray *ssid;

        priv->connection = nm_connection_new ();

        /* Wireless setting */
        setting = nm_setting_wireless_new ();
        ssid = validate_dialog_ssid (self);
        g_object_set (setting, NM_SETTING_WIRELESS_SSID, ssid, NULL);
        nm_connection_add_setting (priv->connection, setting);

        if (ssid) {
            id = nm_utils_ssid_to_utf8 ((char *) ssid->data, ssid->len);
            g_byte_array_free (ssid, TRUE);
        } else
            id = NULL;

        /* Connection setting */
        setting = nm_setting_connection_new ();
        uuid = nm_utils_uuid_generate ();

        /* FIXME: don't autoconnect until the connection is successful at least once */
        /* Don't autoconnect adhoc networks by default for now */
        g_object_set (setting,
                      NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME,
                      NM_SETTING_CONNECTION_UUID, uuid,
                      NM_SETTING_CONNECTION_ID, id,
                      NM_SETTING_CONNECTION_AUTOCONNECT, !priv->adhoc_create,
                      NULL);

        g_free (uuid);
        g_free (id);
        nm_connection_add_setting (priv->connection, setting);

        /* IPv4 setting */
        if (priv->adhoc_create) {
            g_object_set (setting, NM_SETTING_WIRELESS_MODE, "adhoc", NULL);

            setting = nm_setting_ip4_config_new ();
            g_object_set (setting,
                          NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_SHARED,
                          NULL);

            nm_connection_add_setting (priv->connection, setting);
        }
    }

    model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo));
    gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->sec_combo), &iter);
    gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1);

    if (sec && !priv->nag_ignored) {
        GtkWidget *nag_dialog;

        /* Nag the user about certificates or whatever.  Only destroy the dialog
         * if no nagging was done.
         */
        nag_dialog = wireless_security_nag_user (sec);
        if (nag_dialog) {
            gtk_window_set_transient_for (GTK_WINDOW (nag_dialog), GTK_WINDOW (dialog));
            g_signal_connect (nag_dialog, "response",
                              G_CALLBACK (nag_dialog_response_cb),
                              dialog);
            return;
        }
    }

    /* Fill security */
    if (sec) {
        wireless_security_fill_connection (sec, priv->connection);
        wireless_security_unref (sec);
    } else {
        /* Unencrypted */
        setting = nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS);
        g_object_set (setting, NM_SETTING_WIRELESS_SEC, NULL, NULL);
    }

 out:
    g_signal_emit (self, signals[DONE], 0, response);
    nm_utils_dialog_done ();

    /* FIXME: clear security? */
}
Exemple #10
0
static void
mex_plugin_manager_load_plugin (MexPluginManager *manager,
                                const gchar      *filename)
{
  GModule *module;
  gpointer symbol;
  GObject *plugin;
  GType plugin_type;
  gchar *plugin_name;
  gchar *plugin_suffix;

  MexPluginManagerPrivate *priv = manager->priv;

  /* Extract the plugin name */
  plugin_name = g_path_get_basename (filename);
  if ((plugin_suffix = g_strrstr (plugin_name, ".")))
    *plugin_suffix = '\0';

  /* Check if plugin already exists */
  if (g_hash_table_lookup (priv->plugins, plugin_name))
    {
      g_free (plugin_name);
      return;
    }

  module = g_module_open (filename, G_MODULE_BIND_LOCAL);
  if (!module)
    {
      g_warning (G_STRLOC ": Error opening module: %s",
                 g_module_error ());
      g_free (plugin_name);
      return;
    }

  if (!g_module_symbol (module, "mex_get_plugin_type", &symbol))
    {
      g_warning (G_STRLOC ": Unable to get symbol 'mex_get_plugin_type': %s",
                 g_module_error ());
      g_module_close (module);
      g_free (plugin_name);
      return;
    }

  plugin_type = (*(MexPluginGetTypeFunc)symbol)();

  if (!plugin_type)
    {
      g_warning (G_STRLOC ": Plugin '%s' didn't return a type", plugin_name);
      g_module_close (module);
      g_free (plugin_name);
      return;
    }

  /* Unloading modules usually has bad effects - don't allow it */
  g_module_make_resident (module);

  plugin = g_object_new (plugin_type, NULL);

  g_hash_table_insert (priv->plugins,
                       plugin_name,
                       plugin);

  g_signal_emit (manager, signals[PLUGIN_LOADED], 0, plugin);
}
Exemple #11
0
static void
got_more_files (GObject *source_object,
		GAsyncResult *res,
		gpointer user_data)
{
  LoadBasenamesData *data = user_data;
  GList *infos, *l;
  GFileInfo *info;
  const char *name;
  gboolean append_slash;
  char *t;
  char *basename;

  if (data->completer == NULL)
    {
      /* Was cancelled */
      load_basenames_data_free (data);
      return;
    }

  infos = g_file_enumerator_next_files_finish (data->enumerator, res, NULL);

  for (l = infos; l != NULL; l = l->next)
    {
      info = l->data;

      if (data->dirs_only &&
	  g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY)
	{
	  g_object_unref (info);
	  continue;
	}
      
      append_slash = g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY;
      name = g_file_info_get_name (info);
      if (name == NULL)
	{
	  g_object_unref (info);
	  continue;
	}

      
      if (data->should_escape)
	basename = g_uri_escape_string (name,
					G_URI_RESERVED_CHARS_ALLOWED_IN_PATH,
					TRUE);
      else
	/* If not should_escape, must be a local filename, convert to utf8 */
	basename = g_filename_to_utf8 (name, -1, NULL, NULL, NULL);
      
      if (basename)
	{
	  if (append_slash)
	    {
	      t = basename;
	      basename = g_strconcat (basename, "/", NULL);
	      g_free (t);
	    }
	  
	  data->basenames = g_list_prepend (data->basenames, basename);
	}
      
      g_object_unref (info);
    }
  
  g_list_free (infos);
  
  if (infos)
    {
      /* Not last, get more files */
      g_file_enumerator_next_files_async (data->enumerator,
					  100,
					  0,
					  data->cancellable,
					  got_more_files, data);
    }
  else
    {
      data->completer->basename_loader = NULL;
      
      if (data->completer->basenames_dir)
	g_object_unref (data->completer->basenames_dir);
      g_list_free_full (data->completer->basenames, g_free);
      
      data->completer->basenames_dir = g_object_ref (data->dir);
      data->completer->basenames = data->basenames;
      data->completer->basenames_are_escaped = data->should_escape;
      data->basenames = NULL;
      
      g_file_enumerator_close_async (data->enumerator, 0, NULL, NULL, NULL);

      g_signal_emit (data->completer, signals[GOT_COMPLETION_DATA], 0);
      load_basenames_data_free (data);
    }
}
Exemple #12
0
static void html_location_changed(Html* self) {
	gchar* uri = g_strdup(webkit_web_view_get_uri(self->webview));
	g_signal_emit(self, signals[LOCATION_CHANGED], 0, uri);
	g_free(uri);
}
static void
gst_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host,
    gint port, gboolean lock)
{
  GstUDPClient *client;
  GstUDPClient udpclient;
  GTimeVal now;
  GList *find;

  udpclient.host = (gchar *) host;
  udpclient.port = port;

  GST_DEBUG_OBJECT (sink, "adding client on host %s, port %d", host, port);

  if (lock)
    g_mutex_lock (sink->client_lock);

  find = g_list_find_custom (sink->clients, &udpclient,
      (GCompareFunc) client_compare);
  if (find) {
    client = (GstUDPClient *) find->data;

    GST_DEBUG_OBJECT (sink, "found %d existing clients with host %s, port %d",
        client->refcount, host, port);
    client->refcount++;
  } else {
    client = create_client (sink, host, port);

    client->sock = &sink->sock;

    if (gst_udp_get_addr (host, port, &client->theiraddr) < 0)
      goto getaddrinfo_error;

    g_get_current_time (&now);
    client->connect_time = GST_TIMEVAL_TO_TIME (now);

    if (*client->sock > 0) {
      gst_multiudpsink_configure_client (sink, client);
    }

    GST_DEBUG_OBJECT (sink, "add client with host %s, port %d", host, port);
    sink->clients = g_list_prepend (sink->clients, client);
  }

  if (lock)
    g_mutex_unlock (sink->client_lock);

  g_signal_emit (G_OBJECT (sink),
      gst_multiudpsink_signals[SIGNAL_CLIENT_ADDED], 0, host, port);

  GST_DEBUG_OBJECT (sink, "added client on host %s, port %d", host, port);
  return;

  /* ERRORS */
getaddrinfo_error:
  {
    GST_DEBUG_OBJECT (sink, "did not add client on host %s, port %d", host,
        port);
    GST_WARNING_OBJECT (sink, "getaddrinfo lookup error?");
    free_client (client);
    if (lock)
      g_mutex_unlock (sink->client_lock);
    return;
  }
}
Exemple #14
0
void
gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
                                   GtkWidget         *dialog)
{
  GimpDialogFactory      *dialog_factory;
  GimpDialogFactoryEntry *entry;
  GList                  *list;

  g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
  g_return_if_fail (GTK_IS_WIDGET (dialog));

  if (! g_list_find (factory->open_dialogs, dialog))
    {
      g_warning ("%s: dialog not registered", G_STRFUNC);
      return;
    }

  factory->open_dialogs = g_list_remove (factory->open_dialogs, dialog);

  dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);

  if (! (dialog_factory && (entry || GIMP_IS_DOCK (dialog))))
    {
      g_warning ("%s: dialog was not created by a GimpDialogFactory",
                 G_STRFUNC);
      return;
    }

  if (dialog_factory != factory)
    {
      g_warning ("%s: dialog was created by a different GimpDialogFactory",
                 G_STRFUNC);
      return;
    }

  GIMP_LOG (DIALOG_FACTORY, "removing \"%s\"",
            entry ? entry->identifier : "dock");

  for (list = factory->session_infos; list; list = g_list_next (list))
    {
      GimpSessionInfo *session_info = list->data;

      if (session_info->widget == dialog)
        {
          GIMP_LOG (DIALOG_FACTORY,
                    "clearing session info %p (widget %p) for \"%s\"",
                    session_info, session_info->widget,
                    entry ? entry->identifier : "dock");

          session_info->widget = NULL;

          gimp_dialog_factory_unset_widget_data (dialog);

          g_signal_handlers_disconnect_by_func (dialog,
                                                gimp_dialog_factory_set_user_pos,
                                                NULL);
          g_signal_handlers_disconnect_by_func (dialog,
                                                gimp_dialog_factory_remove_dialog,
                                                factory);

          if (entry && entry->session_managed && GTK_WIDGET_TOPLEVEL (dialog))
            g_signal_handlers_disconnect_by_func (dialog,
                                                  gimp_dialog_factory_dialog_configure,
                                                  factory);

          if (GIMP_IS_DOCK (dialog))
            {
              /*  don't save session info for empty docks  */
              factory->session_infos = g_list_remove (factory->session_infos,
                                                      session_info);
              g_object_unref (session_info);

              g_signal_emit (factory, factory_signals[DOCK_REMOVED], 0,
                             dialog);
            }

          break;
        }
    }
}
Exemple #15
0
static void
egg_find_bar_emit_previous (EggFindBar *find_bar)
{
  g_signal_emit (find_bar, find_bar_signals[PREVIOUS], 0);
}
Exemple #16
0
gboolean
gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure  *proc,
                                      const gchar          *menu_path,
                                      GError              **error)
{
  GimpProcedure *procedure;
  gchar         *basename = NULL;
  const gchar   *required = NULL;
  gchar         *p;
  gchar         *mapped_path;

  g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), FALSE);
  g_return_val_if_fail (menu_path != NULL, FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  procedure = GIMP_PROCEDURE (proc);

  p = strchr (menu_path, '>');
  if (p == NULL || (*(++p) && *p != '/'))
    {
      basename = g_path_get_basename (gimp_file_get_utf8_name (proc->file));

      g_set_error (error, GIMP_PLUG_IN_ERROR, GIMP_PLUG_IN_FAILED,
                   "Plug-In \"%s\"\n(%s)\n"
                   "attempted to install procedure \"%s\"\n"
                   "in the invalid menu location \"%s\".\n"
                   "The menu path must look like either \"<Prefix>\" "
                   "or \"<Prefix>/path/to/item\".",
                   basename, gimp_file_get_utf8_name (proc->file),
                   gimp_object_get_name (proc),
                   menu_path);
      goto failure;
    }

  if (g_str_has_prefix (menu_path, "<Toolbox>") ||
      g_str_has_prefix (menu_path, "<Image>"))
    {
      if ((procedure->num_args < 1) ||
          ! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]))
        {
          required = "INT32";
          goto failure;
        }
    }
  else if (g_str_has_prefix (menu_path, "<Layers>"))
    {
      if ((procedure->num_args < 3)                             ||
          ! GIMP_IS_PARAM_SPEC_INT32       (procedure->args[0]) ||
          ! GIMP_IS_PARAM_SPEC_IMAGE_ID    (procedure->args[1]) ||
          ! (G_TYPE_FROM_INSTANCE (procedure->args[2])
                               == GIMP_TYPE_PARAM_LAYER_ID ||
             G_TYPE_FROM_INSTANCE (procedure->args[2])
                               == GIMP_TYPE_PARAM_DRAWABLE_ID))
        {
          required = "INT32, IMAGE, (LAYER | DRAWABLE)";
          goto failure;
        }
    }
  else if (g_str_has_prefix (menu_path, "<Channels>"))
    {
      if ((procedure->num_args < 3)                             ||
          ! GIMP_IS_PARAM_SPEC_INT32       (procedure->args[0]) ||
          ! GIMP_IS_PARAM_SPEC_IMAGE_ID    (procedure->args[1]) ||
          ! (G_TYPE_FROM_INSTANCE (procedure->args[2])
                               == GIMP_TYPE_PARAM_CHANNEL_ID ||
             G_TYPE_FROM_INSTANCE (procedure->args[2])
                               == GIMP_TYPE_PARAM_DRAWABLE_ID))
        {
          required = "INT32, IMAGE, (CHANNEL | DRAWABLE)";
          goto failure;
        }
    }
  else if (g_str_has_prefix (menu_path, "<Vectors>"))
    {
      if ((procedure->num_args < 3)                            ||
          ! GIMP_IS_PARAM_SPEC_INT32      (procedure->args[0]) ||
          ! GIMP_IS_PARAM_SPEC_IMAGE_ID   (procedure->args[1]) ||
          ! GIMP_IS_PARAM_SPEC_VECTORS_ID (procedure->args[2]))
        {
          required = "INT32, IMAGE, VECTORS";
          goto failure;
        }
    }
  else if (g_str_has_prefix (menu_path, "<Colormap>"))
    {
      if ((procedure->num_args < 2)                            ||
          ! GIMP_IS_PARAM_SPEC_INT32      (procedure->args[0]) ||
          ! GIMP_IS_PARAM_SPEC_IMAGE_ID   (procedure->args[1]))
        {
          required = "INT32, IMAGE";
          goto failure;
        }
    }
  else if (g_str_has_prefix (menu_path, "<Load>"))
    {
      if ((procedure->num_args < 3)                       ||
          ! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
          ! G_IS_PARAM_SPEC_STRING   (procedure->args[1]) ||
          ! G_IS_PARAM_SPEC_STRING   (procedure->args[2]))
        {
          required = "INT32, STRING, STRING";
          goto failure;
        }

      if ((procedure->num_values < 1) ||
          ! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->values[0]))
        {
          required = "IMAGE";
          goto failure;
        }
    }
  else if (g_str_has_prefix (menu_path, "<Save>"))
    {
      if ((procedure->num_args < 5)                             ||
          ! GIMP_IS_PARAM_SPEC_INT32       (procedure->args[0]) ||
          ! GIMP_IS_PARAM_SPEC_IMAGE_ID    (procedure->args[1]) ||
          ! GIMP_IS_PARAM_SPEC_DRAWABLE_ID (procedure->args[2]) ||
          ! G_IS_PARAM_SPEC_STRING         (procedure->args[3]) ||
          ! G_IS_PARAM_SPEC_STRING         (procedure->args[4]))
        {
          required = "INT32, IMAGE, DRAWABLE, STRING, STRING";
          goto failure;
        }
    }
  else if (g_str_has_prefix (menu_path, "<Brushes>")     ||
           g_str_has_prefix (menu_path, "<Dynamics>")    ||
           g_str_has_prefix (menu_path, "<Gradients>")   ||
           g_str_has_prefix (menu_path, "<Palettes>")    ||
           g_str_has_prefix (menu_path, "<Patterns>")    ||
           g_str_has_prefix (menu_path, "<ToolPresets>") ||
           g_str_has_prefix (menu_path, "<Fonts>")       ||
           g_str_has_prefix (menu_path, "<Buffers>"))
    {
      if ((procedure->num_args < 1) ||
          ! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]))
        {
          required = "INT32";
          goto failure;
        }
    }
  else
    {
      basename = g_path_get_basename (gimp_file_get_utf8_name (proc->file));

      g_set_error (error, GIMP_PLUG_IN_ERROR, GIMP_PLUG_IN_FAILED,
                   "Plug-In \"%s\"\n(%s)\n"
                   "attempted to install procedure \"%s\" "
                   "in the invalid menu location \"%s\".\n"
                   "Use either \"<Image>\", "
                   "\"<Layers>\", \"<Channels>\", \"<Vectors>\", "
                   "\"<Colormap>\", \"<Brushes>\", \"<Dynamics>\", "
                   "\"<Gradients>\", \"<Palettes>\", \"<Patterns>\", "
                   "\"<ToolPresets>\", \"<Fonts>\" or \"<Buffers>\".",
                   basename, gimp_file_get_utf8_name (proc->file),
                   gimp_object_get_name (proc),
                   menu_path);
      goto failure;
    }

  g_free (basename);

  mapped_path = plug_in_menu_path_map (menu_path, NULL);

  proc->menu_paths = g_list_append (proc->menu_paths, mapped_path);

  g_signal_emit (proc, gimp_plug_in_procedure_signals[MENU_PATH_ADDED], 0,
                 mapped_path);

  return TRUE;

 failure:
  if (required)
    {
      gchar *prefix = g_strdup (menu_path);

      p = strchr (prefix, '>') + 1;
      *p = '\0';

      basename = g_path_get_basename (gimp_file_get_utf8_name (proc->file));

      g_set_error (error, GIMP_PLUG_IN_ERROR, GIMP_PLUG_IN_FAILED,
                   "Plug-In \"%s\"\n(%s)\n\n"
                   "attempted to install %s procedure \"%s\" "
                   "which does not take the standard %s Plug-In "
                   "arguments: (%s).",
                   basename, gimp_file_get_utf8_name (proc->file),
                   prefix, gimp_object_get_name (proc), prefix,
                   required);

      g_free (prefix);
    }

  g_free (basename);

  return FALSE;
}
Exemple #17
0
/**
 * Parse @channel contents as M3U.
 **/
static void
parse_m3u (PlaylistParser *parser,
           GIOChannel     *channel,
           const char     *dirname)
{
        char *line, *p;
        gsize length;

        /**
         * Signal start of playlist.
         **/
        g_signal_emit (parser, signals[SIGNAL_PLAYLIST_START], 0);

        /**
         * Parse @channel line by line.
         **/
        while (g_io_channel_read_line (channel,
                                       &line,
                                       &length, 
                                       NULL,
                                       NULL) == G_IO_STATUS_NORMAL) {
                if (line[0] == '#') {
                        /**
                         * Ignore comments.
                         **/
                        g_free (line);

                        continue;
                }

                /**
                 * This is a normal line. First we de-DOS...
                 **/
                for (p = line; *p != '\0'; p++) {
                        switch (*p) {
                        case '\\':
                                *p = '/';
                                break;
                        case '\r':
                                *p = '\0';
                                break;
                        case '\n':
                                *p = '\0';
                                break;
                        default:
                                break;
                        }
                }

                /**
                 * Now we process it.
                 **/
                if (strstr (line, "://")) {
                        /**
                         * This already is an URI.
                         **/
                        g_signal_emit (parser, signals[SIGNAL_ENTRY], 0, line);
                } else if (g_path_is_absolute (line)) {
                        /**
                         * This is an absolute path.
                         **/
                        got_absolute_path (parser, line);
                } else {
                        char *absolute;

                        /**
                         * This is a relative path.
                         **/
                        absolute = g_build_filename (dirname, line, NULL);
                        got_absolute_path (parser, absolute);
                        g_free (absolute);
                }

                g_free (line);
        }
        
        /**
         * Signal end of playlist.
         **/
        g_signal_emit (parser, signals[SIGNAL_PLAYLIST_END], 0);
}
Exemple #18
0
gboolean on_idle(FmFolder* folder)
{
    GSList* l;
    FmFileInfoJob* job = NULL;
    FmPath* path;
    folder->idle_handler = 0;
    if(folder->files_to_update || folder->files_to_add)
        job = (FmFileInfoJob*)fm_file_info_job_new(NULL);

    if(folder->files_to_update)
    {
        GSList* prev = NULL;
        for(l=folder->files_to_update;l;)
        {
            /* if a file is already in files_to_add, remove it. */
            if(g_slist_find_custom(folder->files_to_add, l->data, (GCompareFunc)strcmp))
            {
                GSList* tmp = l;
                l=l->next;
                if(G_LIKELY(prev))
                    prev->next = l;
                g_free(tmp->data);
                g_slist_free_1(tmp);
                if(G_UNLIKELY(tmp == folder->files_to_update))
                    folder->files_to_update = l;
                continue;
            }
            path = fm_path_new_child(folder->dir_path, (char*)l->data);
            fm_file_info_job_add(job, path);
            fm_path_unref(path);
            g_free(l->data);

            prev = l;
            l=l->next;
        }
        g_slist_free(folder->files_to_update);
        folder->files_to_update = NULL;
    }

    if(folder->files_to_add)
    {
        for(l=folder->files_to_add;l;l=l->next)
        {
            path = fm_path_new_child(folder->dir_path, (char*)l->data);
            fm_file_info_job_add(job, path);
            fm_path_unref(path);
            g_free(l->data);
        }
        g_slist_free(folder->files_to_add);
        folder->files_to_add = NULL;
    }

    if(job)
    {
        g_signal_connect(job, "finished", on_file_info_finished, folder);
        folder->pending_jobs = g_slist_prepend(folder->pending_jobs, job);
        fm_job_run_async(FM_JOB(job));
    }

    if(folder->files_to_del)
    {
        GSList* ll;
        for(ll=folder->files_to_del;ll;ll=ll->next)
        {
            GList* l= (GList*)ll->data;
            ll->data = l->data;
            fm_list_delete_link_nounref(folder->files , l);
        }
        g_signal_emit(folder, signals[FILES_REMOVED], 0, folder->files_to_del);
        g_slist_foreach(folder->files_to_del, (GFunc)fm_file_info_unref, NULL);
        g_slist_free(folder->files_to_del);
        folder->files_to_del = NULL;
    }

    return FALSE;
}
Exemple #19
0
static void fm_job_emit_finished(FmJob* job)
{
    g_signal_emit(job, signals[FINISHED], 0);
}
Exemple #20
0
static gboolean on_job_err(FmDirListJob* job, GError* err, gboolean recoverable, FmFolder* folder)
{
	gboolean ret;
	g_signal_emit(folder, signals[ERROR], 0, err, recoverable, &ret);
    return ret;
}
Exemple #21
0
static gboolean on_delete_event(GtkWidget *widget, GdkEvent *event, AnimationRenderUi *self) {
    if (self->render_in_progress)
	animation_render_ui_stop(self);
    g_signal_emit(G_OBJECT(self), animation_render_ui_signals[CLOSED_SIGNAL], 0);
    return FALSE;
}
Exemple #22
0
static GstFlowReturn
gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
    gboolean steal_ref)
{
  gboolean first = TRUE;

  g_return_val_if_fail (appsrc, GST_FLOW_ERROR);
  g_return_val_if_fail (GST_IS_APP_SRC (appsrc), GST_FLOW_ERROR);
  g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);

  g_mutex_lock (appsrc->priv->mutex);

  while (TRUE) {
    /* can't accept buffers when we are flushing or EOS */
    if (appsrc->priv->flushing)
      goto flushing;

    if (appsrc->priv->is_eos)
      goto eos;

    if (appsrc->priv->max_bytes
        && appsrc->priv->queued_bytes >= appsrc->priv->max_bytes) {
      GST_DEBUG_OBJECT (appsrc,
          "queue filled (%" G_GUINT64_FORMAT " >= %" G_GUINT64_FORMAT ")",
          appsrc->priv->queued_bytes, appsrc->priv->max_bytes);

      if (first) {
        gboolean emit;

        emit = appsrc->priv->emit_signals;
        /* only signal on the first push */
        g_mutex_unlock (appsrc->priv->mutex);

        if (appsrc->priv->callbacks.enough_data)
          appsrc->priv->callbacks.enough_data (appsrc, appsrc->priv->user_data);
        else if (emit)
          g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_ENOUGH_DATA], 0,
              NULL);

        g_mutex_lock (appsrc->priv->mutex);
        /* continue to check for flushing/eos after releasing the lock */
        first = FALSE;
        continue;
      }
      if (appsrc->priv->block) {
        GST_DEBUG_OBJECT (appsrc, "waiting for free space");
        /* we are filled, wait until a buffer gets popped or when we
         * flush. */
        g_cond_wait (appsrc->priv->cond, appsrc->priv->mutex);
      } else {
        /* no need to wait for free space, we just pump more data into the
         * queue hoping that the caller reacts to the enough-data signal and
         * stops pushing buffers. */
        break;
      }
    } else
      break;
  }

  GST_DEBUG_OBJECT (appsrc, "queueing buffer %p", buffer);
  if (!steal_ref)
    gst_buffer_ref (buffer);
  g_queue_push_tail (appsrc->priv->queue, buffer);
  appsrc->priv->queued_bytes += GST_BUFFER_SIZE (buffer);
  g_cond_broadcast (appsrc->priv->cond);
  g_mutex_unlock (appsrc->priv->mutex);

  return GST_FLOW_OK;

  /* ERRORS */
flushing:
  {
    GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
    if (steal_ref)
      gst_buffer_unref (buffer);
    g_mutex_unlock (appsrc->priv->mutex);
    return GST_FLOW_WRONG_STATE;
  }
eos:
  {
    GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
    if (steal_ref)
      gst_buffer_unref (buffer);
    g_mutex_unlock (appsrc->priv->mutex);
    return GST_FLOW_UNEXPECTED;
  }
}
static void
gimp_operation_cage_transform_notify_progress (gpointer instance,
                                               gdouble  progress)
{
  g_signal_emit (instance, cage_transform_signals[PROGRESS], 0, progress);
}
Exemple #24
0
static GstFlowReturn
gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
    GstBuffer ** buf)
{
  GstAppSrc *appsrc = GST_APP_SRC (bsrc);
  GstFlowReturn ret;

  g_mutex_lock (appsrc->priv->mutex);
  /* check flushing first */
  if (G_UNLIKELY (appsrc->priv->flushing))
    goto flushing;

  if (appsrc->priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
    /* if we are dealing with a random-access stream, issue a seek if the offset
     * changed. */
    if (G_UNLIKELY (appsrc->priv->offset != offset)) {
      gboolean res;
      gboolean emit;

      emit = appsrc->priv->emit_signals;
      g_mutex_unlock (appsrc->priv->mutex);

      GST_DEBUG_OBJECT (appsrc,
          "we are at %" G_GINT64_FORMAT ", seek to %" G_GINT64_FORMAT,
          appsrc->priv->offset, offset);

      if (appsrc->priv->callbacks.seek_data)
        res = appsrc->priv->callbacks.seek_data (appsrc, offset,
            appsrc->priv->user_data);
      else if (emit)
        g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
            offset, &res);

      if (G_UNLIKELY (!res))
        /* failing to seek is fatal */
        goto seek_error;

      g_mutex_lock (appsrc->priv->mutex);

      appsrc->priv->offset = offset;
    }
  }

  while (TRUE) {
    /* return data as long as we have some */
    if (!g_queue_is_empty (appsrc->priv->queue)) {
      guint buf_size;

      *buf = g_queue_pop_head (appsrc->priv->queue);
      buf_size = GST_BUFFER_SIZE (*buf);

      GST_DEBUG_OBJECT (appsrc, "we have buffer %p of size %u", *buf, buf_size);

      appsrc->priv->queued_bytes -= buf_size;

      /* only update the offset when in random_access mode */
      if (appsrc->priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
        appsrc->priv->offset += buf_size;
      }

      gst_buffer_set_caps (*buf, appsrc->priv->caps);

      /* signal that we removed an item */
      g_cond_broadcast (appsrc->priv->cond);

      ret = GST_FLOW_OK;
      break;
    } else {
      gboolean emit;

      emit = appsrc->priv->emit_signals;
      g_mutex_unlock (appsrc->priv->mutex);

      /* we have no data, we need some. We fire the signal with the size hint. */
      if (appsrc->priv->callbacks.need_data)
        appsrc->priv->callbacks.need_data (appsrc, size,
            appsrc->priv->user_data);
      else if (emit)
        g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_NEED_DATA], 0, size,
            NULL);

      g_mutex_lock (appsrc->priv->mutex);
      /* we can be flushing now because we released the lock */
      if (G_UNLIKELY (appsrc->priv->flushing))
        goto flushing;

      /* if we have a buffer now, continue the loop and try to return it. In
       * random-access mode (where a buffer is normally pushed in the above
       * signal) we can still be empty because the pushed buffer got flushed or
       * when the application pushes the requested buffer later, we support both
       * possiblities. */
      if (!g_queue_is_empty (appsrc->priv->queue))
        continue;

      /* no buffer yet, maybe we are EOS, if not, block for more data. */
    }

    /* check EOS */
    if (G_UNLIKELY (appsrc->priv->is_eos))
      goto eos;

    /* nothing to return, wait a while for new data or flushing. */
    g_cond_wait (appsrc->priv->cond, appsrc->priv->mutex);
  }
  g_mutex_unlock (appsrc->priv->mutex);

  return ret;

  /* ERRORS */
flushing:
  {
    GST_DEBUG_OBJECT (appsrc, "we are flushing");
    g_mutex_unlock (appsrc->priv->mutex);
    return GST_FLOW_WRONG_STATE;
  }
eos:
  {
    GST_DEBUG_OBJECT (appsrc, "we are EOS");
    g_mutex_unlock (appsrc->priv->mutex);
    return GST_FLOW_UNEXPECTED;
  }
seek_error:
  {
    GST_ELEMENT_ERROR (appsrc, RESOURCE, READ, ("failed to seek"),
        GST_ERROR_SYSTEM);
    return GST_FLOW_ERROR;
  }
}
Exemple #25
0
static void
stmt_reset_cb (GdaStatement *stmt, GdaBatch *batch)
{
	g_signal_emit (batch, gda_batch_signals [CHANGED], 0, stmt);
}
static void
selection_changed_cb (GtkTreeSelection *selection,
                      gpointer          data)
{
  g_signal_emit (data, source_chooser_signals[SELECTION_CHANGED], 0);
}
/**
 * gimp_unit_menu_set_unit:
 * @menu:  The unit menu you want to set the unit for.
 * @unit: The new unit.
 *
 * Sets a new #GimpUnit for the specified #GimpUnitMenu.
 **/
void
gimp_unit_menu_set_unit (GimpUnitMenu *menu,
                         GimpUnit      unit)
{
  GtkWidget *menuitem = NULL;
  GList     *items;
  gint       user_unit;

  g_return_if_fail (GIMP_IS_UNIT_MENU (menu));
  g_return_if_fail (((unit >= GIMP_UNIT_PIXEL) &&
                     ((unit > GIMP_UNIT_PIXEL) || menu->show_pixels) &&
                     (unit < gimp_unit_get_number_of_units ())) ||
                    ((unit == GIMP_UNIT_PERCENT) && menu->show_percent));

  if (unit == menu->unit)
    return;

  items = GTK_MENU_SHELL (GTK_OPTION_MENU (menu)->menu)->children;
  user_unit = (GIMP_UNIT_END +
               (((menu->show_pixels || menu->show_percent) ? 2 : 0) +
                ((menu->show_pixels && menu->show_percent) ? 1 : 0)));

  if ((unit >= GIMP_UNIT_END) && (unit != GIMP_UNIT_PERCENT))
    {
      gchar *string;

      if ((g_list_length (items) - 3) >= user_unit)
        {
          gtk_widget_destroy (GTK_WIDGET (g_list_nth_data (items,
                                                           user_unit - 1)));
          gtk_widget_destroy (GTK_WIDGET (g_list_nth_data (items,
                                                           user_unit - 1)));
        }

      menuitem = gtk_menu_item_new ();
      gtk_menu_shell_append (GTK_MENU_SHELL (GTK_OPTION_MENU (menu)->menu),
                             menuitem);
      gtk_widget_set_sensitive (menuitem, FALSE);
      gtk_menu_reorder_child (GTK_MENU (GTK_OPTION_MENU (menu)->menu),
                              menuitem, user_unit - 1);
      gtk_widget_show (menuitem);

      string = gimp_unit_format_string (menu->format, unit);
      menuitem = gtk_menu_item_new_with_label (string);
      g_free (string);

      gtk_menu_shell_append (GTK_MENU_SHELL (GTK_OPTION_MENU (menu)->menu),
                             menuitem);
      g_object_set_data (G_OBJECT (menuitem), "gimp_unit_menu",
                         GINT_TO_POINTER (unit));
      gtk_menu_reorder_child (GTK_MENU (GTK_OPTION_MENU (menu)->menu),
                              menuitem, user_unit);
      gtk_widget_show (menuitem);

      g_signal_connect (menuitem, "activate",
                        G_CALLBACK (gimp_unit_menu_callback),
                        menu);
    }

  menu->unit = unit;
  gtk_option_menu_set_history (GTK_OPTION_MENU (menu),
                               (unit == GIMP_UNIT_PIXEL) ? 0 :
                               ((unit == GIMP_UNIT_PERCENT) ?
                                (menu->show_pixels ? 1 : 0) :
                                (((menu->show_pixels ||
                                   menu->show_percent) ? 2 : 0) +
                                 ((menu->show_pixels &&
                                   menu->show_percent) ? 1 : 0) +
                                 ((unit < GIMP_UNIT_END) ?
                                  (unit - 1) : GIMP_UNIT_END))));

  g_signal_emit (menu, gimp_unit_menu_signals[UNIT_CHANGED], 0);
}
Exemple #28
0
static void
egg_find_bar_emit_next (EggFindBar *find_bar)
{
  g_signal_emit (find_bar, find_bar_signals[NEXT], 0);
}
gboolean
example_callable_media_stream_change_direction (
    ExampleCallableMediaStream *self,
    TpMediaStreamDirection direction,
    GError **error)
{
  gboolean sending =
    ((self->priv->direction & TP_MEDIA_STREAM_DIRECTION_SEND) != 0);
  gboolean receiving =
    ((self->priv->direction & TP_MEDIA_STREAM_DIRECTION_RECEIVE) != 0);
  gboolean want_to_send =
    ((direction & TP_MEDIA_STREAM_DIRECTION_SEND) != 0);
  gboolean want_to_receive =
    ((direction & TP_MEDIA_STREAM_DIRECTION_RECEIVE) != 0);
  gboolean pending_remote_send =
    ((self->priv->pending_send & TP_MEDIA_STREAM_PENDING_REMOTE_SEND) != 0);
  gboolean pending_local_send =
    ((self->priv->pending_send & TP_MEDIA_STREAM_PENDING_LOCAL_SEND) != 0);
  gboolean changed = FALSE;

  if (want_to_send)
    {
      if (!sending)
        {
          if (pending_local_send)
            {
              g_message ("SIGNALLING: send: I will now send you media on "
                  "stream %u", self->priv->id);
            }

          g_message ("MEDIA: Sending media to peer for stream %u",
              self->priv->id);
          changed = TRUE;
          self->priv->direction |= TP_MEDIA_STREAM_DIRECTION_SEND;
        }
    }
  else
    {
      if (sending)
        {
          g_message ("SIGNALLING: send: I will no longer send you media on "
              "stream %u", self->priv->id);
          g_message ("MEDIA: No longer sending media to peer for stream %u",
              self->priv->id);
          changed = TRUE;
          self->priv->direction &= ~TP_MEDIA_STREAM_DIRECTION_SEND;
        }
      else if (pending_local_send)
        {
          g_message ("SIGNALLING: send: No, I refuse to send you media on "
              "stream %u", self->priv->id);
          changed = TRUE;
          self->priv->pending_send &= ~TP_MEDIA_STREAM_PENDING_LOCAL_SEND;
        }
    }

  if (want_to_receive)
    {
      if (!receiving && !pending_remote_send)
        {
          g_message ("SIGNALLING: send: Please start sending me stream %u",
              self->priv->id);
          changed = TRUE;
          self->priv->pending_send |= TP_MEDIA_STREAM_PENDING_REMOTE_SEND;
          g_timeout_add_full (G_PRIORITY_DEFAULT, self->priv->simulation_delay,
              simulate_contact_agreed_to_send_cb, g_object_ref (self),
              g_object_unref);
        }
    }
  else
    {
      if (receiving)
        {
          g_message ("SIGNALLING: send: Please stop sending me stream %u",
              self->priv->id);
          g_message ("MEDIA: Suppressing output of stream %u",
              self->priv->id);
          changed = TRUE;
          self->priv->direction &= ~TP_MEDIA_STREAM_DIRECTION_RECEIVE;
        }
    }

  if (changed)
    g_signal_emit (self, signals[SIGNAL_DIRECTION_CHANGED], 0);

  return TRUE;
}
Exemple #30
0
/**
 * _rb_player_emit_redirect:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the stream
 * @uri: URI to redirect to
 *
 * Emits the 'redirect' signal to notify listeners that the stream has been
 * redirected. To be used by implementations only.
 */
void
_rb_player_emit_redirect (RBPlayer *player, gpointer stream_data, const char *uri)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[REDIRECT], 0, stream_data, uri);
}