コード例 #1
0
ファイル: gdkapplaunchcontext.c プロジェクト: GNOME/gtk
static gchar *
gdk_app_launch_context_get_display (GAppLaunchContext *context,
                                    GAppInfo          *info,
                                    GList             *files)
{
  GdkAppLaunchContext *ctx = GDK_APP_LAUNCH_CONTEXT (context);
  GdkDisplay *display;

  if (ctx->display)
    display = ctx->display;
  else
    display = gdk_display_get_default ();

  return g_strdup (gdk_display_get_name (display));
}
コード例 #2
0
ファイル: gdkapplaunchcontext.c プロジェクト: GNOME/gtk
static void
gdk_app_launch_context_finalize (GObject *object)
{
  GdkAppLaunchContext *context = GDK_APP_LAUNCH_CONTEXT (object);

  if (context->display)
    g_object_unref (context->display);

  if (context->icon)
    g_object_unref (context->icon);

  g_free (context->icon_name);

  G_OBJECT_CLASS (gdk_app_launch_context_parent_class)->finalize (object);
}
コード例 #3
0
void
mpl_gdk_windowing_launch_failed (GAppLaunchContext *context, 
                                 const char        *startup_notify_id)
{
#if 0
  GdkAppLaunchContextPrivate *priv;
#endif
  GdkScreen *screen;
  StartupTimeoutData *data;
  StartupNotificationData *sn_data;
  GSList *l;

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

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

  data = g_object_get_data (G_OBJECT (screen), "appinfo-startup-data");

  if (data)
    {
      for (l = data->contexts; l != NULL; l = l->next)
	{
	  sn_data = l->data;
	  if (strcmp (startup_notify_id, sn_data->startup_id) == 0)
	    {
	      data->contexts = g_slist_remove (data->contexts, sn_data);
	      end_startup_notification (sn_data->display, sn_data->startup_id);
	      free_startup_notification_data (sn_data);
					      
	      break;
	    }
	}

      if (data->contexts == NULL)
	{
	  g_source_remove (data->timeout_id);
	  data->timeout_id = 0;
	}
    }
}
コード例 #4
0
ファイル: gdkapplaunchcontext.c プロジェクト: GNOME/gtk
static void
gdk_app_launch_context_set_property (GObject      *object,
                                     guint         prop_id,
                                     const GValue *value,
                                     GParamSpec   *pspec)
{
  GdkAppLaunchContext *context = GDK_APP_LAUNCH_CONTEXT (object);

  switch (prop_id)
    {
    case PROP_DISPLAY:
      context->display = g_value_dup_object (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}
コード例 #5
0
static gchar *
gdk_app_launch_context_get_display (GAppLaunchContext *context,
                                    GAppInfo          *info,
                                    GList             *files)
{
    GdkDisplay *display;
    GdkAppLaunchContextPrivate *priv;

    priv = GDK_APP_LAUNCH_CONTEXT (context)->priv;

    if (priv->screen)
        return gdk_screen_make_display_name (priv->screen);

    if (priv->display)
        display = priv->display;
    else
        display = gdk_display_get_default ();

    return g_strdup (gdk_display_get_name (display));
}
コード例 #6
0
static void
gdk_x11_app_launch_context_launch_failed (GAppLaunchContext *context,
                                          const gchar       *startup_notify_id)
{
  GdkAppLaunchContext *ctx;
  GdkX11Screen *screen;
  StartupTimeoutData *data;
  StartupNotificationData *sn_data;
  GSList *l;

  ctx = GDK_APP_LAUNCH_CONTEXT (context);

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

  data = g_object_get_data (G_OBJECT (screen), "appinfo-startup-data");

  if (data)
    {
      for (l = data->contexts; l != NULL; l = l->next)
        {
          sn_data = l->data;
          if (strcmp (startup_notify_id, sn_data->startup_id) == 0)
            {
              data->contexts = g_slist_remove (data->contexts, sn_data);
              end_startup_notification (sn_data->display, sn_data->startup_id);
              free_startup_notification_data (sn_data);

              break;
            }
        }

      if (data->contexts == NULL)
        {
          g_source_remove (data->timeout_id);
          data->timeout_id = 0;
        }
    }
}
コード例 #7
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;
}
コード例 #8
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;
}