コード例 #1
0
ファイル: ol_player_chooser.c プロジェクト: lenoch/osdlyrics
void
ol_player_chooser_set_info_by_state (OlPlayerChooser *window,
                                     enum OlPlayerChooserState state)
{
  ol_assert (OL_IS_PLAYER_CHOOSER (window));
  OlPlayerChooserPrivate *priv = OL_PLAYER_CHOOSER_GET_PRIVATE (window);
  _set_sensitive (window, TRUE);
  switch (state)
  {
  case OL_PLAYER_CHOOSER_STATE_NO_PLAYER:
    ol_player_chooser_set_info (window,
                                _("There is no supported player running"),
                                _("Please choose a player below to launch"));
    ol_player_chooser_set_image_by_name (window, GTK_STOCK_DIALOG_INFO);
    break;
  case OL_PLAYER_CHOOSER_STATE_LAUNCH_FAIL: {
    gchar *title = g_strdup_printf (_("Failed to connect to %s"),
                                      g_app_info_get_name (priv->launch_app));
    gchar *desc = g_strdup_printf (_("%s is not supported by OSD Lyrics, or not running. Please launch another player"),
                                   g_app_info_get_name (priv->launch_app));
    ol_player_chooser_set_info (window, title, desc);
    ol_player_chooser_set_image_by_name (window, GTK_STOCK_DIALOG_ERROR);
    g_free (title);
    g_free (desc);
    _set_launch_app (window, NULL);
    break;
  }
  case OL_PLAYER_CHOOSER_STATE_CONNECTED:
    gtk_widget_hide (GTK_WIDGET (window));
    break;
  default:
    ol_errorf ("Unknown player chooser state %d\n", (int) state);
  }
}
コード例 #2
0
static void
_launch_app (OlPlayerChooser *window,
             GAppInfo *app_info)
{
  GError *err = NULL;
  if (!g_app_info_launch (app_info, NULL, NULL, &err))
  {
    ol_errorf ("Cannot launch %s: %s",
               g_app_info_get_commandline (app_info),
               err->message);
    gchar *title = g_strdup_printf (_("Failed to launch %s"),
                                    g_app_info_get_name (app_info));
    ol_player_chooser_set_info (window, title, err->message);
    ol_player_chooser_set_image_by_name (window, GTK_STOCK_DIALOG_ERROR);
    g_free (title);
    g_error_free (err);
  }
  else
  {
    _set_launch_app (window, app_info);
    gchar *title = g_strdup_printf (_("Launching %s"),
                                    g_app_info_get_name (app_info));
    gchar *desc = g_strdup_printf (_("OSD Lyrics is trying to launch and connect to %s. Please wait for a second."),
                                   g_app_info_get_name (app_info));
    ol_player_chooser_set_info (window, title, desc);
    g_free (title);
    g_free (desc);
    ol_player_chooser_set_image_by_gicon (window, g_app_info_get_icon (app_info));
    _set_sensitive (window, FALSE);
    if (OL_IS_PLAYER_CHOOSER (window))
    {
      _remember_cmd_if_needed (window, g_app_info_get_commandline (app_info));
      gtk_dialog_response (GTK_DIALOG (window), OL_PLAYER_CHOOSER_RESPONSE_LAUNCH);
    }
  }
}