Ejemplo n.º 1
0
char *
mpl_gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
                                         GAppInfo          *info, 
                                         GList             *files)
{
  static int sequence = 0;
#if 0
  GdkAppLaunchContextPrivate *priv;
#endif
  GdkDisplay *display;
  GdkScreen *screen;
  int files_count;
  char *description;
  char *icon_name;
  const char *binary_name;
  const char *application_id;
  char *screen_str;
  char *workspace_str;
#if 0
  GIcon *icon;
#endif
  guint32 timestamp;
  char *startup_id;

#if 0
  priv = GDK_APP_LAUNCH_CONTEXT (context)->priv;

  if (priv->screen)
    {
      screen = priv->screen;
      display = gdk_screen_get_display (priv->screen);
    }
  else if (priv->display)
    {
      display = priv->display;
      screen = gdk_display_get_default_screen (display);
    }
  else
    {
      display = gdk_display_get_default ();
      screen = gdk_display_get_default_screen (display);
    }
#else
      display = gdk_display_get_default ();
      screen = gdk_display_get_default_screen (display);
#endif

  files_count = g_list_length (files);
  if (files_count == 0)
    description = g_strdup_printf (_("Starting %s"), g_app_info_get_name (info));
  else if (files_count == 1)
    description = g_strdup_printf (_("Opening %s"), get_display_name (files->data));
  else
    description = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
						"Opening %d Item",
						"Opening %d Items",
						files_count), files_count);

  icon_name = NULL;
#if 0
  if (priv->icon_name)
    icon_name = g_strdup (priv->icon_name);
  else
    {
      icon = NULL;

      if (priv->icon != NULL)
	icon = g_object_ref (priv->icon);
      else if (files_count == 1)
	icon = get_icon (files->data);

      if (icon == NULL)
	{
	  icon = g_app_info_get_icon (info);
	  g_object_ref (icon);
	}

      if (icon)
	icon_name = gicon_to_string (icon);

      g_object_unref (icon);
    }
#endif

  binary_name = g_app_info_get_executable (info);

#if 0
  timestamp = priv->timestamp;
  if (timestamp == GDK_CURRENT_TIME)
#endif
    timestamp = gdk_x11_display_get_user_time (display);

  screen_str = g_strdup_printf ("%d", gdk_screen_get_number (screen));
#if 0
  if (priv->workspace > -1) 
    workspace_str = g_strdup_printf ("%d", priv->workspace);
  else
#endif
    workspace_str = NULL;

  if (G_IS_DESKTOP_APP_INFO (info))
    application_id = g_desktop_app_info_get_filename (G_DESKTOP_APP_INFO (info));
  else
    application_id = NULL;

  startup_id = g_strdup_printf ("%s-%lu-%s-%s-%d_TIME%lu",
				g_get_prgname (),
				(unsigned long)getpid (),
				g_get_host_name (),
				binary_name,
				sequence++,
				(unsigned long)timestamp);

  
  gdk_x11_display_broadcast_startup_message (display, "new",
					     "ID", startup_id,
					     "NAME", g_app_info_get_name (info),
					     "SCREEN", screen_str,
					     "BIN", binary_name,
					     "ICON", icon_name,
					     "DESKTOP", workspace_str,
					     "DESCRIPTION", description,
					     "WMCLASS", NULL, /* FIXME */
					     "APPLICATION_ID", application_id,
					     NULL);

  g_free (description);
  g_free (screen_str);
  g_free (workspace_str);
  g_free (icon_name);

  add_startup_timeout (screen, startup_id);

  return startup_id;
}
Ejemplo n.º 2
0
static char *
gdk_x11_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
                                                  GAppInfo          *info,
                                                  GList             *files)
{
  static int sequence = 0;
  GdkDisplay *display;
  GdkX11Screen *screen;
  int files_count;
  char *description;
  char *icon_name;
  const char *binary_name;
  const char *application_id;
  char *screen_str;
  char *workspace_str;
  GIcon *icon;
  guint32 timestamp;
  char *startup_id;
  GFileInfo *fileinfo;
  GdkAppLaunchContext *ctx;

  ctx = GDK_APP_LAUNCH_CONTEXT (context);

  display = ctx->display;
  screen = GDK_X11_DISPLAY (display)->screen;

  fileinfo = NULL;

  files_count = g_list_length (files);
  if (files_count == 0)
    {
      description = g_strdup_printf (_("Starting %s"), g_app_info_get_name (info));
    }
  else if (files_count == 1)
    {
      gchar *display_name;

      if (g_file_is_native (files->data))
        fileinfo = g_file_query_info (files->data,
                                      G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
                                      G_FILE_ATTRIBUTE_STANDARD_ICON,
                                      0, NULL, NULL);

      display_name = get_display_name (files->data, fileinfo);
      description = g_strdup_printf (_("Opening %s"), display_name);
      g_free (display_name);
    }
  else
    description = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
                                                "Opening %d Item",
                                                "Opening %d Items",
                                                files_count), files_count);

  icon_name = NULL;
  if (ctx->icon_name)
    icon_name = g_strdup (ctx->icon_name);
  else
    {
      icon = NULL;

      if (ctx->icon != NULL)
        icon = g_object_ref (ctx->icon);
      else if (files_count == 1)
        icon = get_icon (files->data, fileinfo);

      if (icon == NULL)
        {
          icon = g_app_info_get_icon (info);
          if (icon != NULL)
            g_object_ref (icon);
        }

      if (icon != NULL)
        {
          icon_name = gicon_to_string (icon);
          g_object_unref (icon);
        }
    }

  binary_name = g_app_info_get_executable (info);

  timestamp = ctx->timestamp;
  if (timestamp == GDK_CURRENT_TIME)
    timestamp = gdk_x11_display_get_user_time (display);

  screen_str = g_strdup_printf ("%d", gdk_x11_screen_get_screen_number (screen));
  if (ctx->workspace > -1)
    workspace_str = g_strdup_printf ("%d", ctx->workspace);
  else
    workspace_str = NULL;

  if (G_IS_DESKTOP_APP_INFO (info))
    application_id = g_desktop_app_info_get_filename (G_DESKTOP_APP_INFO (info));
  else
    application_id = NULL;

  startup_id = g_strdup_printf ("%s-%lu-%s-%s-%d_TIME%lu",
                                g_get_prgname (),
                                (unsigned long)getpid (),
                                g_get_host_name (),
                                binary_name,
                                sequence++,
                                (unsigned long)timestamp);

  gdk_x11_display_broadcast_startup_message (display, "new",
                                             "ID", startup_id,
                                             "NAME", g_app_info_get_name (info),
                                             "SCREEN", screen_str,
                                             "BIN", binary_name,
                                             "ICON", icon_name,
                                             "DESKTOP", workspace_str,
                                             "DESCRIPTION", description,
                                             "WMCLASS", NULL, /* FIXME */
                                             "APPLICATION_ID", application_id,
                                             NULL);

  g_free (description);
  g_free (screen_str);
  g_free (workspace_str);
  g_free (icon_name);
  if (fileinfo)
    g_object_unref (fileinfo);

  add_startup_timeout (screen, startup_id);

  return startup_id;
}